A platform for community discussion. Free, open, simple.
DEV: Fix chat sidebar system spec flaky (#19844)
Martin Brennan9a6eefaafc70
diff --git a/plugins/chat/spec/system/page_objects/sidebar/sidebar.rb b/plugins/chat/spec/system/page_objects/sidebar/sidebar.rbindex e416e67c897..ededff5373b 100644--- a/plugins/chat/spec/system/page_objects/sidebar/sidebar.rb+++ b/plugins/chat/spec/system/page_objects/sidebar/sidebar.rb@@ -3,6 +3,14 @@module PageObjectsmodule Pagesclass Sidebar < PageObjects::Pages::Base+ def channels_section+ find(".sidebar-section-chat-channels")+ end++ def dms_section+ find(".sidebar-section-chat-dms")+ end+def open_draft_channelfind(".sidebar-section-chat-dms .sidebar-section-header-button", visible: false).clickenddiff --git a/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb b/plugins/chat/spec/system/sidebar_navigation_menu_spec.rbindex 33f7a9b78dd..bdbde125752 100644--- a/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb+++ b/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb@@ -1,6 +1,8 @@# frozen_string_literal: trueRSpec.describe "Sidebar navigation menu", type: :system, js: true do+ let(:sidebar_page) { PageObjects::Pages::Sidebar.new }+fab!(:current_user) { Fabricate(:user) }before do@@ -18,8 +20,8 @@ RSpec.describe "Sidebar navigation menu", type: :system, js: true doit "displays correct channels section title" dovisit("/")- expect(page).to have_css(- ".sidebar-section-chat-channels .sidebar-section-header-text",+ expect(sidebar_page.channels_section).to have_css(+ ".sidebar-section-header-text",text: I18n.t("js.chat.chat_channels"),)end@@ -27,8 +29,8 @@ RSpec.describe "Sidebar navigation menu", type: :system, js: true doit "displays the correct hash icon prefix" dovisit("/")- expect(page).to have_css(- ".sidebar-section-chat-channels .sidebar-section-link-#{channel_1.slug} .sidebar-section-link-prefix svg.prefix-icon.d-icon-hashtag",+ expect(sidebar_page.channels_section).to have_css(+ ".sidebar-section-link-#{channel_1.slug} .sidebar-section-link-prefix svg.prefix-icon.d-icon-hashtag",)end@@ -53,8 +55,8 @@ RSpec.describe "Sidebar navigation menu", type: :system, js: true doit "has a lock badge" dovisit("/")- expect(page).to have_css(- ".sidebar-section-chat-channels .sidebar-section-link-#{private_channel_1.slug} .sidebar-section-link-prefix svg.prefix-badge.d-icon-lock",+ expect(sidebar_page.channels_section).to have_css(+ ".sidebar-section-link-#{private_channel_1.slug} .sidebar-section-link-prefix svg.prefix-badge.d-icon-lock",)endend@@ -67,8 +69,8 @@ RSpec.describe "Sidebar navigation menu", type: :system, js: true doit "unescapes the emoji" dovisit("/")- expect(page).to have_css(- ".sidebar-section-chat-channels .sidebar-section-link-#{channel_1.slug} .emoji",+ expect(sidebar_page.channels_section).to have_css(+ ".sidebar-section-link-#{channel_1.slug} .emoji",)endend@@ -88,8 +90,8 @@ RSpec.describe "Sidebar navigation menu", type: :system, js: true doit "has a muted class" dovisit("/")- expect(page).to have_css(- ".sidebar-section-chat-channels .sidebar-section-link-#{channel_2.slug}.sidebar-section-link--muted",+ expect(sidebar_page.channels_section).to have_css(+ ".sidebar-section-link-#{channel_2.slug}.sidebar-section-link--muted",)endend@@ -101,9 +103,7 @@ RSpec.describe "Sidebar navigation menu", type: :system, js: true dovisit("/")expect(- page.find(".sidebar-section-chat-channels .sidebar-section-link-#{channel_1.slug}")[- "title"- ],+ sidebar_page.channels_section.find(".sidebar-section-link-#{channel_1.slug}")["title"],).to eq("<script>alert('hello')</script>")endend@@ -118,8 +118,8 @@ RSpec.describe "Sidebar navigation menu", type: :system, js: true dovisit("/")expect(- page.find(- ".sidebar-section-chat-dms a.sidebar-section-link:nth-child(1) .sidebar-section-link-prefix img",+ sidebar_page.dms_section.find(+ "a.sidebar-section-link:nth-child(1) .sidebar-section-link-prefix img",)["src"],@@ -130,7 +130,7 @@ RSpec.describe "Sidebar navigation menu", type: :system, js: true dovisit("/")expect(- page.find(".sidebar-section-chat-dms a.sidebar-section-link:nth-child(1)"),+ sidebar_page.dms_section.find("a.sidebar-section-link:nth-child(1)"),).to have_content(other_user.username)end@@ -143,27 +143,27 @@ RSpec.describe "Sidebar navigation menu", type: :system, js: true doit "displays the status" dovisit("/")- expect(- page.find(".sidebar-section-chat-dms a.sidebar-section-link:nth-child(1)"),- ).to have_css(".user-status")+ expect(sidebar_page.dms_section.find("a.sidebar-section-link:nth-child(1)")).to have_css(+ ".user-status",+ )endendendcontext "when channel has more than 2 participants" do- fab!(:user_1) { Fabricate(:user) }- fab!(:user_2) { Fabricate(:user) }+ fab!(:user_1) { Fabricate(:user, username: "zoesmith") }+ fab!(:user_2) { Fabricate(:user, username: "alansmith") }fab!(:dm_channel_1) doFabricate(:direct_message_channel, users: [current_user, user_1, user_2])end- it "displays all participants names" do+ it "displays all participants names in alphabetical order" dovisit("/")expect(- page.find(- ".sidebar-section-chat-dms a.sidebar-section-link:nth-child(1) .sidebar-section-link-content-text",+ sidebar_page.dms_section.find(+ "a.sidebar-section-link:nth-child(1) .sidebar-section-link-content-text",),- ).to have_content("#{user_1.username}, #{user_2.username}")+ ).to have_content("alansmith, zoesmith")endend@@ -179,7 +179,7 @@ RSpec.describe "Sidebar navigation menu", type: :system, js: true doit "escapes the title attribute using it" dovisit("/")- expect(page.find(".sidebar-section-chat-dms .channel-#{dm_channel_1.id}")["title"]).to eq(+ expect(sidebar_page.dms_section.find(".channel-#{dm_channel_1.id}")["title"]).to eq("Chat with @<script>alert('hello')</script>",)end