Files
marketplaces/e2e/README.md

40 lines
3.1 KiB
Markdown
Raw Normal View History

feat: stand up E2E harness, fix a real bootstrap bug it found Track Q Q1/Q4 (docs/PRODUCT-PLAN-v3.1-DELIVERY-PLAN.md). No E2E existed before this. Playwright chosen - no existing test runner preference, and it needs zero extra infra beyond the dev server this repo already has. - playwright.config.ts, package.json e2e/e2e:ui/e2e:report scripts - e2e/smoke.spec.ts app boots, no console errors (network 404s from the absent backend are filtered - expected, not a bug) - e2e/currency-switch.spec.ts Track Q Q4: switching currency must change the displayed price VALUE, not just the label next to it. Written specifically so the upcoming checkout money-truth rewrite (frontend backlog F10-F16, which replaces client-side FX math with a server-computed total) has a regression net under it before that rewrite starts. The first run found a real, current bug: @marketplaces/auth ships plain tsc output (dist/index.js), not Angular Package Format, so it carries no compiled Ivy DI metadata. Any class-based provider from it - not just the Ed25519 Noop stub, AuthService itself hit the same failure - forces Angular to JIT-compile at runtime, which throws immediately when @angular/compiler isn't loaded. That breaks app bootstrap outright, for real users, not just this test. Fixed here with the minimum honest scope: - src/main.ts: import '@angular/compiler' before bootstrap, so JIT works everywhere the package is injected, not just at one call site - src/app/app.config.ts: useFactory instead of useClass for the Noop Ed25519 provider, since it has zero constructor deps and doesn't need Angular to derive metadata for it at all - angular.json: raised the initial-bundle hard-error budget 1.5MB -> 1.8MB, because the compiler import made a correct build refuse to complete. A build that fails outright is worse than a bundle that's honestly larger than it should be. The real fix belongs in the vitanovaPackages auth repo: publish via ng-packagr so consumers get Ivy-compiled output and none of this is necessary. Do not remove the compiler import until that ships - see the comment left in main.ts. Also fixed a genuine test defect while getting this to a real green: the page renders duplicate .currency-option elements (desktop/mobile variants of the same selector), so the first attempt at this test clicked into a hidden duplicate and silently no-opped. Scoped the click to .currency-dropdown.open and added an explicit poll for the DOM to reflect the new currency before reading it back, rather than trusting a fixed timeout. Verified: 3/3 E2E green, 115/115 unit tests green, arch:check clean, production build succeeds. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 13:46:43 +04:00
# E2E — Playwright
Track Q (`docs/PRODUCT-PLAN-v3.1-DELIVERY-PLAN.md`, Q1). None of this existed before 2026-08-18.
## Run
```bash
npm run e2e # headless, boots the dev server automatically
npm run e2e:ui # interactive runner
npm run e2e:report # last HTML report
```
Against a different server (staging, a locally-started backend):
```bash
BASE_URL=https://staging.example.com npm run e2e
```
## What this suite currently covers, and what it doesn't
`environment.ts` ships `useMockData: false` — the dev server this suite boots hits real `/api/` endpoints, which 404 (`../docs/backend/BACKEND-INTEGRATION.md` — no backend is running anywhere this session can reach). The product catalog itself renders from a separate mocked bootstrap/catalog path (`useMockBootstrapOnLocal: true`), so real prices and real currency conversion ARE exercised — `smoke.spec.ts` explicitly ignores the expected 404 console noise rather than pretending it isn't there.
feat: stand up E2E harness, fix a real bootstrap bug it found Track Q Q1/Q4 (docs/PRODUCT-PLAN-v3.1-DELIVERY-PLAN.md). No E2E existed before this. Playwright chosen - no existing test runner preference, and it needs zero extra infra beyond the dev server this repo already has. - playwright.config.ts, package.json e2e/e2e:ui/e2e:report scripts - e2e/smoke.spec.ts app boots, no console errors (network 404s from the absent backend are filtered - expected, not a bug) - e2e/currency-switch.spec.ts Track Q Q4: switching currency must change the displayed price VALUE, not just the label next to it. Written specifically so the upcoming checkout money-truth rewrite (frontend backlog F10-F16, which replaces client-side FX math with a server-computed total) has a regression net under it before that rewrite starts. The first run found a real, current bug: @marketplaces/auth ships plain tsc output (dist/index.js), not Angular Package Format, so it carries no compiled Ivy DI metadata. Any class-based provider from it - not just the Ed25519 Noop stub, AuthService itself hit the same failure - forces Angular to JIT-compile at runtime, which throws immediately when @angular/compiler isn't loaded. That breaks app bootstrap outright, for real users, not just this test. Fixed here with the minimum honest scope: - src/main.ts: import '@angular/compiler' before bootstrap, so JIT works everywhere the package is injected, not just at one call site - src/app/app.config.ts: useFactory instead of useClass for the Noop Ed25519 provider, since it has zero constructor deps and doesn't need Angular to derive metadata for it at all - angular.json: raised the initial-bundle hard-error budget 1.5MB -> 1.8MB, because the compiler import made a correct build refuse to complete. A build that fails outright is worse than a bundle that's honestly larger than it should be. The real fix belongs in the vitanovaPackages auth repo: publish via ng-packagr so consumers get Ivy-compiled output and none of this is necessary. Do not remove the compiler import until that ships - see the comment left in main.ts. Also fixed a genuine test defect while getting this to a real green: the page renders duplicate .currency-option elements (desktop/mobile variants of the same selector), so the first attempt at this test clicked into a hidden duplicate and silently no-opped. Scoped the click to .currency-dropdown.open and added an explicit poll for the DOM to reflect the new currency before reading it back, rather than trusting a fixed timeout. Verified: 3/3 E2E green, 115/115 unit tests green, arch:check clean, production build succeeds. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 13:46:43 +04:00
**This is not the same guarantee as running against a live backend.** Checkout, payment, and anything behind a real endpoint are not covered until `BASE_URL` points at a live environment. Confirmed once, concretely: on the first run, this suite caught a real bug (`@marketplaces/auth` shipping without Angular Ivy metadata, breaking app bootstrap) and a real test defect (a duplicate hidden dropdown made the first currency-switch attempt click a no-op element) — both fixed as part of standing this suite up. See the commit history in `src/main.ts` and this directory for what each was.
## Files
| File | Covers |
|---|---|
| `currency-switch.spec.ts` | `160 RUB` must not silently become `160 USD` on a currency switch — Track Q Q4, and the regression guard `../docs/backend/BACKEND-INTEGRATION.md` §5 exists to close. Written **before** the checkout money-truth rewrite (F10F16 in the frontend backlog), specifically so that rewrite has a net under it. |
feat: stand up E2E harness, fix a real bootstrap bug it found Track Q Q1/Q4 (docs/PRODUCT-PLAN-v3.1-DELIVERY-PLAN.md). No E2E existed before this. Playwright chosen - no existing test runner preference, and it needs zero extra infra beyond the dev server this repo already has. - playwright.config.ts, package.json e2e/e2e:ui/e2e:report scripts - e2e/smoke.spec.ts app boots, no console errors (network 404s from the absent backend are filtered - expected, not a bug) - e2e/currency-switch.spec.ts Track Q Q4: switching currency must change the displayed price VALUE, not just the label next to it. Written specifically so the upcoming checkout money-truth rewrite (frontend backlog F10-F16, which replaces client-side FX math with a server-computed total) has a regression net under it before that rewrite starts. The first run found a real, current bug: @marketplaces/auth ships plain tsc output (dist/index.js), not Angular Package Format, so it carries no compiled Ivy DI metadata. Any class-based provider from it - not just the Ed25519 Noop stub, AuthService itself hit the same failure - forces Angular to JIT-compile at runtime, which throws immediately when @angular/compiler isn't loaded. That breaks app bootstrap outright, for real users, not just this test. Fixed here with the minimum honest scope: - src/main.ts: import '@angular/compiler' before bootstrap, so JIT works everywhere the package is injected, not just at one call site - src/app/app.config.ts: useFactory instead of useClass for the Noop Ed25519 provider, since it has zero constructor deps and doesn't need Angular to derive metadata for it at all - angular.json: raised the initial-bundle hard-error budget 1.5MB -> 1.8MB, because the compiler import made a correct build refuse to complete. A build that fails outright is worse than a bundle that's honestly larger than it should be. The real fix belongs in the vitanovaPackages auth repo: publish via ng-packagr so consumers get Ivy-compiled output and none of this is necessary. Do not remove the compiler import until that ships - see the comment left in main.ts. Also fixed a genuine test defect while getting this to a real green: the page renders duplicate .currency-option elements (desktop/mobile variants of the same selector), so the first attempt at this test clicked into a hidden duplicate and silently no-opped. Scoped the click to .currency-dropdown.open and added an explicit poll for the DOM to reflect the new currency before reading it back, rather than trusting a fixed timeout. Verified: 3/3 E2E green, 115/115 unit tests green, arch:check clean, production build succeeds. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 13:46:43 +04:00
| `smoke.spec.ts` | App boots, storefront renders, no console errors on first paint. |
feat: start @marketplaces/payment implementation package.json already had @marketplaces/payment added (uncommitted) when this started. Wired it in. - app.config.ts: provideMarketplacesPayment(). apiUrl is environment.qrApiUrl with its trailing /api stripped - found and fixed a real bug while wiring this: qrApiUrl already ends in /api, and the package's default paymentsPath is '/api/v1/payments', so passing qrApiUrl unchanged would have silently doubled the path to .../api/api/v1/payments. Confirmed by reading the package's baseUrl() concatenation directly, not guessed. marketplaceDomain is a plain closure (not TenantResolverService) since provideMarketplacesPayment runs outside the injector. - cart.component.ts: createPaymentIntent() and startPolling() now go through MARKETPLACES_PAYMENT_GATEWAY instead of api.service.ts's createPaymentIntent/checkCartPaymentStatus/checkCartCardPaymentStatus (our own earlier inferred contract, now superseded by the package's real, published one - POST/GET {qrApiUrl}/api/v1/payments). Deliberately did NOT swap to the package's own <mp-payment> UI component - that has a different UX paradigm entirely (window.open for redirects instead of an iframe popup, client-side QR generation instead of an external image service) and replacing the existing, already-tested 769-line popup state machine wholesale is a separate, much larger change than "wire the new package in." Only the I/O layer moved; the surrounding state machine (paymentStatus, checkoutInFlight, timeout/success/error handling, bank-iframe UX) is untouched. Response shape differs from the legacy provider: the package's PaymentStatus is a fixed union (created/pending/authorized/paid/failed/ cancelled/expired), not a free-form string+code pair - simplified the status-check conditionals accordingly and added 'authorized' as a second success state (PaymentResult's own status union), which the legacy check didn't have. The package also carries no TTL/expiry field on its response, unlike the legacy provider's qrTTL - polling duration now falls back to PAYMENT_MIN_POLL_SECONDS alone; flagged in a comment. - api.service.ts's createPaymentIntent and its QrCreateResponse-based resolvePaymentQrId/resolvePaymentQrUrl/resolvePaymentLink/ resolveBankPaymentUrl helpers are now dead code. Left in place rather than deleted in the same pass that adds a new external dependency, so a revert doesn't also need to resurrect deleted code. Verified: production build succeeds, 247/247 unit tests, arch:check clean. E2E: 2 of 7 tests currently fail (checkout-request-shape.spec.ts, checkout-idempotent-click.spec.ts), and this is disclosed honestly rather than hidden. Root cause, confirmed by tracing real network requests: the customer-session cookie fake these tests rely on stops working somewhere between the cookie being demonstrably present in the browser (context.cookies(), and document.cookie read from a plain page on the same origin) and Angular's own AuthService reading it - the session-check request never fires at all. This reproduces with or without this session's payment changes (checkout-idempotent-click.spec.ts doesn't touch payment creation and fails the same way), so it is not a regression introduced here, but it is unresolved. Tried switching context.addCookies from {domain,path} to {url} form (the standard fix for this class of Playwright cookie issue) - did not fix it, kept anyway as the more correct form. Documented as a known, unresolved issue directly in both spec files and e2e/README.md rather than deleting or silently marking the tests skip - the request-shape assertions those tests make are still correct, they are just currently unverifiable through this harness. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-21 09:37:16 +04:00
| `admin-dev-bypass.spec.ts` | `?devBypassAdmin=true` actually reaches the admin shell without a Telegram login (Track Q F59). |
| `checkout-request-shape.spec.ts` | The amount actually charged must be computed server-side, never sent by the client (`PHASE-1-MONEY-FX-PAYMENTS-CONTRACT.md` §5.2). Was red for a real bug, not a harness issue — root-caused 2026-08-21, see the `fakeCustomerSession` comment and `api-headers.interceptor.ts`. |
| `checkout-idempotent-click.spec.ts` | Double-clicking checkout sends exactly one checkout-session request (Track Q F62). Same root cause and fix as above. |
feat: stand up E2E harness, fix a real bootstrap bug it found Track Q Q1/Q4 (docs/PRODUCT-PLAN-v3.1-DELIVERY-PLAN.md). No E2E existed before this. Playwright chosen - no existing test runner preference, and it needs zero extra infra beyond the dev server this repo already has. - playwright.config.ts, package.json e2e/e2e:ui/e2e:report scripts - e2e/smoke.spec.ts app boots, no console errors (network 404s from the absent backend are filtered - expected, not a bug) - e2e/currency-switch.spec.ts Track Q Q4: switching currency must change the displayed price VALUE, not just the label next to it. Written specifically so the upcoming checkout money-truth rewrite (frontend backlog F10-F16, which replaces client-side FX math with a server-computed total) has a regression net under it before that rewrite starts. The first run found a real, current bug: @marketplaces/auth ships plain tsc output (dist/index.js), not Angular Package Format, so it carries no compiled Ivy DI metadata. Any class-based provider from it - not just the Ed25519 Noop stub, AuthService itself hit the same failure - forces Angular to JIT-compile at runtime, which throws immediately when @angular/compiler isn't loaded. That breaks app bootstrap outright, for real users, not just this test. Fixed here with the minimum honest scope: - src/main.ts: import '@angular/compiler' before bootstrap, so JIT works everywhere the package is injected, not just at one call site - src/app/app.config.ts: useFactory instead of useClass for the Noop Ed25519 provider, since it has zero constructor deps and doesn't need Angular to derive metadata for it at all - angular.json: raised the initial-bundle hard-error budget 1.5MB -> 1.8MB, because the compiler import made a correct build refuse to complete. A build that fails outright is worse than a bundle that's honestly larger than it should be. The real fix belongs in the vitanovaPackages auth repo: publish via ng-packagr so consumers get Ivy-compiled output and none of this is necessary. Do not remove the compiler import until that ships - see the comment left in main.ts. Also fixed a genuine test defect while getting this to a real green: the page renders duplicate .currency-option elements (desktop/mobile variants of the same selector), so the first attempt at this test clicked into a hidden duplicate and silently no-opped. Scoped the click to .currency-dropdown.open and added an explicit poll for the DOM to reflect the new currency before reading it back, rather than trusting a fixed timeout. Verified: 3/3 E2E green, 115/115 unit tests green, arch:check clean, production build succeeds. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 13:46:43 +04:00
## Adding a test
- Prefer existing CSS classes / ARIA roles already in the templates (`.currency-button`, `role="option"`, etc.) over inventing new selectors — there are no `data-testid` attributes in this codebase yet, and adding them project-wide is out of scope for this suite.
- One behavior per test. Name the file after the behavior, not the page.
- If a test needs backend state that mock data can't produce, mark it `test.skip(!process.env.BASE_URL, 'needs a live backend')` rather than deleting it — it documents the gap.