Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Bob committed Sep 28, 2024
1 parent 80a5663 commit 3a79a09
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
8 changes: 0 additions & 8 deletions spec/features/avo/fields_methods_for_views_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,5 @@ def form_fields
define_method(:form_fields, original_form_fields)
end
end

it "detach works using show and index fields api" do
visit "#{Avo::Engine.routes.url_helpers.resources_course_path(course)}/links?turbo_frame=has_many_field_links&view=show"

expect {
find("tr[data-resource-id='#{course.links.first.to_param}'] [data-control='detach']").click
}.to change(course.links, :count).by(-1)
end
end
end
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 @@ -82,17 +82,6 @@
# expect(page).to have_selector("#{form} input#referrer_destroy_#{post.id}[value='/admin/resources/users/#{user.slug}/posts?turbo_frame=has_many_field_posts']", visible: false)
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 "detaches a post" do
visit url

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

require "rails_helper"

RSpec.describe "Attachment success", type: :system do
RSpec.describe "Associations using *_fields api", type: :system do
let!(:attach_link) { create :course_link }
let!(:course) { create :course }
let!(:links) { create_list :course_link, 3 }
let!(:course) { create :course, links: links }

it "attach works using show and index fields api" do
it "attach and detach works using show and index fields api" do
visit avo.resources_course_path(course)

scroll_to find('turbo-frame[id="has_many_field_show_links"]')
Expand All @@ -23,5 +24,11 @@
end
wait_for_loaded
}.to change(course.links, :count).by 1

expect {
accept_custom_alert do
find("tr[data-resource-id='#{course.links.first.to_param}'] [data-control='detach']").click
end
}.to change(course.links, :count).by(-1)
end
end
15 changes: 15 additions & 0 deletions spec/system/avo/has_many_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,20 @@ def destroy
expect(page).to have_current_path url
expect(page).not_to have_text post.name
end

it "detaches 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='detach']").click
end
}.to change(user.posts, :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 3a79a09

Please sign in to comment.