forked from ministryofjustice/bichard7-next-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BICAW-2610 note preview (ministryofjustice#192)
* Refactored NoteTag component * created show/hide button functionality * show / hide classes working * bare bones * added JSS custom styling framework * imported SVG from figma * extracted most recent note * WIP * added note created date into preview container * Fixed column width in CourtCaseList.tsx * WIP * WIP * WIP * WIP- start of Alice's plan * WIP- * WIP * Note preview functional * Added basic gds stylings * Removed top border on notesRow * set column widths to prevent 2 line headers * removed margin on button * refactored redundant comments * Update note message logic * changed name of tableBody * refactored tablebody into separate component * Added TODOs * re-ordered helper functions in courCaseListEntry component * added elipsis logic on displayed note text * WIP tests to do * Refactor logic into testable functions * WIP setting up test * Added test for getMostRecentNote function * WIP- truncating function not working * fixed truncating test * added logic to filter out system notes * refactored function calls * removed console.logs * moved file locations and updated component testing for icons * refactored component test * added e2e test skeleton * updated display behaviour when there are 0 user notes * tidy up removed console log * updated e2e test to include note preview * removed note preview stories * turned on reactStrictMode * removed unused icon components * removed brackets * removed duplicate tests * fixed breaking storybook test * updated path for conditional render * added more assertions to component tests * updated review notes * fixed tests * updated helper function name * updated path for gds colours --------- Co-authored-by: joe-fol <[email protected]>
- Loading branch information
Showing
12 changed files
with
533 additions
and
423 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { HideButton, PreviewButton } from "../../src/features/CourtCaseList/NotePreviewButton" | ||
|
||
describe("NotePreview.cy.tx", () => { | ||
it("shows the default down chevron with the label 'preview'", () => { | ||
cy.mount(<PreviewButton />) | ||
cy.get(".govuk-accordion-nav__chevron--down").should("exist") | ||
cy.get(".govuk-accordion-nav__chevron").should("exist") | ||
}) | ||
|
||
it("shows the default up chevron with the label 'hide'", () => { | ||
cy.mount(<HideButton />) | ||
cy.get(".govuk-accordion-nav__chevron").should("exist") | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -208,37 +208,6 @@ describe("Case list", () => { | |
}) | ||
}) | ||
|
||
it("should be able to navigate to the case details page and back", () => { | ||
cy.task("insertMultipleDummyCourtCases", { numToInsert: 3, force: "01" }) | ||
|
||
loginAndGoToUrl() | ||
|
||
cy.findByText("Defendant Name 0").click() | ||
|
||
cy.url().should("match", /\/court-cases\//) | ||
cy.findByText("Case Details").should("exist") | ||
|
||
cy.findByText("Cases").click() | ||
|
||
cy.url().should("match", /\/bichard/) | ||
cy.findByText("Court cases").should("exist") | ||
}) | ||
|
||
it("Should display the urgent badge on cases marked as urgent", () => { | ||
cy.task("insertCourtCasesWithFields", [ | ||
{ isUrgent: true, orgForPoliceFilter: "01" }, | ||
{ isUrgent: false, orgForPoliceFilter: "01" }, | ||
{ isUrgent: true, orgForPoliceFilter: "01" } | ||
]) | ||
|
||
loginAndGoToUrl() | ||
|
||
cy.get("tr").not(":first").eq(0).get("td:nth-child(5)").contains(`Case00000`) | ||
cy.get("tr").not(":first").eq(0).contains(`Urgent`).should("exist") | ||
cy.get("tr").not(":first").eq(1).contains(`Urgent`).should("not.exist") | ||
cy.get("tr").not(":first").eq(2).contains(`Urgent`).should("exist") | ||
}) | ||
|
||
it("Should display the resolved badge on cases marked as resolved", () => { | ||
cy.task("insertCourtCasesWithFields", [ | ||
{ resolutionTimestamp: new Date(), orgForPoliceFilter: "01" }, | ||
|
@@ -305,63 +274,6 @@ describe("Case list", () => { | |
cy.get("tr").not(":first").eq(2).get("td:nth-child(7)").contains(`3`).should("exist") | ||
}) | ||
|
||
it("Should display reason (errors and triggers) with correct formatting", () => { | ||
cy.task("insertCourtCasesWithFields", [{ orgForPoliceFilter: "011111" }, { orgForPoliceFilter: "011111" }]) | ||
|
||
cy.task("insertException", { | ||
caseId: 0, | ||
exceptionCode: "HO100310", | ||
errorReport: "HO100310||ds:OffenceReasonSequence" | ||
}) | ||
}) | ||
|
||
it("should display cases for parent forces up to the second-level force", () => { | ||
cy.task("insertCourtCasesWithFields", [ | ||
{ orgForPoliceFilter: "01" }, | ||
{ orgForPoliceFilter: "011" }, | ||
{ orgForPoliceFilter: "0111" }, | ||
{ orgForPoliceFilter: "01111" }, | ||
{ orgForPoliceFilter: "011111" } | ||
]) | ||
|
||
loginAndGoToUrl("[email protected]") | ||
|
||
cy.get("tr").not(":first").get("td:nth-child(5)").contains("Case00000").should("not.exist") | ||
cy.get("tr").not(":first").get("td:nth-child(5)").contains("Case00001").should("not.exist") | ||
cy.get("tr").not(":first").get("td:nth-child(5)").contains("Case00002") | ||
cy.get("tr").not(":first").get("td:nth-child(5)").contains("Case00003") | ||
cy.get("tr").not(":first").get("td:nth-child(5)").contains("Case00004") | ||
}) | ||
|
||
it("can display cases ordered by court name", () => { | ||
cy.task("insertCourtCasesWithFields", [ | ||
{ courtName: "BBBB", orgForPoliceFilter: "011111" }, | ||
{ courtName: "AAAA", orgForPoliceFilter: "011111" }, | ||
{ courtName: "DDDD", orgForPoliceFilter: "011111" }, | ||
{ courtName: "CCCC", orgForPoliceFilter: "011111" } | ||
]) | ||
|
||
loginAndGoToUrl() | ||
|
||
cy.findByText("Court Name").click() | ||
|
||
cy.get("tr") | ||
.not(":first") | ||
.each((row) => { | ||
cy.wrap(row).get("td:nth-child(4)").first().contains("AAAA") | ||
cy.wrap(row).get("td:nth-child(4)").last().contains("DDDD") | ||
}) | ||
|
||
cy.findByText("Court Name").click() | ||
|
||
cy.get("tr") | ||
.not(":first") | ||
.each((row) => { | ||
cy.wrap(row).get("td:nth-child(4)").first().contains("DDDD") | ||
cy.wrap(row).get("td:nth-child(4)").last().contains("AAAA") | ||
}) | ||
}) | ||
|
||
it("should be able to navigate to the case details page and back", () => { | ||
cy.task("insertMultipleDummyCourtCases", { numToInsert: 3, force: "01" }) | ||
|
||
|
@@ -393,26 +305,7 @@ describe("Case list", () => { | |
cy.get("tr").not(":first").eq(2).contains(`Urgent`).should("exist") | ||
}) | ||
|
||
it("Should display the resolved badge on cases marked as resolved", () => { | ||
cy.task("insertCourtCasesWithFields", [ | ||
{ resolutionTimestamp: new Date(), orgForPoliceFilter: "01" }, | ||
{ resolutionTimestamp: null, orgForPoliceFilter: "01" }, | ||
{ resolutionTimestamp: new Date(), orgForPoliceFilter: "01" } | ||
]) | ||
|
||
loginAndGoToUrl() | ||
|
||
cy.get("#filter-button").contains("Show filter").click() | ||
cy.get("#unresolved-and-resolved").click() | ||
cy.get("#search").contains("Apply filters").click() | ||
|
||
cy.get("tr").not(":first").eq(0).get("td:nth-child(5)").contains(`Case00000`) | ||
cy.get("tr").not(":first").eq(0).contains(`Resolved`).should("exist") | ||
cy.get("tr").not(":first").eq(1).contains(`Resolved`).should("not.exist") | ||
cy.get("tr").not(":first").eq(2).contains(`Resolved`).should("exist") | ||
}) | ||
|
||
it("Should display the correct number of user-created notes on cases", () => { | ||
it("Should display a preview of the notes", () => { | ||
const caseNotes: { user: string; text: string }[][] = [ | ||
[ | ||
{ | ||
|
@@ -453,10 +346,8 @@ describe("Case list", () => { | |
|
||
loginAndGoToUrl() | ||
|
||
cy.get("tr").not(":first").eq(0).get("td:nth-child(5)").contains(`Case00000`) | ||
cy.get("tr").not(":first").eq(0).get("td:nth-child(7)").should("be.empty") | ||
cy.get("tr").not(":first").eq(1).get("td:nth-child(7)").contains(`1`).should("exist") | ||
cy.get("tr").not(":first").eq(2).get("td:nth-child(7)").contains(`3`).should("exist") | ||
cy.get("tr").not(":first").eq(1).get("td:nth-child(7)").contains(`Preview`).should("exist").trigger("click") | ||
cy.contains(`Test note 1`).should("exist") | ||
}) | ||
|
||
it("Should display reason (errors and triggers) with correct formatting", () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.