diff --git a/packages/portal/src/components/search/SearchInterface.vue b/packages/portal/src/components/search/SearchInterface.vue index 49ec5c2ac5..0ac5a7cfb4 100644 --- a/packages/portal/src/components/search/SearchInterface.vue +++ b/packages/portal/src/components/search/SearchInterface.vue @@ -412,6 +412,12 @@ if (this.advancedSearchQueryCount > 0) { if (this.hasFulltextQa) { + // override query overrides already here to prevent full-text search breaking + if (this.overrideParams.query) { + params.query = this.overrideParams.query; + delete this.overrideParams.query; + } + // If there are any advanced search full-text rules, then // these are promoted to the primary query, and any other query // (from the simple search bar) is demoted to a qf, fielded to diff --git a/packages/portal/src/pages/collections/_type/_.vue b/packages/portal/src/pages/collections/_type/_.vue index ff50642d5d..be75348659 100644 --- a/packages/portal/src/pages/collections/_type/_.vue +++ b/packages/portal/src/pages/collections/_type/_.vue @@ -177,6 +177,7 @@ if (this.entity) { const entityQuery = getEntityQuery([this.entity.id].concat(this.entity.sameAs || [])); overrideParams.qf = [entityQuery]; + if (!this.$route.query.query) { overrideParams.query = entityQuery; // Triggering best bets. } @@ -303,6 +304,7 @@ return labelledMoreInfo; } }, + methods: { handleEntityRelatedCollectionsFetched(relatedCollections) { this.relatedCollections = relatedCollections; diff --git a/packages/portal/tests/unit/components/search/SearchInterface.spec.js b/packages/portal/tests/unit/components/search/SearchInterface.spec.js index d7cc7d2c0b..889a0eed69 100644 --- a/packages/portal/tests/unit/components/search/SearchInterface.spec.js +++ b/packages/portal/tests/unit/components/search/SearchInterface.spec.js @@ -549,6 +549,41 @@ describe('components/search/SearchInterface', () => { expect(wrapper.vm.apiParams).toEqual(expected); }); + + describe('and a query override', () => { + it('is promoted into query, moving the query override to qf', () => { + const queryOverride = 'skos_concept:"http://data.europeana.eu/concept/001"'; + const $route = { + query: { + qa: [ + 'fulltext:europe', + 'NOT fulltext:united' + ] + } + }; + const expected = { + page: 1, + profile: 'minimal,hits', + query: 'fulltext:europe AND NOT fulltext:united', + qf: [queryOverride, 'contentTier:(1 OR 2 OR 3 OR 4)'], + rows: 24 + }; + + const wrapper = factory({ + propsData: { + overrideParams: { + query: queryOverride + } + }, + mocks: { + $route + } + }); + wrapper.vm.deriveApiParams(); + + expect(wrapper.vm.apiParams).toEqual(expected); + }); + }); }); }); diff --git a/tests/e2e/docker/nightwatch/support/pages.js b/tests/e2e/docker/nightwatch/support/pages.js index 4c4be2d009..7814428049 100644 --- a/tests/e2e/docker/nightwatch/support/pages.js +++ b/tests/e2e/docker/nightwatch/support/pages.js @@ -21,6 +21,7 @@ const pages = { 'gallery foyer page': `${url}/en/galleries`, 'home page': `${url}/en`, 'Newspapers theme search page': `${url}/en/search?qf=collection%3Anewspaper`, + 'newspaper entity page': `${url}/en/collections/topic/18-newspaper`, 'immersive story page': `${url}/en/stories/melitta-bentz-the-woman-who-invented-the-coffee-filter`, 'item page with a IIIF Image': `${url}/en/item/9200357/BibliographicResource_3000095247457`, 'item page with a IIIF Presentation': `${url}/en/item/9200301/BibliographicResource_3000126341277`, diff --git a/tests/e2e/features/search/advanced.feature b/tests/e2e/features/search/advanced.feature index b8af3eba1b..c38e85d0ac 100644 --- a/tests/e2e/features/search/advanced.feature +++ b/tests/e2e/features/search/advanced.feature @@ -12,3 +12,16 @@ Feature: Advanced search And I wait for an `item preview` Then I see a `highlighted search term` with the text "First World War" And I am on an accessible page + + Scenario: Full-text search on a collection page shows hit highlights + When I open the `newspaper entity page` + And I click the `search list view toggle icon` + When I click the `toggle advanced search button` + And I enter "berlin" in the `advanced search query builder: term control` + And I click the `advanced search query builder: field control` + And I click the `advanced search query builder: fulltext field option` + And I click the `advanced search query builder: modifier control` + And I click the `advanced search query builder: exact modifier option` + And I wait for an `item preview` + Then I see a `highlighted search term` with the text "Berlin" + And I am on an accessible page