riyadhafraa 6c160530fa Add e2e tests for the order placement and cancellation flow
Original task (#65): Persist coverage for the new "Order" + "My Orders"
flow with a Playwright spec under artifacts/teaboy-os/tests/ that places
an order, sees the "Awaiting receiver" pill in /my-orders, cancels it,
and verifies the red cancelled pill replaces the timeline and the
cancel button disappears. Both Arabic and English label paths must be
exercised, and the spec must run under `pnpm --filter @workspace/teaboy-os
test:e2e`.

Implementation
- Added artifacts/tx-os/tests/order-place-cancel.spec.mjs (the artifact
  is now `tx-os`; `teaboy-os` no longer exists, so the spec lives in
  the same tests directory as `leave-group-successor.spec.mjs` and is
  picked up automatically by the existing test:e2e Playwright config).
- Style mirrors leave-group-successor.spec.mjs: file-scoped DB pool,
  per-test seeded user with the `user` role, after-all cleanup that
  deletes the spec's orders, the user's stray orders/notifications,
  user_roles, and the user itself.
- The spec runs the same flow twice, once with English labels and once
  with Arabic labels, driven through a `placeAndCancelFlow(page, lang,
  labels)` helper that:
    1. Forces the UI language via `page.addInitScript` writing the
       `tx-lang` localStorage key BEFORE any page script runs.
    2. Seeds the test user with `preferred_language` matching `lang`,
       because AuthContext + login.tsx call
       `i18n.changeLanguage(user.preferredLanguage)` on login and would
       otherwise override the localStorage seed.
    3. Logs in via the real /login form, navigates to /services,
       clicks the available service tile (matched by aria-label =
       localized name), submits the order modal, and waits for the
       POST /api/orders 201 to capture the order id.
    4. Navigates to /my-orders, asserts the first card contains the
       service name, the pending pill ("Awaiting receiver" / "بانتظار
       المستلِم"), and 4 timeline step circles.
    5. Clicks the in-card Cancel button, confirms via the alertdialog,
       waits for the PATCH /api/orders/:id/status 200 → cancelled.
    6. Asserts the timeline step circles are gone, the centered red
       cancelled pill ("Cancelled" / "ملغى") is present, and the
       Cancel button is removed from the card.

Verification
- `pnpm --filter @workspace/tx-os exec playwright install chromium`
- `cd artifacts/tx-os && pnpm exec playwright test --config
  playwright.config.mjs` → all 6 specs pass (the 4 pre-existing ones +
  the 2 new EN/AR tests).

Deviations
- Task referenced the `teaboy-os` artifact path; the actual artifact in
  this codebase is `tx-os`, so the spec was placed under
  `artifacts/tx-os/tests/` and registered with the existing
  `pnpm --filter @workspace/tx-os test:e2e` script (the original
  `teaboy-os` filter no longer exists).

Replit-Task-Id: d2139d0e-9ee0-4795-8f94-29e1cfe4b35a
2026-04-28 05:37:08 +00:00
2026-04-21 12:16:59 +00:00
2026-04-18 02:00:09 +00:00
2026-04-18 02:00:09 +00:00
2026-04-18 02:00:09 +00:00
S
Description
No description provided
139 MiB
Languages
TypeScript 69.4%
JavaScript 29%
CSS 0.6%
Shell 0.6%
Dockerfile 0.2%
Other 0.2%