import { test, expect } from './fixtures'; test.describe('Storefront failure states', () => { test('reports a server failure instead of claiming the store is empty', async ({ page, storefront }) => { await page.route('**/api/items*', (route) => route.fulfill({ status: 500, contentType: 'application/json', body: '{"error":"internal error"}' }) ); await storefront.goto(); // Telling a customer "no items yet" when the server is broken is worse than // saying nothing — it reads as an empty catalogue and hides the outage. await expect(storefront.emptyNotice).toBeHidden(); await expect(storefront.loadFailureNotice).toBeVisible(); await expect(storefront.retryButton).toBeVisible(); }); test('recovers when the server comes back', async ({ page, storefront }) => { let failing = true; await page.route('**/api/items*', (route) => { if (failing) { return route.fulfill({ status: 500, contentType: 'application/json', body: '{"error":"internal error"}' }); } return route.continue(); }); await storefront.goto(); await expect(storefront.retryButton).toBeVisible(); failing = false; await storefront.retryButton.click(); await expect(storefront.loadFailureNotice).toBeHidden(); }); test('a request that never resolves does not render as an empty catalogue', async ({ page, storefront }) => { // Mirrors the real incident: an un-migrated database left every item query // hanging with no response at all. await page.route('**/api/items*', () => { /* never fulfilled */ }); await storefront.goto(); await expect(storefront.emptyNotice).toBeHidden(); }); });