Skip to content

Add petstore SPA UI with Playwright e2e tests#14

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/design-ui-for-pet-store
Draft

Add petstore SPA UI with Playwright e2e tests#14
Copilot wants to merge 3 commits into
mainfrom
copilot/design-ui-for-pet-store

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 28, 2026

Adds a vanilla JS single-page application for the petstore covering all APIs, plus a full Playwright test suite that runs against the real Counterfact backend.

UI (ui/index.html)

Single-file SPA with three tabs, no build step required:

  • Pets — browse by status, search by tags, add/edit (modal)/delete
  • Store — live inventory, place/lookup/delete orders
  • Users — list, add, edit, lookup, delete

API base URL defaults to http://localhost:3100; overridable via ?api=<url> query param (used by tests to isolate on port 3101).

Tests (test/petstore.ui.test.ts)

22 Playwright tests across all three tabs, started with npm run test:ui. Config in playwright.config.ts spins up both the Counterfact backend and a serve static file server automatically. Shared TEST_API_URL extracted to test/constants.ts to keep config and tests in sync.

Route handler fixes

Counterfact passes URL path parameters as strings at runtime. All handlers that look up entities by numeric ID now coerce explicitly:

// Before — strict equality against number always false for string "1"
const pet = $.context.getPetById($.path.petId);

// After
const pet = $.context.getPetById(Number($.path.petId));

Affected: pet/{petId}.ts, pet/{petId}/uploadImage.ts, store/order/{orderId}.ts.

package.json scripts

Script Purpose
test Node built-in runner + tsx loader for unit tests
test:ui Playwright e2e suite
start:test Counterfact on port 3101 (test isolation)

Copilot AI linked an issue Apr 28, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Design UI for simple SPA for pet store Add petstore SPA UI with Playwright e2e tests Apr 28, 2026
Copilot AI requested a review from pmcelhaney April 28, 2026 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI

2 participants