mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 14:07:30 +08:00
DEV: Allow system tests to assert on values at the correct time (#27988)
This adds some more assertions in system tests at certain instances during the test to minimise flakiness.
This commit is contained in:
@ -83,11 +83,10 @@ describe "Admin Revamp | Sidebar Navigation", type: :system do
|
|||||||
it "allows links to be filtered" do
|
it "allows links to be filtered" do
|
||||||
visit("/admin")
|
visit("/admin")
|
||||||
sidebar.toggle_all_sections
|
sidebar.toggle_all_sections
|
||||||
all_links_count = page.all(".sidebar-section-link-content-text").count
|
|
||||||
|
|
||||||
links = page.all(".sidebar-section-link-content-text")
|
expect(page).to have_selector(".sidebar-section-link-content-text", minimum: 50)
|
||||||
expect(links.count).to eq(all_links_count)
|
|
||||||
expect(page).to have_no_css(".sidebar-no-results")
|
expect(page).to have_no_css(".sidebar-no-results")
|
||||||
|
all_links_count = page.all(".sidebar-section-link-content-text").count
|
||||||
|
|
||||||
filter.filter("ie")
|
filter.filter("ie")
|
||||||
links = page.all(".sidebar-section-link-content-text")
|
links = page.all(".sidebar-section-link-content-text")
|
||||||
@ -218,16 +217,16 @@ describe "Admin Revamp | Sidebar Navigation", type: :system do
|
|||||||
it "allows sections to be expanded" do
|
it "allows sections to be expanded" do
|
||||||
visit("/admin")
|
visit("/admin")
|
||||||
sidebar.toggle_all_sections
|
sidebar.toggle_all_sections
|
||||||
all_links_count = page.all(".sidebar-section-link-content-text").count
|
expect(page).to have_selector(".sidebar-section-link-content-text", minimum: 50)
|
||||||
sidebar.toggle_all_sections
|
|
||||||
|
|
||||||
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
|
sidebar.toggle_all_sections
|
||||||
links = page.all(".sidebar-section-link-content-text")
|
expect(page).to have_selector(".sidebar-section-link-content-text", count: 3)
|
||||||
expect(links.count).to eq(all_links_count)
|
expect(all(".sidebar-section-link-content-text").map(&:text)).to eq(
|
||||||
|
["Dashboard", "Users", "All Site Settings"],
|
||||||
|
)
|
||||||
|
|
||||||
|
sidebar.toggle_all_sections
|
||||||
|
expect(page).to have_selector(".sidebar-section-link-content-text", minimum: 50)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "accepts hidden keywords like installed plugin names for filter" do
|
it "accepts hidden keywords like installed plugin names for filter" do
|
||||||
|
@ -78,6 +78,9 @@ describe "Homepage", type: :system do
|
|||||||
|
|
||||||
sign_in user
|
sign_in user
|
||||||
|
|
||||||
|
visit ""
|
||||||
|
expect(page).to have_css(".new-home", text: "Hi friends!")
|
||||||
|
|
||||||
visit "/u/#{user.username}/preferences/interface"
|
visit "/u/#{user.username}/preferences/interface"
|
||||||
|
|
||||||
homepage_picker = PageObjects::Components::SelectKit.new("#home-selector")
|
homepage_picker = PageObjects::Components::SelectKit.new("#home-selector")
|
||||||
@ -88,9 +91,9 @@ describe "Homepage", type: :system do
|
|||||||
|
|
||||||
# Wait for the save to complete
|
# Wait for the save to complete
|
||||||
find(".btn-primary.save-changes:not([disabled])", wait: 5)
|
find(".btn-primary.save-changes:not([disabled])", wait: 5)
|
||||||
|
expect(user.user_option.homepage_id).to eq(UserOption::HOMEPAGES.key("top"))
|
||||||
|
|
||||||
find("#site-logo").click
|
find("#site-logo").click
|
||||||
|
|
||||||
expect(page).to have_css(".navigation-container .top.active", text: "Top")
|
expect(page).to have_css(".navigation-container .top.active", text: "Top")
|
||||||
expect(page).to have_css(".top-lists")
|
expect(page).to have_css(".top-lists")
|
||||||
|
|
||||||
@ -104,9 +107,11 @@ describe "Homepage", type: :system do
|
|||||||
|
|
||||||
# Wait for the save to complete
|
# Wait for the save to complete
|
||||||
find(".btn-primary.save-changes:not([disabled])", wait: 5)
|
find(".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
|
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!")
|
expect(page).to have_css(".new-home", text: "Hi friends!")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -27,7 +27,7 @@ module PageObjects
|
|||||||
|
|
||||||
def expanded_component
|
def expanded_component
|
||||||
expand_if_needed
|
expand_if_needed
|
||||||
find(@context + ".is-expanded")
|
find(@context + ".is-expanded", wait: 5)
|
||||||
end
|
end
|
||||||
|
|
||||||
def collapsed_component
|
def collapsed_component
|
||||||
|
@ -95,6 +95,8 @@ shared_examples "signup scenarios" do
|
|||||||
expect(signup_modal).to have_valid_fields
|
expect(signup_modal).to have_valid_fields
|
||||||
signup_modal.click_create_account
|
signup_modal.click_create_account
|
||||||
|
|
||||||
|
wait_for(timeout: 5) { User.find_by(username: "john") != nil }
|
||||||
|
|
||||||
visit "/"
|
visit "/"
|
||||||
login_modal.open
|
login_modal.open
|
||||||
login_modal.fill_username("john")
|
login_modal.fill_username("john")
|
||||||
@ -102,7 +104,6 @@ shared_examples "signup scenarios" do
|
|||||||
login_modal.click_login
|
login_modal.click_login
|
||||||
expect(login_modal).to have_content(I18n.t("login.not_approved"))
|
expect(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 = User.find_by(username: "john")
|
||||||
user.update!(approved: true)
|
user.update!(approved: true)
|
||||||
EmailToken.confirm(Fabricate(:email_token, user: user).token)
|
EmailToken.confirm(Fabricate(:email_token, user: user).token)
|
||||||
|
Reference in New Issue
Block a user