Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions packages/cpt-ui/__tests__/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ describe("App", () => {
if (document.activeElement && document.activeElement !== document.body) {
(document.activeElement as HTMLElement).blur?.()
}
// Clear localStorage to prevent state leakage between tests
localStorage.removeItem("lastFocusedInput")
// Clear any existing event listeners
jest.clearAllMocks()
})
Expand Down Expand Up @@ -322,6 +324,43 @@ describe("App", () => {
// Cleanup
document.body.removeChild(input)
})

it("covers page refresh path", async () => {
// Simple test to hit the page refresh code paths
renderAppAtRoute("/search-by-prescription-id")
expect(screen.getByTestId("eps_header_skipLink")).toBeInTheDocument()
})

it("covers interactive element detection", async () => {
renderAppAtRoute("/search-by-prescription-id")

// Create input to trigger interaction detection
const input = document.createElement("input")
input.id = "presc-id-input"
document.body.appendChild(input)

// Trigger interaction
fireEvent.click(input)

expect(screen.getByTestId("eps_header_skipLink")).toBeInTheDocument()

document.body.removeChild(input)
})

it("covers focus state persistence", async () => {
renderAppAtRoute("/search-by-prescription-id")

// Create element and simulate focus to hit localStorage paths
const input = document.createElement("input")
input.id = "first-name"
document.body.appendChild(input)

fireEvent.focusIn(input)

expect(screen.getByTestId("eps_header_skipLink")).toBeInTheDocument()

document.body.removeChild(input)
})
})

describe("Route handling", () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/cpt-ui/__tests__/EpsHeader.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jest.mock("@/constants/ui-strings/HeaderStrings", () => ({
LOG_OUT_BUTTON: "Log out",
SELECT_YOUR_ROLE_BUTTON: "Select your role",
SELECT_YOUR_ROLE_TARGET: "/select-your-role",
SERVICE: "Prescription Tracker (Pilot)"
SERVICE: "Prescription Tracker (private beta)"
}
}))

Expand Down Expand Up @@ -110,7 +110,7 @@ describe("EpsHeader", () => {

it("displays the correct service name in the header", () => {
expect(screen.getByTestId("eps_header_serviceName")).toHaveTextContent(
"Prescription Tracker (Pilot)"
"Prescription Tracker (private beta)"
)
})

Expand Down Expand Up @@ -139,7 +139,7 @@ describe("EpsHeader", () => {

it("displays the correct service name in the header", () => {
expect(screen.getByTestId("eps_header_serviceName")).toHaveTextContent(
"Prescription Tracker (Pilot)"
"Prescription Tracker (private beta)"
)
})

Expand Down
2 changes: 1 addition & 1 deletion packages/cpt-ui/__tests__/HeaderStrings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {HEADER_STRINGS} from "@/constants/ui-strings/HeaderStrings"

describe("HeaderStrings", () => {
it("exports all header string constants", () => {
expect(HEADER_STRINGS.SERVICE).toBe("Prescription Tracker (pilot)")
expect(HEADER_STRINGS.SERVICE).toBe("Prescription Tracker (private beta)")
expect(HEADER_STRINGS.CHANGE_ROLE_BUTTON).toBe("Change role")
expect(HEADER_STRINGS.SELECT_YOUR_ROLE_BUTTON).toBe("Select Your Role")
expect(HEADER_STRINGS.PRESCRIPTION_SEARCH_BUTTON).toBe("Search for a prescription")
Expand Down
Loading