1+ import { test , expect , request } from '@playwright/test' ;
2+ const backendURL : string = 'https://petstore.swagger.io/v2/store'
3+
4+ test . describe ( 'Testing access to orders in the pet store' , ( ) => {
5+ test ( 'Return pet inventory by status' , async ( ) => {
6+ const context = await request . newContext ( ) ;
7+ const response = await context . get ( `${ backendURL } /inventory` )
8+ expect ( response . status ( ) ) . toBe ( 200 ) ;
9+
10+ const responseBody = await response . json ( ) ;
11+ console . log ( responseBody ) ;
12+ } ) ;
13+
14+ test ( 'Place an order for a pet' , async ( ) => {
15+ const context = await request . newContext ( ) ;
16+ 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+ } ,
25+ } ) ;
26+ expect ( response . status ( ) ) . toBe ( 200 ) ;
27+
28+ const responseBody = await response . json ( ) ;
29+ console . log ( responseBody ) ;
30+ } ) ;
31+ } ) ;
32+
33+ test . describe ( 'Find purchase order by ID' , async ( ) => {
34+ const orderId = 2 ;
35+ test . beforeAll ( async ( ) => {
36+ const context = await request . newContext ( ) ;
37+ 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+ } ,
46+ } ) ;
47+ expect ( response . status ( ) ) . toBe ( 200 ) ;
48+
49+ const responseBody = await response . json ( ) ;
50+ console . log ( responseBody ) ;
51+ } ) ;
52+
53+ test ( 'Find order' , async ( ) => {
54+ const context = await request . newContext ( ) ;
55+ const response = await context . get ( `${ backendURL } /order/${ orderId } ` ) ;
56+ expect ( response . status ( ) ) . toBe ( 200 ) ;
57+
58+ const responseBody = await response . json ( ) ;
59+ console . log ( responseBody ) ;
60+ } ) ;
61+ } ) ;
62+
63+ test . describe ( 'Delete order by ID' , ( ) => {
64+ const orderId = 3 ;
65+ test . beforeAll ( async ( ) => {
66+ const context = await request . newContext ( ) ;
67+ 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+ } ,
76+ } ) ;
77+ expect ( response . status ( ) ) . toBe ( 200 ) ;
78+
79+ const responseBody = await response . json ( ) ;
80+ console . log ( responseBody ) ;
81+ } ) ;
82+
83+ test ( 'Delete order' , async ( ) => {
84+ const context = await request . newContext ( ) ;
85+ const response = await context . delete ( `${ backendURL } /order/${ orderId } ` ) ;
86+ expect ( response . status ( ) ) . toBe ( 200 ) ;
87+
88+ const responseBody = await response . json ( ) ;
89+ console . log ( responseBody ) ;
90+ } ) ;
91+
92+ test . afterAll ( async ( ) => {
93+ const context = await request . newContext ( ) ;
94+ const response = await context . delete ( `${ backendURL } /order/${ orderId } ` ) ;
95+ expect ( response . status ( ) ) . toBe ( 404 ) ;
96+
97+ const responseBody = await response . json ( ) ;
98+ console . log ( responseBody ) ;
99+ } ) ;
100+ } ) ;
0 commit comments