Skip to content

Commit

Permalink
EREGCSC-2733 -- Expand Search component on search page (#1422)
Browse files Browse the repository at this point in the history
* chore: lint SearchEmptyState; delete RegResults component

* feat: crude import of existing SearchEmptyState component

* feat: update no results text

* chore: move empty state styles from vue component to SCSS

* chore: refactor SearchEmtpyState to use Composition API

* feat: basic styling, crude functionality

* chore: style tweak

* feat: add reset active filters router-link

* feat: quoted search and filter reset logic

* feat: add state for when there is no search query

* feat: other website search links

* feat: adjust correct dimension

* feat: logic for no results message

* chore: encode query for all expand search links

* style: wrap research links on narrower screens

* style: column width and wrapping tweaks

* test: add vitest unit tests

* feat: better conditional logic for quoted searched

* test: cypress e2e tests
  • Loading branch information
PhilR8 authored Sep 20, 2024
1 parent 60b2740 commit ea07826
Show file tree
Hide file tree
Showing 8 changed files with 421 additions and 232 deletions.
91 changes: 89 additions & 2 deletions solution/ui/e2e/cypress/e2e/search.spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");

Expand Down Expand Up @@ -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");
});
});
6 changes: 3 additions & 3 deletions solution/ui/e2e/cypress/fixtures/policy-docs-search.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"results": [
{
"content_headline": "<span class='search-highlight'>FMAP</span> (not “newly eligible” <span class='search-highlight'>FMAP</span>) on Medicaid expenditures associated with these new adults. As it pertains to Section 4106 and the extra 1% <span class='search-highlight'>FMAP</span>, 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,
Expand All @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
67 changes: 66 additions & 1 deletion solution/ui/regulations/css/scss/partials/_search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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"
);
});
});
Loading

0 comments on commit ea07826

Please sign in to comment.