Skip to content

Commit

Permalink
EREGCSC-2289 -- Enable Display of Public Docs in Policy Repo (#1005)
Browse files Browse the repository at this point in the history
* feat: first pass at policy repo search updates

* feat: further refinement to content-search results

* feat: first opinionated pass at main policy repository

* feat: label tweaks

* feat: style anchor differently if search result or not

* feat: don't fetch DocList if there are no params

* feat: add cms design system choice list

* feat: watch v-model changes to update route

* feat: all or none selected logic

* feat: hook up doc types to API request

* feat: doc type label update; result item parts update

* feat: small subject chip style update

* feat: change checkbox color to eRegs Design System blue

* feat: allow 'all' type param

* feat: handle 'all' type param in policy repository view

* feat: sanitize watched query params before acting on them

* fix: don't set page when clearing search input

* test: update getRequestParams unit tests

* chore: cleanup

* fix: do not fetch policy docs on page load if type=all

* test: update policy docs fixture and intercept the new endpoint

* test: minimum viable e2e test coverage
  • Loading branch information
PhilR8 authored Oct 25, 2023
1 parent abc46d3 commit bd5fb38
Show file tree
Hide file tree
Showing 13 changed files with 516 additions and 82 deletions.
85 changes: 77 additions & 8 deletions solution/ui/e2e/cypress/e2e/policy-repository.spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ describe("Policy Repository", () => {
cy.url().should("include", "/policy-repository?subjects=2");
});

it("should make a successful request to the file-manager/files endpoint", () => {
cy.intercept("**/v3/file-manager/files?**").as("files");
it("should make a successful request to the content-search endpoint", () => {
cy.intercept("**/v3/content-search/?**").as("files");
cy.viewport("macbook-15");
cy.eregsLogin({ username, password });
cy.visit("/policy-repository");
Expand All @@ -59,7 +59,7 @@ describe("Policy Repository", () => {
});

it("loads the correct subject and search query when the URL is changed", () => {
cy.intercept("**/v3/file-manager/files?subjects=1&q=test**").as("qFiles");
cy.intercept("**/v3/content-search/?subjects=1&q=test**").as("qFiles");
cy.viewport("macbook-15");
cy.eregsLogin({ username, password });
cy.visit("/policy-repository");
Expand Down Expand Up @@ -109,7 +109,7 @@ describe("Policy Repository", () => {
});

it("should display and fetch the correct subjects on load if they are included in URL", () => {
cy.intercept("**/v3/file-manager/files?subjects=1&subjects=2**", {
cy.intercept("**/v3/content-search/?subjects=1&subjects=2**", {
fixture: "policy-docs.json",
}).as("subjectFiles");
cy.viewport("macbook-15");
Expand All @@ -130,12 +130,13 @@ describe("Policy Repository", () => {
.find("a")
.should("have.attr", "href")
.and("not.include", "undefined")
.and("include", "/42/430/5#430-5");
.and("include", "/42/435/116#435-116");

cy.checkAccessibility();
});

it("should display and fetch the correct search query on load if it is included in URL", () => {
cy.intercept("**/v3/file-manager/files?q=test**").as("qFiles");
cy.intercept("**/v3/content-search/?q=test**").as("qFiles");
cy.viewport("macbook-15");
cy.eregsLogin({ username, password });
cy.visit("/policy-repository/?q=test");
Expand All @@ -145,6 +146,74 @@ describe("Policy Repository", () => {
cy.get("input#main-content").should("have.value", "test");
});

it("should have a Documents to Show checkbox list", () => {
cy.viewport("macbook-15");
cy.eregsLogin({ username, password });
cy.visit("/policy-repository");
cy.get(".doc-type__toggle-container h3").should(
"have.text",
"Documents to Show"
);
cy.get(".doc-type__toggle fieldset").should("exist");
cy.get(".doc-type__toggle fieldset > div").should("have.length", 2);
cy.get(".doc-type__toggle fieldset > div")
.eq(0)
.find("label")
.should("have.text", "Public Resources");
cy.get(".doc-type__toggle fieldset > div")
.eq(0)
.find("input")
.should("be.checked")
.and("have.value", "external");
cy.get(".doc-type__toggle fieldset > div")
.eq(1)
.find("label")
.should("have.text", "Internal Resources");
cy.get(".doc-type__toggle fieldset > div")
.eq(1)
.find("input")
.should("be.checked")
.and("have.value", "internal");
});

it("should show only the Table of Contents if both or neither checkboxes are checked", () => {
cy.viewport("macbook-15");
cy.eregsLogin({ username, password });
cy.visit("/policy-repository");
cy.get(".subj-toc__container").should("exist");
cy.get(".doc-type__toggle fieldset > div")
.eq(0)
.find("input")
.uncheck({force: true});
cy.url().should("include", "/policy-repository?type=internal");
cy.get(".subj-toc__container").should("not.exist");
cy.get(".doc-type__toggle fieldset > div")
.eq(1)
.find("input")
.uncheck({force: true});
cy.get(".subj-toc__container").should("exist");
cy.get(".doc-type__toggle fieldset > div")
.eq(0)
.find("input")
.check({force: true});
cy.get(".doc-type__toggle fieldset > div")
.eq(1)
.find("input")
.check({force: true});
cy.url().should("include", "/policy-repository?type=all");
});

it("should not make a request to the content-search endpoint if both checkboxes are checked on load", () => {
cy.intercept("**/v3/content-search/**").as("contentSearch");
cy.viewport("macbook-15");
cy.eregsLogin({ username, password });
cy.visit("/policy-repository");
cy.wait(2000);
cy.get("@contentSearch.all").then((interception) => {
expect(interception).to.have.length(0);
});
});

it("goes to another SPA page from the policy repository page", () => {
cy.viewport("macbook-15");
cy.eregsLogin({ username, password });
Expand Down Expand Up @@ -183,8 +252,8 @@ describe("Policy Repository Search", () => {
cy.get("#loginIndicator").should("be.visible");
});

it("should make a successful request to the file-manager/files endpoint", () => {
cy.intercept("**/v3/file-manager/files**").as("queriedFiles");
it("should make a successful request to the content-search endpoint", () => {
cy.intercept("**/v3/content-search/?**").as("queriedFiles");
cy.viewport("macbook-15");
cy.eregsLogin({
username,
Expand Down
184 changes: 142 additions & 42 deletions solution/ui/e2e/cypress/fixtures/policy-docs.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,148 @@
{
"count":1,
"next":null,
"count": 2,
"next": null,
"previous": null,
"results":
[
{
"document_name": "[Mock] Cypress Fixture",
"file_name": "ff-test-em.pdf",
"date": "2023-08-30",
"summary": "This is a test of the ABP broadcasting system",
"locations": [
{
"id": 959,
"title": 42,
"part": 430,
"type": "section",
"section_id": 5,
"parent": 955
"results": [
{
"doc_name_string": null,
"file_name_string": null,
"date_string": "2019-07-26",
"summary_string": "State Guidance for the New Limited Exception to the IMD Exclusion for Certain Pregnant and Postpartum Women included in Section 1012 of the Substance Use-Disorder Prevention that Promotes Opioid Recovery and Treatment (SUPPORT) for Patients and Communities Act (Pub. L. 115-271), entitled Help for Moms and Babies",
"locations": [
{
"id": 242,
"title": 42,
"part": 435,
"type": "section",
"section_id": 116,
"parent": 876
},
{
"id": 256,
"title": 42,
"part": 435,
"type": "section",
"section_id": 301,
"parent": 877
},
{
"id": 29,
"title": 42,
"part": 440,
"type": "section",
"section_id": 140,
"parent": 1124
},
{
"id": 30,
"title": 42,
"part": 440,
"type": "section",
"section_id": 160,
"parent": 1124
},
{
"id": 53,
"title": 42,
"part": 440,
"type": "section",
"section_id": 210,
"parent": 1125
},
{
"id": 54,
"title": 42,
"part": 440,
"type": "section",
"section_id": 220,
"parent": 1125
},
{
"id": 10,
"title": 42,
"part": 440,
"type": "section",
"section_id": 250,
"parent": 1125
}
],
"document_type": null,
"resource_type": "external",
"subjects": [],
"category": {
"id": 9,
"name": "CMCS Informational Bulletin (CIB)",
"description": "",
"order": 300,
"show_if_empty": false,
"is_fr_doc_category": false,
"type": "subcategory",
"parent": {
"id": 5,
"name": "Subregulatory Guidance",
"description": "SMDLs, SHOs, CIBs, FAQs, SMM",
"order": 400,
"show_if_empty": true,
"is_fr_doc_category": false,
"type": ""
}
},
{
"id": 850,
"title": 42,
"part": 430,
"type": "section",
"section_id": 10,
"parent": 960
}
],
"document_type": {
"id": 4,
"name": "Informal Guidance",
"description": "Useful internal emails and one-pagers"
"url": "https://www.medicaid.gov/federal-policy-guidance/downloads/cib072619-1012.pdf",
"document_name_headline": null,
"summary_headline": "SUPPORT) for Patients and Communities Act (Pub. L. 115-271), entitled Help for Moms and <span class=\"search-highlight\">Babies</span>"
},
"subjects": [
{
{
"doc_name_string": "[Mock] Cypress Fixture",
"file_name_string": "ff-test-em.pdf",
"date_string": "2023-08-30",
"summary_string": "This is the summary. Rubber baby buggy bumper",
"locations": [
{
"id": 1355,
"title": 42,
"part": 400,
"type": "subpart",
"subpart_id": "A"
},
{
"id": 2974,
"title": 45,
"part": 75,
"type": "section",
"section_id": 101,
"parent": 3318
}
],
"document_type": {
"id": 2,
"full_name": "Alternative Benefit Plan",
"short_name": null,
"abbreviation": "ABP"
}
],
"uid": "e641d2f8-7fde-41d5-a025-8388bb51d6ae",
"document_name_headline": null,
"summary_headline": null
}
]
"name": "Curated Formal Guidance",
"description": "Collections of references and excerpts from public materials, such as State Medicaid Manual"
},
"resource_type": "internal",
"subjects": [
{
"id": 3,
"full_name": "Access to Services",
"short_name": null,
"abbreviation": null
},
{
"id": 4,
"full_name": "Adult Day Health",
"short_name": null,
"abbreviation": null
},
{
"id": 5,
"full_name": "Ambulatory Prenatal Care",
"short_name": null,
"abbreviation": null
}
],
"category": {},
"url": "d89af093-8975-4bcb-a747-abe346ebb274",
"document_name_headline": "[Mock] Cypress Fixture",
"summary_headline": "This is the summary. Rubber <span class=\"search-highlight\">baby</span> buggy bumper"
}
]
}
4 changes: 3 additions & 1 deletion solution/ui/regulations/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
"rules": {
"eqeqeq": "off",
"no-console": ["error", { "allow": ["warn", "error"] }],
"no-nested-ternary": "off",
"vue/order-in-components": "off",
"vue/no-unsupported-features": [
"error",
{
"version": "^2.7.0",
"ignores": []
}
]
],
"vue/no-v-html": "off"
}
}
3 changes: 3 additions & 0 deletions solution/ui/regulations/css/scss/_application_settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ $jump_to_submit_active_focus: $dark_blue;

$policy_subject_selected_chip_background: $dark_blue;

$choice-checked-background-color: $mid_blue;
$choice-checked-border-color: $mid_blue;

// Borders

$border_color: $light_gray;
Expand Down
Loading

0 comments on commit bd5fb38

Please sign in to comment.