diff --git a/src/__tests__/_/Provider.tsx b/src/__tests__/_/Provider.tsx new file mode 100644 index 000000000..d6a9d56e9 --- /dev/null +++ b/src/__tests__/_/Provider.tsx @@ -0,0 +1,43 @@ +import { ReactNode } from "react"; +import { Toaster } from "react-hot-toast"; +import { ThemeContextProvider } from "frontend/design-system/theme/Context"; +import { LinguiProvider } from "translations/utils"; +import { Messages } from "@lingui/core"; +import { ConfirmAlert } from "frontend/design-system/components/ConfirmAlert"; +import { + QueryCache, + QueryClient, + QueryClientProvider, +} from "@tanstack/react-query"; + +export const queryCache = new QueryCache(); + +const queryClient = new QueryClient({ + queryCache, +}); + +function QueryProvider({ children }: { children: ReactNode }) { + return ( + {children} + ); +} + +export function TestProviders({ + children, + translation, +}: { + children: ReactNode; + translation?: Messages; +}) { + return ( + + + + + + {children} + + + + ); +} diff --git a/src/__tests__/account/logout.spec.tsx b/src/__tests__/account/logout.spec.tsx index 52f17c97c..d0f5e68fc 100644 --- a/src/__tests__/account/logout.spec.tsx +++ b/src/__tests__/account/logout.spec.tsx @@ -1,10 +1,10 @@ import { render, screen, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import AccountPassword from "pages/account/password"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; Object.defineProperty(window, "location", { value: { @@ -23,9 +23,9 @@ useRouter.mockImplementation(USE_ROUTER_PARAMS({})); describe("pages/account/logout", () => { it("should log user out", async () => { render( - + - + ); await userEvent.click( diff --git a/src/__tests__/account/password.spec.tsx b/src/__tests__/account/password.spec.tsx index cc97f53d1..8b3b5277f 100644 --- a/src/__tests__/account/password.spec.tsx +++ b/src/__tests__/account/password.spec.tsx @@ -1,8 +1,7 @@ import { render, screen } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import AccountPassword from "pages/account/password"; - +import { TestProviders } from "__tests__/_/Provider"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { closeAllToasts } from "__tests__/_/utils/closeAllToasts"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; @@ -27,9 +26,9 @@ describe("pages/account/password", () => { it("should update password", async () => { render( - + - + ); await userEvent.type( await screen.findByLabelText("Old Password"), @@ -56,9 +55,9 @@ describe("pages/account/password", () => { process.env.NEXT_PUBLIC_IS_DEMO = "true"; render( - + - + ); await userEvent.type( diff --git a/src/__tests__/account/preferences.spec.tsx b/src/__tests__/account/preferences.spec.tsx index ed0dfae7e..45eedb83e 100644 --- a/src/__tests__/account/preferences.spec.tsx +++ b/src/__tests__/account/preferences.spec.tsx @@ -1,10 +1,10 @@ import { render, screen, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import UserPreferences from "pages/account/preferences"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -16,9 +16,9 @@ describe("pages/account/preferences", () => { it("should display user preferences", async () => { render( - + - + ); await waitFor(() => { expect(screen.getByRole("option", { selected: true })).toHaveTextContent( @@ -29,9 +29,9 @@ describe("pages/account/preferences", () => { it("should update user preference", async () => { render( - + - + ); await userEvent.click(screen.getByRole("option", { name: "Light" })); @@ -46,9 +46,9 @@ describe("pages/account/preferences", () => { it("should display updated preference", async () => { render( - + - + ); await waitFor(() => { expect(screen.getByRole("option", { selected: true })).toHaveTextContent( diff --git a/src/__tests__/account/profile.spec.tsx b/src/__tests__/account/profile.spec.tsx index 3991fd74a..d91271718 100644 --- a/src/__tests__/account/profile.spec.tsx +++ b/src/__tests__/account/profile.spec.tsx @@ -1,10 +1,10 @@ import { render, screen, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import AccountProfile from "pages/account/profile"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -15,9 +15,9 @@ useRouter.mockImplementation(USE_ROUTER_PARAMS({})); describe("pages/account/profile", () => { it("should display profile details", async () => { render( - + - + ); await waitFor(() => { expect(screen.getByLabelText("Name")).toHaveValue("Root User"); @@ -26,9 +26,9 @@ describe("pages/account/profile", () => { it("should update profile successfully", async () => { render( - + - + ); await userEvent.clear(screen.getByLabelText("Name")); @@ -46,9 +46,9 @@ describe("pages/account/profile", () => { it("should display updated profile details", async () => { render( - + - + ); await waitFor(() => { expect(screen.getByLabelText("Name")).toHaveValue("Updated Name"); diff --git a/src/__tests__/admin/[entity]/[id]/index.spec.tsx b/src/__tests__/admin/[entity]/[id]/index.spec.tsx index 014b713db..caf5c9d32 100644 --- a/src/__tests__/admin/[entity]/[id]/index.spec.tsx +++ b/src/__tests__/admin/[entity]/[id]/index.spec.tsx @@ -1,9 +1,9 @@ import { render, screen } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import EntityDetails from "pages/admin/[entity]/[id]/index"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -23,9 +23,9 @@ describe("pages/admin/[entity]/[id]/index", () => { it("should show details", async () => { render( - + - + ); expect(await screen.findByLabelText("Details Section")).toHaveTextContent( diff --git a/src/__tests__/admin/[entity]/[id]/update.spec.tsx b/src/__tests__/admin/[entity]/[id]/update.spec.tsx index 9bfb1c367..83c27561f 100644 --- a/src/__tests__/admin/[entity]/[id]/update.spec.tsx +++ b/src/__tests__/admin/[entity]/[id]/update.spec.tsx @@ -1,9 +1,9 @@ import { render, screen, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import EntityUpdate from "pages/admin/[entity]/[id]/update"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -22,9 +22,9 @@ describe("pages/admin/[entity]/update", () => { it("should update data", async () => { render( - + - + ); await waitFor(() => { expect(screen.getByText("Edit Singular entity-1")).toBeInTheDocument(); diff --git a/src/__tests__/admin/[entity]/config/actions.spec.tsx b/src/__tests__/admin/[entity]/config/actions.spec.tsx index 89ec8d298..e47c0c1a8 100644 --- a/src/__tests__/admin/[entity]/config/actions.spec.tsx +++ b/src/__tests__/admin/[entity]/config/actions.spec.tsx @@ -1,5 +1,4 @@ import { render, screen, within } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import EntityFormActionsSettings from "pages/admin/[entity]/config/actions"; @@ -7,6 +6,7 @@ import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { getTableRows } from "__tests__/_/utils/getTableRows"; import { closeAllToasts } from "__tests__/_/utils/closeAllToasts"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -25,9 +25,9 @@ describe("pages/admin/[entity]/config/actions", () => { it("should list entity form actions", async () => { render( - + x - + ); expect(await screen.findByRole("table")).toBeInTheDocument(); @@ -45,9 +45,9 @@ describe("pages/admin/[entity]/config/actions", () => { it("should create new form action successfully", async () => { render( - + - + ); await userEvent.click( @@ -113,9 +113,9 @@ describe("pages/admin/[entity]/config/actions", () => { it("should show the correct form values", async () => { render( - + - + ); expect(await screen.findByRole("table")).toBeInTheDocument(); @@ -153,9 +153,9 @@ describe("pages/admin/[entity]/config/actions", () => { it("should update the actions form", async () => { render( - + - + ); expect(await screen.findByRole("table")).toBeInTheDocument(); @@ -212,9 +212,9 @@ describe("pages/admin/[entity]/config/actions", () => { it("should show the correct form values", async () => { render( - + - + ); expect(await screen.findByRole("table")).toBeInTheDocument(); @@ -251,9 +251,9 @@ describe("pages/admin/[entity]/config/actions", () => { it("should delete form action successfully", async () => { render( - + - + ); expect(await screen.findByRole("table")).toBeInTheDocument(); diff --git a/src/__tests__/admin/[entity]/config/crud__fields.spec.tsx b/src/__tests__/admin/[entity]/config/crud__fields.spec.tsx index c04a663f4..f1a9ffa6e 100644 --- a/src/__tests__/admin/[entity]/config/crud__fields.spec.tsx +++ b/src/__tests__/admin/[entity]/config/crud__fields.spec.tsx @@ -1,5 +1,4 @@ import { render, screen, waitFor, within } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import EntityCrudSettings from "pages/admin/[entity]/config/crud"; import { rest } from "msw"; @@ -7,6 +6,7 @@ import { rest } from "msw"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { BASE_TEST_URL } from "__tests__/_/api-handlers/_utils"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; const server = setupApiHandlers(); @@ -64,9 +64,9 @@ describe("pages/admin/[entity]/config/crud", () => { it("should show current state correctly", async () => { render( - + - + ); const currentTab = await screen.findByRole("tabpanel", { name: tab }); @@ -92,9 +92,9 @@ describe("pages/admin/[entity]/config/crud", () => { it("should change state correctly", async () => { render( - + - + ); const currentTab = screen.getByRole("tabpanel", { name: tab }); @@ -121,9 +121,9 @@ describe("pages/admin/[entity]/config/crud", () => { it("should show updated state correctly", async () => { render( - + - + ); const currentTab = screen.getByRole("tabpanel", { name: tab }); @@ -159,9 +159,9 @@ describe("pages/admin/[entity]/config/crud", () => { ); render( - + - + ); expect( @@ -207,9 +207,9 @@ describe("pages/admin/[entity]/config/crud", () => { ); render( - + - + ); expect( diff --git a/src/__tests__/admin/[entity]/config/crud__tab.spec.tsx b/src/__tests__/admin/[entity]/config/crud__tab.spec.tsx index a2ab4b4ea..f14799c37 100644 --- a/src/__tests__/admin/[entity]/config/crud__tab.spec.tsx +++ b/src/__tests__/admin/[entity]/config/crud__tab.spec.tsx @@ -1,5 +1,4 @@ import { render, screen } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import EntityCrudSettings from "pages/admin/[entity]/config/crud"; import { rest } from "msw"; @@ -8,6 +7,7 @@ import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { BASE_TEST_URL } from "__tests__/_/api-handlers/_utils"; import { sluggify } from "shared/lib/strings"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; const server = setupApiHandlers(); @@ -45,9 +45,9 @@ describe("pages/admin/[entity]/config/crud", () => { it("should defaults to table", async () => { render( - + - + ); expect( @@ -62,9 +62,9 @@ describe("pages/admin/[entity]/config/crud", () => { { tab: "Delete" }, ])("should be tab-able to $tab", async ({ tab }) => { render( - + - + ); expect( await screen.findByRole("button", { @@ -102,9 +102,9 @@ describe("pages/admin/[entity]/config/crud", () => { ); render( - + - + ); expect( diff --git a/src/__tests__/admin/[entity]/config/crud__toggling.spec.tsx b/src/__tests__/admin/[entity]/config/crud__toggling.spec.tsx index d2f219e99..8a63752d3 100644 --- a/src/__tests__/admin/[entity]/config/crud__toggling.spec.tsx +++ b/src/__tests__/admin/[entity]/config/crud__toggling.spec.tsx @@ -1,5 +1,4 @@ import { render, screen, within } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import EntityCrudSettings from "pages/admin/[entity]/config/crud"; import { rest } from "msw"; @@ -7,6 +6,7 @@ import { rest } from "msw"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { BASE_TEST_URL } from "__tests__/_/api-handlers/_utils"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; const server = setupApiHandlers(); @@ -40,9 +40,9 @@ describe("pages/admin/[entity]/config/crud", () => { ); render( - + - + ); expect( @@ -82,9 +82,9 @@ describe("pages/admin/[entity]/config/crud", () => { it("should toggle off functionality", async () => { render( - + - + ); const currentTab = screen.getByRole("tabpanel", { name: tab }); @@ -113,9 +113,9 @@ describe("pages/admin/[entity]/config/crud", () => { it("should toggle on functionality", async () => { render( - + - + ); const currentTab = screen.getByRole("tabpanel", { name: tab }); diff --git a/src/__tests__/admin/[entity]/config/diction.spec.tsx b/src/__tests__/admin/[entity]/config/diction.spec.tsx index 739964a30..48c3a2891 100644 --- a/src/__tests__/admin/[entity]/config/diction.spec.tsx +++ b/src/__tests__/admin/[entity]/config/diction.spec.tsx @@ -1,10 +1,10 @@ import { render, screen, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import EntityDictionSettings from "pages/admin/[entity]/config/diction"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -23,9 +23,9 @@ describe("pages/admin/[entity]/config/diction", () => { it("should display diction values", async () => { render( - + - + ); await waitFor(() => { expect(screen.getByLabelText("Plural")).toHaveValue("Plural entity-1"); @@ -35,9 +35,9 @@ describe("pages/admin/[entity]/config/diction", () => { it("should update diction successfully", async () => { render( - + - + ); await userEvent.type(screen.getByLabelText("Plural"), "Updated"); @@ -54,9 +54,9 @@ describe("pages/admin/[entity]/config/diction", () => { it("should display updated diction values", async () => { render( - + - + ); await waitFor(() => { expect(screen.getByLabelText("Plural")).toHaveValue( diff --git a/src/__tests__/admin/[entity]/config/form.spec.tsx b/src/__tests__/admin/[entity]/config/form.spec.tsx index 208251ba1..6fc0c96e1 100644 --- a/src/__tests__/admin/[entity]/config/form.spec.tsx +++ b/src/__tests__/admin/[entity]/config/form.spec.tsx @@ -1,13 +1,13 @@ /* eslint-disable no-useless-escape */ import { render, screen, within } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import EntityFormExtensionSettings from "pages/admin/[entity]/config/form"; import { closeAllToasts } from "__tests__/_/utils/closeAllToasts"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -38,9 +38,9 @@ describe("pages/admin/[entity]/config/form", () => { ])("$section section", ({ label, section, valid, validInput }) => { it("should show current section value", async () => { render( - + - + ); await userEvent.click(await screen.findByRole("tab", { name: label })); @@ -54,9 +54,9 @@ describe("pages/admin/[entity]/config/form", () => { it("should update when provided value correctly", async () => { render( - + - + ); await userEvent.click(await screen.findByRole("tab", { name: label })); @@ -83,9 +83,9 @@ describe("pages/admin/[entity]/config/form", () => { it("should display updated value", async () => { render( - + - + ); await userEvent.click(await screen.findByRole("tab", { name: label })); @@ -99,9 +99,9 @@ describe("pages/admin/[entity]/config/form", () => { it("should not update when invalid JS is provided", async () => { render( - + - + ); await userEvent.click(await screen.findByRole("tab", { name: label })); @@ -126,9 +126,9 @@ describe("pages/admin/[entity]/config/form", () => { it("should display previous section value", async () => { render( - + - + ); await userEvent.click(await screen.findByRole("tab", { name: label })); @@ -142,9 +142,9 @@ describe("pages/admin/[entity]/config/form", () => { it("should be able to be cleared", async () => { render( - + - + ); await userEvent.click(await screen.findByRole("tab", { name: label })); @@ -164,9 +164,9 @@ describe("pages/admin/[entity]/config/form", () => { it("should display cleared value correctly", async () => { render( - + - + ); await userEvent.click(await screen.findByRole("tab", { name: label })); diff --git a/src/__tests__/admin/[entity]/config/persistent-query.spec.tsx b/src/__tests__/admin/[entity]/config/persistent-query.spec.tsx index 069ceb707..d64fb5785 100644 --- a/src/__tests__/admin/[entity]/config/persistent-query.spec.tsx +++ b/src/__tests__/admin/[entity]/config/persistent-query.spec.tsx @@ -2,12 +2,12 @@ /* eslint-disable testing-library/no-container */ import { render, screen } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import EntityPersistentQuerySettings from "pages/admin/[entity]/config/persistent-query"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -24,9 +24,9 @@ describe("pages/admin/[entity]/config/persistent-query", () => { it("should save persistent queries", async () => { render( - + - + ); await userEvent.click( @@ -59,9 +59,9 @@ describe("pages/admin/[entity]/config/persistent-query", () => { it("should display updated value", async () => { const { container } = render( - + - + ); expect( @@ -83,9 +83,9 @@ describe("pages/admin/[entity]/config/persistent-query", () => { it("should add nested filters", async () => { const { container } = render( - + - + ); await userEvent.click( @@ -143,9 +143,9 @@ describe("pages/admin/[entity]/config/persistent-query", () => { it("should add more filter blocks", async () => { const { container } = render( - + - + ); await userEvent.click( @@ -186,9 +186,9 @@ describe("pages/admin/[entity]/config/persistent-query", () => { it("should render current state correctly", async () => { const { container } = render( - + - + ); expect( @@ -255,9 +255,9 @@ describe("pages/admin/[entity]/config/persistent-query", () => { it("should remove all filters", async () => { render( - + - + ); await userEvent.click( @@ -290,9 +290,9 @@ describe("pages/admin/[entity]/config/persistent-query", () => { it("should not show any filters", async () => { render( - + - + ); expect(screen.queryByLabelText("Field")).not.toBeInTheDocument(); diff --git a/src/__tests__/admin/[entity]/config/presentation.spec.tsx b/src/__tests__/admin/[entity]/config/presentation.spec.tsx index 96e066143..285aa2af2 100644 --- a/src/__tests__/admin/[entity]/config/presentation.spec.tsx +++ b/src/__tests__/admin/[entity]/config/presentation.spec.tsx @@ -1,13 +1,13 @@ /* eslint-disable no-useless-escape */ import { render, screen, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import EntityPresentationScriptSettings from "pages/admin/[entity]/config/presentation"; import { closeAllToasts } from "__tests__/_/utils/closeAllToasts"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -23,9 +23,9 @@ describe("pages/admin/[entity]/config/presentation", () => { ); it("should show current section value", async () => { render( - + - + ); await waitFor(() => { @@ -35,9 +35,9 @@ describe("pages/admin/[entity]/config/presentation", () => { it("should update when provided value correctly", async () => { render( - + - + ); await userEvent.type( @@ -60,9 +60,9 @@ describe("pages/admin/[entity]/config/presentation", () => { it("should display updated value", async () => { render( - + - + ); await waitFor(() => { @@ -74,9 +74,9 @@ describe("pages/admin/[entity]/config/presentation", () => { it("should not update when invalid JS is provided", async () => { render( - + - + ); await userEvent.type(screen.getByLabelText("Script"), "invalid"); @@ -95,9 +95,9 @@ describe("pages/admin/[entity]/config/presentation", () => { it("should display previous section value", async () => { render( - + - + ); await waitFor(() => { @@ -109,9 +109,9 @@ describe("pages/admin/[entity]/config/presentation", () => { it("should be able to be cleared", async () => { render( - + - + ); await userEvent.clear(screen.getByLabelText("Script")); @@ -128,9 +128,9 @@ describe("pages/admin/[entity]/config/presentation", () => { it("should display cleared value correctly", async () => { render( - + - + ); await waitFor(() => { diff --git a/src/__tests__/admin/[entity]/config/relations__labels.spec.tsx b/src/__tests__/admin/[entity]/config/relations__labels.spec.tsx index 08819f9fe..133747341 100644 --- a/src/__tests__/admin/[entity]/config/relations__labels.spec.tsx +++ b/src/__tests__/admin/[entity]/config/relations__labels.spec.tsx @@ -1,10 +1,10 @@ import { render, screen, waitFor, within } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import EntityRelationsSettings from "pages/admin/[entity]/config/relations"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -24,9 +24,9 @@ describe("pages/admin/[entity]/config/relations", () => { describe("Labels", () => { it("should display reference labels", async () => { render( - + - + ); const currentTab = await screen.findByRole("tabpanel", { @@ -53,9 +53,9 @@ describe("pages/admin/[entity]/config/relations", () => { it("should save labels", async () => { render( - + - + ); const currentTab = await screen.findByRole("tabpanel", { @@ -88,9 +88,9 @@ describe("pages/admin/[entity]/config/relations", () => { it("should display updated labels", async () => { render( - + - + ); const currentTab = await screen.findByRole("tabpanel", { diff --git a/src/__tests__/admin/[entity]/config/relations__reference_template.spec.tsx b/src/__tests__/admin/[entity]/config/relations__reference_template.spec.tsx index 46f6ebac7..92263e17a 100644 --- a/src/__tests__/admin/[entity]/config/relations__reference_template.spec.tsx +++ b/src/__tests__/admin/[entity]/config/relations__reference_template.spec.tsx @@ -1,10 +1,10 @@ import { render, screen, waitFor, within } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import EntityRelationsSettings from "pages/admin/[entity]/config/relations"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -23,9 +23,9 @@ describe("pages/admin/[entity]/config/relations", () => { describe("Reference Template", () => { it("should display reference template", async () => { render( - + - + ); await waitFor(() => { expect(screen.getByLabelText("Display Format")).toHaveValue( @@ -36,9 +36,9 @@ describe("pages/admin/[entity]/config/relations", () => { it("should error when invalid template is provided", async () => { render( - + - + ); const currentTab = await screen.findByRole("tabpanel", { @@ -67,9 +67,9 @@ describe("pages/admin/[entity]/config/relations", () => { it("should save valid template", async () => { render( - + - + ); const currentTab = await screen.findByRole("tabpanel", { @@ -97,9 +97,9 @@ describe("pages/admin/[entity]/config/relations", () => { it("should display saved template", async () => { render( - + - + ); await waitFor(() => { expect(screen.getByLabelText("Display Format")).toHaveValue( diff --git a/src/__tests__/admin/[entity]/config/relations__selection.spec.tsx b/src/__tests__/admin/[entity]/config/relations__selection.spec.tsx index b2dc419f8..68609cd61 100644 --- a/src/__tests__/admin/[entity]/config/relations__selection.spec.tsx +++ b/src/__tests__/admin/[entity]/config/relations__selection.spec.tsx @@ -1,10 +1,10 @@ import { render, screen, waitFor, within } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import EntityRelationsSettings from "pages/admin/[entity]/config/relations"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -24,9 +24,9 @@ describe("pages/admin/[entity]/config/relations", () => { describe("Selection", () => { it("should display all related entities in correct state", async () => { render( - + - + ); const currentTab = await screen.findByRole("tabpanel", { @@ -62,9 +62,9 @@ describe("pages/admin/[entity]/config/relations", () => { it("should save toggled state successfully", async () => { render( - + - + ); const currentTab = await screen.findByRole("tabpanel", { @@ -99,9 +99,9 @@ describe("pages/admin/[entity]/config/relations", () => { it("should display updated selection state", async () => { render( - + - + ); const currentTab = await screen.findByRole("tabpanel", { diff --git a/src/__tests__/admin/[entity]/config/views.spec.tsx b/src/__tests__/admin/[entity]/config/views.spec.tsx index 5c5376223..05931c8aa 100644 --- a/src/__tests__/admin/[entity]/config/views.spec.tsx +++ b/src/__tests__/admin/[entity]/config/views.spec.tsx @@ -1,10 +1,10 @@ import { render, screen, within } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import TableViewsSettings from "pages/admin/[entity]/config/views"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import userEvent from "@testing-library/user-event"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -23,9 +23,9 @@ describe("pages/admin/[entity]/config/views", () => { it("should display Table Views", async () => { render( - + - + ); expect( await screen.findByRole("tab", { name: "Verified Entity View" }) @@ -40,9 +40,9 @@ describe("pages/admin/[entity]/config/views", () => { it("should tab through views", async () => { render( - + - + ); expect( await screen.findByRole("tab", { name: "Verified Entity View" }) @@ -75,9 +75,9 @@ describe("pages/admin/[entity]/config/views", () => { it("should delete table view", async () => { render( - + - + ); expect( await screen.findByRole("tab", { name: "Verified Entity View" }) @@ -133,9 +133,9 @@ describe("pages/admin/[entity]/config/views", () => { it("should display delete changes", () => { render( - + - + ); expect(screen.queryAllByRole("tab")).toHaveLength(0); expect(screen.queryByRole("table")).not.toBeInTheDocument(); @@ -144,9 +144,9 @@ describe("pages/admin/[entity]/config/views", () => { it("should add new table view", async () => { render( - + - + ); await userEvent.click( @@ -188,9 +188,9 @@ describe("pages/admin/[entity]/config/views", () => { it("should edit existing tabs", async () => { render( - + - + ); expect( await screen.findByRole("tab", { name: "View 1" }) @@ -220,9 +220,9 @@ describe("pages/admin/[entity]/config/views", () => { it("should save edit changes", async () => { render( - + - + ); expect( await screen.findByRole("tab", { name: "View 1Updated" }) diff --git a/src/__tests__/admin/[entity]/create.spec.tsx b/src/__tests__/admin/[entity]/create.spec.tsx index 7270b7fad..812bb31dd 100644 --- a/src/__tests__/admin/[entity]/create.spec.tsx +++ b/src/__tests__/admin/[entity]/create.spec.tsx @@ -1,9 +1,9 @@ import { render, screen, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import EntityCreate from "pages/admin/[entity]/create"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -22,9 +22,9 @@ describe("pages/admin/[entity]/create", () => { it("should create data", async () => { render( - + - + ); await waitFor(() => { expect(screen.getByText("Create Singular entity-1")).toBeInTheDocument(); diff --git a/src/__tests__/admin/[entity]/index.spec.tsx b/src/__tests__/admin/[entity]/index.spec.tsx index caa2dd363..cbea9ed29 100644 --- a/src/__tests__/admin/[entity]/index.spec.tsx +++ b/src/__tests__/admin/[entity]/index.spec.tsx @@ -1,10 +1,10 @@ import { render, screen } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import EntityTable from "pages/admin/[entity]/index"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { getTableRows } from "__tests__/_/utils/getTableRows"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -22,9 +22,9 @@ describe("pages/admin/[entity]/index", () => { it("should show data", async () => { render( - + - + ); expect(await screen.findByRole("table")).toBeInTheDocument(); diff --git a/src/__tests__/admin/index.spec.tsx b/src/__tests__/admin/index.spec.tsx index d98792816..a7c80cdbe 100644 --- a/src/__tests__/admin/index.spec.tsx +++ b/src/__tests__/admin/index.spec.tsx @@ -1,5 +1,4 @@ import { render, screen, within } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import Dashboard from "pages"; @@ -7,6 +6,7 @@ import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import userEvent from "@testing-library/user-event"; import { getTableRows } from "__tests__/_/utils/getTableRows"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -14,9 +14,9 @@ const useRouter = jest.spyOn(require("next/router"), "useRouter"); // it("should change relative time", async () => { // render( -// +// // -// +// // ); // await userEvent.click( @@ -50,9 +50,9 @@ describe("pages/admin", () => { it("should render table dashboard widget correctly", async () => { render( - + - + ); const widget = await screen.findByLabelText("Foo Table Widget"); @@ -75,9 +75,9 @@ describe("pages/admin", () => { it("should render summary card widget correctly", async () => { render( - + - + ); const widget = await screen.findByLabelText("Bar Card Widget"); @@ -108,9 +108,9 @@ describe("pages/admin", () => { it("should render correct buttons for table widget", async () => { render( - + - + ); const widget = await screen.findByLabelText("Foo Table Widget"); @@ -129,9 +129,9 @@ describe("pages/admin", () => { it("should render correct buttons for summary card widget", async () => { render( - + - + ); const widget = await screen.findByLabelText("Bar Card Widget"); @@ -151,9 +151,9 @@ describe("pages/admin", () => { useRouter.mockImplementation(USE_ROUTER_PARAMS({ replaceMock })); render( - + - + ); await userEvent.click( diff --git a/src/__tests__/admin/settings/data.spec.tsx b/src/__tests__/admin/settings/data.spec.tsx index b9688f2be..2e66f8b5a 100644 --- a/src/__tests__/admin/settings/data.spec.tsx +++ b/src/__tests__/admin/settings/data.spec.tsx @@ -1,11 +1,11 @@ import { render, screen, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import GeneralDataSettings from "pages/admin/settings/data"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { closeAllToasts } from "__tests__/_/utils/closeAllToasts"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -19,9 +19,9 @@ describe("pages/admin/settings/data", () => { describe("Metadata", () => { it("should display metadata columns", async () => { render( - + - + ); await waitFor(() => { expect(screen.getByLabelText("Created At")).toHaveValue("created_at"); @@ -31,9 +31,9 @@ describe("pages/admin/settings/data", () => { it("should update metadata columns successfully", async () => { render( - + - + ); await userEvent.type(screen.getByLabelText("Created At"), "-created"); @@ -52,9 +52,9 @@ describe("pages/admin/settings/data", () => { it("should display updated date values", async () => { render( - + - + ); await waitFor(() => { expect(screen.getByLabelText("Created At")).toHaveValue( @@ -70,9 +70,9 @@ describe("pages/admin/settings/data", () => { describe("Date", () => { it("should display date values", async () => { render( - + - + ); await waitFor(() => { expect(screen.getByLabelText("Format")).toHaveValue("do MMM yyyy"); @@ -81,9 +81,9 @@ describe("pages/admin/settings/data", () => { it("should update date successfully", async () => { render( - + - + ); await userEvent.clear(screen.getByLabelText("Format")); @@ -101,9 +101,9 @@ describe("pages/admin/settings/data", () => { it("should display updated date values", async () => { render( - + - + ); await waitFor(() => { expect(screen.getByLabelText("Format")).toHaveValue("yyyy MMM do"); @@ -113,9 +113,9 @@ describe("pages/admin/settings/data", () => { describe("invalid date formats", () => { it("should not be updated", async () => { render( - + - + ); await userEvent.clear(screen.getByLabelText("Format")); @@ -133,9 +133,9 @@ describe("pages/admin/settings/data", () => { it("should show date format", async () => { render( - + - + ); await waitFor(() => { expect(screen.getByLabelText("Format")).toHaveValue("yyyy MMM do"); diff --git a/src/__tests__/admin/settings/entities.spec.tsx b/src/__tests__/admin/settings/entities.spec.tsx index 31c55cfad..af8fba431 100644 --- a/src/__tests__/admin/settings/entities.spec.tsx +++ b/src/__tests__/admin/settings/entities.spec.tsx @@ -1,10 +1,10 @@ import { render, screen, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import EntitiesSettings from "pages/admin/settings/entities"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -17,9 +17,9 @@ describe("pages/admin/settings/entities", () => { it("should display all entities with correct state", async () => { render( - + - + ); await waitFor(async () => { @@ -51,9 +51,9 @@ describe("pages/admin/settings/entities", () => { it("should toggle entities state successfully", async () => { render( - + - + ); await userEvent.click( @@ -79,9 +79,9 @@ describe("pages/admin/settings/entities", () => { it("should display updated entities state", async () => { render( - + - + ); expect( diff --git a/src/__tests__/admin/settings/menu.spec.tsx b/src/__tests__/admin/settings/menu.spec.tsx index 65f8b1294..33741a402 100644 --- a/src/__tests__/admin/settings/menu.spec.tsx +++ b/src/__tests__/admin/settings/menu.spec.tsx @@ -1,10 +1,10 @@ import { render, screen, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import MenuSettings from "pages/admin/settings/menu"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -17,9 +17,9 @@ describe("pages/admin/settings/menu", () => { it("should display only active entities with correct state", async () => { render( - + - + ); await waitFor(async () => { @@ -44,9 +44,9 @@ describe("pages/admin/settings/menu", () => { it("should toggle menu state successfully", async () => { render( - + - + ); await userEvent.click( @@ -72,9 +72,9 @@ describe("pages/admin/settings/menu", () => { it("should display updated entities state", async () => { render( - + - + ); await waitFor( diff --git a/src/__tests__/admin/settings/site.spec.tsx b/src/__tests__/admin/settings/site.spec.tsx index cce762557..f7a8b73a8 100644 --- a/src/__tests__/admin/settings/site.spec.tsx +++ b/src/__tests__/admin/settings/site.spec.tsx @@ -1,10 +1,10 @@ import { render, screen, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import SiteSettings from "pages/admin/settings/site"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -17,9 +17,9 @@ describe("pages/admin/settings/site", () => { it("should display site values", async () => { render( - + - + ); await waitFor(() => { expect(screen.getByLabelText("Name")).toHaveValue("DashPress"); @@ -35,9 +35,9 @@ describe("pages/admin/settings/site", () => { it("should update site values successfully", async () => { render( - + - + ); await userEvent.type(screen.getByLabelText("Name"), "Updated"); @@ -56,9 +56,9 @@ describe("pages/admin/settings/site", () => { it("should display site values", async () => { render( - + - + ); await waitFor(() => { expect(screen.getByLabelText("Name")).toHaveValue("DashPressUpdated"); diff --git a/src/__tests__/admin/settings/system.spec.tsx b/src/__tests__/admin/settings/system.spec.tsx index 20acbc6ff..c5fdae1d5 100644 --- a/src/__tests__/admin/settings/system.spec.tsx +++ b/src/__tests__/admin/settings/system.spec.tsx @@ -1,10 +1,10 @@ import { render, screen, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import SystemSettings from "pages/admin/settings/system"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -17,9 +17,9 @@ describe("pages/admin/settings/system", () => { it("should display system values", async () => { render( - + - + ); await waitFor(async () => { expect( @@ -30,9 +30,9 @@ describe("pages/admin/settings/system", () => { it("should update system settings successfully", async () => { render( - + - + ); await userEvent.type( @@ -51,9 +51,9 @@ describe("pages/admin/settings/system", () => { it("should display updated system values", async () => { render( - + - + ); await waitFor(() => { expect( diff --git a/src/__tests__/admin/settings/theme.spec.tsx b/src/__tests__/admin/settings/theme.spec.tsx index 5bd1fe1cd..12287dc7f 100644 --- a/src/__tests__/admin/settings/theme.spec.tsx +++ b/src/__tests__/admin/settings/theme.spec.tsx @@ -1,10 +1,10 @@ import { fireEvent, render, screen, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import ThemeSettings from "pages/admin/settings/theme"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -16,9 +16,9 @@ describe("pages/admin/settings/theme", () => { it("should display theme values", async () => { render( - + - + ); await waitFor(() => { expect(screen.getByLabelText("Dark Color Scheme")).toHaveValue("#111111"); @@ -31,9 +31,9 @@ describe("pages/admin/settings/theme", () => { it("should update theme settings successfully", async () => { render( - + - + ); fireEvent.input(screen.getByLabelText("Dark Color Scheme"), { @@ -51,9 +51,9 @@ describe("pages/admin/settings/theme", () => { it("should display updated theme values", async () => { render( - + - + ); await waitFor(() => { expect(screen.getByLabelText("Dark Color Scheme")).toHaveValue("#123456"); @@ -65,9 +65,9 @@ describe("pages/admin/settings/theme", () => { it("should update user preference and switch color successfully", async () => { render( - + - + ); expect(screen.getByLabelText("Dark Color Scheme")).toBeInTheDocument(); @@ -95,9 +95,9 @@ describe("pages/admin/settings/theme", () => { it("should display updated theme values", async () => { render( - + - + ); await waitFor(() => { expect(screen.getByLabelText("Light Color Scheme")).toHaveValue( @@ -116,9 +116,9 @@ describe("pages/admin/settings/theme", () => { it("should not display the other scheme color", async () => { render( - + - + ); await userEvent.click(screen.getByRole("option", { name: "Dark" })); diff --git a/src/__tests__/admin/settings/versions.spec.tsx b/src/__tests__/admin/settings/versions.spec.tsx index da29a79fb..ac7aedf12 100644 --- a/src/__tests__/admin/settings/versions.spec.tsx +++ b/src/__tests__/admin/settings/versions.spec.tsx @@ -1,9 +1,9 @@ import { render, screen, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import VersionInfo from "pages/admin/settings/versions"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -16,9 +16,9 @@ describe("pages/admin/settings/version", () => { it("should display system info", async () => { render( - + - + ); await waitFor(() => { expect(screen.getByText("key1")).toBeInTheDocument(); diff --git a/src/__tests__/auth/index.spec.tsx b/src/__tests__/auth/index.spec.tsx index d5edca48a..4449314d1 100644 --- a/src/__tests__/auth/index.spec.tsx +++ b/src/__tests__/auth/index.spec.tsx @@ -1,11 +1,11 @@ import * as React from "react"; import { render, screen, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import SignIn from "pages/auth"; import userEvent from "@testing-library/user-event"; import { AuthActions } from "frontend/hooks/auth/auth.actions"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -48,9 +48,9 @@ describe("pages/auth", () => { it("should be hidden when NEXT_PUBLIC_IS_DEMO is false", async () => { render( - + - + ); expect( @@ -61,9 +61,9 @@ describe("pages/auth", () => { it("should be shown when NEXT_PUBLIC_IS_DEMO is true", async () => { process.env.NEXT_PUBLIC_IS_DEMO = "true"; render( - + - + ); expect( @@ -76,9 +76,9 @@ describe("pages/auth", () => { localStorage.setItem(AuthActions.JWT_TOKEN_STORAGE_KEY, "foo"); render( - + - + ); await waitFor(() => { @@ -93,9 +93,9 @@ describe("pages/auth", () => { useRouter.mockImplementation(USE_ROUTER_PARAMS({ replaceMock })); render( - + - + ); await userEvent.type( @@ -120,9 +120,9 @@ describe("pages/auth", () => { it("should redirect to dashboard when user is succesfully authenticated", async () => { render( - + - + ); await userEvent.type(await screen.findByLabelText("Username"), "user"); diff --git a/src/__tests__/dashboard/[dashboardId]/widget/[widgetId]/index.spec.tsx b/src/__tests__/dashboard/[dashboardId]/widget/[widgetId]/index.spec.tsx index b892f498c..ecd9d2304 100644 --- a/src/__tests__/dashboard/[dashboardId]/widget/[widgetId]/index.spec.tsx +++ b/src/__tests__/dashboard/[dashboardId]/widget/[widgetId]/index.spec.tsx @@ -1,5 +1,4 @@ import { render, screen } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import UpdateDashboardWidget from "pages/dashboard/[dashboardId]/widget/[widgetId]/index"; @@ -7,6 +6,7 @@ import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import userEvent from "@testing-library/user-event"; import { closeAllToasts } from "__tests__/_/utils/closeAllToasts"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -24,9 +24,9 @@ describe("pages/dashboard/[dashboardId]/widget/[widgetId]/index", () => { ); render( - + - + ); await userEvent.type(await screen.findByLabelText("Title"), "Updated"); @@ -81,9 +81,9 @@ describe("pages/dashboard/[dashboardId]/widget/[widgetId]/index", () => { ); render( - + - + ); await userEvent.type(await screen.findByLabelText("Title"), "Updated"); @@ -131,9 +131,9 @@ describe("pages/dashboard/[dashboardId]/widget/[widgetId]/index", () => { ); render( - + - + ); expect(await screen.findByRole("alert")).toHaveTextContent( diff --git a/src/__tests__/dashboard/[dashboardId]/widget/create.spec.tsx b/src/__tests__/dashboard/[dashboardId]/widget/create.spec.tsx index c703097bf..7030eba48 100644 --- a/src/__tests__/dashboard/[dashboardId]/widget/create.spec.tsx +++ b/src/__tests__/dashboard/[dashboardId]/widget/create.spec.tsx @@ -1,5 +1,4 @@ import { render, screen } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import CreateDashboardWidget from "pages/dashboard/[dashboardId]/widget/create"; @@ -7,6 +6,7 @@ import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import userEvent from "@testing-library/user-event"; import { closeAllToasts } from "__tests__/_/utils/closeAllToasts"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -31,9 +31,9 @@ describe("pages/dashboard/[dashboardId]/widget/create", () => { it("should create summary widget", async () => { render( - + - + ); await userEvent.type( @@ -82,9 +82,9 @@ describe("pages/dashboard/[dashboardId]/widget/create", () => { it("should create table widget", async () => { render( - + - + ); await userEvent.type(await screen.findByLabelText("Title"), "New Table"); diff --git a/src/__tests__/dashboard/manage__actions.spec.tsx b/src/__tests__/dashboard/manage__actions.spec.tsx index 29ddc4e82..158e92a1e 100644 --- a/src/__tests__/dashboard/manage__actions.spec.tsx +++ b/src/__tests__/dashboard/manage__actions.spec.tsx @@ -1,11 +1,11 @@ import { render, screen, within } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import ManageDashboard from "pages/dashboard/manage"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -24,9 +24,9 @@ describe("pages/admin/settings/dashboard", () => { useRouter.mockImplementation(USE_ROUTER_PARAMS({ replaceMock })); render( - + - + ); await userEvent.click( @@ -41,9 +41,9 @@ describe("pages/admin/settings/dashboard", () => { useRouter.mockImplementation(USE_ROUTER_PARAMS({ pushMock })); render( - + - + ); await userEvent.click( @@ -57,9 +57,9 @@ describe("pages/admin/settings/dashboard", () => { it("should delete table widget", async () => { render( - + - + ); const widget = await screen.findByLabelText("Foo Table Widget"); @@ -90,9 +90,9 @@ describe("pages/admin/settings/dashboard", () => { useRouter.mockImplementation(USE_ROUTER_PARAMS({ pushMock })); render( - + - + ); const widget = await screen.findByLabelText("Bar Card Widget"); diff --git a/src/__tests__/dashboard/manage__order.spec.tsx b/src/__tests__/dashboard/manage__order.spec.tsx index 800e6000b..c0159ebc8 100644 --- a/src/__tests__/dashboard/manage__order.spec.tsx +++ b/src/__tests__/dashboard/manage__order.spec.tsx @@ -1,7 +1,6 @@ /* eslint-disable testing-library/no-node-access */ import { ReactNode } from "react"; import { render, screen } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import ManageDashboard from "pages/dashboard/manage"; @@ -9,6 +8,7 @@ import Dashboard from "pages"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -49,9 +49,9 @@ describe("pages/admin/settings/dashboard", () => { describe("Sorting", () => { it("should order widget", async () => { render( - + - + ); const widgets = await screen.findByLabelText("Dashboard Widgets"); @@ -65,9 +65,9 @@ describe("pages/admin/settings/dashboard", () => { it("should change the order of the widgets", async () => { render( - + - + ); await screen.findByLabelText("Foo Table Widget"); @@ -77,9 +77,9 @@ describe("pages/admin/settings/dashboard", () => { it("should show the new ordered widget", async () => { render( - + - + ); const widgets = await screen.findByLabelText("Dashboard Widgets"); @@ -93,9 +93,9 @@ describe("pages/admin/settings/dashboard", () => { it("should not be orderable in the admin page", async () => { render( - + - + ); await screen.findByLabelText("Foo Table Widget"); diff --git a/src/__tests__/integrations/actions/[key].spec.tsx b/src/__tests__/integrations/actions/[key].spec.tsx index 41790e628..bf559abeb 100644 --- a/src/__tests__/integrations/actions/[key].spec.tsx +++ b/src/__tests__/integrations/actions/[key].spec.tsx @@ -1,10 +1,10 @@ import { render, screen } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import ActionsIntegrations from "pages/integrations/actions/[key]"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -23,9 +23,9 @@ describe("pages/integrations/actions/[key]", () => { describe("list", () => { it("should show the list of actions", async () => { render( - + - + ); expect( @@ -39,9 +39,9 @@ describe("pages/integrations/actions/[key]", () => { // it("should show the configure UI for activated actions", async () => { // render( - // + // // - // + // // ); // await waitFor(() => { diff --git a/src/__tests__/integrations/variables__constants.spec.tsx b/src/__tests__/integrations/variables__constants.spec.tsx index 3077a20b0..38a1ab724 100644 --- a/src/__tests__/integrations/variables__constants.spec.tsx +++ b/src/__tests__/integrations/variables__constants.spec.tsx @@ -1,5 +1,4 @@ import { render, screen, within } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import ManageVariables from "pages/integrations/variables"; @@ -8,6 +7,7 @@ import userEvent from "@testing-library/user-event"; import { closeAllToasts } from "__tests__/_/utils/closeAllToasts"; import { getTableRows } from "__tests__/_/utils/getTableRows"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -25,9 +25,9 @@ describe("pages/integrations/variables => constants", () => { describe("list", () => { it("should list constants", async () => { render( - + - + ); expect( @@ -50,9 +50,9 @@ describe("pages/integrations/variables => constants", () => { describe("create", () => { it("should create new constant", async () => { render( - + - + ); await userEvent.click( await screen.findByRole("button", { name: "Add New Constant" }) @@ -76,9 +76,9 @@ describe("pages/integrations/variables => constants", () => { it("should show created constant", async () => { render( - + - + ); expect( @@ -102,9 +102,9 @@ describe("pages/integrations/variables => constants", () => { describe("update", () => { it("should update constant", async () => { render( - + - + ); const table = within( @@ -140,9 +140,9 @@ describe("pages/integrations/variables => constants", () => { it("should show updated constant", async () => { render( - + - + ); expect( @@ -166,9 +166,9 @@ describe("pages/integrations/variables => constants", () => { describe("delete", () => { it("should delete constants", async () => { render( - + - + ); const table = within( diff --git a/src/__tests__/integrations/variables__credentials--non-admin.spec.tsx b/src/__tests__/integrations/variables__credentials--non-admin.spec.tsx index d669183af..bf51dfde8 100644 --- a/src/__tests__/integrations/variables__credentials--non-admin.spec.tsx +++ b/src/__tests__/integrations/variables__credentials--non-admin.spec.tsx @@ -1,7 +1,6 @@ /* eslint-disable prettier/prettier */ import { render, screen, within } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import { rest } from "msw"; import ManageVariables from "pages/admin/settings/variables"; @@ -14,6 +13,7 @@ import { UserPermissions } from "shared/constants/user"; import { AuthActions } from "frontend/hooks/auth/auth.actions"; import { getTableRows } from "__tests__/_/utils/getTableRows"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; const server = setupApiHandlers(); @@ -46,9 +46,9 @@ describe("pages/integrations/variables => credentials -- non admin", () => { describe("priviledge", () => { it("should show correct password text for `CAN_CONFIGURE_APP_USERS`", async () => { render( - + - + ); const priviledgeSection = screen.getByLabelText( "credentials priviledge section" @@ -85,9 +85,9 @@ describe("pages/integrations/variables => credentials -- non admin", () => { it("should not show any password text on constants tab", async () => { render( - + - + ); const priviledgeSection = await screen.findByLabelText( @@ -123,9 +123,9 @@ describe("pages/integrations/variables => credentials -- non admin", () => { describe("list", () => { it("should list credentials", async () => { render( - + - + ); await userEvent.click( diff --git a/src/__tests__/integrations/variables__credentials.spec.tsx b/src/__tests__/integrations/variables__credentials.spec.tsx index 71e8885de..b0796f472 100644 --- a/src/__tests__/integrations/variables__credentials.spec.tsx +++ b/src/__tests__/integrations/variables__credentials.spec.tsx @@ -1,7 +1,6 @@ /* eslint-disable prettier/prettier */ import { render, screen, waitFor, within } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import ManageVariables from "pages/admin/settings/variables"; @@ -10,6 +9,7 @@ import userEvent from "@testing-library/user-event"; import { AuthActions } from "frontend/hooks/auth/auth.actions"; import { getTableRows } from "__tests__/_/utils/getTableRows"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -29,9 +29,9 @@ describe.skip("pages/integrations/variables => credentials", () => { describe("priviledge", () => { it("should not show any password text on constants tab", async () => { render( - + - + ); const priviledgeSection = await screen.findByLabelText( @@ -60,9 +60,9 @@ describe.skip("pages/integrations/variables => credentials", () => { it("should show correct password text on secret tab", async () => { render( - + - + ); const priviledgeSection = await screen.findByLabelText( "credentials priviledge section" @@ -93,9 +93,9 @@ describe.skip("pages/integrations/variables => credentials", () => { describe("list", () => { it("should list credentials", async () => { render( - + - + ); await userEvent.click( @@ -122,9 +122,9 @@ describe.skip("pages/integrations/variables => credentials", () => { describe("reveal", () => { it("should not show credentials action before revealing password", async () => { render( - + - + ); await userEvent.click( @@ -150,9 +150,9 @@ describe.skip("pages/integrations/variables => credentials", () => { it("should show error on invalid password and not reveal data", async () => { render( - + - + ); const priviledgeSection = screen.getByLabelText( @@ -196,9 +196,9 @@ describe.skip("pages/integrations/variables => credentials", () => { it("should reveal credentials and the now show the credentials action buttons", async () => { render( - + - + ); const priviledgeSection = screen.getByLabelText( @@ -251,9 +251,9 @@ describe.skip("pages/integrations/variables => credentials", () => { it("should show credentials action after revealing password", async () => { render( - + - + ); await userEvent.click( @@ -284,9 +284,9 @@ describe.skip("pages/integrations/variables => credentials", () => { describe("update", () => { it("should update secret", async () => { render( - + - + ); await userEvent.click( @@ -349,9 +349,9 @@ describe.skip("pages/integrations/variables => credentials", () => { describe("create", () => { it("should create new secret", async () => { render( - + - + ); await userEvent.click( @@ -402,9 +402,9 @@ describe.skip("pages/integrations/variables => credentials", () => { describe("delete", () => { it("should delete secrets", async () => { render( - + - + ); await userEvent.click( diff --git a/src/__tests__/roles/[roleId]/index.spec.tsx b/src/__tests__/roles/[roleId]/index.spec.tsx index 0ad579736..59ccc828b 100644 --- a/src/__tests__/roles/[roleId]/index.spec.tsx +++ b/src/__tests__/roles/[roleId]/index.spec.tsx @@ -1,5 +1,4 @@ import { render, screen, waitFor, within } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import RolePermissions from "pages/roles/[roleId]/index"; @@ -7,6 +6,7 @@ import RolePermissions from "pages/roles/[roleId]/index"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { closeAllToasts } from "__tests__/_/utils/closeAllToasts"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -24,9 +24,9 @@ describe("pages/roles/[roleId]/index", () => { it("should select all user enabled admin permissions", async () => { render( - + - + ); const currentTab = await screen.findByRole("tabpanel", { name: "App" }); @@ -74,9 +74,9 @@ describe("pages/roles/[roleId]/index", () => { it("should select all user enabled entities permissions", async () => { render( - + - + ); await userEvent.click(await screen.findByRole("tab", { name: "Entities" })); @@ -119,9 +119,9 @@ describe("pages/roles/[roleId]/index", () => { it("should update entity permissions", async () => { render( - + - + ); await userEvent.click(await screen.findByRole("tab", { name: "Entities" })); @@ -181,9 +181,9 @@ describe("pages/roles/[roleId]/index", () => { it("should show updated entity permissions", async () => { render( - + - + ); await userEvent.click(await screen.findByRole("tab", { name: "Entities" })); @@ -211,9 +211,9 @@ describe("pages/roles/[roleId]/index", () => { it("should toggle entities checkbox when 'Can Manage All Entities' is toggled", async () => { render( - + - + ); await userEvent.click(await screen.findByRole("tab", { name: "Entities" })); @@ -245,9 +245,9 @@ describe("pages/roles/[roleId]/index", () => { it("should update admin permissions", async () => { render( - + - + ); const currentTab = await screen.findByRole("tabpanel", { name: "App" }); @@ -295,9 +295,9 @@ describe("pages/roles/[roleId]/index", () => { it("should show updated admin permissions", async () => { render( - + - + ); const currentTab = screen.getByRole("tabpanel", { name: "App" }); @@ -330,9 +330,9 @@ describe("pages/roles/[roleId]/index", () => { describe("Heirachy", () => { it("should toggle heirachy permissions on correctly", async () => { render( - + - + ); await closeAllToasts(); @@ -372,9 +372,9 @@ describe("pages/roles/[roleId]/index", () => { it("should toggle heirachy permissions off correctly", async () => { render( - + - + ); await closeAllToasts(); @@ -414,9 +414,9 @@ describe("pages/roles/[roleId]/index", () => { it("should show turned off children permissions correctly", async () => { render( - + - + ); const currentTab = await screen.findByRole("tabpanel", { name: "App" }); diff --git a/src/__tests__/roles/create.spec.tsx b/src/__tests__/roles/create.spec.tsx index a56a2fa8d..b2a8b568a 100644 --- a/src/__tests__/roles/create.spec.tsx +++ b/src/__tests__/roles/create.spec.tsx @@ -1,11 +1,11 @@ import { render, screen } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import RoleCreate from "pages/roles/create"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -22,9 +22,9 @@ describe("pages/roles/create", () => { ); render( - + - + ); await userEvent.type(await screen.findByLabelText("Name"), "Some New Role"); diff --git a/src/__tests__/roles/index.spec.tsx b/src/__tests__/roles/index.spec.tsx index c9f535c3a..7891d1271 100644 --- a/src/__tests__/roles/index.spec.tsx +++ b/src/__tests__/roles/index.spec.tsx @@ -1,5 +1,4 @@ import { render, screen, within, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import ListRoles from "pages/roles"; @@ -7,6 +6,7 @@ import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import userEvent from "@testing-library/user-event"; import { getTableRows } from "__tests__/_/utils/getTableRows"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -17,9 +17,9 @@ describe("pages/roles", () => { useRouter.mockImplementation(USE_ROUTER_PARAMS({})); render( - + - + ); expect(await getTableRows(await screen.findByRole("table"))) @@ -40,9 +40,9 @@ describe("pages/roles", () => { useRouter.mockImplementation(USE_ROUTER_PARAMS({ pushMock })); render( - + - + ); await userEvent.click(screen.getByRole("button", { name: "Add New Role" })); await waitFor(() => { @@ -56,9 +56,9 @@ describe("pages/roles", () => { useRouter.mockImplementation(USE_ROUTER_PARAMS({ pushMock })); render( - + - + ); const tableRows = await screen.findAllByRole("link", { name: "Edit Role" }); @@ -72,9 +72,9 @@ describe("pages/roles", () => { useRouter.mockImplementation(USE_ROUTER_PARAMS({ replaceMock })); render( - + - + ); const tableRows = await screen.findAllByRole("row"); diff --git a/src/__tests__/setup/credentials.spec.tsx b/src/__tests__/setup/credentials.spec.tsx index d030894da..c9f5a15ea 100644 --- a/src/__tests__/setup/credentials.spec.tsx +++ b/src/__tests__/setup/credentials.spec.tsx @@ -2,14 +2,13 @@ /* eslint-disable testing-library/no-container */ import * as React from "react"; import { render, screen, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { rest } from "msw"; import { BASE_TEST_URL } from "__tests__/_/api-handlers/_utils"; import CredentialsSetup from "pages/setup/credentials"; import userEvent from "@testing-library/user-event"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; -import { queryCache } from "frontend/lib/data/QueryClient"; +import { TestProviders, queryCache } from "__tests__/_/Provider"; const server = setupApiHandlers(); @@ -62,9 +61,9 @@ describe("pages/setup/credentials", () => { ); const { container } = render( - + - + ); expect( @@ -89,9 +88,9 @@ describe("pages/setup/credentials", () => { ); const { container } = render( - + - + ); expect( @@ -155,9 +154,9 @@ describe("pages/setup/credentials", () => { ); const { container } = render( - + - + ); await userEvent.type( @@ -202,9 +201,9 @@ describe("pages/setup/credentials", () => { ); const { container } = render( - + - + ); await userEvent.type( @@ -245,9 +244,9 @@ describe("pages/setup/credentials", () => { }) ); const { container } = render( - + - + ); await userEvent.type( @@ -304,9 +303,9 @@ describe("pages/setup/credentials", () => { ); render( - + - + ); await waitFor(() => { expect(replaceMock).toHaveBeenCalledWith("/setup/user", "/setup/user", { diff --git a/src/__tests__/setup/user.spec.tsx b/src/__tests__/setup/user.spec.tsx index cd3a262b1..5e11591fc 100644 --- a/src/__tests__/setup/user.spec.tsx +++ b/src/__tests__/setup/user.spec.tsx @@ -1,11 +1,11 @@ import * as React from "react"; import { render, screen, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import UserSetup from "pages/setup/user"; import userEvent from "@testing-library/user-event"; import { SETUP_CHECK_DATA } from "__tests__/_/api-handlers/setup"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; const server = setupApiHandlers(); @@ -33,9 +33,9 @@ describe("pages/setup/user", () => { }; render( - + - + ); await userEvent.type( diff --git a/src/__tests__/setup/user__dashboard-redirect.spec.tsx b/src/__tests__/setup/user__dashboard-redirect.spec.tsx index 1bb223b46..d4dcc8393 100644 --- a/src/__tests__/setup/user__dashboard-redirect.spec.tsx +++ b/src/__tests__/setup/user__dashboard-redirect.spec.tsx @@ -1,11 +1,11 @@ import * as React from "react"; import { render, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { rest } from "msw"; import { BASE_TEST_URL } from "__tests__/_/api-handlers/_utils"; import UserSetup from "pages/setup/user"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; const server = setupApiHandlers(); @@ -37,9 +37,9 @@ describe("pages/setup/user", () => { ); render( - + - + ); await waitFor(() => { expect(replaceMock).toHaveBeenCalledWith("/", "/", { locale: "en" }); diff --git a/src/__tests__/setup/users__credentials-redirect.spec.tsx b/src/__tests__/setup/users__credentials-redirect.spec.tsx index e0620091b..ec12d9d79 100644 --- a/src/__tests__/setup/users__credentials-redirect.spec.tsx +++ b/src/__tests__/setup/users__credentials-redirect.spec.tsx @@ -1,11 +1,11 @@ import * as React from "react"; import { render, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { rest } from "msw"; import { BASE_TEST_URL } from "__tests__/_/api-handlers/_utils"; import UserSetup from "pages/setup/user"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; const server = setupApiHandlers(); @@ -37,9 +37,9 @@ describe("pages/setup/user", () => { ); render( - + - + ); await waitFor(() => { expect(replaceMock).toHaveBeenCalledWith( diff --git a/src/__tests__/users/[username]/index.spec.tsx b/src/__tests__/users/[username]/index.spec.tsx index d2d5878aa..1891b55a5 100644 --- a/src/__tests__/users/[username]/index.spec.tsx +++ b/src/__tests__/users/[username]/index.spec.tsx @@ -2,13 +2,13 @@ /* eslint-disable testing-library/no-container */ import { render, screen, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import UserUpdate from "pages/users/[username]/index"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -25,9 +25,9 @@ describe("pages/users/[username]/index", () => { ); render( - + - + ); await waitFor(() => { expect(screen.getByLabelText("Role")).toBeDisabled(); @@ -45,9 +45,9 @@ describe("pages/users/[username]/index", () => { ); const { container } = render( - + - + ); await waitFor(() => { @@ -67,9 +67,9 @@ describe("pages/users/[username]/index", () => { }) ); render( - + - + ); await userEvent.clear(await screen.findByLabelText("Name")); @@ -96,9 +96,9 @@ describe("pages/users/[username]/index", () => { }) ); const { container } = render( - + - + ); await waitFor(() => { @@ -120,9 +120,9 @@ describe("pages/users/[username]/index", () => { }) ); render( - + - + ); await waitFor(() => { @@ -142,9 +142,9 @@ describe("pages/users/[username]/index", () => { }) ); render( - + - + ); await userEvent.type(screen.getByLabelText("Password"), "password"); diff --git a/src/__tests__/users/[username]/index__non-admin.spec.tsx b/src/__tests__/users/[username]/index__non-admin.spec.tsx index ada690054..17553a008 100644 --- a/src/__tests__/users/[username]/index__non-admin.spec.tsx +++ b/src/__tests__/users/[username]/index__non-admin.spec.tsx @@ -1,5 +1,4 @@ import { render, screen, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import { rest } from "msw"; import UserUpdate from "pages/users/[username]/index"; @@ -9,6 +8,7 @@ import { BASE_TEST_URL } from "__tests__/_/api-handlers/_utils"; import { IAuthenticatedUserBag } from "shared/types/user"; import { UserPermissions } from "shared/constants/user"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; const server = setupApiHandlers(); @@ -39,9 +39,9 @@ describe("pages/users/[username]/index", () => { ); render( - + - + ); await waitFor(() => { expect(screen.getByLabelText("Role")).toBeInTheDocument(); @@ -61,9 +61,9 @@ describe("pages/users/[username]/index", () => { }) ); render( - + - + ); await waitFor(() => { diff --git a/src/__tests__/users/create.spec.tsx b/src/__tests__/users/create.spec.tsx index 51fd9e93f..c11e1a7fc 100644 --- a/src/__tests__/users/create.spec.tsx +++ b/src/__tests__/users/create.spec.tsx @@ -1,11 +1,11 @@ import { render, screen } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import UserCreate from "pages/users/create"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -18,9 +18,9 @@ describe("pages/users/create", () => { useRouter.mockImplementation(USE_ROUTER_PARAMS({ pushMock })); render( - + - + ); await userEvent.type( diff --git a/src/__tests__/users/database-link.spec.tsx b/src/__tests__/users/database-link.spec.tsx index 16a3d7796..a2a876464 100644 --- a/src/__tests__/users/database-link.spec.tsx +++ b/src/__tests__/users/database-link.spec.tsx @@ -2,13 +2,13 @@ /* eslint-disable testing-library/no-container */ import { render, screen } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import UsersLinkToDatabase from "pages/users/database-link"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -19,9 +19,9 @@ describe("pages/users/database-link", () => { it("should save the link form correctly", async () => { render( - + - + ); await userEvent.type( @@ -47,9 +47,9 @@ describe("pages/users/database-link", () => { it("should persist the link form correctly", async () => { const { container } = render( - + - + ); expect(container.querySelector(`input[name="table"]`)).toHaveValue( diff --git a/src/__tests__/users/index.spec.tsx b/src/__tests__/users/index.spec.tsx index b4335ad7b..c90f6ab2a 100644 --- a/src/__tests__/users/index.spec.tsx +++ b/src/__tests__/users/index.spec.tsx @@ -1,5 +1,4 @@ import { render, screen, within, waitFor } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import ListUsers from "pages/users"; @@ -7,6 +6,7 @@ import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import userEvent from "@testing-library/user-event"; import { getTableRows } from "__tests__/_/utils/getTableRows"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; setupApiHandlers(); @@ -16,9 +16,9 @@ describe("pages/users", () => { it("should list users", async () => { useRouter.mockImplementation(USE_ROUTER_PARAMS({})); render( - + - + ); expect(await getTableRows(await screen.findByRole("table"))) @@ -38,9 +38,9 @@ describe("pages/users", () => { useRouter.mockImplementation(USE_ROUTER_PARAMS({ pushMock })); render( - + - + ); await userEvent.click(screen.getByRole("button", { name: "Add New User" })); await waitFor(() => { @@ -54,9 +54,9 @@ describe("pages/users", () => { useRouter.mockImplementation(USE_ROUTER_PARAMS({ pushMock })); render( - + - + ); const tableRows = await screen.findAllByRole("link", { name: "Edit User" }); @@ -72,9 +72,9 @@ describe("pages/users", () => { useRouter.mockImplementation(USE_ROUTER_PARAMS({ replaceMock })); render( - + - + ); const tableRows = await screen.findAllByRole("row"); diff --git a/src/frontend/_layouts/app/NavigationSideBar/__tests__/RenderNavigation.spec.tsx b/src/frontend/_layouts/app/NavigationSideBar/__tests__/RenderNavigation.spec.tsx index 0f5f30587..fd2327db3 100644 --- a/src/frontend/_layouts/app/NavigationSideBar/__tests__/RenderNavigation.spec.tsx +++ b/src/frontend/_layouts/app/NavigationSideBar/__tests__/RenderNavigation.spec.tsx @@ -5,11 +5,11 @@ import { SystemLinks, } from "shared/types/menu"; import userEvent from "@testing-library/user-event"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import { rest } from "msw"; import { BASE_TEST_URL } from "__tests__/_/api-handlers/_utils"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; import { SideBar } from "../SideBar"; const server = setupApiHandlers(); @@ -67,9 +67,9 @@ describe("", () => { it("should render all first level items", async () => { render( - + - + ); expect(await screen.findByText("Header")).toBeInTheDocument(); @@ -87,9 +87,9 @@ describe("", () => { it("should hide the menu items when is not full width", async () => { render( - + - + ); expect(screen.queryByText("Header")).not.toBeVisible(); @@ -105,9 +105,9 @@ describe("", () => { it("should render second level items when pressed", async () => { render( - + - + ); expect(screen.getByText("Header")).toBeInTheDocument(); diff --git a/src/frontend/_layouts/app/__tests__/AppLayout.spec.tsx b/src/frontend/_layouts/app/__tests__/AppLayout.spec.tsx index 06699b60f..9e5289170 100644 --- a/src/frontend/_layouts/app/__tests__/AppLayout.spec.tsx +++ b/src/frontend/_layouts/app/__tests__/AppLayout.spec.tsx @@ -1,10 +1,10 @@ -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import { render, screen, waitFor } from "@testing-library/react"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { AuthActions } from "frontend/hooks/auth/auth.actions"; import userEvent from "@testing-library/user-event"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; import { AppLayout } from ".."; import { getAppLayout } from "../getLayout"; @@ -29,9 +29,9 @@ describe("AppLayout", () => { it("should render the content", async () => { render( - + Foo Content - + ); expect(screen.getByText("Foo Content")).toBeInTheDocument(); @@ -51,9 +51,9 @@ describe("AppLayout", () => { it("should hide demo elements when NEXT_PUBLIC_IS_DEMO is false", async () => { render( - + Foo - + ); expect( @@ -66,9 +66,9 @@ describe("AppLayout", () => { process.env.NEXT_PUBLIC_IS_DEMO = "true"; render( - + Foo - + ); await userEvent.click( @@ -83,7 +83,7 @@ describe("AppLayout", () => { describe("getAppLayout", () => { it("should toggle the sidebar and toggle the correct elements", async () => { - render({getAppLayout(

Foo

)}
); + render({getAppLayout(

Foo

)}
); expect(await screen.findByAltText("full logo")).toBeInTheDocument(); expect(screen.queryByAltText("small logo")).not.toBeInTheDocument(); @@ -121,7 +121,7 @@ describe("AppLayout", () => { }); it("should open menu items", async () => { - render({getAppLayout(

Foo

)}
); + render({getAppLayout(

Foo

)}
); await userEvent.click( await screen.findByLabelText("Toggle Profile Menu") @@ -138,7 +138,7 @@ describe("AppLayout", () => { describe("Not Signed In", () => { it("should redirect to sign in when not authenticated", async () => { localStorage.removeItem(AuthActions.JWT_TOKEN_STORAGE_KEY); - render({getAppLayout(

Foo

)}
); + render({getAppLayout(

Foo

)}
); await waitFor(() => { expect(window.location.replace).toHaveBeenCalledWith("/auth"); diff --git a/src/frontend/components/IconInputField/IconInputField.spec.tsx b/src/frontend/components/IconInputField/IconInputField.spec.tsx index bf93a7012..759ed5cbc 100644 --- a/src/frontend/components/IconInputField/IconInputField.spec.tsx +++ b/src/frontend/components/IconInputField/IconInputField.spec.tsx @@ -5,8 +5,8 @@ import userEvent from "@testing-library/user-event"; import { FormButton } from "frontend/design-system/components/Button/FormButton"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; import { msg } from "@lingui/macro"; +import { TestProviders } from "__tests__/_/Provider"; import { IconInputField } from "."; -import { ApplicationRoot } from "../ApplicationRoot"; function TestComponent({ onSubmit, @@ -45,9 +45,9 @@ describe("", () => { it("should render text input only by default", async () => { const onSubmit = jest.fn(); render( - + - + ); expect(screen.queryByLabelText("Icon")).not.toBeInTheDocument(); @@ -66,12 +66,12 @@ describe("", () => { it("should render icon input only when valid icon is passed", async () => { const onSubmit = jest.fn(); render( - + - + ); expect(screen.queryByLabelText("SVG")).not.toBeInTheDocument(); @@ -91,12 +91,12 @@ describe("", () => { it("should render text input when invalid icon is passed", async () => { const onSubmit = jest.fn(); render( - + - + ); expect(screen.queryByLabelText("Icon")).not.toBeInTheDocument(); @@ -115,12 +115,12 @@ describe("", () => { it("should be able to switch to icon input from text input", async () => { const onSubmit = jest.fn(); render( - + - + ); expect(screen.queryByLabelText("Icon")).not.toBeInTheDocument(); @@ -145,12 +145,12 @@ describe("", () => { it("should be able to switch to text input from icon input", async () => { const onSubmit = jest.fn(); render( - + - + ); expect(screen.queryByLabelText("SVG")).not.toBeInTheDocument(); diff --git a/src/frontend/components/SchemaForm/SchemaForm.spec.tsx b/src/frontend/components/SchemaForm/SchemaForm.spec.tsx index 132f32e20..2b39510c0 100644 --- a/src/frontend/components/SchemaForm/SchemaForm.spec.tsx +++ b/src/frontend/components/SchemaForm/SchemaForm.spec.tsx @@ -1,9 +1,9 @@ import * as React from "react"; import { render, screen } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import userEvent from "@testing-library/user-event"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; import { fakeMessageDescriptor } from "translations/fake"; +import { TestProviders } from "__tests__/_/Provider"; import { SchemaForm } from "."; type IAccount = { @@ -66,14 +66,14 @@ describe("", () => { it("should submit valid form and persist value", async () => { const mockOnSubmit = jest.fn(); render( - + onSubmit={mockOnSubmit} buttonText={buttonText} systemIcon="Save" fields={BASE_FIELDS} /> - + ); await userEvent.type(screen.getByLabelText("Name"), "Mary"); @@ -92,7 +92,7 @@ describe("", () => { it("should reset form state when resetForm is true", async () => { const mockOnSubmit = jest.fn(); render( - + onSubmit={mockOnSubmit} buttonText={buttonText} @@ -100,7 +100,7 @@ describe("", () => { fields={BASE_FIELDS} resetForm /> - + ); await userEvent.type(screen.getByLabelText("Name"), "Mary"); @@ -116,7 +116,7 @@ describe("", () => { it("should submit valid form on empty beforeSubmit", async () => { const mockOnSubmit = jest.fn(); render( - + onSubmit={mockOnSubmit} buttonText={buttonText} @@ -126,7 +126,7 @@ describe("", () => { beforeSubmit: "", }} /> - + ); await userEvent.type(screen.getByLabelText("Name"), "Mary"); @@ -142,7 +142,7 @@ describe("", () => { it("should submit values return by beforeSubmit", async () => { const mockOnSubmit = jest.fn(); render( - + onSubmit={mockOnSubmit} buttonText={buttonText} @@ -153,7 +153,7 @@ describe("", () => { beforeSubmit: BEFORE_SUBMIT, }} /> - + ); await userEvent.type(screen.getByLabelText("Name"), "Mary"); @@ -171,7 +171,7 @@ describe("", () => { it("should submit valid form on invalid beforeSubmit JS", async () => { const mockOnSubmit = jest.fn(); render( - + onSubmit={mockOnSubmit} buttonText={buttonText} @@ -181,7 +181,7 @@ describe("", () => { beforeSubmit: "sm ks ks dsldm sl dm", }} /> - + ); await userEvent.type(screen.getByLabelText("Name"), "Mary"); @@ -197,7 +197,7 @@ describe("", () => { it("should throw error and not submit when beforeSubmit returns a string", async () => { const mockOnSubmit = jest.fn(); render( - + onSubmit={mockOnSubmit} buttonText={buttonText} @@ -208,7 +208,7 @@ describe("", () => { beforeSubmit: BEFORE_SUBMIT, }} /> - + ); await userEvent.type(screen.getByLabelText("Name"), "Invalid"); @@ -225,7 +225,7 @@ describe("", () => { it("should edit forms", async () => { const mockOnSubmit = jest.fn(); render( - + onSubmit={mockOnSubmit} buttonText={buttonText} @@ -240,7 +240,7 @@ describe("", () => { beforeSubmit: BEFORE_SUBMIT, }} /> - + ); expect(screen.getByLabelText("Name")).toHaveValue("John Doe"); @@ -261,7 +261,7 @@ describe("", () => { it("should disable form fields", async () => { const mockOnSubmit = jest.fn(); render( - + onSubmit={mockOnSubmit} buttonText={buttonText} @@ -275,7 +275,7 @@ describe("", () => { fieldsState: FIELD_STATE, }} /> - + ); expect(screen.getByLabelText("Email")).not.toBeDisabled(); @@ -292,7 +292,7 @@ describe("", () => { it("should hide form fields", async () => { const mockOnSubmit = jest.fn(); render( - + onSubmit={mockOnSubmit} buttonText={buttonText} @@ -306,7 +306,7 @@ describe("", () => { fieldsState: FIELD_STATE, }} /> - + ); expect(screen.getByLabelText("Email")).toBeInTheDocument(); @@ -323,7 +323,7 @@ describe("", () => { it("should ignore form fields when it recieveds invalid JS", async () => { const mockOnSubmit = jest.fn(); render( - + onSubmit={mockOnSubmit} buttonText={buttonText} @@ -337,7 +337,7 @@ describe("", () => { fieldsState: "sdmsd smd slmd s;ld sl", }} /> - + ); await userEvent.type(screen.getByLabelText("Name"), "Hidden"); @@ -355,7 +355,7 @@ describe("", () => { it("should show validation errors", async () => { const mockOnSubmit = jest.fn(); render( - + onSubmit={mockOnSubmit} buttonText={buttonText} @@ -364,7 +364,7 @@ describe("", () => { ...BASE_FIELDS, }} /> - + ); await userEvent.type(screen.getByLabelText("Name"), "f"); @@ -402,7 +402,7 @@ describe("", () => { it("should use custom labels", async () => { const mockOnSubmit = jest.fn(); render( - + onSubmit={mockOnSubmit} buttonText={buttonText} @@ -415,7 +415,7 @@ describe("", () => { }, }} /> - + ); await userEvent.type( @@ -431,7 +431,7 @@ describe("", () => { it("should render * for required field", async () => { const mockOnSubmit = jest.fn(); render( - + onSubmit={mockOnSubmit} buttonText={buttonText} @@ -445,7 +445,7 @@ describe("", () => { }, }} /> - + ); expect(screen.getAllByText("*").length).toBe(2); @@ -454,7 +454,7 @@ describe("", () => { it("should have form button disabled by default", async () => { const mockOnSubmit = jest.fn(); render( - + onSubmit={mockOnSubmit} buttonText={buttonText} @@ -467,7 +467,7 @@ describe("", () => { }, }} /> - + ); expect(screen.getByRole("button", { name: "Submit Form" })).toBeDisabled(); @@ -480,7 +480,7 @@ describe("", () => { it("should can onChange when fieldChanges", async () => { const onChangeMock = jest.fn(); render( - + onSubmit={jest.fn()} onChange={onChangeMock} @@ -495,7 +495,7 @@ describe("", () => { fieldsState: FIELD_STATE, }} /> - + ); await userEvent.type(screen.getByLabelText("Name"), "Foo"); diff --git a/src/frontend/components/ViewStateMachine/ViewStateMachine.spec.tsx b/src/frontend/components/ViewStateMachine/ViewStateMachine.spec.tsx index 01a8fd7ce..5eba58487 100644 --- a/src/frontend/components/ViewStateMachine/ViewStateMachine.spec.tsx +++ b/src/frontend/components/ViewStateMachine/ViewStateMachine.spec.tsx @@ -1,7 +1,7 @@ import * as React from "react"; import { render, screen } from "@testing-library/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; import { ViewStateMachine } from "."; describe("", () => { @@ -11,11 +11,11 @@ describe("", () => { it("should render only loader when loading", async () => { render( - + Loading

}>

Content

-
+ ); expect(screen.getByText("Loading")).toBeInTheDocument(); @@ -24,11 +24,11 @@ describe("", () => { it("should render only content when not loading", async () => { render( - + Loading

}>

Content

-
+ ); expect(screen.queryByText("Loading")).not.toBeInTheDocument(); @@ -37,7 +37,7 @@ describe("", () => { it("should render error message when present", async () => { render( - + ", () => { >

Content

-
+ ); expect(screen.queryByText("Loading")).not.toBeInTheDocument(); diff --git a/src/frontend/design-system/components/Alert/Stories.tsx b/src/frontend/design-system/components/Alert/Stories.tsx index dfdc8f0b7..9aff65b8e 100644 --- a/src/frontend/design-system/components/Alert/Stories.tsx +++ b/src/frontend/design-system/components/Alert/Stories.tsx @@ -3,7 +3,7 @@ import { Story } from "@storybook/react"; import { GitHub } from "react-feather"; import { action } from "@storybook/addon-actions"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; +import { TestProviders } from "__tests__/_/Provider"; import { Alert, IProps, AlertType } from "."; export default { @@ -15,9 +15,9 @@ export default { }; const Template: Story = (args) => ( - + - + ); export const Info = Template.bind({}); diff --git a/src/frontend/design-system/components/Breadcrumbs/Stories.tsx b/src/frontend/design-system/components/Breadcrumbs/Stories.tsx index 671aa74bf..0b3aae59a 100644 --- a/src/frontend/design-system/components/Breadcrumbs/Stories.tsx +++ b/src/frontend/design-system/components/Breadcrumbs/Stories.tsx @@ -2,7 +2,7 @@ import { Story } from "@storybook/react"; import { action } from "@storybook/addon-actions"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; +import { TestProviders } from "__tests__/_/Provider"; import { Breadcrumbs, IProps } from "."; export default { @@ -28,9 +28,9 @@ export default { }; const Template: Story = (args) => ( - + - + ); export const Default = Template.bind({}); diff --git a/src/frontend/design-system/components/Button/Stories.tsx b/src/frontend/design-system/components/Button/Stories.tsx index 5b24eb37e..843155f10 100644 --- a/src/frontend/design-system/components/Button/Stories.tsx +++ b/src/frontend/design-system/components/Button/Stories.tsx @@ -2,7 +2,7 @@ import { Story } from "@storybook/react"; import { action } from "@storybook/addon-actions"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; +import { TestProviders } from "__tests__/_/Provider"; import { SoftButton } from "./SoftButton"; import { IActionButton } from "./types"; @@ -12,9 +12,9 @@ export default { }; const Template: Story = (args) => ( - + - + ); export const Loading = Template.bind({}); diff --git a/src/frontend/design-system/components/ConfirmAlert/Stories.tsx b/src/frontend/design-system/components/ConfirmAlert/Stories.tsx index c4525c4f5..577b8b405 100644 --- a/src/frontend/design-system/components/ConfirmAlert/Stories.tsx +++ b/src/frontend/design-system/components/ConfirmAlert/Stories.tsx @@ -2,7 +2,7 @@ import { Story } from "@storybook/react"; import { action } from "@storybook/addon-actions"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; +import { TestProviders } from "__tests__/_/Provider"; import { ConfirmAlert } from "."; export default { @@ -17,9 +17,9 @@ export default { }; const Template: Story = (args) => ( - + - + ); export const Default = Template.bind({}); diff --git a/src/frontend/design-system/components/Dropdown/Stories.tsx b/src/frontend/design-system/components/Dropdown/Stories.tsx index 5c23b95ea..d4a48516f 100644 --- a/src/frontend/design-system/components/Dropdown/Stories.tsx +++ b/src/frontend/design-system/components/Dropdown/Stories.tsx @@ -3,7 +3,7 @@ import { Story } from "@storybook/react"; import { action } from "@storybook/addon-actions"; import { MoreVertical } from "react-feather"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; +import { TestProviders } from "__tests__/_/Provider"; import { Dropdown, IProps } from "."; export default { @@ -17,11 +17,11 @@ export default { }; const Template: Story = (args) => ( - +
-
+ ); export const Default = Template.bind({}); diff --git a/src/frontend/design-system/components/DropdownMenu/Stories.tsx b/src/frontend/design-system/components/DropdownMenu/Stories.tsx index 73077cdf1..3571cce7f 100644 --- a/src/frontend/design-system/components/DropdownMenu/Stories.tsx +++ b/src/frontend/design-system/components/DropdownMenu/Stories.tsx @@ -1,7 +1,7 @@ /* eslint-disable react/function-component-definition */ import { Story } from "@storybook/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; +import { TestProviders } from "__tests__/_/Provider"; import { DropDownMenu, IProps } from "."; export default { @@ -34,11 +34,11 @@ export default { }; const Template: Story = (args) => ( - +
-
+ ); export const Default = Template.bind({}); diff --git a/src/frontend/design-system/components/EmptyWrapper/Stories.tsx b/src/frontend/design-system/components/EmptyWrapper/Stories.tsx index a49854c7c..51f6d782f 100644 --- a/src/frontend/design-system/components/EmptyWrapper/Stories.tsx +++ b/src/frontend/design-system/components/EmptyWrapper/Stories.tsx @@ -1,8 +1,8 @@ /* eslint-disable react/function-component-definition */ import { Story } from "@storybook/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import { noop } from "shared/lib/noop"; +import { TestProviders } from "__tests__/_/Provider"; import { EmptyWrapper } from "."; import { IEmptyWrapperProps } from "./types"; @@ -15,9 +15,9 @@ export default { }; const Template: Story = (args) => ( - + - + ); export const Default = Template.bind({}); diff --git a/src/frontend/design-system/components/Form/File/Stories.tsx b/src/frontend/design-system/components/Form/File/Stories.tsx index c31ccb05e..12d872c78 100644 --- a/src/frontend/design-system/components/Form/File/Stories.tsx +++ b/src/frontend/design-system/components/Form/File/Stories.tsx @@ -1,7 +1,7 @@ /* eslint-disable react/function-component-definition */ import { Story } from "@storybook/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; +import { TestProviders } from "__tests__/_/Provider"; import { IProps, Presentation } from "./Presentation"; export default { @@ -17,9 +17,9 @@ export default { }; const Template: Story = (args) => ( - + - + ); export const Default = Template.bind({}); diff --git a/src/frontend/design-system/components/Form/Stories.tsx b/src/frontend/design-system/components/Form/Stories.tsx index 909572505..ae5f35cae 100644 --- a/src/frontend/design-system/components/Form/Stories.tsx +++ b/src/frontend/design-system/components/Form/Stories.tsx @@ -4,9 +4,9 @@ import { Story } from "@storybook/react"; import { Field, Form } from "react-final-form"; import { action } from "@storybook/addon-actions"; import { required } from "frontend/lib/validations"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import { Stack } from "frontend/design-system/primitives/Stack"; import { fakeMessageDescriptor } from "translations/fake"; +import { TestProviders } from "__tests__/_/Provider"; import { FormCheckBox } from "./CheckBox"; import { FormInput } from "./Input"; import { FormNumberInput } from "./Number"; @@ -402,9 +402,9 @@ export default { }; const Template: Story<{}> = (args) => ( - + - + ); export const Default = Template.bind({}); diff --git a/src/frontend/design-system/components/Form/Switch/Stories.tsx b/src/frontend/design-system/components/Form/Switch/Stories.tsx index f15a17193..1dc26b23f 100644 --- a/src/frontend/design-system/components/Form/Switch/Stories.tsx +++ b/src/frontend/design-system/components/Form/Switch/Stories.tsx @@ -1,8 +1,8 @@ /* eslint-disable react/function-component-definition */ import { useState } from "react"; import { Story } from "@storybook/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import { fakeMessageDescriptor } from "translations/fake"; +import { TestProviders } from "__tests__/_/Provider"; import { FormSwitch, IProps } from "."; function Demo(args: IProps) { @@ -25,9 +25,9 @@ export default { }; const Template: Story = (args) => ( - + - + ); export const Default = Template.bind({}); diff --git a/src/frontend/design-system/components/IntermediateCheckBox/Stories.tsx b/src/frontend/design-system/components/IntermediateCheckBox/Stories.tsx index 14bec7783..8857e723d 100644 --- a/src/frontend/design-system/components/IntermediateCheckBox/Stories.tsx +++ b/src/frontend/design-system/components/IntermediateCheckBox/Stories.tsx @@ -2,7 +2,7 @@ import { useState } from "react"; import { Story } from "@storybook/react"; import { action } from "@storybook/addon-actions"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; +import { TestProviders } from "__tests__/_/Provider"; import { IntermediateCheckBox, IProps } from "."; export default { @@ -17,7 +17,7 @@ export default { const ControlledTemplate: Story = (args) => { const [state, setState] = useState("unchecked"); return ( - + = (args) => { } }} /> - + ); }; diff --git a/src/frontend/design-system/components/ListManager/ListManager.spec.tsx b/src/frontend/design-system/components/ListManager/ListManager.spec.tsx index d73015850..2add63339 100644 --- a/src/frontend/design-system/components/ListManager/ListManager.spec.tsx +++ b/src/frontend/design-system/components/ListManager/ListManager.spec.tsx @@ -1,8 +1,8 @@ import { fireEvent, render, screen } from "@testing-library/react"; import { loadedDataState } from "frontend/lib/data/constants/loadedDataState"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import { fakeMessageDescriptor } from "translations/fake"; +import { TestProviders } from "__tests__/_/Provider"; import { ListManager } from "."; const defaultProps = { @@ -50,12 +50,12 @@ describe("ListManager", () => { it("should not render search input when items are small", () => { render( - + ({ label: item.name })} /> - + ); expect(screen.queryByPlaceholderText("Search")).not.toBeInTheDocument(); @@ -63,7 +63,7 @@ describe("ListManager", () => { it("should render search input when items are large", () => { render( - + { )} render={(item) => ({ label: item.name })} /> - + ); expect(screen.getByPlaceholderText("Search")).toBeInTheDocument(); @@ -79,7 +79,7 @@ describe("ListManager", () => { it("should search items by label and name when search input is keyed", () => { render( - + { getLabel={(name) => `1-${name}`} render={(item) => ({ label: item.label })} /> - + ); fireEvent.change(screen.getByPlaceholderText("Search"), { @@ -118,7 +118,7 @@ describe("ListManager", () => { it("should render Empty view when empty", () => { render( - + { }} render={(item) => ({ label: item.label })} /> - + ); expect(screen.getByText("No Item Has Been Added Yet")).toBeInTheDocument(); diff --git a/src/frontend/design-system/components/ListManager/ListManagerItem/Stories.tsx b/src/frontend/design-system/components/ListManager/ListManagerItem/Stories.tsx index 23d88dea7..73fbaf6e8 100644 --- a/src/frontend/design-system/components/ListManager/ListManagerItem/Stories.tsx +++ b/src/frontend/design-system/components/ListManager/ListManagerItem/Stories.tsx @@ -2,7 +2,7 @@ import { Story } from "@storybook/react"; import { action } from "@storybook/addon-actions"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; +import { TestProviders } from "__tests__/_/Provider"; import { ListManagerItem, IListMangerItemProps } from "."; export default { @@ -15,12 +15,12 @@ export default { }; const Template: Story = (args) => ( - + - + ); export const Default = Template.bind({}); diff --git a/src/frontend/design-system/components/ListManager/Stories.tsx b/src/frontend/design-system/components/ListManager/Stories.tsx index c4fed57c5..fa2114fda 100644 --- a/src/frontend/design-system/components/ListManager/Stories.tsx +++ b/src/frontend/design-system/components/ListManager/Stories.tsx @@ -2,8 +2,8 @@ import { Story } from "@storybook/react"; import { actions } from "@storybook/addon-actions"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import { loadedDataState } from "frontend/lib/data/constants/loadedDataState"; +import { TestProviders } from "__tests__/_/Provider"; import { ListManager, IProps } from "."; interface IDemoType { @@ -32,9 +32,9 @@ export default { }; const Template: Story> = (args) => ( - + - + ); export const Default = Template.bind({}); diff --git a/src/frontend/design-system/components/OffCanvas/Stories.tsx b/src/frontend/design-system/components/OffCanvas/Stories.tsx index 7c172ce92..d3f3b0dec 100644 --- a/src/frontend/design-system/components/OffCanvas/Stories.tsx +++ b/src/frontend/design-system/components/OffCanvas/Stories.tsx @@ -2,7 +2,7 @@ import { Story } from "@storybook/react"; import { useState } from "@storybook/addons"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; +import { TestProviders } from "__tests__/_/Provider"; import { OffCanvas, IProps } from "."; export default { @@ -22,12 +22,12 @@ export default { const Template: Story = (args) => { const [open, setOpen] = useState(false); return ( - + setOpen(false)} /> - + ); }; diff --git a/src/frontend/design-system/components/RenderCode/Stories.tsx b/src/frontend/design-system/components/RenderCode/Stories.tsx index 01406af84..cb4cc4a1b 100644 --- a/src/frontend/design-system/components/RenderCode/Stories.tsx +++ b/src/frontend/design-system/components/RenderCode/Stories.tsx @@ -1,7 +1,7 @@ /* eslint-disable react/function-component-definition */ import { Story } from "@storybook/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; +import { TestProviders } from "__tests__/_/Provider"; import { RenderCode, IProps } from "."; export default { @@ -19,9 +19,9 @@ export default { const Template: Story = (args) => { return ( - + - + ); }; diff --git a/src/frontend/design-system/components/Section/MenuSection/Stories.tsx b/src/frontend/design-system/components/Section/MenuSection/Stories.tsx index bebe1fdb4..6d972a083 100644 --- a/src/frontend/design-system/components/Section/MenuSection/Stories.tsx +++ b/src/frontend/design-system/components/Section/MenuSection/Stories.tsx @@ -2,7 +2,7 @@ import { Story } from "@storybook/react"; import { action } from "@storybook/addon-actions"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; +import { TestProviders } from "__tests__/_/Provider"; import { MenuSection, IProps } from "."; export default { @@ -43,9 +43,9 @@ export default { }; const Template: Story = (args) => ( - + - + ); export const Default = Template.bind({}); diff --git a/src/frontend/design-system/components/Section/SectionBox/Stories.tsx b/src/frontend/design-system/components/Section/SectionBox/Stories.tsx index 09b793f74..f4410f9b6 100644 --- a/src/frontend/design-system/components/Section/SectionBox/Stories.tsx +++ b/src/frontend/design-system/components/Section/SectionBox/Stories.tsx @@ -2,7 +2,7 @@ import { Story } from "@storybook/react"; import { action } from "@storybook/addon-actions"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; +import { TestProviders } from "__tests__/_/Provider"; import { SectionBox, IProps } from "."; export default { @@ -15,9 +15,9 @@ export default { }; const Template: Story = (args) => ( - + - + ); export const Default = Template.bind({}); diff --git a/src/frontend/design-system/components/Section/SectionDivider/Stories.tsx b/src/frontend/design-system/components/Section/SectionDivider/Stories.tsx index 877d20f71..5721bd484 100644 --- a/src/frontend/design-system/components/Section/SectionDivider/Stories.tsx +++ b/src/frontend/design-system/components/Section/SectionDivider/Stories.tsx @@ -1,7 +1,7 @@ /* eslint-disable react/function-component-definition */ import { Story } from "@storybook/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; +import { TestProviders } from "__tests__/_/Provider"; import { ContentLayout } from "."; export default { @@ -14,7 +14,7 @@ export default { }; const Template: Story = () => ( - +
Hello @@ -33,7 +33,7 @@ const Template: Story = () => (
-
+ ); export const Default = Template.bind({}); diff --git a/src/frontend/design-system/components/Skeleton/Base/Stories.tsx b/src/frontend/design-system/components/Skeleton/Base/Stories.tsx index e16d0f55c..12bb19e98 100644 --- a/src/frontend/design-system/components/Skeleton/Base/Stories.tsx +++ b/src/frontend/design-system/components/Skeleton/Base/Stories.tsx @@ -1,7 +1,7 @@ /* eslint-disable react/function-component-definition */ import { Story } from "@storybook/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; +import { TestProviders } from "__tests__/_/Provider"; import { BaseSkeleton, IProps } from "."; export default { @@ -11,9 +11,9 @@ export default { }; const Template: Story = (args) => ( - + - + ); export const Default = Template.bind({}); diff --git a/src/frontend/design-system/components/Skeleton/Form/Stories.tsx b/src/frontend/design-system/components/Skeleton/Form/Stories.tsx index 50ab687db..a7938f185 100644 --- a/src/frontend/design-system/components/Skeleton/Form/Stories.tsx +++ b/src/frontend/design-system/components/Skeleton/Form/Stories.tsx @@ -1,7 +1,7 @@ /* eslint-disable react/function-component-definition */ import { Story } from "@storybook/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; +import { TestProviders } from "__tests__/_/Provider"; import { FormSkeleton, FormSkeletonSchema, IProps } from "."; export default { @@ -18,9 +18,9 @@ export default { }; const Template: Story = (args) => ( - + - + ); export const Default = Template.bind({}); diff --git a/src/frontend/design-system/components/Skeleton/List/Stories.tsx b/src/frontend/design-system/components/Skeleton/List/Stories.tsx index 5351ce19d..e0cd94fc7 100644 --- a/src/frontend/design-system/components/Skeleton/List/Stories.tsx +++ b/src/frontend/design-system/components/Skeleton/List/Stories.tsx @@ -1,7 +1,7 @@ /* eslint-disable react/function-component-definition */ import { Story } from "@storybook/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; +import { TestProviders } from "__tests__/_/Provider"; import { ListSkeleton, IProps } from "."; export default { @@ -13,9 +13,9 @@ export default { }; const Template: Story = (args) => ( - + - + ); export const Default = Template.bind({}); diff --git a/src/frontend/design-system/components/Skeleton/Table/Stories.tsx b/src/frontend/design-system/components/Skeleton/Table/Stories.tsx index 38d6604fa..166c8bb8c 100644 --- a/src/frontend/design-system/components/Skeleton/Table/Stories.tsx +++ b/src/frontend/design-system/components/Skeleton/Table/Stories.tsx @@ -1,7 +1,7 @@ /* eslint-disable react/function-component-definition */ import { Story } from "@storybook/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; +import { TestProviders } from "__tests__/_/Provider"; import { TableSkeleton, IProps } from "."; export default { @@ -11,9 +11,9 @@ export default { }; const Template: Story = (args) => ( - + - + ); export const Default = Template.bind({}); diff --git a/src/frontend/design-system/components/Table/Stories.tsx b/src/frontend/design-system/components/Table/Stories.tsx index 5c58605a2..f887bc21a 100644 --- a/src/frontend/design-system/components/Table/Stories.tsx +++ b/src/frontend/design-system/components/Table/Stories.tsx @@ -3,8 +3,8 @@ import { useState } from "react"; import { Story } from "@storybook/react"; import { action } from "@storybook/addon-actions"; import { IPaginatedDataState } from "shared/types/data"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import { msg } from "@lingui/macro"; +import { TestProviders } from "__tests__/_/Provider"; import { Table, DEFAULT_TABLE_STATE } from "."; import { ITableProps } from "./types"; import { TABLE_COLUMNS, TABLE_DATA } from "./data"; @@ -42,7 +42,7 @@ const Template: Story> = (args) => { >({ ...DEFAULT_TABLE_STATE }); return ( - + - + ); }; diff --git a/src/frontend/design-system/components/Table/Table.spec.tsx b/src/frontend/design-system/components/Table/Table.spec.tsx index c730178b4..01c28b49e 100644 --- a/src/frontend/design-system/components/Table/Table.spec.tsx +++ b/src/frontend/design-system/components/Table/Table.spec.tsx @@ -1,7 +1,7 @@ import { render, screen } from "@testing-library/react"; import { msg } from "@lingui/macro"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; import { Table } from "."; import { ITableProps } from "./types"; import { TABLE_COLUMNS, TABLE_DATA } from "./data"; @@ -27,9 +27,9 @@ useRouter.mockImplementation(USE_ROUTER_PARAMS({})); describe("Table", () => { it("should render data rows", async () => { render( - +
- + ); expect( diff --git a/src/frontend/design-system/components/Table/filters/__tests__/index.spec.tsx b/src/frontend/design-system/components/Table/filters/__tests__/index.spec.tsx index 4055305d8..485224141 100644 --- a/src/frontend/design-system/components/Table/filters/__tests__/index.spec.tsx +++ b/src/frontend/design-system/components/Table/filters/__tests__/index.spec.tsx @@ -6,9 +6,9 @@ import { IColumnFilterBag, TableFilterType, } from "shared/types/data"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; import { fakeMessageDescriptor } from "translations/fake"; +import { TestProviders } from "__tests__/_/Provider"; import { TableFilter } from ".."; const setFilterValueJestFn = jest.fn(); @@ -26,7 +26,7 @@ function TestComponent({ }) { const [state, setState] = useState(defaultValue); return ( - + - + ); } diff --git a/src/frontend/design-system/components/Tabs/Stories.tsx b/src/frontend/design-system/components/Tabs/Stories.tsx index 8490af67f..ba2bf8a2e 100644 --- a/src/frontend/design-system/components/Tabs/Stories.tsx +++ b/src/frontend/design-system/components/Tabs/Stories.tsx @@ -1,7 +1,7 @@ /* eslint-disable react/function-component-definition */ import { Story } from "@storybook/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; +import { TestProviders } from "__tests__/_/Provider"; import { Tabs, IProps } from "."; const Content = ({ label }: { label: string }) => { @@ -36,9 +36,9 @@ export default { }; const Template: Story = (args) => ( - + - + ); export const Default = Template.bind({}); diff --git a/src/frontend/design-system/components/Tabs/Tabs.spec.tsx b/src/frontend/design-system/components/Tabs/Tabs.spec.tsx index 6beda8a3c..e2dc6411c 100644 --- a/src/frontend/design-system/components/Tabs/Tabs.spec.tsx +++ b/src/frontend/design-system/components/Tabs/Tabs.spec.tsx @@ -1,7 +1,7 @@ import { render, fireEvent, screen } from "@testing-library/react"; import { fakeMessageDescriptor } from "translations/fake"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import { USE_ROUTER_PARAMS } from "__tests__/_/constants"; +import { TestProviders } from "__tests__/_/Provider"; import { Tabs } from "."; const TAB_CONTENT = [ @@ -29,9 +29,9 @@ useRouter.mockImplementation(USE_ROUTER_PARAMS({})); describe("Tabs", () => { it("should render first tab by default", () => { render( - + - + ); expect(screen.getByText("Foo Content")).toBeVisible(); @@ -41,9 +41,9 @@ describe("Tabs", () => { it("should render first tab when current tab is loading", () => { render( - + - + ); expect(screen.getByText("Foo Content")).toBeVisible(); @@ -53,9 +53,9 @@ describe("Tabs", () => { it("should render currentTab", () => { render( - + - + ); expect(screen.getByText("Foo Content")).not.toBeVisible(); @@ -66,9 +66,9 @@ describe("Tabs", () => { it("should switch tab", async () => { const onChange = jest.fn(); render( - + - + ); expect(screen.getByText("Foo Content")).not.toBeVisible(); expect(screen.getByText("Bar Content")).not.toBeVisible(); @@ -94,9 +94,9 @@ describe("Tabs", () => { it("should not call onChange if current tab is pressed", async () => { const onChange = jest.fn(); render( - + - + ); expect(screen.getByText("Foo Content")).not.toBeVisible(); expect(screen.getByText("Bar Content")).not.toBeVisible(); diff --git a/src/frontend/design-system/components/Toasts/Stories.tsx b/src/frontend/design-system/components/Toasts/Stories.tsx index d95959d3a..634cf5b9b 100644 --- a/src/frontend/design-system/components/Toasts/Stories.tsx +++ b/src/frontend/design-system/components/Toasts/Stories.tsx @@ -3,8 +3,8 @@ import { Story } from "@storybook/react"; import { action as storyAction } from "@storybook/addon-actions"; import { ToastService } from "frontend/lib/toast"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; import { fakeMessageDescriptor } from "translations/fake"; +import { TestProviders } from "__tests__/_/Provider"; interface IProps { label: string; @@ -26,9 +26,9 @@ export default { }; const Template: Story = (args) => ( - + - + ); export const Success = Template.bind({}); diff --git a/src/frontend/design-system/components/Tooltip/Stories.tsx b/src/frontend/design-system/components/Tooltip/Stories.tsx index 9844a25bd..18a27410e 100644 --- a/src/frontend/design-system/components/Tooltip/Stories.tsx +++ b/src/frontend/design-system/components/Tooltip/Stories.tsx @@ -1,7 +1,7 @@ /* eslint-disable react/function-component-definition */ import { Story } from "@storybook/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; +import { TestProviders } from "__tests__/_/Provider"; import { Tooltip, IProps } from "."; export default { @@ -13,9 +13,9 @@ export default { }; const Template: Story = (args) => ( - + Hover over me - + ); export const Default = Template.bind({}); diff --git a/src/frontend/design-system/components/Widgets/Summary/Stories.tsx b/src/frontend/design-system/components/Widgets/Summary/Stories.tsx index 40b0f75e0..7a7413c6d 100644 --- a/src/frontend/design-system/components/Widgets/Summary/Stories.tsx +++ b/src/frontend/design-system/components/Widgets/Summary/Stories.tsx @@ -1,6 +1,6 @@ /* eslint-disable react/function-component-definition */ import { Story } from "@storybook/react"; -import { ApplicationRoot } from "frontend/components/ApplicationRoot"; +import { TestProviders } from "__tests__/_/Provider"; import { SummaryWidget, IProps } from "."; export default { @@ -26,9 +26,9 @@ export default { }; const Template: Story = (args) => ( - + - + ); export const Default = Template.bind({}); diff --git a/src/frontend/lib/data/QueryClient.tsx b/src/frontend/lib/data/QueryClient.tsx index 6ed7d5099..a822f7080 100644 --- a/src/frontend/lib/data/QueryClient.tsx +++ b/src/frontend/lib/data/QueryClient.tsx @@ -1,5 +1,5 @@ import { ReactNode } from "react"; -import { QueryClient, QueryCache } from "@tanstack/react-query"; +import { QueryClient } from "@tanstack/react-query"; import { AsyncStorage, MaybePromise, @@ -9,10 +9,7 @@ import { import { createAsyncStoragePersister } from "@tanstack/query-async-storage-persister"; import { get, set, del } from "idb-keyval"; -export const queryCache = new QueryCache(); - const queryClient = new QueryClient({ - queryCache, defaultOptions: { queries: { gcTime: 1000 * 60 * 60 * 24 * 14, // 14 days