Skip to content

Commit

Permalink
Fix for TC: SALEOR_38 (#5207)
Browse files Browse the repository at this point in the history
* Fix for TC: SALEOR_38

* Rename spec file

* fix changesets

---------

Co-authored-by: M.Graczyk <michalina.graczyk@saleor.io>
  • Loading branch information
2 people authored and Cloud11PL committed Nov 7, 2024
1 parent 725ab22 commit 55988f0
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .changeset/eleven-avocados-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Moving test cases for activation and deactivation staff members to other file and running it in serial mode to avoid login in two tests in the same time (it can cause error with code LOGIN_ATTEMPT_DELAYED)
52 changes: 52 additions & 0 deletions playwright/tests/staffMemberActivation.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { BasicApiService } from "@api/basics";
import { USERS } from "@data/e2eTestData";
import { ConfigurationPage } from "@pages/configurationPage";
import { PermissionGroupsPage } from "@pages/permissionGroupsPage";
import { StaffMembersPage } from "@pages/staffMembersPage";
import { expect } from "@playwright/test";
import { test } from "utils/testWithPermission";

test.use({ permissionName: "admin" });

test.describe.configure({ mode: "serial" });

let staffMembersPage: StaffMembersPage;
let config: ConfigurationPage;
let permissionGroupsPage: PermissionGroupsPage;
let basicApiService: BasicApiService;

test.beforeEach(async ({ page, request }) => {
staffMembersPage = new StaffMembersPage(page, request);
config = new ConfigurationPage(page);
permissionGroupsPage = new PermissionGroupsPage(page);
basicApiService = new BasicApiService(request);
});
test("TC: SALEOR_137 Admin User should be able to deactivate other user @e2e @staff-members", async () => {
await staffMembersPage.goToStaffDetailsPage(USERS.userToBeDeactivated.id);
await staffMembersPage.clickIsActiveCheckbox();
await staffMembersPage.clickSaveButton();
await staffMembersPage.basePage.expectSuccessBanner();
expect(await staffMembersPage.isActiveCheckbox.isChecked()).toEqual(false);

const loginViaApiDeactivatedUserResponse = await basicApiService.logInUserViaApi({
email: USERS.userToBeDeactivated.email,
password: process.env.E2E_PERMISSIONS_USERS_PASSWORD!,
});

expect(loginViaApiDeactivatedUserResponse.data.tokenCreate.errors[0].code).toEqual("INACTIVE");
});
test("TC: SALEOR_38 Admin User should be able to activate other user @e2e @staff-members", async () => {
await staffMembersPage.goToStaffDetailsPage(USERS.userToBeActivated.id);
await staffMembersPage.clickIsActiveCheckbox();
await staffMembersPage.clickSaveButton();
await staffMembersPage.basePage.expectSuccessBanner();
expect(await staffMembersPage.isActiveCheckbox.isChecked()).toEqual(true);

const loginViaApiDeactivatedUserResponse = await basicApiService.logInUserViaApi({
email: USERS.userToBeActivated.email,
password: process.env.E2E_PERMISSIONS_USERS_PASSWORD!,
});

expect(loginViaApiDeactivatedUserResponse.data.tokenCreate.errors).toEqual([]);
expect(loginViaApiDeactivatedUserResponse.data.tokenCreate.token).not.toEqual(null);
});
30 changes: 0 additions & 30 deletions playwright/tests/staffMembers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,7 @@ test.beforeEach(async ({ page, request }) => {
permissionGroupsPage = new PermissionGroupsPage(page);
basicApiService = new BasicApiService(request);
});
test("TC: SALEOR_137 Admin User should be able to deactivate other user @e2e @staff-members", async () => {
await staffMembersPage.goToStaffDetailsPage(USERS.userToBeDeactivated.id);
await staffMembersPage.clickIsActiveCheckbox();
await staffMembersPage.clickSaveButton();
await staffMembersPage.basePage.expectSuccessBanner();
await expect(await staffMembersPage.isActiveCheckbox.isChecked()).toEqual(false);

const loginViaApiDeactivatedUserResponse = await basicApiService.logInUserViaApi({
email: USERS.userToBeDeactivated.email,
password: process.env.E2E_PERMISSIONS_USERS_PASSWORD!,
});

await expect(loginViaApiDeactivatedUserResponse.data.tokenCreate.errors[0].code).toEqual(
"INACTIVE",
);
});
test("TC: SALEOR_38 Admin User should be able to activate other user @e2e @staff-members", async () => {
await staffMembersPage.goToStaffDetailsPage(USERS.userToBeActivated.id);
await staffMembersPage.clickIsActiveCheckbox();
await staffMembersPage.clickSaveButton();
await staffMembersPage.basePage.expectSuccessBanner();
await expect(await staffMembersPage.isActiveCheckbox.isChecked()).toEqual(true);

const loginViaApiDeactivatedUserResponse = await basicApiService.logInUserViaApi({
email: USERS.userToBeActivated.email,
password: process.env.E2E_PERMISSIONS_USERS_PASSWORD!,
});

await expect(loginViaApiDeactivatedUserResponse.data.tokenCreate.errors).toEqual([]);
await expect(loginViaApiDeactivatedUserResponse.data.tokenCreate.token).not.toEqual(null);
});
test("TC: SALEOR_211 Create a staff member @e2e @staff-members", async () => {
const name = faker.name.firstName();
const lastName = faker.name.lastName();
Expand Down

0 comments on commit 55988f0

Please sign in to comment.