WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 5058b57

Browse files
Merge pull request #9 from auto-qa-hub/fixtures-order-data
added fixtures for orders data
2 parents 10f0efb + cb924b0 commit 5058b57

File tree

2 files changed

+33
-29
lines changed

2 files changed

+33
-29
lines changed

test-data/ordersData.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"order1": {
3+
"id": 1,
4+
"petId": 0,
5+
"quantity": 0,
6+
"shipDate": "2025-01-01T17:00:00.000Z",
7+
"status": "placed",
8+
"complete": true
9+
},
10+
"order2": {
11+
"id": 2,
12+
"petId": 0,
13+
"quantity": 0,
14+
"shipDate": "2025-06-01T17:12:00.000Z",
15+
"status": "placed",
16+
"complete": true
17+
},
18+
"order3": {
19+
"id": 3,
20+
"petId": 0,
21+
"quantity": 0,
22+
"shipDate": "2025-06-01T17:12:00.000Z",
23+
"status": "placed",
24+
"complete": true
25+
}
26+
}

tests/storeTests.spec.ts

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {test, expect, request} from '@playwright/test';
2+
import ordersData from '../test-data/ordersData.json';
23
const backendURL: string = 'https://petstore.swagger.io/v2/store'
34

45
test.describe ('Testing access to orders in the pet store', () => {
@@ -14,14 +15,7 @@ test.describe ('Testing access to orders in the pet store', () => {
1415
test('Place an order for a pet', async () => {
1516
const context = await request.newContext();
1617
const response = await context.post(`${backendURL}/order`, {
17-
data: {
18-
"id": 1,
19-
"petId": 0,
20-
"quantity": 0,
21-
"shipDate": "2025-01-01T17:00:00.000Z",
22-
"status": "placed",
23-
"complete": true
24-
},
18+
data: ordersData.order1,
2519
});
2620
expect(response.status()).toBe(200);
2721

@@ -31,18 +25,10 @@ test.describe ('Testing access to orders in the pet store', () => {
3125
});
3226

3327
test.describe('Find purchase order by ID', async () => {
34-
const orderId = 2;
3528
test.beforeAll(async () => {
3629
const context = await request.newContext();
3730
const response = await context.post(`${backendURL}/order`, {
38-
data: {
39-
"id": orderId,
40-
"petId": 0,
41-
"quantity": 0,
42-
"shipDate": "2025-06-01T17:12:00.000Z",
43-
"status": "placed",
44-
"complete": true
45-
},
31+
data: ordersData.order2,
4632
});
4733
expect(response.status()).toBe(200);
4834

@@ -52,7 +38,7 @@ test.describe('Find purchase order by ID', async () => {
5238

5339
test('Find order', async () => {
5440
const context = await request.newContext();
55-
const response = await context.get(`${backendURL}/order/${orderId}`);
41+
const response = await context.get(`${backendURL}/order/${ordersData.order2.id}`);
5642
expect(response.status()).toBe(200);
5743

5844
const responseBody = await response.json();
@@ -61,18 +47,10 @@ test.describe('Find purchase order by ID', async () => {
6147
});
6248

6349
test.describe('Delete order by ID', () => {
64-
const orderId = 3;
6550
test.beforeAll(async () => {
6651
const context = await request.newContext();
6752
const response = await context.post(`${backendURL}/order`, {
68-
data: {
69-
"id": orderId,
70-
"petId": 0,
71-
"quantity": 0,
72-
"shipDate": "2025-06-01T17:12:00.000Z",
73-
"status": "placed",
74-
"complete": true
75-
},
53+
data: ordersData.order3,
7654
});
7755
expect(response.status()).toBe(200);
7856

@@ -82,7 +60,7 @@ test.describe('Delete order by ID', () => {
8260

8361
test('Delete order', async () => {
8462
const context = await request.newContext();
85-
const response = await context.delete(`${backendURL}/order/${orderId}`);
63+
const response = await context.delete(`${backendURL}/order/${ordersData.order3.id}`);
8664
expect(response.status()).toBe(200);
8765

8866
const responseBody = await response.json();
@@ -91,7 +69,7 @@ test.describe('Delete order by ID', () => {
9169

9270
test.afterAll(async () => {
9371
const context = await request.newContext();
94-
const response = await context.delete(`${backendURL}/order/${orderId}`);
72+
const response = await context.delete(`${backendURL}/order/${ordersData.order3.id}`);
9573
expect(response.status()).toBe(404);
9674

9775
const responseBody = await response.json();

0 commit comments

Comments
 (0)