Skip to content

Commit

Permalink
✅ Add tests for controls placement
Browse files Browse the repository at this point in the history
  • Loading branch information
RocKhalil committed Oct 14, 2024
1 parent e65d859 commit 264876f
Showing 1 changed file with 51 additions and 4 deletions.
55 changes: 51 additions & 4 deletions spec/features/avo/resource_controls_placement_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,72 @@
end

describe "with controls on the left" do
it "shows to the left" do
it "shows to the left when configured from Avo.configuration" do
Avo.configuration.resource_controls_placement = :left
visit "/admin/resources/comments"

within find("table") do
# XPath containing the index of the cell
expect(page).to have_xpath('tbody/tr[1]/td[1][@data-control="resource-controls"]')
expect(page).to have_xpath("tbody/tr[1]/td[1][@data-control='resource-controls']")
end
end

it "shows to the left when configured from resource configuration" do
with_temporary_class_option(Avo::Resources::Comment, :controls_placement, :left) do
visit "/admin/resources/comments"

within find("table") do
# XPath containing the index of the cell
expect(page).to have_xpath("tbody/tr[1]/td[1][@data-control='resource-controls']")
end
end
end
end

describe "with controls on the right" do
it "shows to the right" do
it "shows to the right when configured from Avo.configuration" do
Avo.configuration.resource_controls_placement = :right
visit "/admin/resources/comments"

within find("table") do
# XPath containing the index of the cell
expect(page).to have_xpath('tbody/tr[1]/td[6][@data-control="resource-controls"]')
expect(page).to have_xpath("tbody/tr[1]/td[6][@data-control='resource-controls']")
end
end

it "shows to the right when configured from resource configuration" do
with_temporary_class_option(Avo::Resources::Comment, :controls_placement, :right) do
visit "/admin/resources/comments"

within find("table") do
# XPath containing the index of the cell
expect(page).to have_xpath("tbody/tr[1]/td[6][@data-control='resource-controls']")
end
end
end
end

describe "with controls on both sides" do
it "shows on both sides when configured from Avo.configuration" do
Avo.configuration.resource_controls_placement = :both
visit "/admin/resources/comments"

within find("table") do
# XPath containing the index of the cell
expect(page).to have_xpath("tbody/tr[1]/td[1][@data-control='resource-controls']")
expect(page).to have_xpath("tbody/tr[1]/td[7][@data-control='resource-controls']")
end
end

it "shows on both sides when configured from resource configuration" do
with_temporary_class_option(Avo::Resources::Comment, :controls_placement, :both) do
visit "/admin/resources/comments"

within find("table") do
# XPath containing the index of the cell
expect(page).to have_xpath("tbody/tr[1]/td[1][@data-control='resource-controls']")
expect(page).to have_xpath("tbody/tr[1]/td[7][@data-control='resource-controls']")
end
end
end
end
Expand Down

0 comments on commit 264876f

Please sign in to comment.