A platform for community discussion. Free, open, simple.
DEV: Allow system tests to assert on values at the correct time (#27988)
Natalie Tay346c9116b564
diff --git a/spec/system/admin_sidebar_navigation_spec.rb b/spec/system/admin_sidebar_navigation_spec.rbindex 0014b925fc2..84ebdac0d99 100644--- a/spec/system/admin_sidebar_navigation_spec.rb+++ b/spec/system/admin_sidebar_navigation_spec.rb@@ -83,11 +83,10 @@ describe "Admin Revamp | Sidebar Navigation", type: :system doit "allows links to be filtered" dovisit("/admin")sidebar.toggle_all_sections- all_links_count = page.all(".sidebar-section-link-content-text").count- links = page.all(".sidebar-section-link-content-text")- expect(links.count).to eq(all_links_count)+ expect(page).to have_selector(".sidebar-section-link-content-text", minimum: 50)expect(page).to have_no_css(".sidebar-no-results")+ all_links_count = page.all(".sidebar-section-link-content-text").countfilter.filter("ie")links = page.all(".sidebar-section-link-content-text")@@ -218,16 +217,16 @@ describe "Admin Revamp | Sidebar Navigation", type: :system doit "allows sections to be expanded" dovisit("/admin")sidebar.toggle_all_sections- all_links_count = page.all(".sidebar-section-link-content-text").count- sidebar.toggle_all_sections+ expect(page).to have_selector(".sidebar-section-link-content-text", minimum: 50)- links = page.all(".sidebar-section-link-content-text")- expect(links.count).to eq(3)- expect(links.map(&:text)).to eq(["Dashboard", "Users", "All Site Settings"])+ sidebar.toggle_all_sections+ expect(page).to have_selector(".sidebar-section-link-content-text", count: 3)+ expect(all(".sidebar-section-link-content-text").map(&:text)).to eq(+ ["Dashboard", "Users", "All Site Settings"],+ )sidebar.toggle_all_sections- links = page.all(".sidebar-section-link-content-text")- expect(links.count).to eq(all_links_count)+ expect(page).to have_selector(".sidebar-section-link-content-text", minimum: 50)endit "accepts hidden keywords like installed plugin names for filter" dodiff --git a/spec/system/homepage_spec.rb b/spec/system/homepage_spec.rbindex 2be3c5d8033..29546fdda78 100644--- a/spec/system/homepage_spec.rb+++ b/spec/system/homepage_spec.rb@@ -78,6 +78,9 @@ describe "Homepage", type: :system dosign_in user+ visit ""+ expect(page).to have_css(".new-home", text: "Hi friends!")+visit "/u/#{user.username}/preferences/interface"homepage_picker = PageObjects::Components::SelectKit.new("#home-selector")@@ -88,9 +91,9 @@ describe "Homepage", type: :system do# Wait for the save to completefind(".btn-primary.save-changes:not([disabled])", wait: 5)+ expect(user.user_option.homepage_id).to eq(UserOption::HOMEPAGES.key("top"))find("#site-logo").click-expect(page).to have_css(".navigation-container .top.active", text: "Top")expect(page).to have_css(".top-lists")@@ -104,9 +107,11 @@ describe "Homepage", type: :system do# Wait for the save to completefind(".btn-primary.save-changes:not([disabled])", wait: 5)+ expect(user.reload.user_option.homepage_id).to_not eq(UserOption::HOMEPAGES.key("top"))+find("#site-logo").click- expect(page).not_to have_css(".list-container")+ expect(page).to have_current_path("/")expect(page).to have_css(".new-home", text: "Hi friends!")endenddiff --git a/spec/system/page_objects/components/select_kit.rb b/spec/system/page_objects/components/select_kit.rbindex 10ca8d9f73b..254fc78b187 100644--- a/spec/system/page_objects/components/select_kit.rb+++ b/spec/system/page_objects/components/select_kit.rb@@ -27,7 +27,7 @@ module PageObjectsdef expanded_componentexpand_if_needed- find(@context + ".is-expanded")+ find(@context + ".is-expanded", wait: 5)enddef collapsed_componentdiff --git a/spec/system/signup_spec.rb b/spec/system/signup_spec.rbindex 92e789b7079..2746aff5f99 100644--- a/spec/system/signup_spec.rb+++ b/spec/system/signup_spec.rb@@ -95,6 +95,8 @@ shared_examples "signup scenarios" doexpect(signup_modal).to have_valid_fieldssignup_modal.click_create_account+ wait_for(timeout: 5) { User.find_by(username: "john") != nil }+visit "/"login_modal.openlogin_modal.fill_username("john")@@ -102,7 +104,6 @@ shared_examples "signup scenarios" dologin_modal.click_loginexpect(login_modal).to have_content(I18n.t("login.not_approved"))- wait_for(timeout: 5) { User.find_by(username: "john") != nil }user = User.find_by(username: "john")user.update!(approved: true)EmailToken.confirm(Fabricate(:email_token, user: user).token)