Skip to content

Commit 3ae2281

Browse files
committed
fix playwright test cases.
1 parent ee8aeda commit 3ae2281

File tree

1 file changed

+82
-3
lines changed
  • packages/Webkul/Admin/tests/e2e-pw/tests/settings/user

1 file changed

+82
-3
lines changed

packages/Webkul/Admin/tests/e2e-pw/tests/settings/user/users.spec.ts

Lines changed: 82 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,47 @@ async function createGroup(adminPage) {
4242
}
4343

4444
test.describe("user management", () => {
45-
test("should create a user", async ({ adminPage }) => {
45+
test("should create a user with global permission", async ({ adminPage }) => {
46+
/**
47+
* Reaching to the user listing page.
48+
*/
49+
await adminPage.goto("admin/settings/users");
50+
51+
/**
52+
* Opening create user form in modal.
53+
*/
54+
await adminPage.getByRole("button", { name: "Create User" }).click();
55+
56+
/**
57+
* Filling the form with user details.
58+
*/
59+
await adminPage.locator('input[name="name"]').fill(generateFullName());
60+
await adminPage.locator('input[name="email"]').fill(generateEmail());
61+
await adminPage.locator('input[name="password"]').fill("admin123");
62+
await adminPage
63+
.locator('input[name="confirm_password"]')
64+
.fill("admin123");
65+
await adminPage.locator('select[name="role_id"]').selectOption("1");
66+
await adminPage
67+
.locator('select[name="view_permission"]')
68+
.selectOption("global");
69+
70+
/**
71+
* Clicking on the status toggler to make the user active.
72+
*/
73+
await adminPage.click('label[for="status"]');
74+
75+
/**
76+
* Save user and close the modal.
77+
*/
78+
await adminPage.getByRole("button", { name: "Save User" }).click();
79+
80+
await expect(
81+
adminPage.getByText("User created successfully.")
82+
).toBeVisible();
83+
});
84+
85+
test("should create a user with group permission", async ({ adminPage }) => {
4686
/**
4787
* Creating a group to assign to the user.
4888
*/
@@ -70,8 +110,7 @@ test.describe("user management", () => {
70110
await adminPage.locator('select[name="role_id"]').selectOption("1");
71111
await adminPage
72112
.locator('select[name="view_permission"]')
73-
.selectOption("global");
74-
// await adminPage.locator('select[name="groups[]"]').selectOption("1");
113+
.selectOption("group");
75114
await adminPage.getByRole('listbox').selectOption({ label: name.groupName });
76115

77116
/**
@@ -89,6 +128,46 @@ test.describe("user management", () => {
89128
).toBeVisible();
90129
});
91130

131+
test("should create a user with individual permission", async ({ adminPage }) => {
132+
/**
133+
* Reaching to the user listing page.
134+
*/
135+
await adminPage.goto("admin/settings/users");
136+
137+
/**
138+
* Opening create user form in modal.
139+
*/
140+
await adminPage.getByRole("button", { name: "Create User" }).click();
141+
142+
/**
143+
* Filling the form with user details.
144+
*/
145+
await adminPage.locator('input[name="name"]').fill(generateFullName());
146+
await adminPage.locator('input[name="email"]').fill(generateEmail());
147+
await adminPage.locator('input[name="password"]').fill("admin123");
148+
await adminPage
149+
.locator('input[name="confirm_password"]')
150+
.fill("admin123");
151+
await adminPage.locator('select[name="role_id"]').selectOption("1");
152+
await adminPage
153+
.locator('select[name="view_permission"]')
154+
.selectOption("individual");
155+
156+
/**
157+
* Clicking on the status toggler to make the user active.
158+
*/
159+
await adminPage.click('label[for="status"]');
160+
161+
/**
162+
* Save user and close the modal.
163+
*/
164+
await adminPage.getByRole("button", { name: "Save User" }).click();
165+
166+
await expect(
167+
adminPage.getByText("User created successfully.")
168+
).toBeVisible();
169+
});
170+
92171
test("should edit a users", async ({ adminPage }) => {
93172
/**
94173
* Generating new name and email for the user.

0 commit comments

Comments
 (0)