Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix add nested element with multiple nestable elements #2052

Merged
merged 2 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/elements/_element.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<%= link_to_dialog Alchemy.t("New Element"),
alchemy.new_admin_element_path(
parent_element_id: element.id,
page_id: element.page.id
page_version_id: element.page_version_id
), {
size: "320x125",
title: Alchemy.t("New Element")
Expand Down
31 changes: 28 additions & 3 deletions spec/features/admin/edit_elements_feature_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,39 @@
end
end

context "With an element having nestable elements defined" do
context "With an element having one nestable element defined" do
let!(:element) do
create(:alchemy_element, :with_nestable_elements, page_version: a_page.draft_version)
end

scenario "a button to add an nestable element appears." do
scenario "the add element button immediately creates the nested element.", :js do
visit alchemy.admin_elements_path(page_version_id: element.page_version_id)
expect(page).to have_selector(".add-nestable-element-button")
button = page.find(".add-nestable-element-button")
expect(button).to have_content "Add slide"
button.click
expect(page).to have_selector(".element-editor[data-element-name='slide']")
end
end

context "With an element having multiple nestable element defined" do
let!(:element) do
create(:alchemy_element,
:with_nestable_elements,
name: :right_column,
page_version: a_page.draft_version)
end

scenario "the add element button opens add element form.", :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 "New element"
button.click
expect(page).to have_select("Element")
within ".alchemy-dialog" do
select2("Text", from: "Element")
click_button("Add")
end
expect(page).to have_selector(".element-editor[data-element-name='text']")
end
end

Expand Down