Skip to content

Commit 5face23

Browse files
authored
Merge pull request #589 from Women-Coding-Community/feature/api-tests
Updated Playwright test plan and implemented a logic for a few test cases (auth endpoints)
2 parents 5629c8b + 5c85c02 commit 5face23

24 files changed

+692
-173
lines changed

integration-test/.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
API_HOST="http://localhost:8080"
22
API_KEY="api_key"
3+
ADMIN_EMAIL=
4+
ADMIN_PASSWORD=

integration-test/TEST_PLAN.md

Lines changed: 295 additions & 0 deletions
Large diffs are not rendered by default.

integration-test/package-lock.json

Lines changed: 222 additions & 144 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

integration-test/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"author": "",
2020
"license": "ISC",
2121
"dependencies": {
22-
"playwright": "^1.48.2"
22+
"playwright": "^1.48.2",
23+
"zod": "^4.3.6"
2324
},
2425
"devDependencies": {
2526
"@apidevtools/swagger-parser": "github:apidevtools/swagger-parser",
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { expect, test as baseTest } from '@playwright/test';
2+
import { test } from '@utils/fixtures/fixtures';
3+
import { PATHS } from '@utils/datafactory/paths.data';
4+
import { loginResponseSchema } from '@utils/datafactory/schemas/auth.schema';
5+
import { usersResponseSchema } from '@utils/datafactory/schemas/user.account.schema';
6+
7+
const ADMIN_EMAIL = process.env.ADMIN_EMAIL;
8+
const ADMIN_PASSWORD = process.env.ADMIN_PASSWORD;
9+
10+
baseTest.describe('AUTH-01: Login', () => {
11+
baseTest('Login with valid credentials returns token', async ({ request }) => {
12+
const response = await request.post(PATHS.AUTH_LOGIN, {
13+
data: {
14+
email: ADMIN_EMAIL,
15+
password: ADMIN_PASSWORD,
16+
},
17+
});
18+
19+
expect(response.status()).toBe(200);
20+
21+
const body = await response.json();
22+
expect(loginResponseSchema.parse(body)).toBeTruthy();
23+
});
24+
});
25+
26+
test.describe('AUTH-07: Users', () => {
27+
test('Get users with admin token returns user list', async ({ authRequest }) => {
28+
const response = await authRequest.get(PATHS.AUTH_USERS);
29+
30+
expect(response.status()).toBe(200);
31+
32+
const body = await response.json();
33+
const users = usersResponseSchema.parse(body);
34+
expect(users.length).toBeGreaterThan(0);
35+
});
36+
});

integration-test/tests/cms/about.us.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { aboutUsPageData } from '@utils/datafactory/test-data/about.us.page.data
55
import { PATHS } from '@utils/datafactory/paths.data';
66
import { createOrUpdatePage } from '@utils/helpers/preconditions';
77

8-
test.describe('Validate positive test cases for ABOUT Page API', () => {
8+
test.describe.skip('Validate positive test cases for ABOUT Page API', () => {
99
test.beforeEach(async ({ request }) => {
1010
const url = `${PATHS.PLATFORM_PAGE}?pageType=ABOUT_US`;
1111
await createOrUpdatePage(request, 'ABOUT US Page', url, aboutUsPageData);
@@ -32,7 +32,7 @@ test.describe('Validate positive test cases for ABOUT Page API', () => {
3232
});
3333
});
3434

35-
test.describe('unauthorized request with invalid headers', () => {
35+
test.describe.skip('unauthorized request with invalid headers', () => {
3636
const testData = [
3737
{ description: 'header is empty', headers: { 'X-API-KEY': '' } },
3838
{ description: 'header is invalid', headers: { 'X-API-KEY': 'invalid_key' } },

integration-test/tests/cms/celebrate.her.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { celebrateHerData } from '@utils/datafactory/test-data/celebrate.her.pag
55
import { PATHS } from '@utils/datafactory/paths.data';
66
import { createOrUpdatePage } from '@utils/helpers/preconditions';
77

8-
test.describe('Validate positive test cases for Celebrate Her Page API', () => {
8+
test.describe.skip('Validate positive test cases for Celebrate Her Page API', () => {
99
test.beforeEach(async ({ request }) => {
1010
const url = `${PATHS.PLATFORM_PAGE}?pageType=CELEBRATE_HER`;
1111
await createOrUpdatePage(request, 'CELEBRATE HER Page', url, celebrateHerData);
@@ -32,7 +32,7 @@ test.describe('Validate positive test cases for Celebrate Her Page API', () => {
3232
});
3333
});
3434

35-
test.describe('unauthorized request with invalid headers', () => {
35+
test.describe.skip('unauthorized request with invalid headers', () => {
3636
const testData = [
3737
{ description: 'header is empty', headers: { 'X-API-KEY': '' } },
3838
{ description: 'header is invalid', headers: { 'X-API-KEY': 'invalid_key' } },

integration-test/tests/cms/codeofconduct.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { codeOfConductPageData } from '@utils/datafactory/test-data/codeofconduc
55
import { PATHS } from '@utils/datafactory/paths.data';
66
import { createOrUpdatePage } from '@utils/helpers/preconditions';
77

8-
test.describe('Validate positive test cases for Code Of Conduct Page API', () => {
8+
test.describe.skip('Validate positive test cases for Code Of Conduct Page API', () => {
99
test.beforeEach(async ({ request }) => {
1010
const url = `${PATHS.PLATFORM_PAGE}?pageType=CODE_OF_CONDUCT`;
1111
await createOrUpdatePage(request, 'CODE OF CONDUCT Page', url, codeOfConductPageData);
@@ -32,7 +32,7 @@ test.describe('Validate positive test cases for Code Of Conduct Page API', () =>
3232
});
3333
});
3434

35-
test.describe('unauthorized request with invalid headers', () => {
35+
test.describe.skip('unauthorized request with invalid headers', () => {
3636
const testData = [
3737
{ description: 'header is empty', headers: { 'X-API-KEY': '' } },
3838
{ description: 'header is invalid', headers: { 'X-API-KEY': 'invalid_key' } },

integration-test/tests/cms/collaborators.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { createOrUpdatePage } from '@utils/helpers/preconditions';
66
import { collaboratorsPageData } from '@utils/datafactory/test-data/collaborators.page.data';
77

88

9-
test.describe('Validate positive test cases for COLLABORATORS Page API', () => {
9+
test.describe.skip('Validate positive test cases for COLLABORATORS Page API', () => {
1010
test.beforeEach(async ({ request }) => {
1111
const url = `${PATHS.PLATFORM_PAGE}?pageType=COLLABORATOR`;
1212
await createOrUpdatePage(request, 'COLLABORATORS Page', url, collaboratorsPageData);
@@ -29,7 +29,7 @@ test.describe('Validate positive test cases for COLLABORATORS Page API', () => {
2929
});
3030
});
3131

32-
test.describe('unauthorized request with invalid headers', () => {
32+
test.describe.skip('unauthorized request with invalid headers', () => {
3333
const testData = [
3434
{ description: 'header is empty', headers: { 'X-API-KEY': '' } },
3535
{ description: 'header is invalid', headers: { 'X-API-KEY': 'invalid_key' } },

integration-test/tests/cms/events.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { eventsPageData } from '@utils/datafactory/test-data/events.page.data';
55
import { PATHS } from '@utils/datafactory/paths.data';
66
import { createOrUpdatePage } from '@utils/helpers/preconditions';
77

8-
test.describe('Validate positive test cases for EVENTS Page API', () => {
8+
test.describe.skip('Validate positive test cases for EVENTS Page API', () => {
99
test.beforeEach(async ({ request }) => {
1010
const url = `${PATHS.PLATFORM_PAGE}?pageType=EVENTS`;
1111
await createOrUpdatePage(request, 'EVENTS Page', url, eventsPageData);
@@ -32,7 +32,7 @@ test.describe('Validate positive test cases for EVENTS Page API', () => {
3232
});
3333
});
3434

35-
test.describe('unauthorized request with invalid headers', () => {
35+
test.describe.skip('unauthorized request with invalid headers', () => {
3636
const testData = [
3737
{ description: 'header is empty', headers: { 'X-API-KEY': '' } },
3838
{ description: 'header is invalid', headers: { 'X-API-KEY': 'invalid_key' } },

0 commit comments

Comments
 (0)