As mentioned in the previous commits, a `<select>` field which submits its form on change causes many accessibility and usability issues, so we're replacing it with the order links we use everywhere else. Since the links "Id" and "Title" by themselves don't have enough information to let users know they're used to sort by ID or title, we have to update them somehow. We could add a "Sort by:" prefix before the list of links (and associate it with the `aria-labelledby` attribute); however, we don't do this anywhere else and might look weird depending on the screen size. So we're simply adding "Sort by" before each link. Now that we don't use the `wide_order_selector` partial anymore, we can remove it alongside the styles for the `select-order` class.
78 lines
3.4 KiB
Ruby
78 lines
3.4 KiB
Ruby
require "rails_helper"
|
|
|
|
describe "Admin collaborative legislation", :admin do
|
|
context "Index" do
|
|
scenario "Displaying legislation proposals" do
|
|
proposal = create(:legislation_proposal, cached_votes_score: 10)
|
|
|
|
visit admin_legislation_process_proposals_path(proposal.legislation_process_id)
|
|
|
|
within "#legislation_proposal_#{proposal.id}" do
|
|
expect(page).to have_content(proposal.title)
|
|
expect(page).to have_content(proposal.id)
|
|
expect(page).to have_content(proposal.cached_votes_score)
|
|
expect(page).to have_content("Select")
|
|
end
|
|
end
|
|
|
|
scenario "Selecting legislation proposals" do
|
|
proposal = create(:legislation_proposal, cached_votes_score: 10)
|
|
|
|
visit admin_legislation_process_proposals_path(proposal.legislation_process_id)
|
|
click_link "Select"
|
|
|
|
within "#legislation_proposal_#{proposal.id}" do
|
|
expect(page).to have_content("Selected")
|
|
end
|
|
end
|
|
|
|
scenario "Sorting legislation proposals by title" do
|
|
process = create(:legislation_process)
|
|
create(:legislation_proposal, title: "bbbb", legislation_process_id: process.id)
|
|
create(:legislation_proposal, title: "aaaa", legislation_process_id: process.id)
|
|
create(:legislation_proposal, title: "cccc", legislation_process_id: process.id)
|
|
|
|
visit admin_legislation_process_proposals_path(process.id)
|
|
click_link "Sort by title"
|
|
|
|
within("#legislation_proposals_list") do
|
|
within all(".legislation_proposal")[0] { expect(page).to have_content("aaaa") }
|
|
within all(".legislation_proposal")[1] { expect(page).to have_content("bbbb") }
|
|
within all(".legislation_proposal")[2] { expect(page).to have_content("cccc") }
|
|
end
|
|
end
|
|
|
|
scenario "Sorting legislation proposals by supports" do
|
|
process = create(:legislation_process)
|
|
create(:legislation_proposal, cached_votes_score: 10, legislation_process_id: process.id)
|
|
create(:legislation_proposal, cached_votes_score: 30, legislation_process_id: process.id)
|
|
create(:legislation_proposal, cached_votes_score: 20, legislation_process_id: process.id)
|
|
|
|
visit admin_legislation_process_proposals_path(process.id)
|
|
click_link "Sort by total supports"
|
|
|
|
within("#legislation_proposals_list") do
|
|
within all(".legislation_proposal")[0] { expect(page).to have_content("30") }
|
|
within all(".legislation_proposal")[1] { expect(page).to have_content("20") }
|
|
within all(".legislation_proposal")[2] { expect(page).to have_content("10") }
|
|
end
|
|
end
|
|
|
|
scenario "Sorting legislation proposals by Id" do
|
|
process = create(:legislation_process)
|
|
proposal1 = create(:legislation_proposal, title: "bbbb", legislation_process_id: process.id)
|
|
proposal2 = create(:legislation_proposal, title: "aaaa", legislation_process_id: process.id)
|
|
proposal3 = create(:legislation_proposal, title: "cccc", legislation_process_id: process.id)
|
|
|
|
visit admin_legislation_process_proposals_path(process.id, order: :title)
|
|
click_link "Sort by ID"
|
|
|
|
within("#legislation_proposals_list") do
|
|
within all(".legislation_proposal")[0] { expect(page).to have_content(proposal1.id) }
|
|
within all(".legislation_proposal")[1] { expect(page).to have_content(proposal2.id) }
|
|
within all(".legislation_proposal")[2] { expect(page).to have_content(proposal3.id) }
|
|
end
|
|
end
|
|
end
|
|
end
|