Skip to content

Commit

Permalink
EREGCSC-2826 -- Granular counts on the front end (#1419)
Browse files Browse the repository at this point in the history
* feat: first pass at type counts

* feat: crude counts working

* feat: label count styles

* feat: tweak loading styles for counts

* fix: spacing tweak

* test: update fixtures with counts; assert count label exists

* chore: walk back certain typeCount logic; prettier formatting

* feat: very basic fetch counts implementation

* feat: feature complete implementation

* chore: add prettier config; undo prettier trailing comma damage

* chore: add prettier config; undo prettier trailing comma damage

* refactor: move fetchCounts/ref logic to composable

* chore: clean up unused dependencies

* test: add content-search/counts to API api e2e test suite

* test: add counts fixture

* fix: return top margin to subjects label in sidebar

* style: count style tweaks
  • Loading branch information
PhilR8 authored Sep 27, 2024
1 parent 0382d1c commit 95fa9e4
Show file tree
Hide file tree
Showing 14 changed files with 285 additions and 163 deletions.
1 change: 1 addition & 0 deletions solution/ui/e2e/cypress/e2e/api.spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const ACT = "Social Security Act";
const API_ENDPOINTS_V3 = [
`/v3/acts`,
`/v3/content-search?q=${SEARCH_TERM}`,
`/v3/content-search/counts?q=${SEARCH_TERM}`,
`/v3/ecfr_parser_result/${TITLE}`,
`/v3/parser_config`,
`/v3/resources/`,
Expand Down
25 changes: 13 additions & 12 deletions solution/ui/e2e/cypress/e2e/search.spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ describe("Search flow", () => {
});

it("should not show internal checkbox when not logged in", () => {
cy.intercept(`**/v3/content-search/counts**`, {
fixture: "counts.json",
}).as("counts");

cy.viewport("macbook-15");
cy.visit(`/search/?q=${SEARCH_TERM}`, { timeout: 60000 });
cy.get(".doc-type__toggle fieldset > div")
Expand Down Expand Up @@ -189,7 +193,7 @@ describe("Search flow", () => {
cy.get(".doc-type__toggle fieldset > div")
.eq(2)
.find("label")
.should("have.text", "Internal Resources");
.should("have.text", "Internal Resources(1)");
});

it("should not show the categories dropdown when only regulations are selected", () => {
Expand Down Expand Up @@ -242,7 +246,7 @@ describe("Search flow", () => {

cy.url().should(
"include",
`/search?q=${SEARCH_TERM}&type=regulations,external`
`/search?q=${SEARCH_TERM}&type=regulations,external`,
);
cy.url().should("not.include", "internal");

Expand All @@ -253,7 +257,7 @@ describe("Search flow", () => {

cy.url().should(
"include",
`/search?q=${SEARCH_TERM}&type=regulations,external,internal`
`/search?q=${SEARCH_TERM}&type=regulations,external,internal`,
);
});

Expand Down Expand Up @@ -281,17 +285,14 @@ describe("Search flow", () => {
.should(
"have.css",
"background-color",
"rgb(252, 229, 175)"
"rgb(252, 229, 175)",
);
});
});
});

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,
Expand All @@ -303,7 +304,7 @@ describe("Search flow", () => {

cy.get(".no-results__span").should(
"have.text",
`Your search for ${NO_RESULTS_SEARCH_TERM} did not match any results on eRegulations.`
`Your search for ${NO_RESULTS_SEARCH_TERM} did not match any results on eRegulations.`,
);

cy.get("[data-testid=research-row-1]").should("not.exist");
Expand All @@ -315,7 +316,7 @@ describe("Search flow", () => {

cy.get(".no-results__span").should(
"have.text",
`Your search for ${NO_RESULTS_SEARCH_TERM} did not match any results with the selected filters.`
`Your search for ${NO_RESULTS_SEARCH_TERM} did not match any results with the selected filters.`,
);

cy.get("[data-testid=research-row-1]")
Expand All @@ -326,7 +327,7 @@ describe("Search flow", () => {

cy.get(".no-results__span").should(
"have.text",
`Your search for ${NO_RESULTS_SEARCH_TERM} did not match any results on eRegulations.`
`Your search for ${NO_RESULTS_SEARCH_TERM} did not match any results on eRegulations.`,
);

cy.get("[data-testid=research-row-1]").should("not.exist");
Expand All @@ -343,7 +344,7 @@ describe("Search flow", () => {
cy.get(".research__title").should("exist");
cy.get(".research__title").should(
"have.text",
"Continue Your Research"
"Continue Your Research",
);

cy.get("[data-testid=research-row-1]").should("not.exist");
Expand All @@ -356,7 +357,7 @@ describe("Search flow", () => {
cy.get(".research__title").should("exist");
cy.get(".research__title").should(
"have.text",
"Continue Your Research"
"Continue Your Research",
);

cy.get("[data-testid=research-row-1]")
Expand Down
5 changes: 5 additions & 0 deletions solution/ui/e2e/cypress/fixtures/counts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"internal_resource_count": 1,
"public_resource_count": 2,
"regulation_text_count": 3
}
248 changes: 124 additions & 124 deletions solution/ui/e2e/cypress/fixtures/policy-docs-subjects.json
Original file line number Diff line number Diff line change
@@ -1,132 +1,132 @@
{
"count": 3,
"next": null,
"previous": null,
"results": [
{
"type": "internal_file",
"id": 2007,
"created_at": "2024-07-09 15:19:36.129789",
"updated_at": "2024-07-10 10:38:27.931896",
"approved": true,
"category": {
"id": 26,
"name": "Mock Category",
"description": "This is a mock category",
"order": 0,
"show_if_empty": false,
"is_fr_link_category": false,
"type": "internal_category"
},
"cfr_citations": [
"count": 3,
"next": null,
"previous": null,
"results": [
{
"id": 18,
"title": 42,
"part": 430,
"type": "subpart",
"subpart_id": "A"
"type": "internal_file",
"id": 2007,
"created_at": "2024-07-09 15:19:36.129789",
"updated_at": "2024-07-10 10:38:27.931896",
"approved": true,
"category": {
"id": 26,
"name": "Mock Category",
"description": "This is a mock category",
"order": 0,
"show_if_empty": false,
"is_fr_link_category": false,
"type": "internal_category"
},
"cfr_citations": [
{
"id": 18,
"title": 42,
"part": 430,
"type": "subpart",
"subpart_id": "A"
},
{
"id": 25,
"title": 42,
"part": 430,
"type": "section",
"section_id": 10
}
],
"subjects": [
{
"id": 3,
"full_name": "Access to Services",
"short_name": "",
"abbreviation": "",
"description": ""
}
],
"document_id": "internal document id field",
"title": "mock internal file",
"date": "2024-09-09",
"url": "",
"related_resources": [],
"summary": "This is the summary to the mock internal file",
"file_name": "ff-test.pdf",
"file_type": "",
"uid": "1149e520-6691-4f00-9094-d741b0b114a5"
},
{
"id": 25,
"title": 42,
"part": 430,
"type": "section",
"section_id": 10
}
],
"subjects": [
{
"id": 3,
"full_name": "Access to Services",
"short_name": "",
"abbreviation": "",
"description": ""
}
],
"document_id": "internal document id field",
"title": "mock internal file",
"date": "2024-09-09",
"url": "",
"related_resources": [],
"summary": "This is the summary to the mock internal file",
"file_name": "ff-test.pdf",
"file_type": "",
"uid": "1149e520-6691-4f00-9094-d741b0b114a5"
},
{
"type": "public_link",
"id": 1000,
"created_at": "2024-07-08 10:21:58.934030",
"updated_at": "2024-07-10 09:42:40.084033",
"approved": true,
"category": {
"id": 4,
"name": "Subregulatory Guidance",
"description": "SMDLs, SHOs, CIBs, FAQs, SMM",
"order": 400,
"show_if_empty": true,
"is_fr_link_category": false,
"type": "public_category"
},
"cfr_citations": [
{
"id": 209,
"title": 42,
"part": 433,
"type": "subpart",
"subpart_id": "A"
},
{
"id": 938,
"title": 42,
"part": 447,
"type": "section",
"section_id": 253
},
{
"id": 975,
"title": 42,
"part": 447,
"type": "section",
"section_id": 509
"type": "public_link",
"id": 1000,
"created_at": "2024-07-08 10:21:58.934030",
"updated_at": "2024-07-10 09:42:40.084033",
"approved": true,
"category": {
"id": 4,
"name": "Subregulatory Guidance",
"description": "SMDLs, SHOs, CIBs, FAQs, SMM",
"order": 400,
"show_if_empty": true,
"is_fr_link_category": false,
"type": "public_category"
},
"cfr_citations": [
{
"id": 209,
"title": 42,
"part": 433,
"type": "subpart",
"subpart_id": "A"
},
{
"id": 938,
"title": 42,
"part": 447,
"type": "section",
"section_id": 253
},
{
"id": 975,
"title": 42,
"part": 447,
"type": "section",
"section_id": 509
},
{
"id": 976,
"title": 42,
"part": 447,
"type": "section",
"section_id": 510
}
],
"subjects": [
{
"id": 3,
"full_name": "Access to Services",
"short_name": "",
"abbreviation": "",
"description": ""
}
],
"document_id": "document id field",
"title": "mock public link",
"date": "2017-06-29",
"url": "https://www.medicaid.gov/sites/default/files/medicaid-chip-program-information/by-topics/prescription-drugs/downloads/rx-releases/mfr-releases/mfr-rel-105.pdf",
"related_resources": []
},
{
"id": 976,
"title": 42,
"part": 447,
"type": "section",
"section_id": 510
}
],
"subjects": [
{
"id": 3,
"full_name": "Access to Services",
"short_name": "",
"abbreviation": "",
"description": ""
"type": "public_link",
"id": 1000,
"created_at": "2024-07-08 10:21:58.934030",
"updated_at": "2024-07-10 09:42:40.084033",
"approved": true,
"category": {},
"cfr_citations": [],
"subjects": [],
"document_id": "document id field",
"title": "public link without subject or category or keyword",
"date": "2017-06-29",
"url": "https://www.medicaid.gov/sites/default/files/medicaid-chip-program-information/by-topics/prescription-drugs/downloads/rx-releases/mfr-releases/mfr-rel-105.pdf",
"related_resources": []
}
],
"document_id": "document id field",
"title": "mock public link",
"date": "2017-06-29",
"url": "https://www.medicaid.gov/sites/default/files/medicaid-chip-program-information/by-topics/prescription-drugs/downloads/rx-releases/mfr-releases/mfr-rel-105.pdf",
"related_resources": []
},
{
"type": "public_link",
"id": 1000,
"created_at": "2024-07-08 10:21:58.934030",
"updated_at": "2024-07-10 09:42:40.084033",
"approved": true,
"category": {},
"cfr_citations": [],
"subjects": [],
"document_id": "document id field",
"title": "public link without subject or category or keyword",
"date": "2017-06-29",
"url": "https://www.medicaid.gov/sites/default/files/medicaid-chip-program-information/by-topics/prescription-drugs/downloads/rx-releases/mfr-releases/mfr-rel-105.pdf",
"related_resources": []
}
]
]
}
Loading

0 comments on commit 95fa9e4

Please sign in to comment.