mirror of
https://github.com/discourse/discourse.git
synced 2025-04-25 02:54:30 +08:00
DEV: Attempt at stabilizing components listing page system spec (#32352)
This commits reworks the assertions for components shown on the components listing page to eliminate flakiness we've seen with those assertions.
This commit is contained in:
parent
b2ce374650
commit
8367819b1b
@ -84,22 +84,16 @@ describe "Admin Customize Themes Config Area Page", type: :system do
|
||||
config_area.visit
|
||||
|
||||
config_area.status_selector.select("used")
|
||||
expect(config_area).to be_loading
|
||||
expect(config_area.components_shown).to contain_exactly(
|
||||
enabled_component.id,
|
||||
remote_component.id,
|
||||
)
|
||||
expect(config_area).to have_exact_components(enabled_component.id, remote_component.id)
|
||||
|
||||
config_area.status_selector.select("unused")
|
||||
expect(config_area).to be_loading
|
||||
expect(config_area.components_shown).to contain_exactly(
|
||||
expect(config_area).to have_exact_components(
|
||||
disabled_component.id,
|
||||
remote_component_with_update.id,
|
||||
)
|
||||
|
||||
config_area.status_selector.select("updates_available")
|
||||
expect(config_area).to be_loading
|
||||
expect(config_area.components_shown).to contain_exactly(remote_component_with_update.id)
|
||||
expect(config_area).to have_exact_components(remote_component_with_update.id)
|
||||
end
|
||||
|
||||
it "can filter components by name" do
|
||||
@ -107,11 +101,7 @@ describe "Admin Customize Themes Config Area Page", type: :system do
|
||||
|
||||
config_area.name_filter_input.fill_in(with: "glo")
|
||||
|
||||
expect(config_area).to be_loading
|
||||
expect(config_area.components_shown).to contain_exactly(
|
||||
enabled_component.id,
|
||||
disabled_component.id,
|
||||
)
|
||||
expect(config_area).to have_exact_components(enabled_component.id, disabled_component.id)
|
||||
end
|
||||
|
||||
it "keeps the filters shown when there are no components matching the filters" do
|
||||
@ -337,14 +327,13 @@ describe "Admin Customize Themes Config Area Page", type: :system do
|
||||
resize_window(height: 800) do
|
||||
config_area.visit
|
||||
|
||||
expect(config_area.components_shown.size).to eq(4)
|
||||
expect(config_area).to have_exactly_n_components(4)
|
||||
|
||||
page.execute_script("window.scrollTo(0, document.body.scrollHeight)")
|
||||
|
||||
expect(config_area).to be_loading
|
||||
expect(config_area).to have_component(enabled_component.id)
|
||||
|
||||
expect(config_area.components_shown.size).to eq(8)
|
||||
expect(config_area).to have_exactly_n_components(8)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -119,10 +119,6 @@ module PageObjects
|
||||
page.visit("/admin/config/customize/components")
|
||||
end
|
||||
|
||||
def loading?
|
||||
has_css?(".loading-container.visible")
|
||||
end
|
||||
|
||||
def component(id)
|
||||
ComponentRow.new(".admin-config-components__component-row[data-component-id=\"#{id}\"]")
|
||||
end
|
||||
@ -147,8 +143,12 @@ module PageObjects
|
||||
has_no_css?(".admin-config-components__component-row")
|
||||
end
|
||||
|
||||
def components_shown
|
||||
all(".admin-config-components__component-row").map { |node| node["data-component-id"].to_i }
|
||||
def has_exact_components?(*ids)
|
||||
ids.all? { |id| has_component?(id) } && has_exactly_n_components?(ids.size)
|
||||
end
|
||||
|
||||
def has_exactly_n_components?(count)
|
||||
has_css?(".admin-config-components__component-row", count:)
|
||||
end
|
||||
|
||||
def has_name_filter_input?
|
||||
|
Loading…
x
Reference in New Issue
Block a user