Skip to content

Commit

Permalink
adding conditional assertion for TC 137
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowee committed Jul 25, 2024
1 parent 609ac69 commit 074d3c5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 1 addition & 3 deletions playwright/api/basics.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIRequestContext, expect } from "@playwright/test";
import { APIRequestContext } from "@playwright/test";

interface User {
email: string;
Expand Down Expand Up @@ -51,8 +51,6 @@ export class BasicApiService {
});
const loginResponseJson = await loginResponse.json();

expect(loginResponseJson.data.tokenCreate.errors).toEqual([]);

return loginResponseJson;
}
}
14 changes: 12 additions & 2 deletions playwright/tests/auth.setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BasicApiService } from "@api/basics";
import { permissions, USER_PERMISSION, UserPermissionType } from "@data/userPermissions";
import { APIRequestContext, test as setup } from "@playwright/test";
import { permissions, USER_PERMISSION } from "@data/userPermissions";
import { APIRequestContext, expect, test as setup } from "@playwright/test";
import fs from "fs";
import path from "path";

Expand Down Expand Up @@ -28,6 +28,16 @@ const authenticateAndSaveState = async (
const basicApiService = new BasicApiService(request);

const loginResponse = await basicApiService.logInUserViaApi({ email, password });
const errors = loginResponse.data.tokenCreate.errors;

if (
setup.info().title ===
"TC: SALEOR_137 Admin User should be able to deactivate other user @e2e @staff-members"
) {
await expect(errors[0].code).toEqual("INACTIVE");
} else {
await expect(errors).toEqual([]);

Check failure on line 39 in playwright/tests/auth.setup.ts

View workflow job for this annotation

GitHub Actions / run-tests (2/2)

[setup] › auth.setup.ts:86:6 › Authenticate permission users via API

1) [setup] › auth.setup.ts:86:6 › Authenticate permission users via API ────────────────────────── Error: expect(received).toEqual(expected) // deep equality - Expected - 1 + Received + 6 - Array [] + Array [ + Object { + "code": "LOGIN_ATTEMPT_DELAYED", + "message": "Logging has been suspended till 2024-07-25 11:33:42.666835+00:00 due to too many logging attempts originating from the same IP address.", + }, + ] 37 | await expect(errors[0].code).toEqual("INACTIVE"); 38 | } else { > 39 | await expect(errors).toEqual([]); | ^ 40 | } 41 | 42 | const loginJsonInfo = await request.storageState(); at authenticateAndSaveState (/home/runner/work/saleor-dashboard/saleor-dashboard/playwright/tests/auth.setup.ts:39:26) at authSetup (/home/runner/work/saleor-dashboard/saleor-dashboard/playwright/tests/auth.setup.ts:73:5) at /home/runner/work/saleor-dashboard/saleor-dashboard/playwright/tests/auth.setup.ts:92:5

Check failure on line 39 in playwright/tests/auth.setup.ts

View workflow job for this annotation

GitHub Actions / run-tests (2/2)

[setup] › auth.setup.ts:86:6 › Authenticate permission users via API

1) [setup] › auth.setup.ts:86:6 › Authenticate permission users via API ────────────────────────── Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toEqual(expected) // deep equality - Expected - 1 + Received + 6 - Array [] + Array [ + Object { + "code": "LOGIN_ATTEMPT_DELAYED", + "message": "Logging has been suspended till 2024-07-25 11:33:44.428296+00:00 due to too many logging attempts originating from the same IP address.", + }, + ] 37 | await expect(errors[0].code).toEqual("INACTIVE"); 38 | } else { > 39 | await expect(errors).toEqual([]); | ^ 40 | } 41 | 42 | const loginJsonInfo = await request.storageState(); at authenticateAndSaveState (/home/runner/work/saleor-dashboard/saleor-dashboard/playwright/tests/auth.setup.ts:39:26) at authSetup (/home/runner/work/saleor-dashboard/saleor-dashboard/playwright/tests/auth.setup.ts:73:5) at /home/runner/work/saleor-dashboard/saleor-dashboard/playwright/tests/auth.setup.ts:92:5

Check failure on line 39 in playwright/tests/auth.setup.ts

View workflow job for this annotation

GitHub Actions / run-tests (2/2)

[setup] › auth.setup.ts:86:6 › Authenticate permission users via API

1) [setup] › auth.setup.ts:86:6 › Authenticate permission users via API ────────────────────────── Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toEqual(expected) // deep equality - Expected - 1 + Received + 6 - Array [] + Array [ + Object { + "code": "LOGIN_ATTEMPT_DELAYED", + "message": "Logging has been suspended till 2024-07-25 11:33:48.481654+00:00 due to too many logging attempts originating from the same IP address.", + }, + ] 37 | await expect(errors[0].code).toEqual("INACTIVE"); 38 | } else { > 39 | await expect(errors).toEqual([]); | ^ 40 | } 41 | 42 | const loginJsonInfo = await request.storageState(); at authenticateAndSaveState (/home/runner/work/saleor-dashboard/saleor-dashboard/playwright/tests/auth.setup.ts:39:26) at authSetup (/home/runner/work/saleor-dashboard/saleor-dashboard/playwright/tests/auth.setup.ts:73:5) at /home/runner/work/saleor-dashboard/saleor-dashboard/playwright/tests/auth.setup.ts:92:5
}

const loginJsonInfo = await request.storageState();

Expand Down

0 comments on commit 074d3c5

Please sign in to comment.