Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ name: Run API tests
on:
push:
branches: main

pull_request:
branches: main

workflow_dispatch:

env:
API_TOKEN: ${{ secrets.API_TOKEN }}
Expand Down
22 changes: 22 additions & 0 deletions infra/api/helpers/fixtures/test-fixtures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { PetStoreApi, PokemonApi, Users } from '@api-entities';
import { test as base } from '@playwright/test';

type ApiEntities = {
petStoreApi: PetStoreApi;
usersApi: Users;
pokemonApi: PokemonApi;
}

export const test = base.extend<ApiEntities>({
petStoreApi: async ({ request }, use) => {
await use(new PetStoreApi(request));
},

usersApi: async ({ request }, use) => {
await use(new Users(request));
},

pokemonApi: async ({ request }, use) => {
await use(new PokemonApi(request));
}
});
8 changes: 4 additions & 4 deletions tests/api_tests/goRestApi/GoRestApiTests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test.describe('Api tests for GoRestApi endpoints', async () => {
users = new Users(request);
})

test('sanity check', { tag: [TestTags.GO_REST_API] }, async () => {
test('sanity check - [GET] /users', { tag: [TestTags.GO_REST_API] }, async () => {
await test.step('get users endpoint - validate status, body type of obejct properties and default length of the response', async () => {
let response = await users.getUsers();
expect(response?.status()).toBe(StatusCode.OK)
Expand All @@ -24,7 +24,7 @@ test.describe('Api tests for GoRestApi endpoints', async () => {
/**
* @description there is a bug with this endpoint - it does not authorize any generated toke=n whatsoever
*/
test('gender equality', { tag: [TestTags.GO_REST_API] }, async () => {
test('gender equality - [POST] /users', { tag: [TestTags.GO_REST_API] }, async () => {
await test.step('make an api request to make both male and female genders equal', async () => {
await users.makeBothGendersEven();
let maleGender = await users.getGender('male')
Expand All @@ -33,7 +33,7 @@ test.describe('Api tests for GoRestApi endpoints', async () => {
})
})

test('replace email extension of users', { tag: [TestTags.GO_REST_API] }, async () => {
test('replace email extension of users - [PATCH] /users/:userId', { tag: [TestTags.GO_REST_API] }, async () => {
await test.step('extract extension of each user email and replace each extension with co.il', async () => {
let response = await users.replaceEmailExtensionForUsers()
expect(response?.status()).toBe(StatusCode.OK)
Expand All @@ -45,7 +45,7 @@ test.describe('Api tests for GoRestApi endpoints', async () => {
})
})

test('delete inactive users', { tag: [TestTags.GO_REST_API] }, async () => {
test('delete inactive users - [DELETE] /users/:userId', { tag: [TestTags.GO_REST_API] }, async () => {
await test.step('make a request to delete all users that have an inactive status', async () => {
let response = await users.deleteInactiveUsers()
expect(response?.status()).toBe(StatusCode.UNAUTHORIZED)
Expand Down
12 changes: 6 additions & 6 deletions tests/api_tests/petStore/PetStoreCrudTests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test.describe.serial('CRUD API tests for the Pet Store API', async () => {
petStoreCrudActions = new PetStoreApi(request)
})

test('get a specific pet for sanity checkup', { tag: [TestTags.PET_STORE] }, async () => {
test('get a specific pet for sanity checkup - [GET] /pet/:petId', { tag: [TestTags.PET_STORE] }, async () => {
await test.step('make an api request to a specific pet ID', async () => {
let response = await petStoreCrudActions.getPet(id)
let responseJson: IPet = await response?.json()
Expand All @@ -21,7 +21,7 @@ test.describe.serial('CRUD API tests for the Pet Store API', async () => {
})
})

test('create a new pet', { tag: [TestTags.PET_STORE] }, async () => {
test('create a new pet - [POST] /pet', { tag: [TestTags.PET_STORE] }, async () => {
await test.step('create a new pet via post request', async () => {
let petData = {
id: petId,
Expand All @@ -47,7 +47,7 @@ test.describe.serial('CRUD API tests for the Pet Store API', async () => {
})
})

test('validate the pet existance', { tag: [TestTags.PET_STORE] }, async () => {
test('validate pet exists - [GET] /pet/:petId', { tag: [TestTags.PET_STORE] }, async () => {
await test.step('validate the pet that was created from previous test now exists', async () => {
let response = await petStoreCrudActions.getPet(petId)
let responseBody: IPet = await response?.json();
Expand All @@ -58,15 +58,15 @@ test.describe.serial('CRUD API tests for the Pet Store API', async () => {
})
})

test.skip('create pet image', { tag: [TestTags.PET_STORE] }, async () => {
test.skip('create pet image - [POST] /pet/:petId', { tag: [TestTags.PET_STORE] }, async () => {
await test.step('upload another image to the pet that was created in the previous test', async () => {
let imageFileName: string = 'pug.png'
let response = await petStoreCrudActions.uploadPetImage(petId, imageFileName);
expect(response?.status()).toBe(StatusCode.OK);
})
})

test('update pet', { tag: [TestTags.PET_STORE] }, async () => {
test('update pet - [PATCH] /pet/:petId', { tag: [TestTags.PET_STORE] }, async () => {
await test.step('update the newly created pet that was created in previous test', async () => {
let petData = {
id: petId,
Expand All @@ -91,7 +91,7 @@ test.describe.serial('CRUD API tests for the Pet Store API', async () => {
})
})

test('delete pet', { tag: [TestTags.PET_STORE] }, async () => {
test('delete pet - [DELETE] /pet/:petId', { tag: [TestTags.PET_STORE] }, async () => {
await test.step('delete the pet that was created and updated in previous tests', async () => {
let response = await petStoreCrudActions.deletePet(petId)
expect(response?.status()).toBe(StatusCode.OK)
Expand Down
6 changes: 3 additions & 3 deletions tests/api_tests/pokemon/PokemonApiTests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test.describe('Pokemon API CRUD tests', async () => {
pokemonApi = new PokemonApi(request);
})

test('GET the pokemon resources', { tag: [TestTags.POKEMON_API] }, async () => {
test('GET the pokemon resources - [GET] /pokemon', { tag: [TestTags.POKEMON_API] }, async () => {
await test.step('GET first 20 pokemon resources by default and validate initial response', async () => {
let res = await pokemonApi.getPokemon();
let jsonResponse = await res?.json()
Expand All @@ -27,15 +27,15 @@ test.describe('Pokemon API CRUD tests', async () => {
})
})

test('get all pokemon resources', { tag: [TestTags.POKEMON_API] }, async () => {
test('get all pokemon resources pagination - [GET] /pokemon', { tag: [TestTags.POKEMON_API] }, async () => {
await test.step('get all pokemon recourses via limit and offset pagination', async () => {
let response = await pokemonApi.getAllPokemonRecourses(limit, offset)
let responseLength = response?.length
expect(responseLength).toBe(1304)
})
})

test('response keys type validation', { tag: [TestTags.POKEMON_API] }, async () => {
test('response keys type validation - [GET] /pokemon', { tag: [TestTags.POKEMON_API] }, async () => {
await test.step('validate that each key in the results response object are equals to strings', async () => {
let res = await pokemonApi.getPokemon()
let resJson = await res?.json()
Expand Down