From c738c8f2e84992bc20aacb6a6857e47161236b15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Fri, 12 Jul 2024 21:16:35 +0100 Subject: [PATCH] test: Remove vanillaStore, instead import useStore --- editor.planx.uk/src/@planx/components/Calculate/logic.test.ts | 4 ++-- .../src/@planx/components/DrawBoundary/Public/Public.test.tsx | 4 ++-- .../src/@planx/components/FileUploadAndLabel/Editor.test.tsx | 4 ++-- .../src/@planx/components/FileUploadAndLabel/Public.test.tsx | 4 ++-- editor.planx.uk/src/@planx/components/Pay/Editor.test.tsx | 4 ++-- editor.planx.uk/src/@planx/components/Result/Public.test.tsx | 4 ++-- .../src/@planx/components/Review/Public/Public.test.tsx | 4 ++-- .../src/@planx/components/shared/Preview/Card.test.tsx | 4 ++-- editor.planx.uk/src/components/Feedback/index.test.tsx | 4 ++-- editor.planx.uk/src/components/Header.test.tsx | 4 ++-- .../FlowEditor/lib/__tests__/advancedAutomations.test.ts | 4 ++-- .../src/pages/FlowEditor/lib/__tests__/automations.test.ts | 4 ++-- .../src/pages/FlowEditor/lib/__tests__/clones.test.ts | 4 ++-- .../pages/FlowEditor/lib/__tests__/externalPortals.test.ts | 4 ++-- .../src/pages/FlowEditor/lib/__tests__/filters.test.ts | 4 ++-- .../src/pages/FlowEditor/lib/__tests__/flags.test.ts | 4 ++-- .../src/pages/FlowEditor/lib/__tests__/granularity.test.ts | 4 ++-- .../src/pages/FlowEditor/lib/__tests__/navigation.test.ts | 4 ++-- .../src/pages/FlowEditor/lib/__tests__/ordering.test.ts | 4 ++-- .../pages/FlowEditor/lib/__tests__/preview/canGoBack.test.ts | 4 ++-- .../pages/FlowEditor/lib/__tests__/preview/changeAnswer.ts | 4 ++-- .../pages/FlowEditor/lib/__tests__/preview/hasPaid.test.ts | 4 ++-- .../FlowEditor/lib/__tests__/preview/overrideAnswer.test.ts | 4 ++-- .../FlowEditor/lib/__tests__/preview/previousCard.test.ts | 4 ++-- .../src/pages/FlowEditor/lib/__tests__/preview/record.test.ts | 4 ++-- .../__tests__/preview/removeNodesDependentOnPassport.test.ts | 4 ++-- .../FlowEditor/lib/__tests__/preview/resetPreview.test.ts | 4 ++-- .../FlowEditor/lib/__tests__/preview/upcomingCardIds.test.ts | 4 ++-- .../src/pages/FlowEditor/lib/__tests__/setValue.test.ts | 4 ++-- .../src/pages/FlowEditor/lib/__tests__/unseen.test.ts | 4 ++-- .../src/pages/FlowEditor/lib/__tests__/useNotValues.test.ts | 4 ++-- .../src/pages/FlowEditor/lib/__tests__/user.test.ts | 4 ++-- editor.planx.uk/src/pages/Preview/SaveAndReturn.test.tsx | 4 ++-- editor.planx.uk/src/routes/utils.test.tsx | 4 ++-- 34 files changed, 68 insertions(+), 68 deletions(-) diff --git a/editor.planx.uk/src/@planx/components/Calculate/logic.test.ts b/editor.planx.uk/src/@planx/components/Calculate/logic.test.ts index 6d27065ed8..2dde552b55 100644 --- a/editor.planx.uk/src/@planx/components/Calculate/logic.test.ts +++ b/editor.planx.uk/src/@planx/components/Calculate/logic.test.ts @@ -1,7 +1,7 @@ import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { Store, vanillaStore } from "pages/FlowEditor/lib/store"; +import { Store, useStore } from "pages/FlowEditor/lib/store"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; const { upcomingCardIds, resetPreview, record } = getState(); // Helper method diff --git a/editor.planx.uk/src/@planx/components/DrawBoundary/Public/Public.test.tsx b/editor.planx.uk/src/@planx/components/DrawBoundary/Public/Public.test.tsx index 570a387cbb..87c345b2ec 100644 --- a/editor.planx.uk/src/@planx/components/DrawBoundary/Public/Public.test.tsx +++ b/editor.planx.uk/src/@planx/components/DrawBoundary/Public/Public.test.tsx @@ -2,7 +2,7 @@ import { Breadcrumbs } from "@opensystemslab/planx-core/types"; import { PASSPORT_REQUESTED_FILES_KEY } from "@planx/components/FileUploadAndLabel/model"; import { screen } from "@testing-library/react"; import axios from "axios"; -import { vanillaStore } from "pages/FlowEditor/lib/store"; +import { useStore } from "pages/FlowEditor/lib/store"; import React from "react"; import { act } from "react-dom/test-utils"; import { axe, setup } from "testUtils"; @@ -18,7 +18,7 @@ jest.mock("axios"); const mockedAxios = axios as jest.Mocked; global.URL.createObjectURL = jest.fn(); -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; test("recovers previously submitted files when clicking the back button", async () => { const handleSubmit = jest.fn(); diff --git a/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Editor.test.tsx b/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Editor.test.tsx index 1c3b97a4cd..7e75a02126 100644 --- a/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Editor.test.tsx +++ b/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Editor.test.tsx @@ -1,5 +1,5 @@ import { screen } from "@testing-library/react"; -import { vanillaStore } from "pages/FlowEditor/lib/store"; +import { useStore } from "pages/FlowEditor/lib/store"; import React from "react"; import { DndProvider } from "react-dnd"; import { HTML5Backend } from "react-dnd-html5-backend"; @@ -7,7 +7,7 @@ import { setup } from "testUtils"; import FileUploadAndLabelComponent from "./Editor"; -const { getState } = vanillaStore; +const { getState } = useStore; describe("FileUploadAndLabel - Editor Modal", () => { // TODO correctly mock an authenticated Platform Admin user so 'add new' button is enabled in final test diff --git a/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Public.test.tsx b/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Public.test.tsx index a8a8435fd8..7011823847 100644 --- a/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Public.test.tsx +++ b/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Public.test.tsx @@ -1,7 +1,7 @@ import { act, screen, waitFor, within } from "@testing-library/react"; import { UserEvent } from "@testing-library/user-event/dist/types/setup/setup"; import axios from "axios"; -import { vanillaStore } from "pages/FlowEditor/lib/store"; +import { useStore } from "pages/FlowEditor/lib/store"; import { FullStore } from "pages/FlowEditor/lib/store"; import React from "react"; import { axe, setup } from "testUtils"; @@ -11,7 +11,7 @@ import { mockFileTypes, mockFileTypesUniqueKeys } from "./mocks"; import { PASSPORT_REQUESTED_FILES_KEY } from "./model"; import FileUploadAndLabelComponent from "./Public"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; let initialState: FullStore; jest.mock("axios"); diff --git a/editor.planx.uk/src/@planx/components/Pay/Editor.test.tsx b/editor.planx.uk/src/@planx/components/Pay/Editor.test.tsx index 3357aee964..6f3c1d4086 100644 --- a/editor.planx.uk/src/@planx/components/Pay/Editor.test.tsx +++ b/editor.planx.uk/src/@planx/components/Pay/Editor.test.tsx @@ -1,7 +1,7 @@ import { User } from "@opensystemslab/planx-core/types"; import { fireEvent, waitFor } from "@testing-library/react"; import { toggleFeatureFlag } from "lib/featureFlags"; -import { FullStore, vanillaStore } from "pages/FlowEditor/lib/store"; +import { FullStore, useStore } from "pages/FlowEditor/lib/store"; import React from "react"; import { DndProvider } from "react-dnd"; import { HTML5Backend } from "react-dnd-html5-backend"; @@ -35,7 +35,7 @@ describe("Pay component - Editor Modal", () => { jest.setTimeout(20000); // Set up mock state with platformAdmin user so all Editor features are enabled - const { getState, setState } = vanillaStore; + const { getState, setState } = useStore; const mockUser: User = { id: 123, email: "b.baggins@shire.com", diff --git a/editor.planx.uk/src/@planx/components/Result/Public.test.tsx b/editor.planx.uk/src/@planx/components/Result/Public.test.tsx index 5aa861166c..415fcd39ce 100644 --- a/editor.planx.uk/src/@planx/components/Result/Public.test.tsx +++ b/editor.planx.uk/src/@planx/components/Result/Public.test.tsx @@ -2,10 +2,10 @@ import { screen } from "@testing-library/react"; import React from "react"; import { axe, setup } from "testUtils"; -import { vanillaStore } from "../../../pages/FlowEditor/lib/store"; +import { useStore } from "../../../pages/FlowEditor/lib/store"; import Result from "./Public"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; beforeEach(() => { getState().resetPreview(); diff --git a/editor.planx.uk/src/@planx/components/Review/Public/Public.test.tsx b/editor.planx.uk/src/@planx/components/Review/Public/Public.test.tsx index beb16b0701..afc6b37639 100644 --- a/editor.planx.uk/src/@planx/components/Review/Public/Public.test.tsx +++ b/editor.planx.uk/src/@planx/components/Review/Public/Public.test.tsx @@ -1,5 +1,5 @@ import { act, screen, waitFor, within } from "@testing-library/react"; -import { FullStore, vanillaStore } from "pages/FlowEditor/lib/store"; +import { FullStore, useStore } from "pages/FlowEditor/lib/store"; import React from "react"; import { axe, setup } from "testUtils"; @@ -25,7 +25,7 @@ import { import { mockedBreadcrumbs, mockedFlow, mockedPassport } from "./mocks/simple"; import Review from "./Presentational"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; let initialState: FullStore; diff --git a/editor.planx.uk/src/@planx/components/shared/Preview/Card.test.tsx b/editor.planx.uk/src/@planx/components/shared/Preview/Card.test.tsx index 83baaeeaa8..381b22462c 100644 --- a/editor.planx.uk/src/@planx/components/shared/Preview/Card.test.tsx +++ b/editor.planx.uk/src/@planx/components/shared/Preview/Card.test.tsx @@ -1,13 +1,13 @@ import Button from "@mui/material/Button"; import { act, screen, waitFor } from "@testing-library/react"; -import { FullStore, vanillaStore } from "pages/FlowEditor/lib/store"; +import { FullStore, useStore } from "pages/FlowEditor/lib/store"; import React from "react"; import { axe, setup } from "testUtils"; import { ApplicationPath } from "types"; import Card from "./Card"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; let initialState: FullStore; diff --git a/editor.planx.uk/src/components/Feedback/index.test.tsx b/editor.planx.uk/src/components/Feedback/index.test.tsx index 181d6e09d9..2009dea98f 100644 --- a/editor.planx.uk/src/components/Feedback/index.test.tsx +++ b/editor.planx.uk/src/components/Feedback/index.test.tsx @@ -4,13 +4,13 @@ import { getInternalFeedbackMetadata, insertFeedbackMutation, } from "lib/feedback"; -import { vanillaStore } from "pages/FlowEditor/lib/store"; +import { useStore } from "pages/FlowEditor/lib/store"; import React from "react"; import { axe, setup } from "testUtils"; import Feedback from "./index"; -const { setState } = vanillaStore; +const { setState } = useStore; const mockedBreadcrumbs: Breadcrumbs = { LU5xin8PHs: { diff --git a/editor.planx.uk/src/components/Header.test.tsx b/editor.planx.uk/src/components/Header.test.tsx index e3e2cfee26..f7a358169e 100644 --- a/editor.planx.uk/src/components/Header.test.tsx +++ b/editor.planx.uk/src/components/Header.test.tsx @@ -1,6 +1,6 @@ import { Team } from "@opensystemslab/planx-core/types"; import { screen } from "@testing-library/react"; -import { vanillaStore } from "pages/FlowEditor/lib/store"; +import { useStore } from "pages/FlowEditor/lib/store"; import React from "react"; import { act } from "react-dom/test-utils"; import * as ReactNavi from "react-navi"; @@ -10,7 +10,7 @@ import flowWithoutSections from "../pages/FlowEditor/lib/__tests__/mocks/flowWit import flowWithThreeSections from "../pages/FlowEditor/lib/__tests__/mocks/flowWithThreeSections.json"; import Header from "./Header"; -const { setState, getState } = vanillaStore; +const { setState, getState } = useStore; const mockTeam1: Team = { id: 123, diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/advancedAutomations.test.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/advancedAutomations.test.ts index e0df4e2696..ac20d92923 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/advancedAutomations.test.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/advancedAutomations.test.ts @@ -1,8 +1,8 @@ import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { Store, vanillaStore } from "../store"; +import { Store, useStore } from "../store"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; const flow: Store.flow = { _root: { diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/automations.test.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/automations.test.ts index 9b2599a997..54fc776b78 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/automations.test.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/automations.test.ts @@ -1,9 +1,9 @@ import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; import shuffle from "lodash/shuffle"; -import { vanillaStore } from "../store"; +import { useStore } from "../store"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; beforeEach(() => { getState().resetPreview(); diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/clones.test.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/clones.test.ts index 71f051ccf6..d87413e083 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/clones.test.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/clones.test.ts @@ -1,5 +1,5 @@ -import { vanillaStore } from "../store"; -const { getState, setState } = vanillaStore; +import { useStore } from "../store"; +const { getState, setState } = useStore; import forwardsFlow from "./mocks/flowWithClones.json"; import reverseFlow from "./mocks/flowWithReverseClones.json"; diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/externalPortals.test.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/externalPortals.test.ts index 6646cafadd..d43d63afbd 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/externalPortals.test.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/externalPortals.test.ts @@ -1,8 +1,8 @@ -import { FullStore, vanillaStore } from "../store"; +import { FullStore, useStore } from "../store"; import multipleExternalPortals from "./mocks/multipleExternalPortals.json"; import singleExternalPortal from "./mocks/singleExternalPortal.json"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; const { upcomingCardIds, record } = getState(); let initialState: FullStore; diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/filters.test.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/filters.test.ts index 30e90ac03d..9ce3674e38 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/filters.test.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/filters.test.ts @@ -1,9 +1,9 @@ -import { vanillaStore } from "../store"; +import { useStore } from "../store"; import flowWithAutoAnsweredFilterPaths from "./mocks/flowWithAutoAnsweredFilterPaths.json"; import flowWithBranchingFilters from "./mocks/flowWithBranchingFilters.json"; import flowWithRootFilter from "./mocks/flowWithRootFilter.json"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; const { upcomingCardIds, resetPreview, diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/flags.test.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/flags.test.ts index 857ba71305..1c6e8f4e83 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/flags.test.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/flags.test.ts @@ -1,8 +1,8 @@ import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { vanillaStore } from "../store"; +import { useStore } from "../store"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; describe("in a flow with no collected flags, the user", () => { beforeEach(() => { diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/granularity.test.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/granularity.test.ts index aaf4e7201f..95aaa41af7 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/granularity.test.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/granularity.test.ts @@ -1,8 +1,8 @@ import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { Store, vanillaStore } from "../store"; +import { Store, useStore } from "../store"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; const flow: Store.flow = { _root: { diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/navigation.test.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/navigation.test.ts index 21a56af59f..0e92ae9bc6 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/navigation.test.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/navigation.test.ts @@ -1,10 +1,10 @@ import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { FullStore, vanillaStore } from "../store"; +import { FullStore, useStore } from "../store"; import flowWithoutSections from "./mocks/flowWithClones.json"; import flowWithThreeSections from "./mocks/flowWithThreeSections.json"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; const { filterFlowByType, initNavigationStore, record } = getState(); let initialState: FullStore; diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/ordering.test.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/ordering.test.ts index 43f1fdb515..d27323334a 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/ordering.test.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/ordering.test.ts @@ -1,8 +1,8 @@ import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { Store, vanillaStore } from "../store"; +import { Store, useStore } from "../store"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; const flow: Store.flow = { _root: { diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/canGoBack.test.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/canGoBack.test.ts index 6a12ab655d..22f0af6d53 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/canGoBack.test.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/canGoBack.test.ts @@ -1,8 +1,8 @@ import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { Store, vanillaStore } from "../../store"; +import { Store, useStore } from "../../store"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; const { canGoBack, getCurrentCard, resetPreview, record, changeAnswer } = getState(); diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/changeAnswer.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/changeAnswer.ts index 03cc472c81..fe9bf87b80 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/changeAnswer.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/changeAnswer.ts @@ -1,9 +1,9 @@ import cloneDeep from "lodash/cloneDeep"; -import { Store, vanillaStore } from "../../store"; +import { Store, useStore } from "../../store"; import flowWithAutoAnswersMock from "../mocks/flowWithAutoAnswers.json"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; const flowWithAutoAnswers = cloneDeep(flowWithAutoAnswersMock) as Store.flow; diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/hasPaid.test.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/hasPaid.test.ts index a32b6cce32..b829da536a 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/hasPaid.test.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/hasPaid.test.ts @@ -1,8 +1,8 @@ import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { vanillaStore } from "../../store"; +import { useStore } from "../../store"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; const { record, hasPaid } = getState(); test("hasPaid is updated if a Pay component has been recorded", () => { diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/overrideAnswer.test.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/overrideAnswer.test.ts index c7bcb0da1b..6aa0936cf4 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/overrideAnswer.test.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/overrideAnswer.test.ts @@ -1,6 +1,6 @@ -import { vanillaStore } from "../../store"; +import { useStore } from "../../store"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; const { overrideAnswer, getCurrentCard, upcomingCardIds, record } = getState(); diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/previousCard.test.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/previousCard.test.ts index 92ccc71a37..cdb1986792 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/previousCard.test.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/previousCard.test.ts @@ -1,6 +1,6 @@ -import { vanillaStore } from "../../store"; +import { useStore } from "../../store"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; const { resetPreview, previousCard, getCurrentCard } = getState(); diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/record.test.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/record.test.ts index e8d825104f..5c39916a80 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/record.test.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/record.test.ts @@ -1,8 +1,8 @@ import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { vanillaStore } from "../../store"; +import { useStore } from "../../store"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; const { record } = getState(); describe("error handling", () => { diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/removeNodesDependentOnPassport.test.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/removeNodesDependentOnPassport.test.ts index dcf8e20d8b..bcc4415941 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/removeNodesDependentOnPassport.test.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/removeNodesDependentOnPassport.test.ts @@ -1,11 +1,11 @@ import cloneDeep from "lodash/cloneDeep"; -import { Store, vanillaStore } from "../../store"; +import { Store, useStore } from "../../store"; import { removeNodesDependentOnPassport } from "../../store/preview"; import breadcrumbsDependentOnPassportMock from "../mocks/breadcrumbsDependentOnPassport.json"; import flowWithPassportComponentsMock from "../mocks/flowWithPassportComponents.json"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; let breadcrumbsDependentOnPassport = cloneDeep( breadcrumbsDependentOnPassportMock, diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/resetPreview.test.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/resetPreview.test.ts index c212c43630..add46df266 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/resetPreview.test.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/resetPreview.test.ts @@ -1,6 +1,6 @@ -import { vanillaStore } from "../../store"; +import { useStore } from "../../store"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; const { resetPreview } = getState(); diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/upcomingCardIds.test.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/upcomingCardIds.test.ts index 6c3a1f5e05..b166ce5463 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/upcomingCardIds.test.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/upcomingCardIds.test.ts @@ -1,8 +1,8 @@ import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { Store, vanillaStore } from "../../store"; +import { Store, useStore } from "../../store"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; const { upcomingCardIds, resetPreview, record, getCurrentCard } = getState(); const flow: Store.flow = { diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/setValue.test.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/setValue.test.ts index 72983ec6fd..7aae5da40a 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/setValue.test.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/setValue.test.ts @@ -1,9 +1,9 @@ import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; import { cloneDeep, merge } from "lodash"; -import { Store, vanillaStore } from "../store"; +import { Store, useStore } from "../store"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; const { resetPreview, record, computePassport, getCurrentCard } = getState(); const baseFlow: Store.flow = { diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/unseen.test.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/unseen.test.ts index a4575e3558..4ea8774a75 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/unseen.test.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/unseen.test.ts @@ -1,6 +1,6 @@ -import { Store, vanillaStore } from "../store"; +import { Store, useStore } from "../store"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; // https://github.com/theopensystemslab/planx-new/pull/430#issue-625111571 const flow: Store.flow = { diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/useNotValues.test.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/useNotValues.test.ts index 54a789d760..cb74d0cebc 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/useNotValues.test.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/useNotValues.test.ts @@ -1,4 +1,4 @@ -import { Store, vanillaStore } from "../store"; +import { Store, useStore } from "../store"; // flow preview: https://i.imgur.com/nCov5CE.png @@ -106,7 +106,7 @@ const flow: Store.flow = { }, }; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; describe("if I initially pick", () => { beforeEach(() => { diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/user.test.ts b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/user.test.ts index 5c0f9e24c7..2f14e589aa 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/user.test.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/__tests__/user.test.ts @@ -1,8 +1,8 @@ import { User } from "@opensystemslab/planx-core/types"; -import { FullStore, vanillaStore } from "../store"; +import { FullStore, useStore } from "../store"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; const { canUserEditTeam } = getState(); const redUser: User = { diff --git a/editor.planx.uk/src/pages/Preview/SaveAndReturn.test.tsx b/editor.planx.uk/src/pages/Preview/SaveAndReturn.test.tsx index 87a154a4c6..d69ea4433e 100644 --- a/editor.planx.uk/src/pages/Preview/SaveAndReturn.test.tsx +++ b/editor.planx.uk/src/pages/Preview/SaveAndReturn.test.tsx @@ -1,12 +1,12 @@ import Button from "@mui/material/Button"; import { act, screen, waitFor } from "@testing-library/react"; -import { FullStore, vanillaStore } from "pages/FlowEditor/lib/store"; +import { FullStore, useStore } from "pages/FlowEditor/lib/store"; import React from "react"; import { axe, setup } from "testUtils"; import SaveAndReturn, { ConfirmEmail } from "./SaveAndReturn"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; let initialState: FullStore; diff --git a/editor.planx.uk/src/routes/utils.test.tsx b/editor.planx.uk/src/routes/utils.test.tsx index 6e47cd424f..0d398a6318 100644 --- a/editor.planx.uk/src/routes/utils.test.tsx +++ b/editor.planx.uk/src/routes/utils.test.tsx @@ -1,11 +1,11 @@ import { waitFor } from "@testing-library/react"; import { NaviRequest } from "navi"; -import { FullStore, vanillaStore } from "pages/FlowEditor/lib/store"; +import { FullStore, useStore } from "pages/FlowEditor/lib/store"; import { ApplicationPath } from "types"; import { isSaveReturnFlow, setPath } from "./utils"; -const { getState, setState } = vanillaStore; +const { getState, setState } = useStore; let initialState: FullStore; const mockFlow = {