From 5a3e4275159cb41a77727c1128d6a6be6aafe34d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Mon, 9 Dec 2024 13:36:03 +0000 Subject: [PATCH] test: Upadte test cases --- .../components/Pay/Editor/Editor.test.tsx | 6 ++-- .../components/Pay/Public/Pay.fixture.tsx | 2 +- .../@planx/components/Pay/Public/Pay.test.tsx | 29 ++++++++----------- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/editor.planx.uk/src/@planx/components/Pay/Editor/Editor.test.tsx b/editor.planx.uk/src/@planx/components/Pay/Editor/Editor.test.tsx index df48b7880c..f5e2235869 100644 --- a/editor.planx.uk/src/@planx/components/Pay/Editor/Editor.test.tsx +++ b/editor.planx.uk/src/@planx/components/Pay/Editor/Editor.test.tsx @@ -117,7 +117,7 @@ describe("Pay component - Editor Modal", () => { , ); @@ -146,7 +146,7 @@ describe("Pay component - Editor Modal", () => { act(() => setState({ user: mockUser, flowName: "test flow" })); const mockNode = { data: { - fn: "fee", + fn: "application.fee.payable", govPayMetadata: [ { key: "flow", value: "flowName" }, { key: "source", value: "PlanX" }, @@ -260,7 +260,7 @@ describe("Pay component - Editor Modal", () => { , ); diff --git a/editor.planx.uk/src/@planx/components/Pay/Public/Pay.fixture.tsx b/editor.planx.uk/src/@planx/components/Pay/Public/Pay.fixture.tsx index d27d0ad125..d65b881627 100644 --- a/editor.planx.uk/src/@planx/components/Pay/Public/Pay.fixture.tsx +++ b/editor.planx.uk/src/@planx/components/Pay/Public/Pay.fixture.tsx @@ -8,7 +8,7 @@ export default function Fixture() { handleSubmit={console.log} title="Pay" description="" - fn="fee" + fn="application.fee.payable" color="#efefef" govPayMetadata={[]} /> diff --git a/editor.planx.uk/src/@planx/components/Pay/Public/Pay.test.tsx b/editor.planx.uk/src/@planx/components/Pay/Public/Pay.test.tsx index 0391100764..cbdef61be1 100644 --- a/editor.planx.uk/src/@planx/components/Pay/Public/Pay.test.tsx +++ b/editor.planx.uk/src/@planx/components/Pay/Public/Pay.test.tsx @@ -32,18 +32,10 @@ const flowWithUndefinedFee: Store.Flow = { _root: { edges: ["setValue", "pay"], }, - setValue: { - type: TYPES.SetValue, - edges: ["pay"], - data: { - fn: "application.fee.payable", - val: "0", - }, - }, pay: { type: TYPES.Pay, data: { - fn: "application.fee.typo", + fn: "application.fee.payable", }, }, }; @@ -92,22 +84,21 @@ const defaultProps = { }; describe("Pay component when fee is undefined or £0", () => { - beforeEach(() => { - getState().resetPreview(); - }); + beforeAll(() => (initialState = getState())); + afterEach(() => act(() => setState(initialState))); it("Shows an error if fee is undefined", () => { const handleSubmit = vi.fn(); - setState({ flow: flowWithUndefinedFee, breadcrumbs: breadcrumbs }); + setState({ flow: flowWithUndefinedFee, breadcrumbs: {} }); expect(getState().computePassport()).toEqual({ - data: { "application.fee.payable": ["0"] }, + data: { "application.fee.payable": undefined }, }); setup( , @@ -456,6 +447,8 @@ describe("Confirm component in information-only mode", () => { }); describe("the demo user view", () => { + beforeAll(() => (initialState = getState())); + beforeEach(() => { act(() => setState({ @@ -464,14 +457,16 @@ describe("the demo user view", () => { ); }); + afterEach(() => act(() => setState(initialState))); + it("should render an error when teamSlug is demo", async () => { const handleSubmit = vi.fn(); const { queryByText } = setup( , ); const errorHeader = queryByText("GOV.UK Pay is not enabled for demo users");