FIX: new chat from url flaky fix (#27414)
The order of chat direct message groups can sometimes place usernames in an unexpected order, this change tests multiple combinations of usernames and accepts them no matter what order they are in.
This commit is contained in:
parent
27efa2d8b7
commit
fb11ab5895
|
@ -14,6 +14,10 @@ RSpec.describe "Chat New Message from params", type: :system do
|
|||
sign_in(current_user)
|
||||
end
|
||||
|
||||
def group_slug(users)
|
||||
users.pluck(:username).permutation.map { |u| u.join("-") }.join("|")
|
||||
end
|
||||
|
||||
context "with a single user" do
|
||||
it "redirects to existing chat channel" do
|
||||
chat_page.visit_new_message(user_1)
|
||||
|
@ -42,9 +46,10 @@ RSpec.describe "Chat New Message from params", type: :system do
|
|||
|
||||
it "loads existing dm channel when one exists" do
|
||||
expect { chat_page.visit_new_message([user_1, user_2]) }.not_to change { Chat::Channel.count }
|
||||
users = [user_1.username, user_2.username].permutation.map { |u| u.join("-") }.join("|")
|
||||
|
||||
expect(page).to have_current_path(%r{/chat/c/(#{users})/#{group_dm.id}})
|
||||
expect(page).to have_current_path(
|
||||
%r{/chat/c/(#{group_slug([user_1, user_2])})/#{group_dm.id}},
|
||||
)
|
||||
end
|
||||
|
||||
it "creates a dm channel when none exists" do
|
||||
|
@ -53,7 +58,7 @@ RSpec.describe "Chat New Message from params", type: :system do
|
|||
)
|
||||
|
||||
expect(page).to have_current_path(
|
||||
"/chat/c/#{user_1.username}-#{user_3.username}/#{Chat::Channel.last.id}",
|
||||
%r{/chat/c/#{group_slug([user_1, user_3])}/#{Chat::Channel.last.id}},
|
||||
)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue