Skip to content

Commit

Permalink
extract test that uses turbo to system test
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Bob committed Sep 28, 2024
1 parent 8a6870b commit 6d3a98a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
11 changes: 0 additions & 11 deletions spec/features/avo/has_many_field_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,6 @@
expect(page).to have_selector("[data-component='resources-index'] #{form} button[data-control='destroy'][data-resource-id='#{post.to_param}'][data-turbo-frame='has_many_field_posts']")
end

it "deletes a post" do
visit url

expect {
find("[data-resource-id='#{post.to_param}'] [data-control='destroy']").click
}.to change(Post, :count).by(-1)

expect(page).to have_current_path url
expect(page).not_to have_text post.name
end

it "detaches a post" do
visit url

Expand Down
20 changes: 20 additions & 0 deletions spec/system/avo/has_many_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,24 @@ def destroy
end
end
end

describe "with a related post" do
let!(:post) { create :post, user: user }
let!(:url) { "/admin/resources/users/#{user.slug}?tab-group_second_tabs_group=Posts" }

it "deletes a post" do
visit url

scroll_to find('turbo-frame[id="has_many_field_show_posts"]')

expect {
accept_custom_alert do
find("[data-resource-id='#{post.to_param}'] [data-control='destroy']").click
end
}.to change(Post, :count).by(-1)

expect(page).to have_current_path url
expect(page).not_to have_text post.name
end
end
end

0 comments on commit 6d3a98a

Please sign in to comment.