agentleFS
PydanticKnown publisherpydantic/ai-chat-ui/tests/CLAUDE.md

ai-chat-ui / tests

CLAUDE.md71 starsChanged 3 months agoMITView on GitHub

All deterministic tests drive the real FastAPI server at tests/server/server.py, which uses pydantic-ai's FunctionModel to return predictable streams. The models mapping is the authoritative fixture registry. A spec picks an entry via sendMessage(page, '<name>', '<message>'). When you need new behavior, add a FunctionModel to the server's models dict and select it from the spec. Do not introduce page.route mocks — they duplicated the SSE wire format and drifted on the SDK v5→v6 bump, which is why we switched.

  • In this repositoryOne other file it gives its agents.

The file

We split this CLAUDE.md into the rules it gives an agent

9 rules. About 0 are common, 2 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All deterministic tests drive the real FastAPI server at tests/server/server.py, which uses pydantic-ai's FunctionModel to return …

    line 5
  2. Very specific:

    When you need new behavior, add a FunctionModel to the server's models dict and select it from the spec.

    line 7
  3. Very specific:

    Prefer accessible selectors: getByRole, getByPlaceholder, getByText, getByLabel

    line 11
  4. Very specific:

    Use data-testid (or data-tool-name on Tool) only when no semantic selector exists

    line 12
  5. Distinctive:

    Never use CSS selectors or XPath

    line 13
  6. Very specific:

    Use web-first assertions (expect(locator).toBeVisible()) — they auto-retry

    line 23
  7. Very specific:

    Never use page.waitForTimeout() — use expect with auto-retry, page.waitForFunction, or the waitForPersisted helper in e2e/conversation.ts …

    line 24
  8. Very specific:

    Test names: describe user behavior, not implementation (approve runs the tool and shows the result)

    line 42
  9. Distinctive:

    Every new user-facing feature needs at least one deterministic E2E spec

    line 46

≈ “Common” is an estimate: at least 1 in 5 of the 26,980 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

Testing Standards

Paradigm: server-driven, no page.route mocks

All deterministic tests drive the real FastAPI server at tests/server/server.py, which uses pydantic-ai's FunctionModel to return predictable streams. The models mapping is the authoritative fixture registry. A spec picks an entry via sendMessage(page, '<name>', '<message>').

When you need new behavior, add a FunctionModel to the server's models dict and select it from the spec. Do not introduce page.route mocks — they duplicated the SSE wire format and drifted on the SDK v5→v6 bump, which is why we switched.

Selectors

  • Prefer accessible selectors: getByRole, getByPlaceholder, getByText, getByLabel
  • Use data-testid (or data-tool-name on Tool) only when no semantic selector exists
  • Never use CSS selectors or XPath

Test isolation

  • Each test gets a fresh browser context (Playwright default)
  • Tests must not depend on each other or share state
  • The server is shared across tests; specs must be idempotent against shared server state

Assertions

  • Use web-first assertions (expect(locator).toBeVisible()) — they auto-retry
  • Never use page.waitForTimeout() — use expect with auto-retry, page.waitForFunction, or the waitForPersisted helper in e2e/conversation.ts (polls IndexedDB)
  • Assert on user-visible outcomes, not implementation details

File layout

  • tests/server/ — the FastAPI test server (Python, owned by uv)
  • tests/e2e/deterministic/*.spec.ts — Playwright specs against FunctionModel fixtures (run on every PR)
  • tests/e2e/offline/*.spec.ts — Playwright specs against the built offline/index.html, run on every PR under playwright.offline.config.ts (not E2E_TEST_DIR) because they need vite preview serving the artifact rather than the dev server
  • tests/e2e/llm/*.spec.ts — live-provider Playwright specs (gated on workflow_dispatch)
  • tests/e2e/{conversation,sidebar,tools}.ts — shared spec helpers
  • tests/headless/*.test.ts — Vitest tests that exercise the wire protocol directly via TestChat (no browser)
  • tests/chat-client.ts, tests/global-setup.ts — Vitest server-spawn helpers

Naming

  • Playwright spec files: *.spec.ts
  • Vitest headless files: *.test.ts
  • Describe blocks: feature area (chat, sidebar, tool approval)
  • Test names: describe user behavior, not implementation (approve runs the tool and shows the result)

When to add tests

  • Every new user-facing feature needs at least one deterministic E2E spec
  • Bug fixes should include a regression test when feasible
  • New tool-shape behavior (approval, streaming, errors) should be exercised by a headless test in tests/headless/ first, then a deterministic Playwright spec

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.