From d403127bf3b5dbd866ad5e8fad4d50b793b13253 Mon Sep 17 00:00:00 2001 From: sagarKumar Date: Mon, 14 Apr 2025 14:49:58 +0530 Subject: [PATCH 1/2] written script for attribut management --- .../settings/automation/attribute.spec.ts | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 packages/Webkul/Admin/tests/e2e-pw/tests/settings/automation/attribute.spec.ts diff --git a/packages/Webkul/Admin/tests/e2e-pw/tests/settings/automation/attribute.spec.ts b/packages/Webkul/Admin/tests/e2e-pw/tests/settings/automation/attribute.spec.ts new file mode 100644 index 000000000..560f60988 --- /dev/null +++ b/packages/Webkul/Admin/tests/e2e-pw/tests/settings/automation/attribute.spec.ts @@ -0,0 +1,90 @@ +import { test } from "../../../setup"; +import { generateFirstName, generateFullName, generateSKU } from "../../../utils/faker"; + +test.describe("attribute management", async () => { + + test("should create an attribute", async ({ adminPage }) => { + + /** + * Reaching to the attribute listing page. + */ + await adminPage.goto("admin/settings/attributes"); + + /** + * Opening create attribute form in modal. + */ + await adminPage.getByRole('link', { name: 'Create Attribute' }).click(); + + /** + * Filling the form with attribute details. + */ + + await adminPage.getByRole('textbox', { name: 'Name' }).click(); + await adminPage.getByRole('textbox', { name: 'Name' }).fill(generateFullName()); + await adminPage.getByRole('textbox', { name: 'Code' }).click(); + await adminPage.getByRole('textbox', { name: 'Code' }).fill(generateSKU()); + await adminPage.getByRole('textbox', { name: 'Code' }).press('Tab'); + await adminPage.locator('#type').selectOption('text'); + await adminPage.locator('#entity_type').selectOption('persons'); + await adminPage.locator('#validation').selectOption('numeric'); + + /** + * Save attribute and close the modal. + */ + await adminPage.getByRole('button', { name: 'Save Attribute' }).click(); + + + }) + test("should edit an attribute", async ({ adminPage }) => { + /** + * Reaching to the attribute listing page. + */ + await adminPage.goto("admin/settings/attributes"); + + + /** + * Clicking on the edit button for the first attribute opens the modal. + */ + await adminPage.locator('//span[@class="cursor-pointer rounded-md p-1.5 text-2xl transition-all hover:bg-gray-200 dark:hover:bg-gray-800 max-sm:place-self-center icon-edit"]').first().click(); + + + /** + * Fill the form with the attribute details. + */ + await adminPage.getByRole('textbox', { name: 'Name' }).click(); + await adminPage.getByRole('textbox', { name: 'Name' }).fill(generateFullName()); + await adminPage.getByRole('textbox', { name: 'Code' }).press('Tab'); + await adminPage.locator('#entity_type').selectOption('persons'); + + /** + * Save attribute and close the modal. + */ + await adminPage.getByRole('button', { name: 'Save Attribute' }).click(); + + }) + test("should delete an attribute", async ({ adminPage }) => { + /** + * Reaching to the attribute listing page. + */ + await adminPage.goto("admin/settings/attributes"); + + + /** + * Clicking on the delete button for the first attribute opens the modal. + */ + await adminPage.locator('//span[@class="cursor-pointer rounded-md p-1.5 text-2xl transition-all hover:bg-gray-200 dark:hover:bg-gray-800 max-sm:place-self-center icon-delete"]').first().click(); + /** + * Delete confirmation modal. + */ + await adminPage.getByRole('button', { name: 'Agree', exact: true }).click(); + + + /** + * Checking if the attribute is deleted successfully. + */ + + await adminPage.getByText('Attribute deleted successfully.').isVisible(); + + }) + +}) \ No newline at end of file From 4cc577a759c755c26bbaf6229b1bbfb406473a5e Mon Sep 17 00:00:00 2001 From: sagarKumar Date: Mon, 14 Apr 2025 17:38:12 +0530 Subject: [PATCH 2/2] . --- .../tests/settings/automation/attribute.spec.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/Webkul/Admin/tests/e2e-pw/tests/settings/automation/attribute.spec.ts b/packages/Webkul/Admin/tests/e2e-pw/tests/settings/automation/attribute.spec.ts index 560f60988..5bc883891 100644 --- a/packages/Webkul/Admin/tests/e2e-pw/tests/settings/automation/attribute.spec.ts +++ b/packages/Webkul/Admin/tests/e2e-pw/tests/settings/automation/attribute.spec.ts @@ -1,4 +1,4 @@ -import { test } from "../../../setup"; +import { expect, test } from "../../../setup"; import { generateFirstName, generateFullName, generateSKU } from "../../../utils/faker"; test.describe("attribute management", async () => { @@ -32,7 +32,10 @@ test.describe("attribute management", async () => { * Save attribute and close the modal. */ await adminPage.getByRole('button', { name: 'Save Attribute' }).click(); - + /** + * Checking if the attribute is save successfully. + */ + await expect(adminPage.getByText('Success', { exact: true })).toBeVisible(); }) test("should edit an attribute", async ({ adminPage }) => { @@ -60,6 +63,11 @@ test.describe("attribute management", async () => { * Save attribute and close the modal. */ await adminPage.getByRole('button', { name: 'Save Attribute' }).click(); + /** + * Checking if the attribute is updated successfully. + */ + await expect(adminPage.getByText('Success', { exact: true })).toBeVisible(); + }) test("should delete an attribute", async ({ adminPage }) => { @@ -83,7 +91,7 @@ test.describe("attribute management", async () => { * Checking if the attribute is deleted successfully. */ - await adminPage.getByText('Attribute deleted successfully.').isVisible(); + await expect(adminPage.getByText('Attribute deleted successfully.')).toBeVisible(); })