Skip to content

Commit 2219fa4

Browse files
authored
Merge pull request #5 from destrutoyt/dev
Add "Add to Cart" test according to Test Plan
2 parents ad72d85 + 35844f9 commit 2219fa4

File tree

5 files changed

+38
-6
lines changed

5 files changed

+38
-6
lines changed

docs/test-plan.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Test Plan for AutomationPractice by Miguel Garces
22
*Project Owner: Miguel Garces*
3-
*Latest Revision: 8/12/2025*
3+
*Latest Revision: 8/13/2025*
44

55
## Project Overview
66
This project performs end-to-end testing to the demo website [Automation Exercise](https://automationexercise.com/). It extensively covers major user flows such as login/registration, product filtering, checkout, and API functionality.
@@ -32,7 +32,7 @@ This project performs end-to-end testing to the demo website [Automation Exercis
3232
| User Login/Logout | UI + Session Handling || Check for session persistence |
3333
| Product Search & Filters | UI || Filter by category and other options available |
3434
| Product Preview | UI || Verifies product information is matches with listing |
35-
| Add to Cart | UI + Validation | 🔄 | Validates product is in the cart |
35+
| Add to Cart | UI + Validation | | Validates product is in the cart |
3636
| Checkout Process | UI | 🔄 | N/A |
3737
| Purchase Confirmation | UI + Validation | 🔄 | Ensure successful purchase and verify product is found in "Orders" |
3838
| Contact Form | UI + Form Validation || N/A |

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "qa-automation-automationexercise",
3-
"version": "2.2",
3+
"version": "2.3",
44
"description": "QA automation project showcasing UI, API, and visual tests for AutomationExercise. Integrated with Docker, Allure, and CI/CD pipelines.",
55
"main": "index.js",
66
"directories": {
@@ -10,8 +10,9 @@
1010
"test": "npx playwright test",
1111
"test:headed": "npx playwright test --headed",
1212
"test:debug": "npx playwright test --debug",
13-
"test:auth": "npx playwright test tests/auth-flow.spec.ts",
14-
"test:product": "npx playwright test tests/product-interactions.spec.ts",
13+
"test:auth": "npx playwright test --grep @AUTH",
14+
"test:product": "npx playwright test --grep @PRODUCT",
15+
"test:cart": "npx playwright test --grep @CART",
1516
"test:allure": "rimraf allure-results && npx playwright test && npx allure generate allure-results --clean -o allure-report && npx allure open allure-report"
1617
},
1718
"repository": {

tests/cart-checkout.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { test, expect } from '@playwright/test'
2+
import { UserLogin } from '../page-objects/Login'
3+
import { ProductTypes } from '../utils/types/productTypes'
4+
import products from '../utils/fixtures/productData.json'
5+
6+
const productData: ProductTypes[] = products.products
7+
8+
test.beforeEach(async ({ page }) => {
9+
const userLogin = new UserLogin(page)
10+
await userLogin.autoLogin() // Uses predefined credentials from loginData.json. Manual login with provided credentials is available.
11+
await page.goto('/products')
12+
})
13+
14+
test.only('@CART - Add product to cart and validate it', async ({ page }) => {
15+
16+
const cartTable = page.locator('#cart_info_table tbody');
17+
let productID : number = productData[0].id;
18+
console.log(productID)
19+
20+
// Add X product to the cart and verify confirmation msg
21+
await page.click(`[data-product-id="${productID}"]`)
22+
await expect(page.locator('.modal-content .modal-header h4')).toHaveText('Added!')
23+
24+
// Goes to "View Cart" and confirms product is in cart
25+
await page.click('.modal-content a[href="/view_cart"]')
26+
await expect(cartTable.locator(`tr#product-${productID}`)).toBeVisible() // getByText() can cause issues if one or more items are named "Blue Top"
27+
})

utils/fixtures/productData.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"products": [
3-
{
3+
{
4+
"id": 1,
45
"name": "Blue Top",
56
"price": "Rs. 500",
67
"category": "Women > Tops",
@@ -10,6 +11,7 @@
1011
"detailsUrl": "/product_details/1"
1112
},
1213
{
14+
"id": 24,
1315
"name": "Colour Blocked Shirt – Sky Blue",
1416
"price": "Rs. 849",
1517
"category": "Kids > Tops & Shirts",
@@ -19,6 +21,7 @@
1921
"detailsUrl": "/product_details/24"
2022
},
2123
{
24+
"id": 43,
2225
"name": "GRAPHIC DESIGN MEN T SHIRT - BLUE",
2326
"price": "Rs. 1389",
2427
"category": "Men > Tshirts",

utils/types/productTypes.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export interface ProductTypes {
2+
id: number;
23
name: string;
34
price: string;
45
category: string;

0 commit comments

Comments
 (0)