From f370962cd76e78fbf2ff0c2ad8852cb6ce294d4b Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 8 Feb 2024 12:51:44 +0100 Subject: [PATCH] Harden edit elements feature spec There is JS involved opening the dialog, so we need to tell Capybara to wait for it. --- .../admin/edit_elements_feature_spec.rb | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/spec/features/admin/edit_elements_feature_spec.rb b/spec/features/admin/edit_elements_feature_spec.rb index e4c6028c35..6006048871 100644 --- a/spec/features/admin/edit_elements_feature_spec.rb +++ b/spec/features/admin/edit_elements_feature_spec.rb @@ -62,13 +62,17 @@ end end - scenario "the add button opens add element form with the clipboard tab" do + scenario "the add button opens add element form with the clipboard tab", :js do visit alchemy.admin_elements_path(page_version_id: element.page_version_id) button = page.find(".add-nestable-element-button") expect(button).to have_content "Add Slide" button.click - expect(page).to have_select("Element") - expect(page).to have_css("[panel='paste_element_tab']") + + expect(page).to have_css(".alchemy-dialog") + within ".alchemy-dialog" do + expect(page).to have_select("Element") + expect(page).to have_css("[panel='paste_element_tab']") + end end end @@ -92,8 +96,11 @@ scenario "the add button now opens add element form with the clipboard tab" do find("a.add-nestable-element-button").click - expect(page).to have_select("Element") - expect(page).to have_css("[panel='paste_element_tab']") + expect(page).to have_css(".alchemy-dialog") + within ".alchemy-dialog" do + expect(page).to have_select("Element") + expect(page).to have_css("[panel='paste_element_tab']") + end end end end @@ -112,8 +119,9 @@ button = page.find(".add-nestable-element-button") expect(button).to have_content "New element" button.click - expect(page).to have_select("Element") + expect(page).to have_css(".alchemy-dialog") within ".alchemy-dialog" do + expect(page).to have_select("Element") select2("Text", from: "Element") click_button("Add") end