diff --git a/solution/ui/e2e/cypress/e2e/search.spec.cy.js b/solution/ui/e2e/cypress/e2e/search.spec.cy.js index 6444a0f2be..235cebc91b 100644 --- a/solution/ui/e2e/cypress/e2e/search.spec.cy.js +++ b/solution/ui/e2e/cypress/e2e/search.spec.cy.js @@ -3,6 +3,9 @@ const TITLE_45 = 45; const SEARCH_TERM = "FMAP"; const SEARCH_TERM_2 = "almond"; +const NO_RESULTS_SEARCH_TERM = "no results"; +const SPACED_SEARCH_TERM = "test query"; +const QUOTED_SEARCH_TERM = '"test query"'; const username = Cypress.env("TEST_USERNAME"); const password = Cypress.env("TEST_PASSWORD"); @@ -15,11 +18,11 @@ describe("Search flow", () => { cy.intercept("**/v3/titles", [TITLE_42, TITLE_45]).as("titles"); - cy.intercept("**/v3/content-search/**", { + cy.intercept(`**/v3/content-search/**`, { fixture: "policy-docs-search.json", }).as("subjectFiles"); - cy.intercept(`**/v3/title/${TITLE_42}/parts`, { + cy.intercept("**/v3/title/${TITLE_42}/parts", { fixture: "parts-42.json", }).as("parts42"); @@ -283,4 +286,88 @@ describe("Search flow", () => { }); }); }); + + it("shows the appropriate messages when there are no search results", () => { + cy.intercept(`**/v3/content-search/**`, { + internal_count: 0, + public_count: 0, + reg_text_count: 0, + next: null, + previous: null, + count: 0, + results: [], + }).as("noResults"); + + cy.viewport("macbook-15"); + cy.visit(`/search/?q=${NO_RESULTS_SEARCH_TERM}`, { timeout: 60000 }); + + cy.get(".no-results__span").should( + "have.text", + `Your search for ${NO_RESULTS_SEARCH_TERM} did not match any results on eRegulations.` + ); + + cy.get("[data-testid=research-row-1]").should("not.exist"); + + cy.get(".doc-type__toggle fieldset > div") + .eq(1) + .find("input") + .check({ force: true }); + + cy.get(".no-results__span").should( + "have.text", + `Your search for ${NO_RESULTS_SEARCH_TERM} did not match any results with the selected filters.` + ); + + cy.get("[data-testid=research-row-1]") + .should("exist") + .find("[data-testid=reset-filters-parent] a") + .should("have.text", " reset all active filters") + .click({ force: true }); + + cy.get(".no-results__span").should( + "have.text", + `Your search for ${NO_RESULTS_SEARCH_TERM} did not match any results on eRegulations.` + ); + + cy.get("[data-testid=research-row-1]").should("not.exist"); + + cy.get(".doc-type__toggle fieldset > div") + .eq(1) + .find("input") + .should("not.be.checked"); + }); + + it("has a Continue Your Research section on the search page", () => { + cy.viewport("macbook-15"); + cy.visit(`/search/?q=${SEARCH_TERM}`, { timeout: 60000 }); + cy.get(".research__title").should("exist"); + cy.get(".research__title").should( + "have.text", + "Continue Your Research" + ); + + cy.get("[data-testid=research-row-1]").should("not.exist"); + cy.get("[data-testid=research-row-2]").should("exist"); + }); + + it("properly quotes searches and updates the Continue Your Research component when quoted", () => { + cy.viewport("macbook-15"); + cy.visit(`/search/?q=${SPACED_SEARCH_TERM}`, { timeout: 60000 }); + cy.get(".research__title").should("exist"); + cy.get(".research__title").should( + "have.text", + "Continue Your Research" + ); + + cy.get("[data-testid=research-row-1]") + .should("exist") + .find("[data-testid=quoted-search-link-parent] a") + .should("exist") + .and("have.text", '"test query"') + .click({ force: true }); + + cy.url().should("include", "/search?q=%22test+query%22"); + + cy.get("[data-testid=research-row-1]").should("not.exist"); + }); }); diff --git a/solution/ui/e2e/cypress/fixtures/policy-docs-search.json b/solution/ui/e2e/cypress/fixtures/policy-docs-search.json index 0093b098b1..b5290b1d14 100644 --- a/solution/ui/e2e/cypress/fixtures/policy-docs-search.json +++ b/solution/ui/e2e/cypress/fixtures/policy-docs-search.json @@ -5,7 +5,7 @@ "results": [ { "content_headline": "FMAP (not “newly eligible” FMAP) on Medicaid expenditures associated with these new adults. As it pertains to Section 4106 and the extra 1% FMAP, can CMS please confirm that Delaware can claim the extra 1% on Section 4106 services attributable to our new adults up to 100% FPL that currently", - "name_headline": "Delaware QQ - ACA 4106 Provision", + "name_headline": "Delaware ZZ - ACA 4106 Provision", "reg_text": null, "resource": { "approved": true, @@ -31,7 +31,7 @@ "created_at": "2024-07-18 10:22:56.341901", "date": "2014-06-23", "document_id": "", - "file_name": "Delaware QQ - ACA 4106 Provision.msg", + "file_name": "Delaware ZZ - ACA 4106 Provision.msg", "file_type": "", "id": 3541, "related_resources": null, @@ -59,7 +59,7 @@ } ], "summary": "Emails between DE and CMCS regarding questions about the ACA section 4106 and the extra 1% FMAP as they prepare for SPA submission", - "title": "Delaware QQ - ACA 4106 Provision", + "title": "Delaware ZZ - ACA 4106 Provision", "type": "internal_file", "uid": "868e968c-d1f5-4518-b458-b6e735ef0f3d", "updated_at": "2024-07-18 10:22:56.351740", diff --git a/solution/ui/regulations/css/scss/partials/_search.scss b/solution/ui/regulations/css/scss/partials/_search.scss index 406f0dbd39..671555ae58 100644 --- a/solution/ui/regulations/css/scss/partials/_search.scss +++ b/solution/ui/regulations/css/scss/partials/_search.scss @@ -14,8 +14,10 @@ @include eds-gutters; margin-top: var(--spacer-5); + margin-bottom: var(--spacer-5); display: flex; flex-direction: column; + min-height: 300px; max-width: var(--eds-width-md); h1 { @@ -59,6 +61,13 @@ } .doc__list { + .no-results__span { + display: block; + margin-top: var(--spacer-4); + margin-bottom: var(--spacer-5); + font-size: $font-size-lg; + line-height: 1.5rem; + } .result { &__link { a { @@ -77,7 +86,6 @@ display: flex; flex-direction: row; justify-content: center; - margin-bottom: 100px; @media (min-width: $eds-width-sm) { justify-content: flex-start; @@ -172,3 +180,60 @@ } } } + +// CONTINUE RESEARCH CONTAINER ----------------- + +.research__container { + > * { + padding: var(--spacer-4); + } + + &--results { + margin-top: var(--spacer-6); + } + + &--no-results { + margin-bottom: var(--spacer-6); + } + + .research__title { + display: flex; + align-items: center; + font-size: $font-size-lg; + line-height: 1.5rem; + font-weight: bold; + text-transform: capitalize; + background-color: $lightest_gray; + margin-block-start: 0; + margin-block-end: 0; + } + + .research__row { + display: flex; + font-size: $font-size-md; + border: 1px solid $light_gray; + border-top: unset; + + .row__title { + display: inline-block; + flex: 0 0 280px; + margin-right: var(--spacer-6); + + @media (max-width: $eds-width-sm) { + flex: 0 0 135px; + } + } + + .row__content { + &--list { + display: flex; + flex-wrap: wrap; + align-content: flex-start; + margin: 0; + padding: 0; + list-style-type: none; + gap: var(--spacer-3); + } + } + } +} diff --git a/solution/ui/regulations/eregs-vite/src/components/SearchContinueResearch.test.js b/solution/ui/regulations/eregs-vite/src/components/SearchContinueResearch.test.js new file mode 100644 index 0000000000..847c0bf525 --- /dev/null +++ b/solution/ui/regulations/eregs-vite/src/components/SearchContinueResearch.test.js @@ -0,0 +1,49 @@ +import { describe, it, expect } from "vitest"; + +import SearchContinueResearch from "./SearchContinueResearch.vue"; + +describe("Search Continue Research", () => { + it("correctly determines if a query string has spaces", () => { + expect(SearchContinueResearch.hasSpaces("test")).toBe(false); + expect(SearchContinueResearch.hasSpaces("test query")).toBe( + true + ); + }); + + it("correctly determines if a query has quotes", () => { + expect(SearchContinueResearch.hasQuotes("test")).toBe(false); + expect(SearchContinueResearch.hasQuotes('"test"')).toBe(true); + expect(SearchContinueResearch.hasQuotes("'test'")).toBe(true); + }); + + it("makes the expected ECFR link", () => { + expect( + SearchContinueResearch.makeEcfrLink({ + query: "test query", + title: 42, + }) + ).toBe( + "https://www.ecfr.gov/search?search[hierarchy][title]=42&search[query]=test%20query" + ); + }); + + it("makes the expected Federal Register link", () => { + expect( + SearchContinueResearch.makeFederalRegisterLink("test query") + ).toBe( + "https://www.federalregister.gov/documents/search?conditions[agencies][]=centers-for-medicare-medicaid-services&conditions[term]=test%20query" + ); + }); + + it("makes the expected Medicaid.gov link", () => { + expect(SearchContinueResearch.makeMedicaidGovLink("test query")).toBe( + "https://www.medicaid.gov/search-gsc?&gsc.sort=#gsc.tab=0&gsc.q=test%20query&gsc.sort=" + ); + }); + + it("makes the expected US Code link", () => { + expect(SearchContinueResearch.makeUsCodeLink("test query")).toBe( + "https://uscode.house.gov/search.xhtml?edition=prelim&searchString=%28test%20query%29+AND+%28%28title%3A%2842%29+AND+chapter%3A%287%29+AND+subchapter%3A%2819%29%29+OR+%28title%3A%2842%29+AND+chapter%3A%287%29+AND+subchapter%3A%2821%29%29+OR+%28title%3A%2842%29+AND+chapter%3A%287%29+AND+subchapter%3A%2818%29%29+OR+%28title%3A%2842%29+AND+chapter%3A%287%29+AND+subchapter%3A%2816%29%29+OR+%28title%3A%2842%29+AND+chapter%3A%287%29+AND+subchapter%3A%2811%29%29%29&pageNumber=1&itemsPerPage=100&sortField=RELEVANCE&displayType=CONTEXT&action=search&q=dGVzdCBxdWVyeQ%3D%3D%7C%3A%3A%3A%3A%3A%3A%3A%3Afalse%3A%7C%3A%3A%3A%3A%3A%3A%3A%3Afalse%3A%7Ctrue%7C%5B42%3A%3A%3A%3A7%3A19%3A%3A%3Atrue%3A%3B42%3A%3A%3A%3A7%3A21%3A%3A%3Atrue%3A%3B42%3A%3A%3A%3A7%3A18%3A%3A%3Atrue%3A%3B42%3A%3A%3A%3A7%3A16%3A%3A%3Atrue%3A%3B42%3A%3A%3A%3A7%3A11%3A%3A%3Atrue%3A%5D%7C%5BQWxsIEZpZWxkcw%3D%3D%3A%5D" + ); + }); +}); diff --git a/solution/ui/regulations/eregs-vite/src/components/SearchContinueResearch.vue b/solution/ui/regulations/eregs-vite/src/components/SearchContinueResearch.vue new file mode 100644 index 0000000000..5827115c28 --- /dev/null +++ b/solution/ui/regulations/eregs-vite/src/components/SearchContinueResearch.vue @@ -0,0 +1,173 @@ + + + + + diff --git a/solution/ui/regulations/eregs-vite/src/components/SearchEmptyState.vue b/solution/ui/regulations/eregs-vite/src/components/SearchEmptyState.vue deleted file mode 100644 index 07df8eee9f..0000000000 --- a/solution/ui/regulations/eregs-vite/src/components/SearchEmptyState.vue +++ /dev/null @@ -1,145 +0,0 @@ - - - - - diff --git a/solution/ui/regulations/eregs-vite/src/components/search/RegResults.vue b/solution/ui/regulations/eregs-vite/src/components/search/RegResults.vue deleted file mode 100644 index 33520a81e3..0000000000 --- a/solution/ui/regulations/eregs-vite/src/components/search/RegResults.vue +++ /dev/null @@ -1,72 +0,0 @@ - - - diff --git a/solution/ui/regulations/eregs-vite/src/views/Search.vue b/solution/ui/regulations/eregs-vite/src/views/Search.vue index ca49bee01a..c2650c7d2e 100644 --- a/solution/ui/regulations/eregs-vite/src/views/Search.vue +++ b/solution/ui/regulations/eregs-vite/src/views/Search.vue @@ -1,5 +1,5 @@