Cart changes
Check what the cart keeps after an update.
- The first quantity enters the cart.
- A later quantity replaces the earlier quantity.
- The cart shows the requested total, without adding the quantities together.
Guided shop project · Playwright
A shop can show a success message and still save the wrong order. Build tests that check what the shop actually keeps. Follow the lessons, then bring your checks into a suite.
What you will build
Check what the cart keeps after an update.
Check the cart after a request is rejected.
Check the order behind the confirmation message.
Bring the checks together with separate setup for each test.
Add an available quantity to the cart. Then request more than the stock limit. Check that the error appears and the cart keeps the earlier quantity.
Each task has a short lesson, a starter test and a checklist. Write the missing checks yourself. Use a hint when you need help. Open a worked solution with an explanation when ready.
Run tests checks the working shop. Verify runs your test against the working shop, then checks each planted break separately. It reports whether your test noticed the changed behaviour.
The editor runs supported Playwright commands in your browser. It is not a full local Playwright installation. Use a wide screen for the editor. Your code and verified runs stay in this browser. They do not sync between devices. If storage is blocked, they last until you leave.
Recorded starter test
Stock-limit teaching task · 2026-10-20
import { test, expect } from '@playwright/test';
test('sets an available cart quantity', async ({ page }) => {
await page.goto('/');
await page.getByLabel('Quantity').fill('1');
await page.getByRole('button', { name: 'Update cart' }).click();
await expect(page.getByTestId('basket-quantity')).toHaveText('1');
});
// Add a check for a rejected quantity.
// Read the stock limit from data-testid="available-stock".
// Check the error and the quantity left in the cart.
Existing practice problems and Verify stay free. Browse free problems.