From 54353932533613658da52874a4de0b5ebf91d91d Mon Sep 17 00:00:00 2001 From: caichi Date: Mon, 18 Nov 2024 16:01:50 +0900 Subject: [PATCH] fix: publish and unpublish items test --- web/e2e/project/content/content.spec.ts | 34 +++++++++++++++++-------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/web/e2e/project/content/content.spec.ts b/web/e2e/project/content/content.spec.ts index b8425eb53..2efb09b5f 100644 --- a/web/e2e/project/content/content.spec.ts +++ b/web/e2e/project/content/content.spec.ts @@ -48,38 +48,52 @@ test("Item CRUD and searching has succeeded", async ({ page }) => { await expect(page.getByRole("cell", { name: "new text" })).toBeHidden(); }); -test("Publishing and Unpublishing item has succeeded", async ({ page }) => { +test("Publishing and Unpublishing item from edit page has succeeded", async ({ page }) => { await page.locator("li").filter({ hasText: "Text" }).locator("div").first().click(); await handleFieldForm(page, "text"); - await page.getByText("Settings").first().click(); - await page.getByRole("row", { name: "Owner" }).getByRole("switch").click(); - await page.getByRole("button", { name: "Save changes" }).last().click(); - await closeNotification(page); await page.getByText("Content").first().click(); await page.getByRole("button", { name: "plus New Item" }).click(); await page.getByLabel("text").click(); await page.getByLabel("text").fill("text"); await page.getByRole("button", { name: "Save" }).click(); await closeNotification(page); + await expect(page.getByText("DRAFT")).toBeVisible(); await page.getByRole("button", { name: "Publish" }).click(); await closeNotification(page); await expect(page.getByText("PUBLIC")).toBeVisible(); await page.getByLabel("Back").click(); await expect(page.getByText("PUBLIC")).toBeVisible(); - await page.getByLabel("", { exact: true }).check(); + await page.getByRole("cell").getByLabel("edit").locator("svg").click(); + await expect(page.getByText("PUBLIC")).toBeVisible(); + await page.getByRole("button", { name: "ellipsis" }).click(); await page.getByText("Unpublish").click(); await closeNotification(page); await expect(page.getByText("DRAFT")).toBeVisible(); - await page.getByRole("cell").getByLabel("edit").locator("svg").click(); + await page.getByLabel("Back").click(); await expect(page.getByText("DRAFT")).toBeVisible(); - await page.getByRole("button", { name: "Publish" }).click(); +}); + +test("Publishing and Unpublishing item from table has succeeded", async ({ page }) => { + await page.locator("li").filter({ hasText: "Text" }).locator("div").first().click(); + await handleFieldForm(page, "text"); + await page.getByText("Content").first().click(); + await page.getByRole("button", { name: "plus New Item" }).click(); + await page.getByLabel("text").click(); + await page.getByLabel("text").fill("text"); + await page.getByRole("button", { name: "Save" }).click(); + await closeNotification(page); + await expect(page.getByText("DRAFT")).toBeVisible(); + await page.getByLabel("Back").click(); + await expect(page.getByText("DRAFT")).toBeVisible(); + await page.getByLabel("", { exact: true }).check(); + await page.getByText("Publish", { exact: true }).click(); + await page.getByRole("button", { name: "Yes" }).click(); await closeNotification(page); await expect(page.getByText("PUBLIC")).toBeVisible(); - await page.getByRole("button", { name: "ellipsis" }).click(); await page.getByText("Unpublish").click(); await closeNotification(page); await expect(page.getByText("DRAFT")).toBeVisible(); - await page.getByLabel("Back").click(); + await page.getByRole("cell").getByLabel("edit").locator("svg").click(); await expect(page.getByText("DRAFT")).toBeVisible(); });