Skip to content

Add Playwright end-to-end tests - #93

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1789504419-playwright-e2e
Open

devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1789504419-playwright-e2e

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Adds a Playwright suite under e2e/ (26 tests, @playwright/test 1.63.0) that runs against the full src/docker-compose.yml stack, plus a GitHub Actions workflow that runs it on every PR and push to main. Getting the stack to a state where these tests could run required a few small repo fixes, listed below.

What is tested (e2e/tests/*.spec.ts)

  • health.spec.ts/healthz returns 200 Healthy on the gateway and all five services.
  • swagger.spec.ts — Swagger UI loads in Chromium for Notification and Customer (title, operations visible); swagger/v1/swagger.json is a valid OpenAPI 3 doc for every service.
  • gateway.spec.ts — every routed list endpoint returns 200 JSON through YARP; unknown path is 404.
  • customers.spec.ts / products.spec.ts — create → get → list → update → delete round-trip through the gateway, then 404 on re-read/re-delete; 404 for unknown id; 400 for a malformed body.
  • notification.spec.tsPOST .../events/order-placed → 201 with {id, previewUrl}; GET /{id} returns the stored event data and renderedSubject: 'Order Confirmed — $149.99'; /preview opened in the browser renders the order summary card with the customer name, order number, and total as $1,234.56; edge cases $0.05, $1.00, $10,000.00; 404 for unknown id/preview.

Note on gateway paths: YARP only strips the /api/<plural> prefix, so the downstream controller route must be repeated, e.g. GET /api/customers/api/customer. e2e/helpers/urls.ts centralises this. I left the gateway config unchanged.

Note on amounts: NotificationRenderer.FormatCurrency documents TotalAmount as cents and divides by 100, so the tests send cents (14999$149.99).

How to run

cd e2e
npm ci
npx playwright install --with-deps chromium
npm run test:e2e          # webServer hook runs docker compose up --build and waits for /healthz
npm run stack:down        # docker compose down -v

BASE_URL (or PLAYWRIGHT_BASE_URL) overrides the gateway URL; SERVICES_HOST / <SERVICE>_URL override direct service URLs; SKIP_WEBSERVER=1 skips compose (CI uses this); POSTGRES_HOST_PORT changes the published Postgres port. Details in e2e/README.md.

Local run: SKIP_WEBSERVER=1 npx playwright test → 26 passed, 0 failed, 0 skipped. Also verified from a torn-down stack via npm run test:e2e (webServer path) → 26 passed.

Repo fixes needed to run the stack

  • Build: *.API.csproj referenced ..\..\Shared\...; the correct path is ..\..\..\Shared\.... Docker builds failed on main without this. (global.json left as-is; it works with the sdk:10.0 image and SDK 10.0.4xx.)
  • Customer/Product CRUD: both controllers were scaffold stubs with no entities. Added minimal EF Core CRUD so a round-trip can be tested:
    CustomerProfile { int Id; string Name; string Email; DateTime CreatedAt }   // POST/PUT body: { name, email }
    ProductItem     { int Id; string Name; string Sku; decimal Price; int StockQuantity; DateTime CreatedAt }
    GET /api/customer | GET,PUT,DELETE /api/customer/{id:int} | POST /api/customer → 201 + Location
    
    DbContext.Database.EnsureCreated() on startup, same as Notification.API.
  • Currency: containers run with the invariant culture, so ToString("C2") rendered ¤149.99. FormatCurrency now uses CultureInfo.GetCultureInfo("en-US").
  • docker-compose: services now depends_on: postgres: condition: service_healthy (with a pg_isready healthcheck) and restart: on-failure. Previously EnsureCreated() raced Postgres startup and Customer/Product/Notification crashed on first boot. Postgres host port is ${POSTGRES_HOST_PORT:-5432}. Removed the obsolete version: key.

CI

.github/workflows/playwright.yml: setup-node 22 → npm ciplaywright install --with-deps chromiumnode scripts/start-stack.mjs (compose up + health wait) → npm run test:e2e → upload playwright-report (always) → dump compose logs on failure → docker compose down -v (always).

No tests are skipped.

Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/62d614c5bc714cae9d77a348597e66c5
Open in Devin Desktop: https://partner-workshops.devinenterprise.com/desktop/session/62d614c5bc714cae9d77a348597e66c5?variant=devin
Requested by: @mbatchelor81

- e2e/ Playwright project (API + browser tests, webServer starts docker compose)
- GitHub Actions workflow running the suite against docker compose
- Fix Shared project reference paths so the services build in Docker
- Customer/Product: minimal EF Core CRUD replacing the scaffold stubs
- Notification: format currency with en-US so containers render $ not ¤
- docker-compose: wait for Postgres health, configurable host port
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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.

1 participant