Статья ещё не опубликована на языке Russian. Показана версия на English.
Testing Distributed Full-Stack Systems: Unit, Contract, Workflow Replay, and Browser E2E
Опубликовано
2 мин на чтение
Distributed AI SaaS apps fail most painfully at the seams: a shared payload schema drifts between web and worker, a workflow refactor breaks replay of 3-day-old executions, an i18n catalog drops a key in one locale, or a responsive CSS tweak overflows 375px mobile screens. A layered testing strategy catches each defect at the cheapest possible layer.
The Distributed SaaS Testing Pyramid
| Layer | Target | Speed | What It Guarantees |
|---|---|---|---|
| 1. Pure Unit Tests | State machines, RRF fusion, quota math, slugifiers | Milliseconds | Core domain invariants hold across edge cases |
| 2. Contract & Catalog Tests | Shared Zod schemas, SQL RPC contracts, i18n parity | Seconds | Web, worker, DB, and locales never drift out of sync |
| 3. Workflow Replay Tests | Saved workflow event histories replayed against new code | Seconds | Zero-downtime deployments never break in-flight executions |
| 4. Offline AI / RAG Evals | Golden retrieval + judge rubrics on fixed fixtures | Seconds-minutes | Prompt and model changes do not regress accuracy |
| 5. Real Browser E2E (Playwright) | Auth, inbox, builder flows, responsive mobile layouts | Minutes | Real DOM, focus, keyboard, and network behavior work end to end |
Regression-First Bug Fixing
Every production bug fixed without a regression test tends to return three months later during an unrelated refactor. Follow a strict three-step rhythm:
ts
// 1. Reproduce the exact defect in a targeted test first (must fail before fix)
it("rejects out-of-order status downgrade from read back to delivered", () => {
expect(shouldApplyDeliveryStatus("read", "delivered")).toBe(false);
expect(shouldApplyDeliveryStatus("delivered", "read")).toBe(true);
});
// 2. Implement the minimal fix
// 3. Verify the test turns green alongside typecheck and browser checks
Verification Discipline
- Treat flaky or skipped tests as broken tests; quarantine or fix root causes (timers, race conditions, shared global state) rather than ignoring red CI signals.
- Test desktop and narrow mobile viewports (375px) plus light and dark themes on every user-facing UI change.
Explore the other engineering tracks:
Было ли это полезно?