← Back to Stage 4
Stage 4#421Coding · Senior~10 min read

Write the reload recovery Playwright scenario

Testing + Tooling Drills · End-to-End Recovery

Submit a transfer, persist local pending state, reload, show pending, poll backend, and transition to reconciled.

Prompt

Write the reload recovery Playwright scenario

This is a hands-on rep. Attempt the drill before reading the model answer, then narrate the tradeoffs as if an interviewer is watching.

💡
Tip

This is the scenario that proves the architecture works for users.

Foundation

What to ground before answering

Submit a transfer, persist local pending state, reload, show pending, poll backend, and transition to reconciled.

Focus vocabulary: Playwright, reload, pending state.

The useful mental model is not to memorize a perfect answer. It is to explain what owns the data, what can fail, what the user sees, and what test would prove the behavior.

Coding drill

Recover pending state after reload

Target: 20mNot run

Make the behavior executable before comparing against the model answer.

type LocalPending = { clientOperationId: string; txHash?: string };
type BackendTransfer = { id: string; clientOperationId?: string; status: 'submitted' | 'reconciled' };

function recoverTransferView(local: LocalPending | null, backend: BackendTransfer | null): string {
  // TODO: derive the user-visible state after page reload.
  return 'empty';
}
TypeScript · runnable
System design

Interview explanation prompt

  • What problem is this practice item really testing?
  • What state or contract boundary must be explicit?
  • What edge case would cause a production regression?
  • What would you test first?
  • How would you explain the tradeoff in two minutes?
Self-grade

Self-grade

  • Strong answer handles the edge cases before polishing syntax.
  • Strong answer explains why the chosen type or function boundary prevents bugs.
  • Weak answer passes only the happy path or hides uncertainty in booleans and nullable fields.

Model Answer

function recoverTransferView(local: LocalPending | null, backend: BackendTransfer | null): string {
  if (backend?.status === 'reconciled') return 'complete';
  if (backend) return 'backend-pending';
  if (local) return 'local-pending';
  return 'empty';
}
Review

Recall before moving on

  • What is the one-sentence answer for "Write the reload recovery Playwright scenario"?
  • Which real experience from PR TIMES, React/TypeScript migration, or systems work supports it?
  • What edge case would you volunteer before the interviewer asks?
  • What is the smallest test or artifact that proves the design works?