Skip to content

Add testing framework with 48 unit tests, 8 E2E tests, and demo app#1

Open
aaronDowning wants to merge 3 commits intooojacoboo:mainfrom
aaronDowning:feat/testing-framework
Open

Add testing framework with 48 unit tests, 8 E2E tests, and demo app#1
aaronDowning wants to merge 3 commits intooojacoboo:mainfrom
aaronDowning:feat/testing-framework

Conversation

@aaronDowning
Copy link
Copy Markdown

Summary

I read through the spec and built a testing foundation to validate that the examples are structurally sound and behaviorally correct.

  • 48 unit tests covering Zod schema validation, XState state machine transitions, intent extraction, and registry constraints
  • 8 Playwright E2E tests testing the full pipeline: user types intent → registry matches → flow renders → state machine enforces transitions
  • Demo app — minimal Express app demonstrating the Flow lifecycle with three Flows (overdue payments, pay rent, create work order)
  • Testing guide at docs/guides/testing.md covering the testing strategy for each layer

What's included

Layer Tests What it validates
Schema (Zod) 16 Valid props, boundary values, type safety, defaults
State Machine (XState) 19 Transitions, happy path, error recovery, invalid events
Intent Extraction 10 Entity parsing, defaults, required vs optional fields
Registry 9 Lookup, filtering, duplicate prevention, AI tool generation, constraint enforcement
E2E (Playwright) 8 Full intent→render pipeline, registry blocking, payment lifecycle

How to run

npm install
npm test                    # 48 unit tests (vitest)
npm run test:e2e            # 8 E2E tests (playwright, headless)
npm run test:e2e:headed     # E2E with visible browser
npm run demo                # Run the demo app at localhost:3847

Approach

The src/ implementations are intentionally minimal — just enough to make the spec examples runnable and testable. They validate the contracts described in the docs (intentId format, meta requirements, schema enforcement, state machine behavior) without making assumptions about the production implementation.

Happy to iterate on this — let me know what direction you'd like to take it.

Adds a testing foundation for IntentFlow with three layers:

**Reference implementations (src/)**
Minimal defineFlow, defineIntent, and FlowRegistry that validate
the spec's TypeScript examples are structurally sound.

**Unit tests (tests/) — 48 tests**
- Schema validation: Zod schemas accept valid props, reject boundary
  cases (empty arrays, negative values, invalid enums)
- State machine: XState transitions for happy path, error recovery,
  cancellation, self-transitions, and invalid event handling
- Intent extraction: entity parsing, defaults, required vs optional
- Registry: registration, lookup, filtering, duplicate prevention,
  AI tool definition generation, constraint enforcement

**E2E tests (tests/e2e/) — 8 tests**
- Intent matching: natural language → correct Flow rendered
- Registry constraint: unregistered intents blocked
- State machine: full payment lifecycle in the browser

**Demo app (demo/)**
Minimal Express app demonstrating the full IntentFlow lifecycle:
intent input → registry lookup → schema validation → state machine
transitions → UI rendering. Three Flows: overdue payments, pay rent,
create work order.

**Testing guide (docs/guides/testing.md)**
Strategy guide covering schema, state machine, registry, and intent
testing layers with code examples.

Run: npm test (unit) | npm run test:e2e (browser) | npm run demo (app)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants