New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add facet metadata to specialist documents #304
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
839dcd3
Include facet values in metadata and footer
fofr f78c988
Test random but valid specialist documents
fofr a9950c2
Add custom breadcrumb for specialist documents
fofr 0a1ec6b
Split dates and other in document footer
fofr 5779bdb
Use change_notes to determine if updated
fofr d2c769e
Add airbrake notifications and refactor specialist presenter
c893440
Add more tests for specialist document
dbc2b01
Add integration test for metadata
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
class BenchmarkingAbTestRequest | ||
attr_accessor :requested_variant | ||
|
||
delegate :analytics_meta_tag, to: :requested_variant | ||
|
||
def initialize(request) | ||
dimension = Rails.application.config.benchmarking_ab_test_dimension | ||
ab_test = GovukAbTesting::AbTest.new( | ||
"Benchmarking", | ||
dimension: dimension | ||
) | ||
@requested_variant = ab_test.requested_variant(request.headers) | ||
end | ||
|
||
def in_benchmarking? | ||
requested_variant.variant_b? | ||
end | ||
|
||
def set_response_vary_header(response) | ||
requested_variant.configure_response(response) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
require 'test_helper' | ||
|
||
class SpecialistDocumentTest < ActionDispatch::IntegrationTest | ||
test "random but valid items do not error" do | ||
setup_and_visit_random_content_item(document_type: 'aaib_report') | ||
setup_and_visit_random_content_item(document_type: 'raib_report') | ||
setup_and_visit_random_content_item(document_type: 'tax_tribunal_decision') | ||
setup_and_visit_random_content_item(document_type: 'cma_case') | ||
end | ||
|
||
test "renders title, description and body" do | ||
setup_and_visit_content_item('aaib-reports') | ||
|
||
|
@@ -33,13 +40,65 @@ class SpecialistDocumentTest < ActionDispatch::IntegrationTest | |
within shared_component_selector("document_footer") do | ||
component_args = JSON.parse(page.text) | ||
history = component_args.fetch("history") | ||
|
||
assert_equal history.first["note"], @content_item["details"]["change_history"].last["note"] | ||
assert_equal history.last["note"], @content_item["details"]["change_history"].first["note"] | ||
assert_equal history.size, @content_item["details"]["change_history"].size | ||
end | ||
end | ||
|
||
test "renders text facets correctly" do | ||
setup_and_visit_content_item('countryside-stewardship-grants') | ||
|
||
def test_meta(component) | ||
within shared_component_selector(component) do | ||
component_args = JSON.parse(page.text) | ||
assert_equal component_args["other"]["Grant type"], "<a href=\"/countryside-stewardship-grants?grant_type%5B%5D=option\">Option</a>" | ||
assert_equal component_args["other"]["Tiers or standalone items"], | ||
["<a href=\"/countryside-stewardship-grants?tiers_or_standalone_items%5B%5D=higher-tier\">Higher Tier</a>", | ||
"<a href=\"/countryside-stewardship-grants?tiers_or_standalone_items%5B%5D=mid-tier\">Mid Tier</a>"].join(", ") | ||
assert_equal component_args["other"]["Land use"], | ||
["<a href=\"/countryside-stewardship-grants?land_use%5B%5D=arable-land\">Arable land</a>", | ||
"<a href=\"/countryside-stewardship-grants?land_use%5B%5D=wildlife-package\">Wildlife package</a>", | ||
"<a href=\"/countryside-stewardship-grants?land_use%5B%5D=water-quality\">Water quality</a>", | ||
"<a href=\"/countryside-stewardship-grants?land_use%5B%5D=wildlife-package\">Wildlife package</a>"].join(", ") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is wildlife package included twice? |
||
assert_equal component_args["other"]["Funding (per unit per year)"], | ||
"<a href=\"/countryside-stewardship-grants?funding_amount%5B%5D=more-than-500\">More than £500</a>" | ||
end | ||
end | ||
test_meta("document_footer") | ||
test_meta("metadata") | ||
end | ||
|
||
test "renders date facets correctly" do | ||
setup_and_visit_content_item('drug-device-alerts') | ||
|
||
within shared_component_selector("document_footer") do | ||
component_args = JSON.parse(page.text) | ||
assert_equal component_args["other_dates"]["Issued"], "6 July 2015" | ||
end | ||
|
||
within shared_component_selector("metadata") do | ||
component_args = JSON.parse(page.text) | ||
assert_equal component_args["other"]["Issued"], "6 July 2015" | ||
end | ||
end | ||
|
||
|
||
test "renders when no facet or finder" do | ||
setup_and_visit_content_item('business-finance-support-scheme') | ||
assert_has_component_metadata_pair("first_published", "9 July 2015") | ||
|
||
within shared_component_selector("document_footer") do | ||
component_args = JSON.parse(page.text) | ||
assert_equal component_args["other_dates"], {} | ||
end | ||
|
||
within shared_component_selector("metadata") do | ||
component_args = JSON.parse(page.text) | ||
assert_equal component_args["other"], {} | ||
end | ||
end | ||
|
||
test "renders a contents list" do | ||
setup_and_visit_content_item('aaib-reports') | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should include the not allowed value in the Airbrake notification for easier debugging.