Skip to content

feat: driver package — execute a scenario against a real LiveDocument - #3

Merged
tannevaled merged 1 commit into
mainfrom
driver-run-package
Nov 10, 2026
Merged

tannevaled merged 1 commit into
mainfrom
driver-run-package

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Summary

Third piece of the automation layer: driver.Run(ctx, live, scenario, doSubmit) executes a parsed scenario's steps against a real engine.LiveDocument.

  • click: resolves the selector (QuerySelector), calls LiveDocument.Click (already a real mousedown/mouseup/click, bubbling).
  • fill: clears the field's CURRENT value via Backspace (one real keydown/input/keyup per character, same as a user deleting it) before Type-ing the new value — never a bulk assignment, so a controlled React/Vue input sees exactly the sequence a real user retyping the field would produce.
  • assert: resolves the selector (failing the run if nothing matches); with a text attribute, compares against the element's own value (input/textarea) or text content (anything else).
  • submit: always computes PreviewSubmit's own dry-run (method/target/body) first; performs the real Submit only when doSubmit is true, swapping in the resulting LiveDocument on a real navigation.

A scenario's pin block, if present, is checked FIRST — URL and every selector must already match, or Run refuses with a single error naming every mismatch found, before any step runs.

No new engine-level capability: every step is a thin call into LiveDocument's already-existing, already-tested primitives.

One real finding while writing the end-to-end test: an inline onclick="..." HTML attribute string is not wired to anything in go-webengine/engine (only addEventListener/the onclick IDL property are) — not a driver bug, just this engine's own documented scope; the test uses addEventListener, matching the engine's own test conventions.

Test plan

  • TestRunClickFillAssert — end to end: fill → click (a real addEventListener handler) → assert the resulting text
  • TestRunFillReplacesExistingValue — fill genuinely replaces a stale value, not appends
  • TestRunAssertSelectorNotFoundFailsTheRun
  • TestRunPinMismatchStopsBeforeAnyStep / TestRunPinURLMismatch
  • TestRunSubmitDryRunDoesNotTouchNetwork — the test server fails if it ever sees a POST
  • TestRunSubmitRealRequestNavigates — doSubmit=true performs the real request and the returned LiveDocument is the new page
  • go build/go vet/gofmt -l/govulncheck ./... clean
  • go test ./... green (29 tests across all three packages), go test ./... -race clean

🤖 Generated with Claude Code

driver.Run(ctx, live, scenario, doSubmit) executes each step in order:

- click: resolves the selector (QuerySelector), calls LiveDocument.Click
  (already a real mousedown/mouseup/click, bubbling).
- fill: clears the field's CURRENT value via Backspace (one real
  keydown/input/keyup per character, same as a user deleting it) before
  Type-ing the new value — never a bulk assignment, so a controlled
  React/Vue input sees exactly the sequence a real user retyping the
  field would produce.
- assert: resolves the selector (failing the run if nothing matches);
  with a text attribute, compares against the element's own value
  (input/textarea) or text content (anything else).
- submit: always computes LiveDocument.PreviewSubmit's own dry-run
  (method/target/body) first; performs the real LiveDocument.Submit only
  when doSubmit is true, swapping in the resulting LiveDocument on a
  real navigation (Submit's own contract already closes the superseded
  one).

A scenario's pin block, if present, is checked FIRST — URL and every
selector must already match, or Run refuses with a single error naming
every mismatch found, before any step runs.

No new engine-level capability: every step is a thin call into
LiveDocument's already-existing, already-tested primitives (confirmed
directly before writing this package).

One real finding while writing the end-to-end test: an inline
onclick="..." HTML attribute string is not wired to anything in
go-webengine/engine (only addEventListener/the onclick IDL property
are) — not a driver bug, just this engine's own documented scope; the
test uses addEventListener, matching the engine's own test conventions.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit b6d081e into main Nov 10, 2026
1 check passed
@tannevaled
tannevaled deleted the driver-run-package branch November 10, 2026 16:14
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.

1 participant