Skip to content

Commit 2f5c156

Browse files
committed
fix folder name + few logic and test modifications
1 parent ee47064 commit 2f5c156

File tree

10 files changed

+59
-59
lines changed

10 files changed

+59
-59
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
test:
1313
timeout-minutes: 60
1414
runs-on: ubuntu-latest
15-
# strategy:
16-
# fail-fast: false
17-
# matrix:
18-
# greps: ['@PET_STORE, @POKEMON_API']
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
greps: ['@PET_STORE_API, @POKEMON_API']
1919
steps:
2020
- uses: actions/checkout@v3
2121
- uses: actions/setup-node@v3
@@ -30,6 +30,6 @@ jobs:
3030
- uses: actions/upload-artifact@v3
3131
if: always()
3232
with:
33-
name: playwright-report
33+
name: playwright-report-${{ matrix.greps }}
3434
path: playwright-report/
3535
retention-days: 30

infra/api/apiRequests/ApiRequests.ts renamed to infra/api/apiClient/ApiClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ export interface ApiOptionalParams<T> {
3636
}
3737

3838

39-
export class ApiRequests {
39+
export class ApiClient {
4040
constructor(public apiRequestContext: APIRequestContext) {
4141
this.apiRequestContext = apiRequestContext
4242
}
4343

4444
/**
45-
* @description resuable code to add the authorization header is an authorization is requiired to make the request
45+
* @description resuable code to add the authorization header if an authorization is requiired to make the request
4646
* @param headers
4747
*/
4848
private async addAuthorizationHeader(headers: { [key: string]: string }) {

infra/api/entities/gorestapi/Users.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { APIResponse } from "@playwright/test";
2-
import { ApiRequests, RequestMethods } from "../../apiRequests/ApiRequests";
2+
import { ApiClient, RequestMethods } from "../../apiClient/ApiClient";
33
import Randomizer from "../../helpers/faker/Randomizer";
44
import { ApplicationUrl } from "../../helpers/urls/ApplicationUrl";
55

6-
export class Users extends ApiRequests {
6+
export class Users extends ApiClient {
77
private usersEnpoint = `${ApplicationUrl.GO_REST_API}/users`
88

99
public async getUsers() {
@@ -41,25 +41,25 @@ export class Users extends ApiRequests {
4141
if (maleUsers === femaleUsers) {
4242
return response;
4343
} else if (maleUsers > femaleUsers) {
44-
let femaleData = {
45-
id: Randomizer.getRandomNumber(),
46-
name: Randomizer.getRandomFemaleFirstName(),
47-
email: Randomizer.getRandomEmail(),
48-
gender: 'female',
49-
status: 'active',
50-
}
5144
for (let i = 0; i < differrence; i++) {
45+
let femaleData = {
46+
id: Randomizer.getRandomNumber(),
47+
name: Randomizer.getRandomFemaleFirstName(),
48+
email: Randomizer.getRandomEmail(),
49+
gender: 'female',
50+
status: 'active',
51+
}
5252
response = await this.post(this.usersEnpoint, femaleData, { authoriaztionRequired: true })
5353
}
5454
} else {
55-
let maleData = {
56-
id: Randomizer.getRandomNumber(),
57-
name: Randomizer.getRandomMaleFirstName(),
58-
email: Randomizer.getRandomEmail(),
59-
gender: 'male',
60-
status: 'active',
61-
}
6255
for (let i = 0; i < differrence; i++) {
56+
let maleData = {
57+
id: Randomizer.getRandomNumber(),
58+
name: Randomizer.getRandomMaleFirstName(),
59+
email: Randomizer.getRandomEmail(),
60+
gender: 'male',
61+
status: 'active',
62+
}
6363
response = await this.post(this.usersEnpoint, maleData, { authoriaztionRequired: true })
6464
}
6565
}

infra/api/entities/petStore/PetStoreCrudActions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { APIRequestContext, APIResponse } from "@playwright/test";
2-
import { ApiRequests } from "../../apiRequests/ApiRequests";
2+
import { ApiClient } from "../../apiClient/ApiClient";
33
import { ApiEndpoints } from "../../endpoints/ApiEndpoints";
44
import { ApplicationUrl } from "../../helpers/urls/ApplicationUrl";
55
import path from "path";
66
import Randomizer from "../../helpers/faker/Randomizer";
77
import fs from 'fs'
88

9-
export class PetStoreCrudActions extends ApiRequests {
9+
export class PetStoreCrudActions extends ApiClient {
1010

1111
private petStorePetEndpoint = `${ApplicationUrl.PET_STORE_URL}/${ApiEndpoints.PET}`
1212

infra/api/entities/pokemon/PokemonApi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { APIRequestContext, APIResponse, expect } from "@playwright/test";
2-
import { ApiRequests, RequestMethods, StatusCode } from "../../apiRequests/ApiRequests";
2+
import { ApiClient, RequestMethods, StatusCode } from "../../apiClient/ApiClient";
33
import { ApplicationUrl } from "../../helpers/urls/ApplicationUrl";
44

5-
export class PokemonApi extends ApiRequests {
5+
export class PokemonApi extends ApiClient {
66
private POKEMON_BASE_URL = ApplicationUrl.POKEMON_URL;
77
private POKEMON_ENDPOINT = `${this.POKEMON_BASE_URL}/pokemon`;
88

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"author": "",
99
"license": "ISC",
1010
"devDependencies": {
11-
"@playwright/test": "^1.40.0",
11+
"@playwright/test": "^1.43.0",
1212
"@types/node": "^20.10.0",
1313
"typescript": "^5.3.2"
1414
},

tests/api_tests/goRestApi/GoRestApiTests.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { test, request, expect } from '@playwright/test'
2-
import { StatusCode } from '../../../infra/api/apiRequests/ApiRequests';
2+
import { StatusCode } from '../../../infra/api/apiClient/ApiClient';
33
import { IUser } from '../../../infra/api/helpers/interfaces/ApiObjectsInterfaces';
44
import { Users } from '../../../infra/api/entities/gorestapi/Users';
55

@@ -12,15 +12,15 @@ test.describe('Api tests for GoRestApi endpoints', async () => {
1212
})
1313

1414

15-
test.skip('get all users', async () => {
15+
test.skip('get all users', { tag: ['@GO_REST_API'] }, async () => {
1616
await test.step('get all users from all pages from users endpoint', async () => {
1717
let res = await users.getAllUsers(pageNumber)
1818
expect(res.every(res => res.status())).toBe(StatusCode.OK)
1919
})
2020
})
2121

2222

23-
test('sanity check', async () => {
23+
test('sanity check', { tag: ['@GO_REST_API'] }, async () => {
2424
await test.step('get users endpoint - validate status, body type of obejct properties and default length of the response', async () => {
2525
let response = await users.getUsers();
2626
expect(response?.status()).toBe(StatusCode.OK)
@@ -34,7 +34,7 @@ test.describe('Api tests for GoRestApi endpoints', async () => {
3434
/**
3535
* @description there is a bug with this endpoint - it does not authorize any generated toke=n whatsoever
3636
*/
37-
test.skip('gender equality', async () => {
37+
test.skip('gender equality', { tag: ['@GO_REST_API'] }, async () => {
3838
await test.step('make an apir equest to make both male and female genders equal', async () => {
3939
let response = await users.makeBothGendersEven();
4040
expect(response?.status()).toBe(StatusCode.OK)
@@ -44,7 +44,7 @@ test.describe('Api tests for GoRestApi endpoints', async () => {
4444
})
4545
})
4646

47-
test('replace email extension of users', async () => {
47+
test('replace email extension of users', { tag: ['@GO_REST_API'] }, async () => {
4848
await test.step('extract extension of each user email and replace each extension with co.il', async () => {
4949
let response = await users.replaceEmailExtensionForUsers()
5050
expect(response?.status()).toBe(StatusCode.OK)
@@ -54,7 +54,7 @@ test.describe('Api tests for GoRestApi endpoints', async () => {
5454
})
5555
})
5656

57-
test('delete inactive users', async () => {
57+
test('delete inactive users', { tag: ['@GO_REST_API'] }, async () => {
5858
await test.step('make a request to delete all users that have an inactive status', async () => {
5959
let response = await users.deleteInactiveUsers()
6060
expect(response?.status()).toBe(StatusCode.UNAUTHORIZED)

tests/api_tests/petStore/PetStoreCrudTests.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect, test } from '@playwright/test'
22
import { PetStoreCrudActions } from '../../../infra/api/entities/petStore/PetStoreCrudActions'
33
import { STATUS_CODES } from 'http';
4-
import { StatusCode } from '../../../infra/api/apiRequests/ApiRequests';
4+
import { StatusCode } from '../../../infra/api/apiClient/ApiClient';
55
import { Ipet } from '../../../infra/api/helpers/interfaces/ApiObjectsInterfaces';
66
import Randomizer from '../../../infra/api/helpers/faker/Randomizer';
77

@@ -15,7 +15,7 @@ test.describe.serial('CRUD API tests for the Pet Store API', async () => {
1515
petStoreCrudActions = new PetStoreCrudActions(request)
1616
})
1717

18-
test('get a specific pet for sanity checkup @PET_STORE', async () => {
18+
test('get a specific pet for sanity checkup', { tag: ['@PET_STORE_API'] }, async () => {
1919
await test.step('make an api request to a specific pet ID', async () => {
2020
let response = await petStoreCrudActions.getPet(id)
2121
let responseJson: Ipet = await response?.json()
@@ -24,7 +24,7 @@ test.describe.serial('CRUD API tests for the Pet Store API', async () => {
2424
})
2525
})
2626

27-
test('create a new pet @PET_STORE', async () => {
27+
test('create a new pet', { tag: ['@PET_STORE_API'] }, async () => {
2828
await test.step('create a new pet via post request', async () => {
2929
let petData = {
3030
id: petId,
@@ -50,7 +50,7 @@ test.describe.serial('CRUD API tests for the Pet Store API', async () => {
5050
})
5151
})
5252

53-
test('validate the pet existance @PET_STORE', async () => {
53+
test('validate the pet existance', { tag: ['@PET_STORE_API'] }, async () => {
5454
await test.step('validate the pet that was created from previous test now exists', async () => {
5555
let response = await petStoreCrudActions.getPet(petId)
5656
let responseBody: Ipet = await response?.json();
@@ -61,15 +61,15 @@ test.describe.serial('CRUD API tests for the Pet Store API', async () => {
6161
})
6262
})
6363

64-
test.skip('create pet image @PET_STORE', async () => {
64+
test.skip('create pet image', { tag: ['@PET_STORE_API'] }, async () => {
6565
await test.step('upload another image to the pet that was created in the previous test', async () => {
6666
let imageFileName: string = 'pug.png'
6767
let response = await petStoreCrudActions.uploadPetImage(petId, imageFileName);
6868
expect(response?.status()).toBe(StatusCode.OK);
6969
})
7070
})
7171

72-
test('update pet @PET_STORE', async () => {
72+
test('update pet', { tag: ['@PET_STORE_API'] }, async () => {
7373
await test.step('update the newly created pet that was created in previous test', async () => {
7474
let petData = {
7575
id: petId,
@@ -94,7 +94,7 @@ test.describe.serial('CRUD API tests for the Pet Store API', async () => {
9494
})
9595
})
9696

97-
test('delete pet @PET_STORE', async () => {
97+
test('delete pet', { tag: ['@PET_STORE_API'] }, async () => {
9898
await test.step('delete the pet that was created and updated in previous tests', async () => {
9999
let response = await petStoreCrudActions.deletePet(petId)
100100
expect(response?.status()).toBe(StatusCode.OK)

tests/api_tests/pokemon/PokemonApiTests.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect, test } from '@playwright/test'
22
import { PokemonApi } from '../../../infra/api/entities/pokemon/PokemonApi'
3-
import { ApiRequests, StatusCode } from '../../../infra/api/apiRequests/ApiRequests'
3+
import { ApiClient, StatusCode } from '../../../infra/api/apiClient/ApiClient'
44
import { IpokemonResults } from '../../../infra/api/helpers/interfaces/ApiObjectsInterfaces'
55

66
test.describe('Pokemon API CRUD tests', async () => {
@@ -12,13 +12,13 @@ test.describe('Pokemon API CRUD tests', async () => {
1212
pokemonApi = new PokemonApi(request);
1313
})
1414

15-
test('GET the pokemon resources @POKEMON_API', async () => {
15+
test('GET the pokemon resources', { tag: ['@POKEMON_API'] }, async () => {
1616
await test.step('GET first 20 pokemon resources by default and validate initial response', async () => {
1717
let res = await pokemonApi.getPokemon();
1818
let jsonResponse = await res?.json()
1919
expect(res?.status()).toBe(StatusCode.OK)
2020
expect(jsonResponse).toEqual(expect.objectContaining({
21-
count: 1292,
21+
count: 1302,
2222
next: "https://pokeapi.co/api/v2/pokemon?offset=20&limit=20",
2323
previous: null,
2424
results: expect.any(Array)
@@ -27,16 +27,16 @@ test.describe('Pokemon API CRUD tests', async () => {
2727
})
2828
})
2929

30-
test('get all pokemon resources @POKEMON_API', async () => {
30+
test('get all pokemon resources', { tag: ['@POKEMON_API'] }, async () => {
3131
await test.step('get all pokemon recourses via limit and offset pagination', async () => {
3232
let response = await pokemonApi.getAllPokemonRecourses(limit, offset, { limitOffsetPagination: true })
3333
let responseLength = response.length
34-
expect(responseLength).toBe(1292)
34+
expect(responseLength).toBe(1302)
3535
})
3636
})
3737

3838

39-
test('response keys type validation @POKEMON_API', async () => {
39+
test('response keys type validation', { tag: ['@POKEMON_API'] }, async () => {
4040
await test.step('validate that each key in the results response object are equals to strings', async () => {
4141
let res = await pokemonApi.getPokemon()
4242
let resJson = await res?.json()

0 commit comments

Comments
 (0)