Skip to content

A platform for community discussion. Free, open, simple.

DEV: Attempt at stabilizing components listing page system spec (#32352)

Osama Sayegh8367819b1b52
diff --git a/spec/system/admin_customize_components_config_area_spec.rb b/spec/system/admin_customize_components_config_area_spec.rb
index 81bf0ceabc1..e4a9984442e 100644
--- a/spec/system/admin_customize_components_config_area_spec.rb
+++ b/spec/system/admin_customize_components_config_area_spec.rb
@@ -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
diff --git a/spec/system/page_objects/pages/admin_customize_components_config_area.rb b/spec/system/page_objects/pages/admin_customize_components_config_area.rb
index a2b3b1ccba5..79daef33c36 100644
--- a/spec/system/page_objects/pages/admin_customize_components_config_area.rb
+++ b/spec/system/page_objects/pages/admin_customize_components_config_area.rb
@@ -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?