-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added scripts for creating and searching a pet (#4)
- Loading branch information
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// @ts-check | ||
import {test, expect} from "@playwright/test" | ||
|
||
test ("Create a new pet", async({request, baseURL}) => { | ||
|
||
const response = await request.post(`${baseURL}pet`, { | ||
data: { | ||
"id": 6199, | ||
"category": { | ||
"id": 2107, | ||
"name": "playwright dog" | ||
}, | ||
"name": "playwright Tommy", | ||
"photoUrls": [ | ||
"string" | ||
], | ||
"tags": [ | ||
{ | ||
"id": 1708, | ||
"name": "black" | ||
} | ||
], | ||
"status": "available" | ||
|
||
} | ||
}); | ||
|
||
// assert that the api is working as expected | ||
expect(response.ok()).toBeTruthy(); | ||
expect(response.status()).toBe(200); | ||
|
||
// saving created pet info | ||
const petDetail = await response.json(); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// @ts-check | ||
import {test, expect} from "@playwright/test" | ||
|
||
test("Create a pet and fetch its detail", async({request, baseURL}) => { | ||
const response = await request.post(`${baseURL}pet`, { | ||
data : { | ||
"id": Date.now(), | ||
"category": { | ||
"id": 8077, | ||
"name": "playwright cat" | ||
}, | ||
"name": "playwright duffy", | ||
"photoUrls": [ | ||
"string" | ||
], | ||
"tags": [ | ||
{ | ||
"id": 7017, | ||
"name": "white" | ||
} | ||
], | ||
"status": "available" | ||
} | ||
}); | ||
|
||
// assert that the api is working as expected | ||
expect(response.ok()).toBeTruthy(); | ||
expect(response.status()).toBe(200); | ||
|
||
// saving the pet id of the newly created pet | ||
const petInfo = await response.json(); | ||
const petId = petInfo.id | ||
|
||
// getting the details of the pet using petid | ||
const getPet = await request.get(`${baseURL}pet/`+petId); | ||
|
||
// assert that the api is working as expected | ||
expect(getPet.ok()).toBeTruthy(); | ||
expect(getPet.status()).toBe(200); | ||
|
||
|
||
// stroing the pet details and assert that the petid is correct | ||
const pet_Info = await getPet.json(); | ||
expect(pet_Info.id).toBe(petId); | ||
|
||
}); |