diff --git a/e2e/delete-cube-collection.spec.ts b/e2e/delete-cube-collection.spec.ts new file mode 100644 index 00000000..45aa3d2a --- /dev/null +++ b/e2e/delete-cube-collection.spec.ts @@ -0,0 +1,40 @@ +import { test, expect } from "@playwright/test"; + +test("Should be able to delete a cube collection", async ({ page }) => { + await page.goto("http://localhost:3000/en/cubes"); + await expect(page.getByTestId("empty-cubes-container")).toBeVisible(); + await expect(page.getByTestId("create-collection-button")).toBeVisible(); + await page.getByTestId("create-collection-button").click(); + await page.getByTestId("drawer-input-name").click(); + await page.getByTestId("drawer-input-name").fill("fake-cube-name"); + await page.getByTestId("checkbox-category-6x6").click(); + await page.getByTestId("drawer-accept-button").click(); + await expect(page.getByTestId("cube-name-fake-cube-name")).toBeVisible(); + await expect(page.getByTestId("cube-options")).toBeVisible(); + await page.getByTestId("cube-options").click(); + await expect(page.getByTestId("dropdown-cube-options-delete")).toBeVisible(); + await page.getByTestId("dropdown-cube-options-delete").click(); + await expect(page.getByTestId("dialog-delete-cube-container")).toBeVisible(); + await expect(page.getByTestId("dialog-delete-cube-title")).toBeVisible(); + await expect( + page.getByTestId("dialog-delete-cube-description") + ).toBeVisible(); + await expect(page.getByTestId("dialog-delete-cube-warning")).toBeVisible(); + await expect(page.getByTestId("dialog-delete-cube-input")).toBeVisible(); + await expect( + page.getByTestId("dialog-delete-cube-cancel-button") + ).toBeVisible(); + await expect( + page.getByTestId("dialog-delete-cube-accept-button") + ).toBeVisible(); + await page.getByTestId("dialog-delete-cube-input").click(); + await page.getByTestId("dialog-delete-cube-input").fill("asd"); + await page.getByTestId("dialog-delete-cube-accept-button").click(); + await expect( + page.getByTestId("dialog-delete-cube-error-message") + ).toBeVisible(); + await page.getByTestId("dialog-delete-cube-input").click(); + await page.getByTestId("dialog-delete-cube-input").fill("fake-cube-name"); + await page.getByTestId("dialog-delete-cube-accept-button").click(); + await expect(page.getByTestId("empty-cubes-container")).toBeVisible(); +}); diff --git a/e2e/test-4.spec.ts b/e2e/test-4.spec.ts deleted file mode 100644 index bcc2f1b6..00000000 --- a/e2e/test-4.spec.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { test, expect } from "@playwright/test"; - -test("Should create and delete a cube", async ({ page }) => { - await page.goto("http://localhost:3000/en/cubes"); - await page.getByRole("button").click(); - await page.getByPlaceholder("Brand | Model | Version |").click(); - await page.getByPlaceholder("Brand | Model | Version |").fill("test"); - await page.getByRole("button", { name: "Create" }).click(); - await expect(page.getByText("test")).toBeVisible(); - await page.getByRole("button").nth(2).click(); - await page.getByRole("button", { name: "Delete" }).click(); - await page.getByRole("button", { name: "Delete" }).nth(1).click(); - await expect(page.getByText("No cubes for display.")).toBeVisible(); -}); diff --git a/src/components/cubes/cubes-table.tsx b/src/components/cubes/cubes-table.tsx index 47878018..13b842c0 100644 --- a/src/components/cubes/cubes-table.tsx +++ b/src/components/cubes/cubes-table.tsx @@ -116,12 +116,13 @@ export default function CubesTable({ - - + openDialogType({ type: "edit", @@ -132,6 +133,7 @@ export default function CubesTable({ Edit openDialogType({ type: "delete", diff --git a/src/components/dialogs/dialog-delete-collection/dialog-delete-collection.tsx b/src/components/dialogs/dialog-delete-collection/dialog-delete-collection.tsx index 2fd8859b..73761d79 100644 --- a/src/components/dialogs/dialog-delete-collection/dialog-delete-collection.tsx +++ b/src/components/dialogs/dialog-delete-collection/dialog-delete-collection.tsx @@ -46,15 +46,23 @@ export default function DialogDeleteCollection() { }; return ( <> - + - {t("Cubes-modal.delete-collection")} - + + {t("Cubes-modal.delete-collection")} + + {t("Cubes-modal.delete-collection-description")} - + {t("Cubes-modal.warning-alert")}{" "} {t("Cubes-modal.warning-msg")} @@ -71,18 +79,33 @@ export default function DialogDeleteCollection() { setError((prev) => ({ ...prev, status: false, message: "" })); setCubeName(e.target.value); }} + data-testId="dialog-delete-cube-input" /> {error && error.status && ( -

{error.message}

+

+ {error.message} +

)}
- + -