Skip to content

Commit

Permalink
Harden edit elements feature spec
Browse files Browse the repository at this point in the history
There is JS involved opening the dialog, so we
need to tell Capybara to wait for it.
  • Loading branch information
tvdeyen committed Feb 8, 2024
1 parent 5d4c6d5 commit f370962
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions spec/features/admin/edit_elements_feature_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f370962

Please sign in to comment.