Мазмұнға өту
Мақала Kazakh тілінде әлі жарияланбаған. 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

LayerTargetSpeedWhat It Guarantees
1. Pure Unit TestsState machines, RRF fusion, quota math, slugifiersMillisecondsCore domain invariants hold across edge cases
2. Contract & Catalog TestsShared Zod schemas, SQL RPC contracts, i18n paritySecondsWeb, worker, DB, and locales never drift out of sync
3. Workflow Replay TestsSaved workflow event histories replayed against new codeSecondsZero-downtime deployments never break in-flight executions
4. Offline AI / RAG EvalsGolden retrieval + judge rubrics on fixed fixturesSeconds-minutesPrompt and model changes do not regress accuracy
5. Real Browser E2E (Playwright)Auth, inbox, builder flows, responsive mobile layoutsMinutesReal 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:

Бұл пайдалы болды ма?