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 2f1fee0

Browse files
Merge pull request #4 from auto-qa-hub/store_tests
Added Store tests and Test Plan
2 parents c4c44f4 + cae6e7e commit 2f1fee0

File tree

2 files changed

+134
-0
lines changed

2 files changed

+134
-0
lines changed

TEST_PLAN.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Test Plan for Swagger Petstore API
2+
3+
## Introduction
4+
This document describes the test plan for automated testing of the PetStore API. The goal of testing is to verify
5+
the correctness of the main endpoints and their compliance with the documentation.
6+
The tests will be implemented using Playwright.
7+
8+
## Test Approach
9+
The testing approach for the PetStore API focuses on verifying that the API aligns with its documented specifications and consistently performs as expected under different conditions.
10+
11+
## Test Types
12+
Functional Testing: Verify that each API endpoint works as expected, including correct CRUD operations (Create, Read, Update, Delete).
13+
Boundary Testing: Test edge cases to ensure the API handles inputs at the extremes (e.g., large data sets, maximum and minimum field values).
14+
Error Handling: Test both positive and negative scenarios, in case the server is designed to handle negative scenarios.
15+
16+
## Risk & Mitigation
17+
- **API Instability**
18+
**Risk**: The Pet Store API may experience downtime or unexpected behavior during testing, leading to test failures or delays.
19+
**Mitigation**: Monitor the API's status and schedule tests during off-peak hours.
20+
21+
- **Incomplete Test Data**
22+
**Risk**: Insufficient test data may result in incomplete test coverage. Without proper data, some scenarios, especially edge cases, may be missed.
23+
**Mitigation**: Develop a well-rounded dataset that includes both positive and negative test cases. This should cover normal use cases and edge conditions.
24+
25+
## Entry Criteria
26+
- API documentation is available and up-to-date.
27+
- Test environment is set up and accessible.
28+
- Test data is prepared and covers key scenarios.
29+
- Playwright is configured.
30+
- API is stable for testing.
31+
32+
## Exit Criteria
33+
- All planned test cases have been executed.
34+
- Test results have been reviewed.

tests/storeTests.spec.ts

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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

Comments
 (0)