E2E: booking flow test fails — time slot buttons not found #65

Closed
opened 2026-03-19 12:47:43 +00:00 by ghost · 1 comment
ghost commented 2026-03-19 12:47:43 +00:00 (Migrated from github.com)

Problem

apps/e2e/tests/book.spec.ts:62 (complete booking flow) consistently fails:

Locator: getByRole('button', { name: /\d{1,2}:\d{2}/ })
Error: element(s) not found

The test expects time slot buttons to be visible but none appear. This happens consistently on feature branches but passes on main.

Possible causes

  • Test data seeding issue — no services/staff/availability configured in E2E environment
  • Timing issue with branding context fetch causing delayed render
  • Date-dependent availability logic

Impact

Non-blocking for unrelated PRs, but creates CI noise. Appeared in PRs #64 (merged despite this failure as changes were unrelated).

Expected fix

Investigate the E2E test setup to ensure booking time slots are properly seeded, or adjust the test to handle empty availability gracefully.

## Problem `apps/e2e/tests/book.spec.ts:62` (complete booking flow) consistently fails: ``` Locator: getByRole('button', { name: /\d{1,2}:\d{2}/ }) Error: element(s) not found ``` The test expects time slot buttons to be visible but none appear. This happens consistently on feature branches but passes on main. ## Possible causes - Test data seeding issue — no services/staff/availability configured in E2E environment - Timing issue with branding context fetch causing delayed render - Date-dependent availability logic ## Impact Non-blocking for unrelated PRs, but creates CI noise. Appeared in PRs #64 (merged despite this failure as changes were unrelated). ## Expected fix Investigate the E2E test setup to ensure booking time slots are properly seeded, or adjust the test to handle empty availability gracefully.
ghost commented 2026-03-19 12:57:06 +00:00 (Migrated from github.com)

Root Cause

The VitePWA workbox configuration includes runtimeCaching for /api/* requests with a NetworkFirst strategy. When the service worker activates during the E2E test, it intercepts API requests before Playwright's page.route() mocks can handle them. This means the availability mock is bypassed, the request hits the real API server (which returns empty availability since no data is seeded), and no time slot buttons are rendered.

The test fails intermittently between main/branches because the timing of service worker activation varies — if the SW activates before the availability fetch fires, the mock is bypassed; if not, it works.

Fix

PR #66 adds serviceWorkers: 'block' to the Playwright config, preventing the service worker from activating during E2E tests. This is Playwright's recommended approach when using page.route() for request interception.

## Root Cause The VitePWA workbox configuration includes `runtimeCaching` for `/api/*` requests with a `NetworkFirst` strategy. When the service worker activates during the E2E test, it intercepts API requests **before** Playwright's `page.route()` mocks can handle them. This means the availability mock is bypassed, the request hits the real API server (which returns empty availability since no data is seeded), and no time slot buttons are rendered. The test fails intermittently between main/branches because the timing of service worker activation varies — if the SW activates before the availability fetch fires, the mock is bypassed; if not, it works. ## Fix PR #66 adds `serviceWorkers: 'block'` to the Playwright config, preventing the service worker from activating during E2E tests. This is Playwright's [recommended approach](https://playwright.dev/docs/service-workers-experimental) when using `page.route()` for request interception.
This repo is archived. You cannot comment on issues.
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: groombook/app#65