Technical Documentation — Deterministic Playwright + TypeScript

System Architecture & Implementation Guide

A production-grade Playwright + TypeScript automation architecture for multi-tenant B2B SaaS platforms. Executes deterministic TypeScript in CI while pairing with structured IDE workflows for rapid test authoring, DOM locator diagnostics, and 1:1 Test Management traceability.

4
IDE Workflows
Standardized engineering skills
3-Tier
Environment Isolation
dev (write) • stage (RO) • prod (locked)
0
Raw Selectors in Specs
Enforced by eslint-plugin-playwright
LIFO
Self-Cleaning Data
EntitySupplyManager + Golden ID guard
1 : 1
TMS Step Mapping
1 Test Case Step = 1 Playwright Test
01

Interactive System Map

Select any component to inspect its implementation
Playwright Runner & Setup Chain playwright.config.ts

Every run executes a deterministic 3-stage project dependency chain: auth-setup signs in once with retry resilience, seed-data verifies baseline dev records without blocking, and browser workers run in fresh contexts.

// Project dependency chain in playwright.config.ts
projects: [
  { name: 'auth-setup', testMatch: /auth\.setup\.ts/ },
  {
    name: 'seed-data',
    testMatch: /seed-data\.setup\.ts/,
    dependencies: ['auth-setup'],
    use: { storageState: STORAGE_STATE_PATH },
  },
  {
    name: 'chromium',
    dependencies: ['seed-data'],
    use: { storageState: STORAGE_STATE_PATH },
  },
]
02

Gemini 4 Argon Agentic Skills (.agent/skills/)

👉 Select a skill to explore its workflow

End-to-End Ticket-to-Spec Workflow (.agent/skills/create-tests/SKILL.md)

Most Used Daily

Turns a Jira/Linear/GitHub issue and developer PR diff into Test Management cases, a Page Object, and a verified Playwright spec.

Step 01
Read Ticket & PR Diff

Reads ticket description, comments, and developer PR diff to catch undocumented UI changes or feature flags.

Step 02
Probe Live Dev DOM

Inspects the live page on dev to discover stable data-testid, data-qa, and ARIA role locators.

Step 03
Propose 1:1 Steps

Designs happy-path, negative, and edge steps for user approval before writing code (1 TMS step = 1 test).

Step 04
Write POM & Verify

Extends BasePage, writes the spec with tmsCase() & isDevRun(), and runs lint + type-check.

Interactive DOM Locator Self-Healing (.agent/skills/heal-locators/SKILL.md)

Zero Runtime Overhead

Instead of brittle runtime AI calls that slow down CI, locator healing happens interactively in Antigravity with human confirmation.

Step 01
Parse Failure Trace

Extracts the broken selector, Page Object method, and call site from test-results/.

Step 02
Inspect Live Route

Opens the target route and inspects the current accessibility tree and attributes.

Step 03
Score 3 Candidates (0–100)

Proposes 3 scored replacements ordered by data-testid/qa (98) → role (92) → label (85).

Step 04
Patch & Re-Run

Patches the Page Object in src/pages/ after approval and re-runs the spec to confirm green.

Client Project Onboarding Wizard (.agent/skills/project-setup/SKILL.md)

One-Time Setup

Executed immediately after clicking "Use this template" on GitHub for a new client engagement.

Step 01
Collect Client Context

Asks for tenant names, base URL pattern, primary test attribute, timezone, and TMS URL in one prompt.

Step 02
Confirm Blueprint

Presents a single confirmation table before touching any repository files.

Step 03
Configure Repo

Updates playwright.config.ts, environment.helper.ts, .env.example, and GitHub Actions.

Step 04
Validate Build

Runs npm run lint && npm run type-check and lists all discovered Playwright projects.

Per-Engineer Machine Setup (.agent/skills/local-setup/SKILL.md)

Team Onboarding

Gets any new QA engineer or developer ready to run tests locally in under 2 minutes.

Step 01
Check Prerequisites

Verifies Node.js 20+, npm, git, and GitHub CLI (gh auth status) on the machine.

Step 02
Install & Browsers

Runs npm ci and installs Chromium for local execution.

Step 03
Scaffold .env

Copies .env.example to .env and prompts for local test credentials.

Step 04
Smoke Verification

Executes the smoke suite and prints the daily command cheat sheet.

03

Interactive Environment & Safety Gate Simulator

👉 Test how resolveContext() & isDevRun() protect stage and prod
Resolved Environment
dev (WRITES ALLOWED)
isDevRun() Guard
true → Mutating Specs RUN
Playwright Grep Filter
All Tags (@smoke/@sanity/@regression)
seed-data.setup.ts
ACTIVE (Seeds missing dev records)
04

Interactive Repository Layout Explorer

👉 Click any file in the tree to inspect its code & responsibility
playwright.config.ts Core Runner
GEMINI.md House Rules
eslint.config.mjs Lint Gate
src/pages/base.page.ts UI Toolkit
src/helpers/environment.helper.ts Safety Gate
src/helpers/data-supply.helper.ts Self-Cleaning
src/helpers/auth-token.helper.ts Token Borrow
src/constants/protected-data.constants.ts Golden Data
tests/e2e/smoke/navigation.spec.ts 1:1 Spec
playwright.config.ts URL Resolution & Project Chain

Pins the execution timezone, enforces grep: /@prod-safe/ automatically when ENV=prod, and chains auth-setup → seed-data → browsers.

export default defineConfig({
  timeout: 60_000,
  expect: { timeout: 10_000 },
  /* Automatic production safety lock */
  grep: context.environment === 'prod' ? /@prod-safe/ : undefined,
  use: {
    baseURL: context.baseURL,
    timezoneId: context.timezoneId,
    trace: 'retain-on-failure',
  },
});
05

Enterprise BasePage & Helper Toolkit

Built for complex enterprise SPAs

readAllVirtualizedRows() Virtualized DOM

Scrolls bidirectional virtualized tables from top to bottom, indexing every row by data-index so rows unmounted at the top are preserved in order, and verifies the total against "Showing N entries".

fillSecure() Zero Secret Leaks

Wraps password and API token inputs in Fill secure field [Password] with ***REDACTED*** so sensitive credentials never appear in HTML or Allure step logs.

InMemoryTokenClient Hybrid UI + API

Intercepts the SPA's next outgoing network request to borrow its in-memory Bearer token, enabling authenticated GraphQL and REST backend assertions without storing tokens in localStorage.

FileDownloadInspector Deep File Verification

Parses downloaded streams to verify actual exported content: CSV headers/rows, PDF magic bytes (%PDF-), and ZIP/XLSX binary headers (PK\x03\x04).

06

Daily Commands Cheat Sheet

👉 Click "Copy" on any command block
Run a Single Spec on Dev
ENV=dev npx playwright test tests/e2e/smoke/navigation.spec.ts --project=chromium
Stage Read-Only Smoke Run (@prod-safe)
ENV=stage npx playwright test --grep @prod-safe --project=chromium
Run Against an Ephemeral PR Preview URL
CUSTOM_URL=https://preview.example.com npx playwright test --grep @smoke
Quality Gates (ESLint + Playwright Rules + TypeScript)
npm run lint && npm run type-check