API: product search, sorting and a 404
App: TrendKart, a practice fashion marketplace (Myntra-style). Login: Guest checkout works; members: arya@trendkart.test / Trendy@123 or register. REST API: tests call it as /api/... through the request fixture or page.request; GET /api lists every endpoint ↗.
Interview scenario
"The search API backs the whole listing page. Test GET /api/products: 'shirt' returns 5 products whose names all contain Shirt, sort=price_asc comes back ascending, a product can be fetched by id, and an unknown id is a 404."
Acceptance criteria
- GET /api/products?q=shirt: total 5 and every item name contains 'shirt' (case-insensitive).
- GET /api/products?q=shirt&sort=price_asc: prices ascend.
- GET /api/products/104: name Men Printed Round Neck T-shirt, price 399, sizes include M.
- GET /api/products/999: status 404, error.code not_found.
Runs in your browser with a Playwright-compatible API: locators, auto-waiting actions, expect, imports between files and test.extend fixtures. Saved in this browser. Ctrl/⌘ + Enter runs.
Test output
Press Run tests to watch your code drive the practice app in the preview.
Reference solution
Try it yourself first. Then compare with the Playwright solution and the same test in Selenium Java with TestNG.