Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #242 from alphagov/sorting-feedback
Add sorting to organisation summary table
- Loading branch information
Showing
9 changed files
with
175 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.table-sortable { | ||
.sortable-column { | ||
padding: 0; | ||
} | ||
|
||
.sortable-column div { | ||
padding: $table-cell-padding; | ||
} | ||
|
||
.sortable-column a:hover, | ||
.sortable-column a:focus { | ||
text-decoration: none; | ||
|
||
div { | ||
background-color: #ccc; | ||
} | ||
} | ||
|
||
.sorted-column div { | ||
background-color: #ddd; | ||
} | ||
|
||
.sorted-column .glyphicon { | ||
margin-left: 5px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
require 'rails_helper' | ||
require 'gds_api/test_helpers/support_api' | ||
|
||
feature "Summary of Organisation feedback" do | ||
include GdsApi::TestHelpers::SupportApi | ||
background do | ||
login_as create(:user) | ||
end | ||
|
||
before do | ||
stub_summary_sorted_by('last_7_days') | ||
explore_anonymous_feedback_with(organisation: "Cabinet Office") | ||
end | ||
|
||
scenario "defaults to sorting feedback by last 7 days" do | ||
expect(page).to have_content("Feedback for Cabinet Office") | ||
expect(organisation_summary_results).to eq(organisation_summary) | ||
expect(page).to have_selector('th.sorted-column', text: "7 days") | ||
end | ||
|
||
scenario "organisation feedback table can be sorted by path, 7, 30 and 90 days" do | ||
{ | ||
path: 'Page', | ||
last_7_days: '7 days', | ||
last_30_days: '30 days', | ||
last_90_days: '90 days', | ||
}.each do |param, name| | ||
stub_summary_sorted_by(param.to_s) | ||
within '.table-sortable thead' do | ||
click_on name | ||
end | ||
expect(organisation_summary_results).to eq(organisation_summary) | ||
expect(page).to have_selector('th.sorted-column', text: name) | ||
expect(page).to have_no_selector('th a', text: name) | ||
end | ||
end | ||
|
||
def stub_summary_sorted_by(ordering) | ||
stub_anonymous_feedback_organisation_summary('cabinet-office', ordering, { | ||
"title" => "Cabinet Office", | ||
"anonymous_feedback_counts" => [ | ||
{ path: '/done-well', last_7_days: 5, last_30_days: 10, last_90_days: 20 }, | ||
{ path: '/not-bad-my-friend' }, | ||
{ path: '/fair-enough' }, | ||
], | ||
}) | ||
end | ||
|
||
def organisation_summary | ||
[ | ||
{ | ||
"Page" => "/done-well", | ||
"7 days" => "5 items", | ||
"30 days" => "10 items", | ||
"90 days" => "20 items", | ||
}, { | ||
"Page" => "/not-bad-my-friend", | ||
"7 days" => "0 items", | ||
"30 days" => "0 items", | ||
"90 days" => "0 items", | ||
}, { | ||
"Page" => "/fair-enough", | ||
"7 days" => "0 items", | ||
"30 days" => "0 items", | ||
"90 days" => "0 items", | ||
} | ||
] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters