Skip to content

Instantly share code, notes, and snippets.

@MatMoore
Created February 5, 2024 11:27
Show Gist options
  • Save MatMoore/0a7aaf88de2d283b42fc71e85d07d126 to your computer and use it in GitHub Desktop.
Save MatMoore/0a7aaf88de2d283b42fc71e85d07d126 to your computer and use it in GitHub Desktop.
Finder frontend behaviour
TopicalFacet
#sentence_fragment
multiple values
is expected to eql "end_date"
disallowed values
is expected to be nil
single value
is expected to eql "end_date"
Registries::TopicTaxonomyRegistry
when topic taxonomy api is available
will provide the taxonomy tree not including those in the alpha phase
will fetch an expanded topic taxon by content_id
when topic taxonomy API is unavailable
will return an (uncached) empty hash
Search::QueryBuilder
should include a count
with pagination
should use documents_per_page from content item
with A/B parameters
should include an A/B query
#start
starts at zero when page param is an array
starts at zero when page param is zero
starts at zero when page param is empty
starts at zero by default
is paginated
starts at zero when page param is an invalid string
starts at zero when page param is nil
with debug parameters
should include a debug query
with a base filter
should include fields prefixed with filter_
without keywords
should not include a keyword query
should include an order query
with a custom order
should include a custom order query
without any facets
should include base return fields
with keywords
should not include an order query
should include a keyword query
longer than the maximum query length
should include a truncated
with stopwords
should not include stopwords in search
ignores case of keywords
strips punctuation from stopword check
does not strip numbers from search
without stopwords
should include stopwords in search
with field boosts
should include field boosts for eligible content items
without debug parameters
should not include a debug query
with facets
should include base and extra return fields
should include reject fields prefixed with reject_
facets with or combine_mode
should filter on both alpha and beta in the second query
should generate two queries
should filter on just alpha in the first query
facets with filter_keys
should use the filter value in fields
of 'content_id' type
with `and` combine_mode
adds a `filter_facet_values` filter with the content_id
with `or` combine_mode
sends the correct `filter_any_facet_values` to each query
EntryPresenter
#updated_at
returns the release timestamp
returns the public timestamp
#summary
displays the truncated description
returns nil
#feed_ended_id
returns a feed_ended_id
#tag
returns a tag
All components
date_filter
is documented
has a correctly named spec file
has a correctly named SCSS file (PENDING: No reason given)
has the correct class in the ERB template (PENDING: No reason given)
has a correctly named template file
has the correct documentation
doesn't use `html_safe`
expander
has the correct class in the ERB template
has a correctly named template file
doesn't use `html_safe`
has the correct documentation
has a correctly named SCSS file
has a correctly named spec file
is documented
Healthchecks::RegistriesCache
All Registries have cached data
has an OK status
Registries caches are empty
has a critical status
EmailAlertTitleBuilder
when there is one facet
when no choice is selected
is expected to eq "Prefixes:"
when one choice is selected
is expected to eq "Prefix: topic name one"
when two choices are selected
is expected to eq "Prefixes: topic name one and topic name two"
when there are no facets
is expected to eq "Prefix"
when there are multiple facets with the same filter_key
is expected to eq "News and communicatons with people of Harry Potter, Ron Weasley, Albus Dumbledore, Cornelius Fudge, ... and 1 other organisation, topics of Magical Education, Brexit, and Herbology, and 2 document types"
when there are multiple facets
when no choice is selected
is expected to eq "Prefix:"
when one dynamic facet is selected
is expected to eq "Prefix with people of Harry Potter and Ron Weasley"
when two facets are selected
is expected to eq "Prefix: with facet name one of topic name one and topic name two and facet name two of topic name three and topic name four"
when one facet is selected
when two choices are selected
is expected to eq "Prefix: with facet name one of topic name one and topic name two"
when one choice is selected
is expected to eq "Prefix: with facet name one of topic name one"
when a facet_connector is provided
is expected to eq "All documents filtered by Statistics (published) and Research"
DateFacet
#query_params
multiple date values
is expected to eql {"date_of_occurrence"=>{"from"=>"22/09/1988", "to"=>"22/09/2014"}}
#sentence_fragment
6 digit date value
is expected to eql "date_of_occurrence"
multiple date values
is expected to eql "date_of_occurrence"
single date value
is expected to eql "date_of_occurrence"
SpellingSuggestionPresenter
#suggestions
presents spelling suggestions
TaxonFacet
#sentence_fragment
disallowed value selected
is expected to be nil
allowed value selected
is expected to eql "level_one_taxon"
#topics
will return an array of topics
will have a default option
topic items
will have values required for rendering
#sub_topics
will return an array of sub-topics
will have a default option
will provide values required for rendering items
FilterableFacet
#preposition
has a default preposition
has a preposition specified in the facet content
#to_partial_path
with another kind of facet
is expected to eql "example_facet"
with a Facet
is expected to eql "filterable_facet"
ParameterParser::EmailAlertParameterParser
#valid?
when there are no permitted facets
with bad params provided
is expected to equal true
with no user params provided
is expected to equal true
with good params provided
is expected to equal true
when there are permitted facets (CMA cases)
with bad keys provided in params
is expected to equal true
with unpermitted params provided
is expected to equal true
with good params provided
is expected to equal true
with bad values provided in params
is expected to equal true
with no user params provided
is expected to equal true
when there are bad facets in the content item
with good params provided
is expected to equal true
with bad values provided in params
is expected to equal false
with no user params provided
is expected to equal true
with bad keys provided in params
is expected to equal false
#applied_filters
when there are permitted facets (CMA Cases)
with good params provided
is expected to eq {"case_type"=>["ca98-and-civil-cartels", "consumer-enforcement"]}
with unpermitted params provided
is expected to eq {"case_type"=>["ca98-and-civil-cartels", "consumer-enforcement"]}
with no user params provided
is expected to eq {}
when there are 'dynamic' facets (News and Communications)
with both subscriber_list_params and params provided
is expected to eq {"organisations"=>["department-of-mysteries", "gringots"], "people"=>["albus-dumbledore", "harry-potter"]}
with subscriber_list_params params provided
is expected to eq {"organisations"=>["department-of-mysteries", "gringots"], "people"=>["albus-dumbledore"]}
with filter params provided
is expected to eq {"people"=>["albus-dumbledore"]}
with no user params provided
is expected to eq {}
when there are 'option lookup' facets (Policy Papers and Consultations)
is expected to eq {"organisations"=>["department-of-mysteries", "gringots"], "people"=>["cornelius-fudge"]}
when there are facets containing filter_values (Research and Statistics)
is expected to eq {"content_store_document_type"=>["statistics_published"], "organisations"=>["department-of-mysteries"]}
when there are no permitted facets
with filter params provided
is expected to eq {}
with user params provided
is expected to eq {}
with no user params provided
is expected to eq {}
expander
shows the given title and content
sets open on load correctly
accepts button data attributes
renders nothing without passed content
sets a margin bottom
Registries::FullTopicTaxonomyRegistry
when topic taxonomy API is unavailable
will return an (uncached) empty hash
when topic taxonomy api is available
can look up a child taxon by basepath
can look up a level one taxon by basepath
Filters::RadioFilter
#active?
when a default allowed value is set
when params is an array
should be true
when params is nil
should be true
when no default allowed value is set
when params is nil
should be false
when params is empty
should be false
#value
without option lookup
when no option is provided and a default value is set
should return the default value
when a disallowed param is provided
a default option is set
should return the default value
a default option is NOT provided
should return an empty array
when the option is not a string and a default value is set
should return the default value
when an allowed option is provided
should return the option as an array
with option lookup
when no option is selected
should return the corresponding default values from the option_lookup
when a disallowed value is provided
when a default value is not set
should return an empty array
when a default value is set
should return the corresponding default values from the option_lookup
when an allowed option is selected
should return the corresponding values from the option_lookup
#key
when a filter_key is not present
returns key
when a filter_key is present
returns filter_key
SignupLinksPresenter
url helpers
#signup_links[:feed_link]
with some values
returns the finder URL appended with permitted query params
with a licence transaction
returns nil
with no values
returns the finder URL appended with .atom
#email_signup_link
with no values
returns the finder URL appended with /email-signup
with some values
returns the finder URL appended with permitted query params
ResultSetPresenter
#displayed_total
displays the total and the document noun
#total_count
displays the total count
#documents
#search_results_content[:document_list_component_data]
has the right data
with &debug_score=1
shows debug metadata
there is one document in the results
creates a new search_result_presenter hash for each result
there are 3 documents in the results
creates a new document for each result
with universal analytics ecommerce disabled
doesn't include UA ecommerce attributes
FacetParser
with a select facet definition
should build a list of allowed values
is expected to eql "case_type"
is expected to be a kind of OptionSelectFacet
is expected to eql "of type"
is expected to eql "Case type"
Registries::WorldLocationsRegistry
when world locations API is unavailable
will return an (uncached) empty array
when world locations api is available
will return all world locations
will fetch an expanded world location by slug
SearchResultPresenter
#document_list_component_data
returns a hash of the data we need to show the document
has parts
when the result is number 4 or higher
does not show any parts
when the result is number 3 or lower
notifies of a validation error for missing part data
shows only parts with required data
#subtext
returns nothing unless the document is historic or debug_score is set to true
The document has been reranked
gives the original score and rank in the debug text
debug_score is true
returns debug metadata
The document is historic and the debug_score is true
returns 'Published by' and debug metadata together
The document is historic
returns 'Published by' text
structure_metadata
A text based facet and a document tagged to the key of the facet
displays text based metadata
A date based facet and a document tagged to the key of the facet
displays date based metadata
Document
initialization
defaults to nil without a public timestamp
returns a link as a path
es_score
es_score is 0.005
#metadata
The facet key is an organisation or a document collection
uses title instead of label
the facet key is an organisation and the document is a mainstream document
does not display metadata because we are not interested in who publishes a mainstream document
There is one facet with type text
The document is tagged to a single value of the facet filter key
gets metadata for a simple text value
There is a short name in the facet
replaces the name field in the metafata by the short name from the facet
The document is tagged to a multiple values of the facet filter key
gets the metadata
There is one facet with type "date"
gets the metadata
RedirectionController
#redirect_brexit
replaces the brexit param with the brexit taxon, overwriting other taxons
redirects to the same slug with the brexit taxon
#redirect_consultations
redirects to /search/policy-papers-and-consultations retaining world locations and setting content-store-document-type
redirects to /search/policy-papers-and-consultations retaining level one and two taxons and setting content-store-document-type
redirects to /search/policy-papers-and-consultations replacing departments with organisations and setting content-store-document-type
#redirect_latest
copes with incorrect types being passed as parameters
redirects to /search/all replacing departments with organisations
redirects to /search/all retaining topical events
redirects to /search/all retaining world locations
#redirect_statistics_announcements
redirects to /search/research-and-statistics
#redirect_covid
replaces the topical event with the coronavirus taxon, overwriting other taxons
redirects to the same slug with the coronavirus taxon
#advanced_search
redirects to news and comms finder
redirects with a topic parameter, translating the base path to content_id
redirects the services finder
The group does not exist
returns 404
The topic does not exist
redirects ignoring the topic
StatisticsSortPresenter
#selected_option
Release date (latest) is selected by the user
returns Updated (newest)
Updated (oldest) is selected by the user
returns Updated (oldest)
upcoming statistics is selected
returns Release date (soonest) as the default
upcoming statistics is selected
returns Release date (latest) as the default
no option is selected by the user
returns the default option
an unpermitted option is selected by the user
returns the default option
upcoming statistics is selected
returns Release date (soonest)
published statistics is selected
returns the default option
research is selected
returns the default option
cancelled statistics is selected
returns Updated (newest)
Sort option release-date-oldest is selected by the user
cancelled statistics statistics is selected
returns Release date (oldest) as the default
upcoming statistics is selected
returns Release date (soonest) as the default
a permitted option is selected by the user
returns the permitted sort option
#to_hash
upcoming_statistics is selected
has 4 options
excludes public timestamp options
sets relevance_value
sets default_value
keywords are not entered
disables relevance
keywords are entered
enables relevance
published_statistics is selected
provides updated-newest as the default value
has 4 options
has a relevance_value
excludes release timestamp options
keywords are entered
enables relevance
keywords are not entered
disables relevance
document group is unset
excludes release timestamp options
returns a hash containing an array of options
has a relevance_value
sets the default option as selected
has 4 options
provides a default value
keywords are not entered
disables relevance
keywords are entered
enables relevance
#default_option and #default_value
when research is selected
returns updated newest
when upcoming_statistics is selected
returns release timestamp
when published_statistics is selected
returns updated newest
when no value is selected
returns updated newest as the default
when cancelled_statistics is selected
returns public timestamp
#has_options?
returns true if there are sort options in the content item
returns false if there are no options in the content item
Services::EmailAlertApi
#find_or_create_subscriber_list_cached
email-alert-api finds or creates the subscriber list
caches the subscriber list once created
returns a newly created subscriber list
email alert api refuses to create the subscriber list
bubbles up the 422 error
ResultSetParser
with a result set hash with some documents
is expected to eql :a_document_instance and :another_document_instance
is expected to eql 1
is expected to eql 2
RadioFacetForMultipleFilters
#query_params
value selected
is expected to eq {"type"=>"value_1"}
#options
invalid value
sets the options, selecting the default value
valid value
sets the options, selecting the correct value
MetadataPresenter
#present
presents the metadata
ParamsCleaner
#fetch
returns the default when the param class differs
returns the param when the default class matches
#cleaned
strips leading and trailing whitespace from array-of-stringstring parameters
removes params with blank values
DEPRECATION WARNING: Comparing equality between `ActionController::Parameters` and a `Hash` is deprecated and will be removed in Rails 7.2. Please only do comparisons between instances of `ActionController::Parameters`. If you need to compare to a hash, first convert it using `ActionController::Parameters#new`. To disable the deprecated behavior set `Rails.application.config.action_controller.allow_deprecated_parameters_hash_equality = false`. (called from block (3 levels) in <top (required)> at /Users/matt.moore/code/finder-frontend/spec/lib/params_cleaner_spec.rb:14)
leaves normal params alone
makes an array of a array-like hash
strips leading and trailing whitespace from string parameters
DEPRECATION WARNING: Comparing equality between `ActionController::Parameters` and a `Hash` is deprecated and will be removed in Rails 7.2. Please only do comparisons between instances of `ActionController::Parameters`. If you need to compare to a hash, first convert it using `ActionController::Parameters#new`. To disable the deprecated behavior set `Rails.application.config.action_controller.allow_deprecated_parameters_hash_equality = false`. (called from block (3 levels) in <top (required)> at /Users/matt.moore/code/finder-frontend/spec/lib/params_cleaner_spec.rb:20)
does not touch other types of hash-params
FacetTagsPresenter
#selected_filter_descriptions
includes prepositions for each facet
#present
returns a hash containing expected keys
display_total_selected_filters
displays the count of total filters applied, not the count of filter types applied
KeywordFacet
#query_params
value selected
is expected to eql {"keywords"=>["keyword"]}
#sentence_fragment
keywords with multiple quotes
is expected to eql "\"Merry Christmas\"", "\" Happy Birthday\"", "i'm", "100", and "today"
keywords with quotes
is expected to eql "\"Merry Christmas\""
without any keywords
is expected to be nil
keywords without quotes
is expected to eql ""
PageMetadataHelper
#page_metadata
contains links to organisations
it is a topic page
does not contain the "inverse" key
it is not a topic page
does not contain the "inverse" key
there are no organisations
does not contain the "from" key
SortOptionPresenter
default?
returns false if option is NOT default
returns true if option is default
#value
a value is not provided
returns label parameterized
a value is provided
returns the given value
to_hash
returns a hash including label, value, tracking_attributes
Registries::Registry
#can_refresh_cache?
returns false
SortPresenter
#has_options?
returns true if there are sort options in the content item (FAILED - 1)
returns false if there are no options in the content item (FAILED - 2)
#default_value
returns a default_value if there is a default option specified in the content item (FAILED - 3)
returns nil if there is not a default option specified in the content item (FAILED - 4)
#to_hash
should enable the popularity option if keywords are not present (FAILED - 5)
returns a hash containing options, default_value, and relevance_value (FAILED - 6)
returns nil when the finder doesn't have sort options (FAILED - 7)
provides a default option if one is specified (FAILED - 8)
provides a relevance option if one is specified (FAILED - 9)
sets an option as selected if a valid order is provided by the user (FAILED - 10)
should disable the relevance option if keywords are not present (FAILED - 11)
keywords are not blank
should not disable relevance (FAILED - 12)
should disable popularity (FAILED - 13)
an unacceptable order is provided
no option is selected (FAILED - 14)
order is not specified and default option exists
returns sort options with default option selected (FAILED - 15)
#default_option
a default option is specified in the content item
returns the default SortOptionPresenter (FAILED - 16)
no default option is specified in the content item
returns nil (FAILED - 17)
#selected_option
no option is selected by the user
returns a default content item sort option (FAILED - 18)
an option is selected by the user
returns a selected content item sort option (FAILED - 19)
no default or selected option is available
returns nil (FAILED - 20)
HiddenFacet
#to_partial_path
with a Facet
is expected to eql "hidden_facet"
#query_params
value selected
returns the value
invalid value selected
removes the invalid values
no allowed values specified
returns the values without validation
Filters::OfficialDocumentsFilter
#filter_hashes
returns valid official_documents filter hashes
Healthcheck
when everything is fine
returns an OK status
TopicFinderHelper
#topic_finder?
returns true because there is a topic parameter that exists
returns false because there is a topic parameter that does not exist
returns false because there is no topic parameter
Filters::RadioFilterForMultipleFields
#query_hash
no filter hashes are given
throws and error
invalid parameter
returns the default query hash
empty parameter
returns the default query hash
valid parameter
returns valid query hash
Redirecting
coronavirus topical event searches
sends coronavirus topical event to a redirect (array params)
ignores atom feeds
sends coronavirus topical event to a redirect (string params)
includes other params too
ignores other topical events
related_to_brexit searches
includes other params too
doesn't redirect empty params
redirects to the Brexit handler
FacetTagPresenter
taxonomy tags
hides the taxonomy tags when requested from a topic page
shows the taxonomy tags when requested from any other page
SignupPresenter
no facets in email signup
#can_modify_choices?
returns an empty array
#choices?
returns false
#choices
returns an empty array
single facet
#choices?
returns true
#choices
returns an array of signup facets
#can_modify_choices?
returns false
multiple facets
#choices
returns an array of signup facets
#can_modify_choices?
returns true
#choices?
returns true
CheckboxFacet
#checked?
checkbox is selected
is expected to eql true
checkbox is not selected
is expected to eql false
#query_params
checkbox is selected
is expected to eql {"show_extra_information"=>"selectedvalue"}
checkbox is not selected
is expected to eql {}
#sentence_fragment
single value
is expected to eql "show_extra_information"
when multiple values are provided
when a value is provided
is expected to eql "show_extra_information"
when no value is provided
is expected to be nil
OptionSelectFacet
#query_params
value selected
is expected to eql {"test_values"=>["allowed-value-1"]}
#sentence_fragment
multiple values
is expected to eql "test_values"
disallowed values
is expected to be nil
single value
is expected to eql "test_values"
#unselected?
some selected values
is expected to equal false
no selected values
is expected to equal true
#cache_key
where facet names differ
cache keys should differ
where facet allowed values differ in order
cache keys should differ
Filters::DateFilter
#query_hash
when to date is provided
include the to date
when from date is provided
include the from date
when both to and from dates are provided
include both to and from dates
#active?
when empty dates are provided
should be false
when params is nil
should be false
HiddenClearableFacet
#query_params
value selected
is expected to eql {"test_facet"=>["allowed-value-1"]}
#has_filters?
no value
is expected to eql false
has a value
is expected to eql true
#sentence_fragment
disallowed values
is expected to be nil
single value
is expected to eql "test_facet"
multiple values
is expected to eql "test_facet"
DateParser
returns the correct date for July
returns the correct date for 010101
returns the correct date for June with preceeding whitespace
returns the correct date for with preceeding whitespace
returns the correct date for 21 01 2002 with trailing whitespace
returns the correct date for 21-1-2002 with trailing whitespace
returns the correct date for 21-01-2002 with preceeding whitespace
returns the correct date for 1
returns the correct date for August with preceeding whitespace
returns the correct date for september 2014 with trailing whitespace
returns the correct date for 21.01.2002 with trailing whitespace
returns the correct date for 21 01 2002 with preceeding whitespace
returns the correct date for 09/2013
returns the correct date for 2008 with preceeding whitespace
returns the correct date for 1234
returns the correct date for 2004/6/1 with preceeding whitespace
returns the correct date for 21012002 with trailing whitespace
returns the correct date for 21.01.14 with preceeding whitespace
returns the correct date for 20120 with trailing whitespace
returns the correct date for 01/11/2014 with preceeding whitespace
returns the correct date for 21 January 2014 with trailing whitespace
returns the correct date for 21-01-14 with trailing whitespace
returns the correct date for 21.01.14 with trailing whitespace
returns the correct date for
returns the correct date for 21 January 2014
returns the correct date for November with preceeding whitespace
returns the correct date for 20120
returns the correct date for April
returns the correct date for 21/01/99 with preceeding whitespace
returns the correct date for 21012002 with preceeding whitespace
returns the correct date for 21/01/14
returns the correct date for November with trailing whitespace
handles dates without years correctly
returns the correct date for 21.01.99
returns the correct date for July with preceeding whitespace
returns the correct date for July with trailing whitespace
returns the correct date for 20120 with preceeding whitespace
returns the correct date for 21-01-14
returns the correct date for October with trailing whitespace
returns the correct date for september 2014
returns the correct date for 1 with preceeding whitespace
returns the correct date for 21.01.99 with trailing whitespace
returns the correct date for 21/01/2002
returns the correct date for 21/1/2002 with trailing whitespace
returns the correct date for March
returns the correct date for 21 1 2002
returns the correct date for 22 Sept 2014
returns the correct date for 09/2013 with preceeding whitespace
returns the correct date for 21 1 2002 with preceeding whitespace
returns the correct date for 21-1-2002 with preceeding whitespace
returns the correct date for Britain First with preceeding whitespace
returns the correct date for March with trailing whitespace
returns the correct date for 21.01.14
returns the correct date for 21st january 2014
returns the correct date for March with preceeding whitespace
returns the correct date for November
returns the correct date for October with preceeding whitespace
returns the correct date for October
returns the correct date for January
returns the correct date for February with trailing whitespace
returns the correct date for 21/1/2002
returns the correct date for April with trailing whitespace
returns the correct date for 1234 with preceeding whitespace
returns the correct date for 010101 with preceeding whitespace
returns the correct date for 21/01/14 with trailing whitespace
returns the correct date for 21-01-99 with trailing whitespace
returns the correct date for 21-01-99 with preceeding whitespace
returns the correct date for with trailing whitespace
returns the correct date for May with trailing whitespace
returns the correct date for January with preceeding whitespace
returns the correct date for 21-1-2002
returns the correct date for January with trailing whitespace
returns the correct date for 22 Sept 2014 with trailing whitespace
returns the correct date for 21 01 99 with trailing whitespace
returns the correct date for 21/01/14 with preceeding whitespace
returns the correct date for 2008 with trailing whitespace
returns the correct date for 21 1 2002 with trailing whitespace
returns the correct date for April with preceeding whitespace
returns the correct date for 6 april 2018 to april 2018 with preceeding whitespace
returns the correct date for 22/09/25 with preceeding whitespace
returns the correct date for September
returns the correct date for 1234 with trailing whitespace
returns the correct date for 6 april 2018 to april 2018 with trailing whitespace
returns the correct date for 21.01.2002
returns the correct date for 21-01-2002
returns the correct date for 21/01/99
returns the correct date for randomwords with trailing whitespace
returns the correct date for 1 with trailing whitespace
returns the correct date for 21.1.2002 with preceeding whitespace
returns the correct date for 21012002
returns the correct date for 21.01.2002 with preceeding whitespace
returns the correct date for September with trailing whitespace
returns the correct date for 21 01 2002
returns the correct date for 22/09/25
returns the correct date for 21 01 99
returns the correct date for August
returns the correct date for August with trailing whitespace
returns the correct date for September with preceeding whitespace
returns the correct date for 21-01-2002 with trailing whitespace
returns the correct date for
returns the correct date for February with preceeding whitespace
returns the correct date for 21st january 2014 with trailing whitespace
returns the correct date for 21/1/2002 with preceeding whitespace
returns the correct date for 21/01/2002 with preceeding whitespace
returns the correct date for 21/01/2002 with trailing whitespace
returns the correct date for 21.1.2002
returns the correct date for 2004/6/1
returns the correct date for December with trailing whitespace
returns the correct date for December
returns the correct date for 31/15/14 with trailing whitespace
returns the correct date for september 2014 with preceeding whitespace
returns the correct date for 21.01.99 with preceeding whitespace
returns the correct date for 01/11/2014 with trailing whitespace
returns the correct date for 01/11/2014
returns the correct date for 21-01-14 with preceeding whitespace
returns the correct date for 2008
returns the correct date for 21-01-99
returns the correct date for 21/01/99 with trailing whitespace
returns the correct date for 21st january 2014 with preceeding whitespace
returns the correct date for with preceeding whitespace
returns the correct date for 1@ with trailing whitespace
returns the correct date for 09/2013 with trailing whitespace
returns the correct date for 010101 with trailing whitespace
returns the correct date for June
returns the correct date for Britain First
returns the correct date for randomwords
returns the correct date for Britain First with trailing whitespace
returns the correct date for May with preceeding whitespace
returns the correct date for 2004/6/1 with trailing whitespace
returns the correct date for randomwords with preceeding whitespace
returns the correct date for 22 Sept 2014 with preceeding whitespace
returns the correct date for December with preceeding whitespace
returns the correct date for 22/09/25 with trailing whitespace
returns the correct date for 31/15/14
returns the correct date for 6 april 2018 to april 2018
returns the correct date for 21 01 99 with preceeding whitespace
returns the correct date for 31/15/14 with preceeding whitespace
returns the correct date for 21 January 2014 with preceeding whitespace
returns the correct date for 1@ with preceeding whitespace
returns the correct date for February
returns the correct date for 1@
returns the correct date for May
returns the correct date for 21.1.2002 with trailing whitespace
returns the correct date for June with trailing whitespace
returns the correct date for with trailing whitespace
Filters::ResearchAndStatisticsFilter
#filter_hashes
returns valid reearch and stats filter hashes
FinderBreadcrumbsPresenter
breadcrumbs
has a link to home as the first entry
returns nil if there is no breadcrumb info
has no organisation link when the breadcrumb hash is invalid
has organisation breadcrumbs when the breadcrumb hash is populated
EmailAlertSubscriptionsController
GET #new
finder email signup item doesn't exist
returns a 404, rather than 5xx
finder email signup item does exist
returns a success (FAILED - 21)
POST #create
when the signup page has 'option lookup' filters (Policy Papers and Consultations)
redirects to the correct email subscription URL
when unprocessable keys are provided by the user
will redirect the user to the signup page (FAILED - 22)
when the finder signup page has filters (CMA Cases)
when a required filter is not provided
returns the user to the signup page with an error (FAILED - 23)
when all required filters are provided
redirects to the subscription url
when the signup page has 'dynamic' filters (News and Communications)
redirects to the correct email subscription url with subscriber_list_params
without allowed filters it redirects to the default email subscription url
when facet choices contain filter_values (Research and Statistics)
will redirect the user to the subscription URL
when filter and subscriber_list_params params are empty
will render the signup page URL again (FAILED - 24)
when the subscriber_list_params params are not provided
will redirect the user to the subscription URL
when the filter params are not provided
will redirect the user to the subscription URL
when unprocessable keys are provided by the user
will redirect the user to the signup page (FAILED - 25)
when additional keys or values are provided by the user
will strip surplus keys or values
when Email Alert API returns a 422 error
returns a 200 and displays the signup page (FAILED - 26)
when finder email signup item doesn't exist
returns a 404
Filters::TextFilter
#query_hash
when params has multiple values and option_lookup is present
should contain all values
when params is present and option_lookup is empty
should contain no values
when params is present and option_lookup is present
should contain all values
when params is present and option_lookup is absent
should contain all values
#key
when a filter_key is present
returns filter_key
when a filter_key is not present
returns key
#active?
when params is nil
should be false
when params is empty
should be false
ParamValidator
bad from_date params
#errors_hash
bad to_date params
#errors_hash
Metrics
.observe_duration
returns the result of the given block
fails gracefully if the histogram does not exist
observes the duration of the given block for the given histogram with the given labels
fails gracefully if the operation raises an error
.increment_counter
fails gracefully if the counter does not exist
fails gracefully if the operation raises an error
observes an increment of 1 for the given counter with the given labels
FacetsBuilder
facets
option_select_facet_hash facet
builds a option_select facet (FAILED - 27)
date facet
builds a taxon facet (FAILED - 28)
checkbox facet
builds a checkbox facet (FAILED - 29)
hidden_clearable facet
builds a checkbox facet (FAILED - 30)
radio facet
builds a checkbox facet (FAILED - 31)
hidden facet
builds a hidden facet (FAILED - 32)
taxon facet
builds a taxon facet (FAILED - 33)
allowed values
The allowed values are in the registry
gets values from the registry (FAILED - 34)
The allowed values are in the search results
gets the allowed values from the search results (FAILED - 35)
The allowed values are in the content item hash
copies allowed values from the hash (FAILED - 36)
Search::Query
when manually overriding parameters to use the v2 API
calls the v2 API
when searching using a single query
E, [2024-02-05T11:25:33.670794 #55479] ERROR -- : Prometheus Exporter, failed to send message Connection refused - connect(2) for "localhost" port 9394
uses the standard search endpoint
when merging, de-duplicating and sorting
when keywords are not used
most-relevant
de-duplicates and returns in the order rummager returns
default
de-duplicates and returns in the order rummager returns
behaves like sorts by other fields
a-to-z
de-duplicates and sorts by title descending
most-viewed
de-duplicates and sorts by popularity descending
most-recent
de-duplicates and sorts by public_updated descending
when keywords exist in search
with valid date params
has no errors
with invalid date params
stores an error for bad 'from date'
stores an error for bad 'to date'
default
de-duplicates and sorts by es_score descending
behaves like sorts by other fields
a-to-z
de-duplicates and sorts by title descending
most-viewed
de-duplicates and sorts by popularity descending
most-recent
de-duplicates and sorts by public_updated descending
most-relevant
de-duplicates and sorts by es_score descending
when in AB test variant B
calls the v2 API
FindersController
Errors on date filters
should detect bad 'to' dates (FAILED - 37)
should detect bad 'from' dates (FAILED - 38)
with legacy query parameters for announcements
redirects a request using both a non-default finder and has legacy parameters (FAILED - 39)
when there are legacy parameters present
strips out all from subtaxons parameter (FAILED - 40)
strips out all from departments parameter (FAILED - 41)
strips out all from taxons parameter (FAILED - 42)
replaces departments with organisations parameter (FAILED - 43)
with legacy query parameters for publications
redirects a request using both a non-default finder and has legacy parameters (FAILED - 44)
when there are legacy parameters present
replaces departments with organisations parameter (FAILED - 45)
strips out all from departments parameter (FAILED - 46)
strips out all from subtaxons parameter (FAILED - 47)
strips out all from taxons parameter (FAILED - 48)
when a non-default finder is needed
redirects to policy-papers-and-consultations finder with parameters for consultations (FAILED - 49)
redirects to transparency-and-freedom-of-information-releases finder with parameters for transparency-data (FAILED - 50)
redirects to official-documents finder for command_and_act_papers (FAILED - 51)
redirects to transparency-and-freedom-of-information-releases finder with parameters for corporate-reports (FAILED - 52)
redirects to guidance-and-regulation finder for regulations (FAILED - 53)
redirects to official-documents finder with parameters for act_papers (FAILED - 54)
redirects to transparency-and-freedom-of-information-releases finder with parameters for foi-releases (FAILED - 55)
redirects to research-and-statistics finder for statistics (FAILED - 56)
redirects to official-documents finder with parameters for command_papers (FAILED - 57)
redirects to guidance-and-regulation finder for guidance (FAILED - 58)
redirects to services finder for forms (FAILED - 59)
redirects to policy-papers-and-consultations finder with parameters for closed-consultations (FAILED - 60)
redirects to policy-papers-and-consultations finder with parameters for open-consultations (FAILED - 61)
redirects to policy-papers-and-consultations finder with parameters for corporate-reports (FAILED - 62)
redirects to research-and-statistics finder with parameters for corporate-reports (FAILED - 63)
GET show
finder item returns forbidden response when user not authorised
returns 403
finder item has been unpublished
returns a 404 for HTML requests
returns a message indicating the atom feed has ended
returns a 404 for json responses
and it was a policy finder page
returns a policy specific message indicating the atom feed has ended
finder item doesn't exist
returns a 404, rather than 5xx for the atom feed
returns a 404, rather than 5xx
a finder doesn't render a malicious search input
renders the users malicious input escaped (FAILED - 64)
a finder content item with a default order exists
sorts the finder results by public timestamp (FAILED - 65)
a finder content item exists
returns a 406 if an invalid format is requested (FAILED - 66)
correctly renders a finder page (FAILED - 67)
can respond with JSON (FAILED - 68)
can respond with an atom feed (FAILED - 69)
with AB test
sends ab_params to search query if page is being tested (FAILED - 70)
doesn't render the A for finders (FAILED - 71)
should render the page without an AB test variant for search (FAILED - 72)
renders the A variant for /search/all pages (FAILED - 73)
renders the Z variant for /search/all pages (FAILED - 74)
renders the B variant for /search/all pages (FAILED - 75)
sends ab_params to search query if page is being tested (FAILED - 76)
doesn't render the B for finders (FAILED - 77)
sends ab_params to search query if page is being tested (FAILED - 78)
doesn't render the Z for finders (FAILED - 79)
When private cache is set
can respond with an atom feed with private cache set (FAILED - 80)
Spelling suggestions
Gives the spelling suggestion and links to it (FAILED - 81)
AtomPresenter
#title
provides the finder title with filters applied
no facets selected
provides the finder title from the content item when no filters are applied
#updated_at
provides the date of the most recent document update
#entries
provides an array of EntryPresenter documents
ScreenReaderFilterDescriptionPresenter
#hidden_text
creates appropriate hidden text for the facet without a facet tag for a non default value
creates appropriate hidden text for the facet without a facet tag for a default value
will not include a facet without a facet tag if there is no selected value or default value
Registries::OrganisationsRegistry
when rummager is unavailable
will return an (uncached) empty hash
when rummager is available
will fetch organisation information by slug
will return organisations sorted by title with closed orgs at the end
ContentItem
as_hash
returns a content item as a hash
is_finder?
returns true when document_type is not finder
when document_type is not a finder
returns false when document_type is finder
load a content item from the content store
returns a content item as a hash
is_redirect?
returns false when document_type is not redirect
when document_type is redirect
returns true when document_type is redirect
is_search?
returns false when document_type is not search
when document_type is search
returns true when document_type is search
SearchParameters
#search_term
truncates a too-long search query
Registries::BaseRegistries
provides topic_taxonomy registry as part_of_taxonomy_tree
provides world_locations registry
fetches all registries
#ensure_warm_cache
populates the cache of all registries that implement refresh_cache
#refresh_cache
refreshes the cache of all registries that implement refresh_cache
Registries::RolesRegistry
there is no slug or title
will remove those results
when rummager is unavailable
will return an (uncached) empty hash
when rummager is available
will fetch role information by slug
will return all roles associated with documents ascending by name
PaginationPresenter
#next_and_prev_links
when per_page is unset
returns nil
when there are no other pages with results
returns nil
when there are only next pages
returns a next page link
when there are only previous pages
returns a previous page link
when there are next and previous pages
returns next and previous page links
components/_date_filter
does not display error if it isn't passed an error message
returns nothing when no key or name provided
returns two text fields with associated labels when key and name provided
prefills user values
displays an error if it's passed an error message
SubscriberListParamsPresenter
#subscriber_list_params
returns hash with values if they are included in the content_item
returns empty hash if email_filter_facet includes facet_choices in the content_item
returns empty hash if none passed in
returns hash with values if they are dynamic attributes
translates a facet id into a filter key if it is present
translates option_lookup values into a filter key if they are present
StatisticsMetadataPresenter
#present
when only updated date
formats the metadata
when both release date and updated dates
formats the metadata
Registries::ManualsRegistry
when rummager is unavailable
will return an (uncached) empty hash
when rummager is available
will fetch manual information by slug
will fetch the correct types of document
there is no id or title
will remove those results
Registries::PeopleRegistry
when rummager is available
will fetch person information by slug
will return all people associated with documents ascending by name
there is no slug or title
will remove those results
when rummager is unavailable
will return an (uncached) empty hash
UrlBuilder
#url_builder
when given a path and query params
builds a url with a query
when given a path, query params, and additional params
builds a url that includes the additional params
EmailAlertSignupAPI
#signup_url
no default_attributes or attributes
returns the url email-alert-api gives back
default attributes provided
calls the API
when choices have filter_values
calls the API
with a single facet finder
with multiple choices selected and a title prefix
calls the API
with one choice selected and a title prefix
calls the API
without a title prefix
calls the API
no options available
calls the API
with a multi facet finder
without a title prefix
calls the API
no options available
calls the API
with one choice selected and a title prefix
calls the API
with multiple choices selected and a title prefix
calls the API
with link-based facets
part_of_taxonomy_tree facet
calls the API
roles facet
calls the API
organisation facet
calls the API
content_store_document_type
calls the API
handling default values
converts scalar values to arrays
people facet
calls the API
world facet
calls the API
RadioFacet
#query_params
value selected
is expected to eql {"type"=>"selected_value"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment