discourse/plugins/chat/spec/system/document_title_spec.rb
Alan Guo Xiang Tan 477a67e4fb
DEV: Fix flaky system test (#26479)
Why this change?

`expect(page.title).to starts_with("...")` does not rely on capybara
waiters. This commit switches us to use `have_title` instead which will
rely on Capybara waiters.
2024-04-03 10:04:48 +08:00

40 lines
998 B
Ruby

# frozen_string_literal: true
RSpec.describe "Document title", type: :system do
fab!(:current_user) { Fabricate(:user) }
let(:chat_page) { PageObjects::Pages::Chat.new }
context "when visiting a public channel" do
fab!(:channel_1) { Fabricate(:category_channel) }
before do
chat_system_bootstrap
channel_1.add(current_user)
sign_in(current_user)
end
it "shows the channel name in the document title" do
chat_page.visit_channel(channel_1)
expect(page).to have_title("##{channel_1.title}")
end
end
context "when visiting a direct message channel" do
fab!(:channel_1) { Fabricate(:direct_message_channel, users: [current_user]) }
before do
chat_system_bootstrap
channel_1.add(current_user)
sign_in(current_user)
end
it "shows the channel name in the document title" do
chat_page.visit_channel(channel_1)
expect(page).to have_title("#{channel_1.title(current_user)}")
end
end
end