From 340671edd0336e07dab78e784ec3377b4c002828 Mon Sep 17 00:00:00 2001 From: Diego Cohen Date: Fri, 22 Nov 2024 16:11:39 -0500 Subject: [PATCH] Add coverage for page statuses --- __test__/pages/hold/eddRequestPage.test.tsx | 49 +++++++++++++++++++-- pages/hold/request/[id]/edd.tsx | 2 +- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/__test__/pages/hold/eddRequestPage.test.tsx b/__test__/pages/hold/eddRequestPage.test.tsx index b2053cc35..d1ec932fa 100644 --- a/__test__/pages/hold/eddRequestPage.test.tsx +++ b/__test__/pages/hold/eddRequestPage.test.tsx @@ -21,6 +21,7 @@ import { EDD_FORM_FIELD_COPY, } from "../../../src/config/constants" import { fetchDeliveryLocations } from "../../../src/server/api/hold" +import { EDDPageStatusMessages } from "../../../src/utils/holdPageUtils" jest.mock("../../../src/server/auth") jest.mock("../../../src/server/api/bib") @@ -163,7 +164,6 @@ describe("EDD Request page", () => { discoveryBibResult={bibWithItems.resource} discoveryItemResult={bibWithItems.resource.items[2]} patronId="123" - eddRequestable={true} isAuthenticated={true} /> ) @@ -191,14 +191,13 @@ describe("EDD Request page", () => { expect(screen.getByTestId("edd-request-form")).toBeInTheDocument() }) }) - describe("EDD Request error handling", () => { + describe("EDD Request form validation", () => { beforeEach(async () => { render( ) @@ -300,4 +299,48 @@ describe("EDD Request page", () => { ).toBeInTheDocument() }) }) + describe("EDD page status banner messages", () => { + it("shows an unavailable error message when the page loads with an unavailable status", async () => { + render( + + ) + expect( + screen.getByText(EDDPageStatusMessages.unavailable.heading) + ).toBeInTheDocument() + }) + it("shows a failed error message when the page loads with an failed status", async () => { + render( + + ) + expect( + screen.getByText(EDDPageStatusMessages.failed.heading) + ).toBeInTheDocument() + }) + it("shows an invalid error message when the page loads with an invalid status", async () => { + render( + + ) + expect( + screen.getByText(EDDPageStatusMessages.invalid.message) + ).toBeInTheDocument() + }) + }) }) diff --git a/pages/hold/request/[id]/edd.tsx b/pages/hold/request/[id]/edd.tsx index fda4b4514..0cc4e5be3 100644 --- a/pages/hold/request/[id]/edd.tsx +++ b/pages/hold/request/[id]/edd.tsx @@ -245,7 +245,7 @@ export async function getServerSideProps({ params, req, res, query }) { isAuthenticated, pageStatus: !isEddAvailable ? "unavailable" - : query?.formInvalid + : query?.formInvalid === true ? "invalid" : null, },