diff --git a/.gitignore b/.gitignore index ae88943fe..77fc0993b 100644 --- a/.gitignore +++ b/.gitignore @@ -35,7 +35,7 @@ yarn-error.log* tsconfig.tsbuildinfo -.config-data/**/*.json +.config-data dist/ diff --git a/src/__tests__/admin/[entity]/config/crud__tab.spec.tsx b/src/__tests__/admin/[entity]/config/crud__tab.spec.tsx index 63c1bce09..f5062fdeb 100644 --- a/src/__tests__/admin/[entity]/config/crud__tab.spec.tsx +++ b/src/__tests__/admin/[entity]/config/crud__tab.spec.tsx @@ -7,6 +7,7 @@ import { rest } from "msw"; import { setupApiHandlers } from "__tests__/_/setupApihandlers"; import { BASE_TEST_URL } from "__tests__/_/api-handlers/_utils"; +import { sluggify } from "shared/lib/strings"; const server = setupApiHandlers(); @@ -80,7 +81,9 @@ describe("pages/admin/[entity]/config/crud", () => { }) ).toBeVisible(); - expect(replaceMock).toHaveBeenCalledWith(`/hello-there?foo=bar&tab=${tab}`); + expect(replaceMock).toHaveBeenCalledWith( + `/hello-there?foo=bar&tab=${sluggify(tab)}` + ); }); it("should default to the tab from query and be to go back to table", async () => { @@ -132,6 +135,6 @@ describe("pages/admin/[entity]/config/crud", () => { }) ).toHaveTextContent("Table"); - expect(replaceMock$1).toHaveBeenCalledWith("/?tab=Table"); + expect(replaceMock$1).toHaveBeenCalledWith("/?tab=table"); }); }); diff --git a/src/__tests__/api/dashboards/[dashboardId]/[widgetId]/index.spec.ts b/src/__tests__/api/dashboards/[dashboardId]/[widgetId]/index.spec.ts index 8330f68cc..6eb2fc39a 100644 --- a/src/__tests__/api/dashboards/[dashboardId]/[widgetId]/index.spec.ts +++ b/src/__tests__/api/dashboards/[dashboardId]/[widgetId]/index.spec.ts @@ -145,7 +145,7 @@ describe("/api/dashboards/[dashboardId]/[widgetId]/index", () => { expect(deleteRequest.res._getStatusCode()).toBe(400); expect(deleteRequest.res._getJSONData()).toMatchInlineSnapshot(` { - "message": "This service is not available on the demo site", + "message": "This action is not available on the demo site", "method": "DELETE", "name": "BadRequestError", "path": "", diff --git a/src/__tests__/api/dashboards/[dashboardId]/index.spec.ts b/src/__tests__/api/dashboards/[dashboardId]/index.spec.ts index e2d96df50..498184c0f 100644 --- a/src/__tests__/api/dashboards/[dashboardId]/index.spec.ts +++ b/src/__tests__/api/dashboards/[dashboardId]/index.spec.ts @@ -189,7 +189,7 @@ describe("/api/dashboards/[dashboardId]/index", () => { describe("/api/dashboards/[dashboardId]/index generation", () => { beforeAll(async () => { - await setupAllTestData(["schema", "app-config"]); + await setupAllTestData(["schema", "app-config", "credentials"]); await setupDashboardTestData([]); }); @@ -203,7 +203,6 @@ describe("/api/dashboards/[dashboardId]/index generation", () => { await handler(req, res); - expect(res._getStatusCode()).toBe(200); expect(res._getJSONData()).toMatchInlineSnapshot(` [ { diff --git a/src/__tests__/integrations/actions/[key].spec.tsx b/src/__tests__/integrations/actions/[key].spec.tsx new file mode 100644 index 000000000..41edb05d2 --- /dev/null +++ b/src/__tests__/integrations/actions/[key].spec.tsx @@ -0,0 +1,56 @@ +import React from "react"; +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 userEvent from "@testing-library/user-event"; +// import { closeAllToasts } from "__tests__/_/utils/closeAllToasts"; + +setupApiHandlers(); + +describe("pages/integrations/actions/[key]", () => { + const useRouter = jest.spyOn(require("next/router"), "useRouter"); + beforeAll(() => { + useRouter.mockImplementation(() => ({ + asPath: "/", + query: { + key: "slack", + }, + isReady: true, + })); + }); + + describe("list", () => { + it("should show the list of actions", async () => { + render( + + + + ); + + expect( + await screen.findByRole("link", { name: "Slack" }) + ).toBeInTheDocument(); + expect(screen.getByRole("link", { name: "HTTP" })).toBeInTheDocument(); + expect( + screen.getByRole("link", { name: "Non Activated Actions" }) + ).toBeInTheDocument(); + }); + + // it("should show the configure UI for activated actions", async () => { + // render( + // + // + // + // ); + + // await waitFor(() => { + // expect( + // screen.getByRole("option", { selected: true }) + // ).toHaveTextContent("Slack"); + // }); + // }); + }); +}); diff --git a/src/__tests__/integrations/variables__credentials.spec.tsx b/src/__tests__/integrations/variables__credentials.spec.tsx index becd46c38..79ad26cb3 100644 --- a/src/__tests__/integrations/variables__credentials.spec.tsx +++ b/src/__tests__/integrations/variables__credentials.spec.tsx @@ -100,7 +100,9 @@ describe("pages/integrations/variables => credentials", () => { await screen.findByRole("tab", { name: "Secrets" }) ); - const table = screen.getByRole("table"); + const table = within( + screen.getByRole("tabpanel", { name: "Secrets" }) + ).getByRole("table"); expect( await within(table).findByRole("row", { @@ -183,7 +185,9 @@ describe("pages/integrations/variables => credentials", () => { "Invalid Password" ); - const table = screen.getByRole("table"); + const table = within( + screen.getByRole("tabpanel", { name: "Secrets" }) + ).getByRole("table"); expect( await within(table).findByRole("row", { @@ -223,7 +227,9 @@ describe("pages/integrations/variables => credentials", () => { }) ); - const table = screen.getByRole("table"); + const table = within( + screen.getByRole("tabpanel", { name: "Secrets" }) + ).getByRole("table"); expect( await within(table).findByRole("row", { @@ -323,7 +329,9 @@ describe("pages/integrations/variables => credentials", () => { await screen.findByRole("tab", { name: "Secrets" }) ); - const table = screen.getByRole("table"); + const table = within( + screen.getByRole("tabpanel", { name: "Secrets" }) + ).getByRole("table"); expect( await within(table).findByRole( @@ -436,7 +444,9 @@ describe("pages/integrations/variables => credentials", () => { await screen.findByRole("tab", { name: "Secrets" }) ); - const tableRows = await screen.findAllByRole("row"); + const table = screen.getByRole("tabpanel", { name: "Secrets" }); + + const tableRows = await within(table).findAllByRole("row"); expect(tableRows).toHaveLength(5); @@ -454,7 +464,7 @@ describe("pages/integrations/variables => credentials", () => { await within(confirmBox).findByRole("button", { name: "Confirm" }) ); - expect(await screen.findAllByRole("row")).toHaveLength(4); + expect(await within(table).findAllByRole("row")).toHaveLength(4); expect((await screen.findAllByRole("status"))[0]).toHaveTextContent( "Secret Deleted Successfully"