From 3ed26fb53008c8d9bd1931970911ffb15504a7ad Mon Sep 17 00:00:00 2001 From: Alvaro Sanchez Date: Mon, 19 Feb 2024 17:57:23 -0600 Subject: [PATCH] Added profile integration test for sorting gems in profile page alphabetically --- test/integration/profile_test.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/integration/profile_test.rb b/test/integration/profile_test.rb index eb907abdbf2..92c61b6efe1 100644 --- a/test/integration/profile_test.rb +++ b/test/integration/profile_test.rb @@ -177,4 +177,19 @@ def sign_out assert page.has_content? "special note" assert page.has_content? "request note" end + + test "sort gems alphabetically in profile" do + alphabetical_first = FactoryBot.create(:rubygem, name: "AGem", owners: [@user], downloads: 1) + alphabetical_last = FactoryBot.create(:rubygem, name: "ZGem", owners: [@user], downloads: 999) + + visit profile_path(@user.handle) + dropdown = find(:element, "data-gem-sort-target": "select") + form = find(:element, "data-gem-sort-target": "form") + dropdown.select("Name") + # Submit form without button + Capybara::RackTest::Form.new(form.base.driver, form.native).submit({}) + rubygem_links = page.all(:element, "a", class: "gems__gem__name") + assert rubygem_links.first.text == alphabetical_first.name + assert rubygem_links.last.text == alphabetical_last.name + end end