11import { test , expect , request } from '@playwright/test' ;
2+ import ordersData from '../test-data/ordersData.json' ;
23const backendURL : string = 'https://petstore.swagger.io/v2/store'
34
45test . 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
3327test . 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
6349test . 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