Skip to content

Journeys: eval <js> and wait --fn <expression>; Page.WaitForFunctionAsync - #71

Merged
Mpdreamz merged 3 commits into
mainfrom
feature/journey-eval-wait-fn
Dec 2, 2026
Merged

Mpdreamz merged 3 commits into
mainfrom
feature/journey-eval-wait-fn

Conversation

@Mpdreamz

@Mpdreamz Mpdreamz commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Closes #70
Closes #52

  • Page.WaitForFunctionAsync(expression, timeout, pollInterval): polls until truthy and returns the value as JSON; a promise is awaited (the first version did not await a promise inside its wrapper; fixed and tested).
  • Journeys: eval <js> is a checkpoint recording the result as JSON (undefined when none); wait --fn <expression> polls until truthy, up to the navigation timeout, and a throwing expression fails the step. Both in Nullean.Cdp.Journeys and in @nullean/journeys (the shared error fixtures and usage strings are updated), and both export to agent-browser unchanged.
  • wait --download stays refused; DECISIONS.md, the command reference and READMEs are updated.

Tested: mise run test (536 pass, live Chrome); journeys-js typecheck, npm test and live tests. Mutation check: stubbing the runner's wait --fn makes the two new live tests fail.

🤖 Generated with Claude Code

@Mpdreamz Mpdreamz added the feature A new capability (minor bump) label Dec 2, 2026
@Mpdreamz
Mpdreamz force-pushed the feature/journey-eval-wait-fn branch from af63d8e to b6a3792 Compare December 2, 2026 15:51
Mpdreamz and others added 3 commits December 2, 2026 16:54
Polls a JS expression until it is truthy and returns its value, with a timeout and poll interval.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
eval records the expression's value as a JSON checkpoint (a promise is awaited); wait --fn polls
Page.WaitForFunctionAsync until it is truthy. Both in the .NET runner and in @nullean/journeys, and both export
to agent-browser unchanged. Also fixes WaitForFunctionAsync not awaiting a promise inside its wrapper.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ailure on Windows

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Mpdreamz
Mpdreamz force-pushed the feature/journey-eval-wait-fn branch from b6a3792 to 52ec655 Compare December 2, 2026 15:54
@Mpdreamz
Mpdreamz merged commit 66013b3 into main Dec 2, 2026
14 checks passed
@Mpdreamz
Mpdreamz deleted the feature/journey-eval-wait-fn branch December 2, 2026 16:33
Mpdreamz added a commit to nullean/snapshots that referenced this pull request Dec 3, 2026
## Why

nullean/pagefind-net's E2E tests assert on what a page's JS API returns
(`window.pagefind.search(term)` → result URLs and count), which a
`.journey` could not express, so they dropped down to
`Page.EvaluateAsync`. Journey steps live in Nullean.Cdp.Journeys; the
steps asked for shipped in Nullean.Cdp 0.14.0 (nullean/cdp#70, via
nullean/cdp#71), so this takes the pin.

## What

- `Nullean.Cdp` and `Nullean.Cdp.Journeys` 0.13.0 → 0.14.0.
- `eval <js>` records the expression's value as JSON in the transcript
(`undefined` when there is none, a promise awaited), and `wait --fn
<expression>` waits until it is truthy. No code in this repository is
needed for them: transcript sections come from the checkpoint commands.
- A live journey `journeys/eval.journey` against a new fixture page,
`site/api.html`, whose API exists only after a delay (so `wait --fn` is
what makes the evals deterministic), with its verified transcript.
- `docs/formats/browser.md` gets a section on asserting on a page's
JavaScript, the Browser agent skill and `DECISIONS.md` are updated, and
`eval` is no longer listed as unsupported.

The unreleased 0.19.0 release does not include this; it goes out in the
next one.

## Verified

- `mise run test`: every test project passes (Browser: 224 passed, 1
skipped as before), including the new journey in a real Chrome, `mise
run format` and `mise run check` clean.
- Mutation: changing one value in the verified transcript fails
`Run(eval)`.
- The transcript was read before it was accepted: a promise is awaited
(`.then(r => r.length)` → `1`), `[]` stays `[]`, `undefined` is
`undefined`.

## Not covered

- Failure paths (a `wait --fn` that never turns truthy, an `eval` that
throws) are Nullean.Cdp's and are tested there; this repository's
existing "a failed step fails the assertion" covers propagation.
- No native AOT publish was run locally: CI's AOT pack jobs cover the
new Cdp version.

Closes #84

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature A new capability (minor bump)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Journey steps: eval <js> and wait --fn <expr> Add a wait-for-function helper (wait until a JS expression is truthy)

1 participant