Skip to content

Commit

Permalink
test(@dpc-sdp/ripple-tide-search): refactored some tests to isolate a…
Browse files Browse the repository at this point in the history
…ggregations feature from grants
  • Loading branch information
jeffdowdle committed Jul 11, 2023
1 parent e10e101 commit 4ff7d18
Show file tree
Hide file tree
Showing 5 changed files with 325 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Feature: Search listing - Aggregations

As a user I can see lists of values filter values, sourced from either drupal Taxonomies or Elastic Aggregations

Background:
Given the endpoint "/api/tide/site" with query "?id=8888" returns fixture "/site/reference" with status 200
And I am using a "macbook-16" device

@mockserver
Example: Aggregations and Taxonomies
Given the endpoint "/api/tide/page" with query "?path=/aggregations&site=8888" returns fixture "/search-listing/aggregations/page" with status 200
And the search network request is stubbed with fixture "/search-listing/aggregations/response" and status 200
And the current date is "Fri, 02 Feb 2050 03:04:05 GMT"

When I visit the page "/aggregations"
Then the search listing page should have 2 results
And the search network request should be called with the "/search-listing/aggregations/request" fixture

When I click the search listing dropdown field labelled "Elastic aggregation test"
# First item is hardcoded, the rest come from ES aggregation
Then the selected dropdown field should have the items:
| Hard coded |
| Business |
| Government |
| Individual |
| Not-for-profit groups |
# Close the dropdown
When I click the search listing dropdown field labelled "Elastic aggregation test"

When I click the search listing dropdown field labelled "Taxonomy test"
# These come from Tide page API response (taxonomies)
Then the selected dropdown field should have the items:
| Arts |
| Business |
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"title": "Grants and programs",
"changed": "2022-11-02T12:47:29+11:00",
"created": "2022-11-02T12:47:29+11:00",
"type": "tide_search_listing",
"nid": "11dede11-10c0-111e1-1100-000000000330",
"showTopicTags": true,
"summary": "",
"searchListingConfig": {
"searchPlaceholder": "Search all grants and programs",
"resultsPerPage": 10
},
"queryConfig": {
"multi_match": {
"query": "{{query}}",
"fields": [
"title^3",
"field_landing_page_summary^2",
"body",
"field_paragraph_body",
"summary_processed"
]
}
},
"results": {
"layout": {
"component": "TideSearchResultsList"
},
"item": {
"grant": {
"component": "TideGrantSearchResult"
}
}
},
"globalFilters": [
{ "terms": { "type": ["grant"] } },
{ "terms": { "field_node_site": [8888] } }
],
"userFilters": [
{
"id": "audience",
"component": "TideSearchFilterDropdown",
"filter": {
"type": "terms",
"value": "field_audience_name.keyword"
},
"aggregations": {
"field": "field_audience_name.keyword",
"source": "elastic"
},
"props": {
"id": "audience",
"label": "Elastic aggregation test",
"placeholder": "Individuals and organisation types",
"type": "RplFormDropdown",
"multiple": true,
"options": [
{
"id": "1",
"label": "Hard coded",
"value": "Hard coded"
}
]
}
},
{
"id": "topic",
"component": "TideSearchFilterDropdown",
"filter": {
"type": "terms",
"value": "field_topic_name"
},
"aggregations": {
"field": "topic",
"source": "taxonomy"
},
"props": {
"id": "topic",
"label": "Taxonomy test",
"placeholder": "Grant topic",
"type": "RplFormDropdown",
"multiple": true,
"options": [
{
"id": "1",
"label": "Arts",
"value": "Arts"
},
{
"id": "2",
"label": "Business",
"value": "Business"
}
]
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"query": {
"bool": {
"must": [{ "match_all": {} }],
"filter": [
{ "terms": { "type": ["grant"] } },
{ "terms": { "field_node_site": [8888] } }
]
}
},
"size": 10,
"from": 0,
"sort": [{ "_score": "desc" }, { "_doc": "desc" }],
"aggs": {
"audience": {
"terms": {
"field": "field_audience_name.keyword",
"order": { "_key": "asc" }
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": null,
"hits": [
{
"_index": "a83890f7a31dea14e1ae83c6f0afacca--elasticsearch_index_default_node",
"_id": "entity:node/32830:en",
"_score": 1.0,
"_source": {
"_language": "en",
"node_grants": ["node_access_all:0"],
"url": [
"/site-8888/tc-9b-grant-page-closed",
"/site-57/tc-9b-grant-page-closed",
"/site-56/tc-9b-grant-page-closed",
"/site-129/tc-9b-grant-page-closed",
"/site-157/tc-9b-grant-page-closed",
"/site-283/tc-9b-grant-page-closed",
"/site-125/tc-9b-grant-page-closed",
"/site-281/tc-9b-grant-page-closed",
"/site-290/tc-9b-grant-page-closed",
"/site-287/tc-9b-grant-page-closed",
"/site-4/tc-9b-grant-page-closed",
"/site-224/tc-9b-grant-page-closed",
"/site-408/tc-9b-grant-page-closed",
"/site-507/tc-9b-grant-page-closed",
"/site-509/tc-9b-grant-page-closed",
"/site-515/tc-9b-grant-page-closed",
"/site-581/tc-9b-grant-page-closed",
"/site-582/tc-9b-grant-page-closed",
"/site-622/tc-9b-grant-page-closed",
"/site-679/tc-9b-grant-page-closed",
"/site-1285/tc-9b-grant-page-closed",
"/site-1287/tc-9b-grant-page-closed",
"/site-8891/tc-9b-grant-page-closed",
"/site-8896/tc-9b-grant-page-closed"
],
"changed": ["2023-05-09T15:00:46+10:00"],
"created": ["2023-05-09T15:00:46+10:00"],
"field_audience": [83],
"field_audience_name": ["Business"],
"field_audience_uuid": ["eb8e493b-d633-4ec9-99f6-1a825e7242c8"],
"field_content_category": [1340],
"field_content_category_name": ["Grants"],
"field_event_intro_text": ["news intro test"],
"field_landing_page_intro_text": ["Blah blah"],
"field_landing_page_summary": [
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam tincidunt sit amet ligula sit amet lacinia. In a leo nec tortor aliquet faucibus."
],
"field_media_image_absolute_path": [
"https://nginx-php.pr-1500.content-vic.sdp4.sdp.vic.gov.au/sites/default/files/tide_demo_content/Melbourne-tram.jpg"
],
"field_node_dates_end_value": ["2019-04-09T20:00:00+10:00"],
"field_node_dates_start_value": ["2019-03-09T19:00:00+11:00"],
"field_node_on_going": [false],
"field_node_primary_csite": [8888],
"field_node_site": [
8888, 57, 56, 129, 157, 283, 125, 281, 290, 287, 4, 224, 408, 507,
509, 515, 581, 582, 622, 679, 1285, 1287, 8891, 8896
],
"field_tags": [1466],
"field_tags_name": ["Demo Tag"],
"field_tags_path": ["/tags/demo-tag"],
"field_tags_uuid": ["11dede11-10c0-111e1-1101-000000000010"],
"field_topic": [1478],
"field_topic_name": ["Demo Topic"],
"field_topic_path": ["/topic/demo-topic"],
"field_topic_uuid": ["11dede11-10c0-111e1-1102-000000000020"],
"funding_level_from": [11326],
"funding_level_to": [26494],
"langcode": ["en"],
"nid": [32830],
"status": [true],
"title": ["THIS IS A TEST"],
"type": ["grant"],
"uid": [1],
"uuid": ["0327b98e-d85e-4386-8bd0-02be571cafcc"]
},
"sort": [1.0, 3523]
},
{
"_index": "a83890f7a31dea14e1ae83c6f0afacca--elasticsearch_index_default_node",
"_id": "entity:node/32829:en",
"_score": 1.0,
"_source": {
"_language": "en",
"node_grants": ["node_access_all:0"],
"url": ["/site-8888/tc-9a-grant-simple-test-date-range"],
"changed": ["2023-05-09T15:00:46+10:00"],
"created": ["2023-05-09T15:00:46+10:00"],
"field_audience": [83],
"field_audience_name": ["Not-for-profit groups", "Government"],
"field_audience_uuid": ["eb8e493b-d633-4ec9-99f6-1a825e7242c8"],
"field_content_category": [1340],
"field_content_category_name": ["Grants"],
"field_event_intro_text": ["news intro test"],
"field_landing_page_intro_text": ["Blah blah"],
"field_landing_page_summary": [
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam tincidunt sit amet ligula sit amet lacinia. In a leo nec tortor aliquet faucibus."
],
"field_media_image_absolute_path": [
"https://nginx-php.pr-1500.content-vic.sdp4.sdp.vic.gov.au/sites/default/files/tide_demo_content/Melbourne-tram.jpg"
],
"field_node_dates_end_value": ["2050-07-16T00:00:00+10:00"],
"field_node_dates_start_value": ["2019-04-08T18:00:00+10:00"],
"field_node_on_going": [false],
"field_node_primary_csite": [8888],
"field_node_site": [8888],
"field_tags": [1466, 1467],
"field_tags_name": ["Demo Tag", "Another Demo Tag"],
"field_tags_path": ["/tags/demo-tag", "/tags/another-demo-tag"],
"field_tags_uuid": [
"11dede11-10c0-111e1-1101-000000000010",
"11dede11-10c0-111e1-1101-000000000011"
],
"field_topic": [1478],
"field_topic_name": ["Demo Topic"],
"field_topic_path": ["/topic/demo-topic"],
"field_topic_uuid": ["11dede11-10c0-111e1-1102-000000000020"],
"funding_level_from": [11326],
"funding_level_to": [26494],
"langcode": ["en"],
"nid": [32829],
"status": [true],
"title": ["TC-9a Grant Simple Test - Date Range"],
"type": ["grant"],
"uid": [1],
"uuid": ["244b27ce-634c-4721-b70a-fea107b2ba9f"]
},
"sort": [1.0, 3522]
}
]
},
"aggregations": {
"audience": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "Business",
"doc_count": 66
},
{
"key": "Government",
"doc_count": 73
},
{
"key": "Individual",
"doc_count": 28
},
{
"key": "Not-for-profit groups",
"doc_count": 121
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
},
"aggregations": {
"field": "field_topic_name",
"source": "elastic"
"source": "taxonomy"
},
"props": {
"id": "topic",
Expand Down

0 comments on commit 4ff7d18

Please sign in to comment.