Skip to content

Commit

Permalink
EREGCSC-2461 -- Use new category/subcategory model on repository (#1161)
Browse files Browse the repository at this point in the history
* feat: use categories instead of document type for labels

* chore: optional chaining for access check safety

* test: update snapshot

* test: update fixture and e2e tests
  • Loading branch information
PhilR8 authored Feb 7, 2024
1 parent 976a1b7 commit e586373
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 12 deletions.
82 changes: 79 additions & 3 deletions solution/ui/e2e/cypress/e2e/policy-repository.spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,60 @@ describe("Policy Repository", () => {
cy.url().should("include", "/resources");
});

it("should have the correct labels for public and internal documents", () => {
cy.intercept("**/v3/content-search/?q=test**", {
fixture: "policy-docs.json",
}).as("queriedFiles");
cy.viewport("macbook-15");
cy.eregsLogin({
username,
password,
landingPage: "/policy-repository/",
});
cy.visit("/policy-repository/");
cy.get("input#main-content")
.should("be.visible")
.type("test", { force: true });
cy.get(".search-field .v-input__icon--append button").click({
force: true,
});
cy.wait("@queriedFiles").then((interception) => {
expect(interception.response.statusCode).to.eq(200);
});

// Public doc
cy.get(".category-labels")
.eq(0)
.find(".doc-type__label")
.should("include.text", " Public ")
.find("i")
.should("have.class", "fa-users");
cy.get(".category-labels")
.eq(0)
.find(".category-label")
.should("include.text", " Subregulatory Guidance ");
cy.get(".category-labels")
.eq(0)
.find(".subcategory-label")
.should("include.text", "CMCS Informational Bulletin (CIB)");

// Internal doc
cy.get(".category-labels")
.eq(1)
.find(".doc-type__label")
.should("include.text", " Internal ")
.find("i")
.should("have.class", "fa-key");
cy.get(".category-labels")
.eq(1)
.find(".category-label")
.should("include.text", "TestCat");
cy.get(".category-labels")
.eq(1)
.find(".subcategory-label")
.should("include.text", "TestSubCat");
});

it("returns you to the custom eua login page when you log out", () => {
cy.viewport("macbook-15");
cy.eregsLogin({ username, password, landingPage: "/policy-repository/" });
Expand Down Expand Up @@ -545,7 +599,7 @@ describe("Policy Repository Search", () => {
});
});

it("should have the correct public/internal label", () => {
it("should have the correct labels for public and internal documents", () => {
cy.intercept("**/v3/content-search/?q=test**", {
fixture: "policy-docs.json",
}).as("queriedFiles");
Expand All @@ -565,15 +619,37 @@ describe("Policy Repository Search", () => {
cy.wait("@queriedFiles").then((interception) => {
expect(interception.response.statusCode).to.eq(200);
});
cy.get(".doc-type__label")

// Public doc
cy.get(".category-labels")
.eq(0)
.find(".doc-type__label")
.should("include.text", " Public ")
.find("i")
.should("have.class", "fa-users");
cy.get(".doc-type__label")
cy.get(".category-labels")
.eq(0)
.find(".category-label")
.should("include.text", " Subregulatory Guidance ");
cy.get(".category-labels")
.eq(0)
.find(".subcategory-label")
.should("include.text", "CMCS Informational Bulletin (CIB)");

// Internal doc
cy.get(".category-labels")
.eq(1)
.find(".doc-type__label")
.should("include.text", " Internal ")
.find("i")
.should("have.class", "fa-key");
cy.get(".category-labels")
.eq(1)
.find(".category-label")
.should("include.text", "TestCat");
cy.get(".category-labels")
.eq(1)
.find(".subcategory-label")
.should("include.text", "TestSubCat");
});
});
17 changes: 16 additions & 1 deletion solution/ui/e2e/cypress/fixtures/policy-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,22 @@
"abbreviation": null
}
],
"category": {},
"category": {
"id": 2,
"name": "TestSubCat",
"description": "",
"order": 0,
"show_if_empty": false,
"type": "repositorysubcategory",
"parent": {
"id": 1,
"name": "TestCat",
"description": "This is a test category. It may have child subcategories.",
"order": 0,
"show_if_empty": false,
"type": ""
}
},
"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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,24 +166,33 @@ const resultLinkClasses = (doc) => ({
/>
<template v-if="doc.resource_type === 'internal'">
<CategoryLabel
v-if="!_isEmpty(doc.document_type)"
:name="doc.document_type.name"
v-if="!_isEmpty(doc.category)"
:name="
doc.category?.parent
? doc.category?.parent?.name
: doc.category?.name
"
type="category"
/>
<CategoryLabel
v-if="doc.category?.parent"
:name="doc.category?.name"
type="subcategory"
/>
</template>
<template v-else>
<CategoryLabel
v-if="!_isEmpty(doc.category)"
:name="
doc.category.parent
? doc.category.parent.name
: doc.category.name
doc.category?.parent
? doc.category?.parent?.name
: doc.category?.name
"
type="category"
/>
<CategoryLabel
v-if="doc.category?.parent"
:name="doc.category.name"
:name="doc.category?.name"
type="subcategory"
/>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ exports[`Supplemental Content > Checks to see if the snap shot matches 1`] = `
>
Subpart A Resources
</h2>
<!---->
<div
class="supplemental-content-container"
>
Expand Down Expand Up @@ -5902,7 +5901,6 @@ exports[`Supplemental Content > Checks to see if the snap shot matches 1`] = `
>
Subpart A Resources
</h2>
<!---->
<div
class="supplemental-content-container"
>
Expand Down

0 comments on commit e586373

Please sign in to comment.