diff --git a/plugins/chat/app/jobs/regular/chat_notify_mentioned.rb b/plugins/chat/app/jobs/regular/chat_notify_mentioned.rb
index d6fa48e3320..b10083f5ff0 100644
--- a/plugins/chat/app/jobs/regular/chat_notify_mentioned.rb
+++ b/plugins/chat/app/jobs/regular/chat_notify_mentioned.rb
@@ -65,7 +65,7 @@ module Jobs
username: @creator.username,
tag: Chat::ChatNotifier.push_notification_tag(:mention, @chat_channel.id),
excerpt: @chat_message.push_notification_excerpt,
- post_url: "#{@chat_channel.relative_url}?messageId=#{@chat_message.id}",
+ post_url: "#{@chat_channel.relative_url}/#{@chat_message.id}",
}
translation_prefix =
diff --git a/plugins/chat/assets/javascripts/discourse/chat-route-map.js b/plugins/chat/assets/javascripts/discourse/chat-route-map.js
index 2ffee549611..d303778eaee 100644
--- a/plugins/chat/assets/javascripts/discourse/chat-route-map.js
+++ b/plugins/chat/assets/javascripts/discourse/chat-route-map.js
@@ -5,17 +5,16 @@ export default function () {
path: "/channel/:channelId/:channelTitle",
});
- this.route(
- "channel",
- { path: "/c/:channelTitle/:channelId/" },
- function () {
- this.route("info", { path: "/info" }, function () {
- this.route("about", { path: "/about" });
- this.route("members", { path: "/members" });
- this.route("settings", { path: "/settings" });
- });
- }
- );
+ this.route("channel", { path: "/c/:channelTitle/:channelId" }, function () {
+ this.route("from-params", { path: "/" });
+ this.route("near-message", { path: "/:messageId" });
+
+ this.route("info", { path: "/info" }, function () {
+ this.route("about", { path: "/about" });
+ this.route("members", { path: "/members" });
+ this.route("settings", { path: "/settings" });
+ });
+ });
this.route("draft-channel", { path: "/draft-channel" });
this.route("browse", { path: "/browse" }, function () {
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-card.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-channel-card.hbs
index a7c4b39bb4f..0bc79af6c6e 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel-card.hbs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel-card.hbs
@@ -10,7 +10,7 @@
>
#{message2.user.username}
##{channel.name}
diff --git a/plugins/chat/spec/jobs/regular/chat_notify_mentioned_spec.rb b/plugins/chat/spec/jobs/regular/chat_notify_mentioned_spec.rb
index 5fe55080999..99db2226233 100644
--- a/plugins/chat/spec/jobs/regular/chat_notify_mentioned_spec.rb
+++ b/plugins/chat/spec/jobs/regular/chat_notify_mentioned_spec.rb
@@ -215,7 +215,7 @@ describe Jobs::ChatNotifyMentioned do
)
expect(desktop_notification.data[:excerpt]).to eq(message.push_notification_excerpt)
expect(desktop_notification.data[:post_url]).to eq(
- "/chat/c/#{public_channel.slug}/#{public_channel.id}?messageId=#{message.id}",
+ "/chat/c/#{public_channel.slug}/#{public_channel.id}/#{message.id}",
)
end
@@ -229,7 +229,7 @@ describe Jobs::ChatNotifyMentioned do
username: user_1.username,
tag: Chat::ChatNotifier.push_notification_tag(:mention, public_channel.id),
excerpt: message.push_notification_excerpt,
- post_url: "/chat/c/#{public_channel.slug}/#{public_channel.id}?messageId=#{message.id}",
+ post_url: "/chat/c/#{public_channel.slug}/#{public_channel.id}/#{message.id}",
translated_title: payload_translated_title,
},
)
diff --git a/plugins/chat/spec/models/chat_message_spec.rb b/plugins/chat/spec/models/chat_message_spec.rb
index fd775b984aa..5f42e77f583 100644
--- a/plugins/chat/spec/models/chat_message_spec.rb
+++ b/plugins/chat/spec/models/chat_message_spec.rb
@@ -138,7 +138,7 @@ describe ChatMessage do
chatbbcodeuser
diff --git a/plugins/chat/spec/plugin_spec.rb b/plugins/chat/spec/plugin_spec.rb
index 6a23fe258de..b90f1861e64 100644
--- a/plugins/chat/spec/plugin_spec.rb
+++ b/plugins/chat/spec/plugin_spec.rb
@@ -155,10 +155,9 @@ describe Chat do
end
it "renders messages" do
- results =
- InlineOneboxer.new(["#{chat_url}?messageId=#{chat_message.id}"], skip_cache: true).process
+ results = InlineOneboxer.new(["#{chat_url}/#{chat_message.id}"], skip_cache: true).process
expect(results).to be_present
- expect(results[0][:url]).to eq("#{chat_url}?messageId=#{chat_message.id}")
+ expect(results[0][:url]).to eq("#{chat_url}/#{chat_message.id}")
expect(results[0][:title]).to eq(
"Message ##{chat_message.id} by #{chat_message.user.username} – ##{chat_channel.name}",
)
@@ -197,7 +196,7 @@ describe Chat do
end
it "renders messages" do
- expect(Oneboxer.preview("#{chat_url}?messageId=#{chat_message.id}")).to match_html <<~HTML
+ expect(Oneboxer.preview("#{chat_url}/#{chat_message.id}")).to match_html <<~HTML
@@ -207,7 +206,7 @@ describe Chat do
#{user.username}
diff --git a/plugins/chat/spec/system/bookmark_message_spec.rb b/plugins/chat/spec/system/bookmark_message_spec.rb
index 2b843360958..e8afe05c918 100644
--- a/plugins/chat/spec/system/bookmark_message_spec.rb
+++ b/plugins/chat/spec/system/bookmark_message_spec.rb
@@ -52,8 +52,14 @@ RSpec.describe "Bookmark message", type: :system, js: true do
context "when mobile", mobile: true do
it "allows to bookmark a message" do
chat.visit_channel(category_channel_1)
+ expect(channel).to have_no_loading_skeleton
- channel.message_by_id(message_1.id).click(delay: 0.5)
+ i = 0.5
+ try_until_success(timeout: 20) do
+ channel.message_by_id(message_1.id).click(delay: i)
+ first(".bookmark-btn")
+ i += 0.1
+ end
find(".bookmark-btn").click
bookmark_modal.fill_name("Check this out later")
diff --git a/plugins/chat/spec/system/navigating_to_message_spec.rb b/plugins/chat/spec/system/navigating_to_message_spec.rb
index 3b5fe12398d..9dae4fe8b81 100644
--- a/plugins/chat/spec/system/navigating_to_message_spec.rb
+++ b/plugins/chat/spec/system/navigating_to_message_spec.rb
@@ -26,7 +26,7 @@ RSpec.describe "Navigating to message", type: :system, js: true do
Fabricate(
:post,
topic: topic_1,
- raw: "#{link}",
+ raw: "#{link}",
)
end
@@ -45,7 +45,7 @@ RSpec.describe "Navigating to message", type: :system, js: true do
Fabricate(
:chat_message,
chat_channel: channel_1,
- message: "[#{link}](/chat/c/-/#{channel_1.id}?messageId=#{first_message.id})",
+ message: "[#{link}](/chat/c/-/#{channel_1.id}/#{first_message.id})",
)
end
@@ -77,7 +77,7 @@ RSpec.describe "Navigating to message", type: :system, js: true do
Fabricate(
:chat_message,
chat_channel: channel_2,
- message: "[#{link}](/chat/c/-/#{channel_1.id}?messageId=#{first_message.id})",
+ message: "[#{link}](/chat/c/-/#{channel_1.id}/#{first_message.id})",
)
channel_2.add(current_user)
end
@@ -94,7 +94,7 @@ RSpec.describe "Navigating to message", type: :system, js: true do
context "when navigating directly to a message link" do
it "highglights the correct message" do
- visit("/chat/c/-/#{channel_1.id}?messageId=#{first_message.id}")
+ visit("/chat/c/-/#{channel_1.id}/#{first_message.id}")
expect(page).to have_css(
".chat-message-container.highlighted[data-id='#{first_message.id}']",
@@ -111,7 +111,7 @@ RSpec.describe "Navigating to message", type: :system, js: true do
Fabricate(
:post,
topic: topic_1,
- raw: "#{link}",
+ raw: "#{link}",
)
end
@@ -130,7 +130,7 @@ RSpec.describe "Navigating to message", type: :system, js: true do
Fabricate(
:chat_message,
chat_channel: channel_1,
- message: "[#{link}](/chat/c/-/#{channel_1.id}?messageId=#{first_message.id})",
+ message: "[#{link}](/chat/c/-/#{channel_1.id}/#{first_message.id})",
)
end
diff --git a/plugins/chat/spec/system/transcript_spec.rb b/plugins/chat/spec/system/transcript_spec.rb
index ad5e75212b5..08809cec57a 100644
--- a/plugins/chat/spec/system/transcript_spec.rb
+++ b/plugins/chat/spec/system/transcript_spec.rb
@@ -26,12 +26,12 @@ RSpec.describe "Quoting chat message transcripts", type: :system, js: true do
end
def select_message_mobile(message)
- if page.has_css?(".chat-message-container.selecting-messages")
- chat_channel_page.message_by_id(message.id).find(".chat-message-selector").click
- else
- chat_channel_page.message_by_id(message.id).click(delay: 0.5)
- find(".chat-message-action-item[data-id=\"selectMessage\"]").click
+ i = 0.5
+ try_until_success(timeout: 20) do
+ chat_channel_page.message_by_id(message.id).click(delay: i)
+ first(".chat-message-action-item[data-id=\"selectMessage\"]")
end
+ find(".chat-message-action-item[data-id=\"selectMessage\"] button").click
end
def cdp_allow_clipboard_access!
@@ -62,15 +62,15 @@ RSpec.describe "Quoting chat message transcripts", type: :system, js: true do
selector =
case button
when "quote"
- "#chat-quote-btn"
+ "chat-quote-btn"
when "copy"
- "#chat-copy-btn"
+ "chat-copy-btn"
when "cancel"
- "#chat-cancel-selection-btn"
+ "chat-cancel-selection-btn"
when "move"
- "#chat-move-to-channel-btn"
+ "chat-move-to-channel-btn"
end
- within(".chat-selection-management-buttons") { find(selector).click }
+ find_button(selector, disabled: false, wait: 5).click
end
def copy_messages_to_clipboard(messages)
@@ -78,7 +78,7 @@ RSpec.describe "Quoting chat message transcripts", type: :system, js: true do
messages.each { |message| select_message_desktop(message) }
expect(chat_channel_page).to have_selection_management
click_selection_button("copy")
- expect(page).to have_content("Chat quote copied to clipboard")
+ expect(page).to have_selector(".chat-copy-success")
clip_text = read_clipboard
expect(clip_text.chomp).to eq(generate_transcript(messages, current_user))
clip_text
@@ -227,6 +227,7 @@ RSpec.describe "Quoting chat message transcripts", type: :system, js: true do
it "first navigates to the channel's category before opening the topic composer with the quote prefilled",
mobile: true do
chat_page.visit_channel(chat_channel_1)
+
expect(chat_channel_page).to have_no_loading_skeleton
select_message_mobile(message_1)
diff --git a/plugins/chat/spec/system/user_menu_notifications/sidebar_spec.rb b/plugins/chat/spec/system/user_menu_notifications/sidebar_spec.rb
index 6adb92ab675..b52f70fd4c5 100644
--- a/plugins/chat/spec/system/user_menu_notifications/sidebar_spec.rb
+++ b/plugins/chat/spec/system/user_menu_notifications/sidebar_spec.rb
@@ -59,7 +59,7 @@ RSpec.describe "User menu notifications | sidebar", type: :system, js: true do
end
expect(find("#quick-access-chat-notifications")).to have_link(
I18n.t("js.notifications.popup.direct_message_chat_mention.direct"),
- href: "/chat/c/#{other_user.username}/#{dm_channel_1.id}?messageId=#{message.id}",
+ href: "/chat/c/#{other_user.username}/#{dm_channel_1.id}/#{message.id}",
)
end
end
@@ -100,7 +100,7 @@ RSpec.describe "User menu notifications | sidebar", type: :system, js: true do
identifier: "@#{group.name}",
channel: channel_1.name,
),
- href: "/chat/c/#{channel_1.slug}/#{channel_1.id}?messageId=#{message.id}",
+ href: "/chat/c/#{channel_1.slug}/#{channel_1.id}/#{message.id}",
)
end
end
@@ -126,7 +126,7 @@ RSpec.describe "User menu notifications | sidebar", type: :system, js: true do
expect(find("#quick-access-chat-notifications")).to have_link(
I18n.t("js.notifications.popup.chat_mention.direct", channel: channel_1.name),
- href: "/chat/c/#{channel_1.slug}/#{channel_1.id}?messageId=#{message.id}",
+ href: "/chat/c/#{channel_1.slug}/#{channel_1.id}/#{message.id}",
)
end
end
@@ -153,7 +153,7 @@ RSpec.describe "User menu notifications | sidebar", type: :system, js: true do
identifier: "@all",
channel: channel_1.name,
),
- href: "/chat/c/#{channel_1.slug}/#{channel_1.id}?messageId=#{message.id}",
+ href: "/chat/c/#{channel_1.slug}/#{channel_1.id}/#{message.id}",
)
end
end
diff --git a/plugins/chat/spec/system/visit_channel_spec.rb b/plugins/chat/spec/system/visit_channel_spec.rb
index 1fe73fad66b..2a7a45fa40b 100644
--- a/plugins/chat/spec/system/visit_channel_spec.rb
+++ b/plugins/chat/spec/system/visit_channel_spec.rb
@@ -69,7 +69,7 @@ RSpec.describe "Visit channel", type: :system, js: true do
context "when loading a non existing message of a channel" do
it "shows an error" do
- visit("/chat/c/-/#{category_channel_1.id}?messageId=-999")
+ visit("/chat/c/-/#{category_channel_1.id}/-999")
expect(page).to have_content(I18n.t("not_found"))
end
diff --git a/plugins/chat/test/javascripts/unit/helpers/format-chat-date-test.js b/plugins/chat/test/javascripts/unit/helpers/format-chat-date-test.js
index e6fe904aabd..474dba68dcc 100644
--- a/plugins/chat/test/javascripts/unit/helpers/format-chat-date-test.js
+++ b/plugins/chat/test/javascripts/unit/helpers/format-chat-date-test.js
@@ -12,9 +12,6 @@ module("Discourse Chat | Unit | Helpers | format-chat-date", function (hooks) {
this.set("message", { id: 1 });
await render(hbs`{{format-chat-date this.message this.details}}`);
- assert.equal(
- query(".chat-time").getAttribute("href"),
- "/chat/c/-/1?messageId=1"
- );
+ assert.equal(query(".chat-time").getAttribute("href"), "/chat/c/-/1/1");
});
});
diff --git a/plugins/chat/test/javascripts/widgets/chat-invitation-notification-item-test.js b/plugins/chat/test/javascripts/widgets/chat-invitation-notification-item-test.js
index 862cfaeada6..16b16fd3585 100644
--- a/plugins/chat/test/javascripts/widgets/chat-invitation-notification-item-test.js
+++ b/plugins/chat/test/javascripts/widgets/chat-invitation-notification-item-test.js
@@ -45,7 +45,7 @@ module(
query(".chat-invitation a").getAttribute("href"),
`/chat/c/${slugifyChannel({
title: data.chat_channel_title,
- })}/${data.chat_channel_id}?messageId=${data.chat_message_id}`
+ })}/${data.chat_channel_id}/${data.chat_message_id}`
);
});
}
diff --git a/plugins/chat/test/javascripts/widgets/chat-mention-notification-item-test.js b/plugins/chat/test/javascripts/widgets/chat-mention-notification-item-test.js
index 62603da1be1..d640ba8fccf 100644
--- a/plugins/chat/test/javascripts/widgets/chat-mention-notification-item-test.js
+++ b/plugins/chat/test/javascripts/widgets/chat-mention-notification-item-test.js
@@ -54,7 +54,7 @@ module(
query(".chat-invitation a").getAttribute("href"),
`/chat/c/${slugifyChannel({
title: data.chat_channel_title,
- })}/${data.chat_channel_id}?messageId=${data.chat_message_id}`
+ })}/${data.chat_channel_id}/${data.chat_message_id}`
);
});
}
@@ -93,7 +93,7 @@ module(
query(".chat-invitation a").getAttribute("href"),
`/chat/c/${slugifyChannel({
title: data.chat_channel_title,
- })}/${data.chat_channel_id}?messageId=${data.chat_message_id}`
+ })}/${data.chat_channel_id}/${data.chat_message_id}`
);
});
}
@@ -132,7 +132,7 @@ module(
query(".chat-invitation a").getAttribute("href"),
`/chat/c/${slugifyChannel({
title: data.chat_channel_title,
- })}/${data.chat_channel_id}?messageId=${data.chat_message_id}`
+ })}/${data.chat_channel_id}/${data.chat_message_id}`
);
});
}
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index 22009af6faa..c822777e709 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -245,7 +245,7 @@ RSpec.configure do |config|
end
Capybara.threadsafe = true
- Capybara.disable_animation = true
+ Capybara.disable_animation = false
Capybara.configure do |capybara_config|
capybara_config.server_host = "localhost"
diff --git a/spec/support/system_helpers.rb b/spec/support/system_helpers.rb
index 028483bf886..336584a231c 100644
--- a/spec/support/system_helpers.rb
+++ b/spec/support/system_helpers.rb
@@ -32,7 +32,9 @@ module SystemHelpers
start ||= Time.zone.now
backoff ||= frequency
yield
- rescue RSpec::Expectations::ExpectationNotMetError
+ rescue RSpec::Expectations::ExpectationNotMetError,
+ Capybara::ExpectationNotMet,
+ Capybara::ElementNotFound
raise if Time.zone.now >= start + timeout.seconds
sleep backoff
backoff += frequency
@@ -67,8 +69,15 @@ module SystemHelpers
ENV["TZ"] = timezone
- Capybara.using_session(timezone) { freeze_time(&example) }
+ using_session(timezone) { freeze_time(&example) }
ENV["TZ"] = previous_browser_timezone
end
+
+ # When using parallelism, Capybara's `using_session` method can cause
+ # intermittent failures as two sessions can be created with the same name
+ # in different tests and be run at the same time.
+ def using_session(name, &block)
+ Capybara.using_session(name.to_s + self.method_name, &block)
+ end
end