Commit Graph

21 Commits

Author SHA1 Message Date
mcfn fb7c338a81 [packages/cli-v2]test: add storage e2e coverage 2026-03-30 10:27:13 +08:00
mcfn 2eb6b2c0d2 [packages/cli-v2]test: add cookies e2e coverage 2026-03-30 09:06:49 +08:00
mcfn ba8d546973 [packages/cli-v2]test: add wait e2e coverage 2026-03-30 01:09:45 +08:00
mcfn 0e530e3965 [packages/cli-v2]test: add logs e2e coverage 2026-03-29 23:55:26 +08:00
mcfn.feng 29ce2f380b [packages/cli-v2]chore: merge release/1.0.0 and resolve cli-v2 conflicts
Integrate new commands from release/1.0.0 (pdf, query, hover, focus,
press, drag, upload, mouse-move, cursor-position, scroll, etc.) with
screenshot implementation. Deduplicate base64 dependency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 23:39:25 +08:00
mcfn dd6c46ec5b [packages/cli-v2]test: add pdf e2e coverage 2026-03-29 20:12:11 +08:00
mcfn 6e1bcca0fe [packages/cli-v2]test: add query e2e coverage 2026-03-29 19:00:43 +08:00
mcfn c7a52a6cad [packages/cli-v2]test: add describe state e2e 2026-03-29 17:55:27 +08:00
mcfn c2517be90c [packages/cli-v2]feat: add observation batch 2 2026-03-29 17:48:56 +08:00
mcfn.feng 5e219a8609 [packages/cli-v2]feat: implement browser screenshot command with annotate support
Add full implementation of `browser screenshot <path>` (§10.2) including:
- Core viewport screenshot via CDP Page.captureScreenshot
- --full flag for full-page capture using Page.getLayoutMetrics
- --selector flag to clip to a specific CSS element region
- --screenshot-format (png/jpeg) with extension inference
- --screenshot-quality for JPEG compression control
- --annotate flag that overlays numbered labels on interactive elements
  and returns annotations metadata (ref, number, role, name, box)

Expand RefCache to store role/name (RefEntry) so annotate can build
complete annotation metadata without re-fetching the AX tree.

Includes 11 unit tests and 12 E2E tests covering happy paths
(json/text/jpeg/full/selector/annotate) and error paths
(invalid path, session/tab not found, missing args).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 17:47:45 +08:00
mcfn 33019d55b6 [packages/cli-v2]feat: add observation batch 1 2026-03-29 12:16:09 +08:00
mcfn a06b293b66 [packages/cli-v2]test: browser inspect-point E2E + UT baseline (TDD)
§10.11 inspect-point command: TDD tests + NOT_IMPLEMENTED stub.

- 10 UTs for parse_coordinates (valid, decimals, spaces, negative, zero, errors)
- 10 E2E tests: happy JSON/text, parent-depth, no-element, session/tab not found, missing args, invalid coords
- Stub execute() returns NOT_IMPLEMENTED
- CLI/Action/Router/Output wiring complete
- Text format: role "name" / selector: ref / point: x,y

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-29 11:19:57 +08:00
Adcent 24c05c128c [codex] Implement browser interaction commands (#351)
* Add browser click interaction tests

* Expand browser click interaction coverage

* [packages/cli-v2]feat: implement browser click command with shared element resolution

Add full browser click implementation with CDP mouse event dispatch,
selector/coordinate parsing, --button/--count/--new-tab flags, navigation
detection, and XPath support. Extract element resolution into a shared
browser::element utility for reuse by future interaction commands.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* [packages/cli-v2]fix: use shared resolver for --new-tab href check and add click to help

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Add browser type interaction tests

* [packages/cli-v2]feat: implement browser type command

Keystroke-by-keystroke text input via CDP Input.dispatchKeyEvent.
Resolves element through shared element utility, focuses and positions
cursor at end before typing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* [packages/cli-v2]fix: populate context URL/title and use char count in browser type

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Add browser fill interaction tests

* [packages/cli-v2]feat: implement browser fill command

Direct value setting via native input setter with synthetic input event
dispatch. No keystroke simulation — replaces existing value entirely.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* [packages/cli-v2]fix: pick native value setter based on element type in browser fill

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Add textarea fill regression test

* Add browser select interaction tests

* [packages/cli-v2]feat: implement browser select command

Select dropdown options by value or visible text (--by-text flag).
Dispatches input and change events after selection.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* [packages/cli-v2]fix: use resolved node for select instead of re-querying with querySelector

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Format interaction files for lint

* [packages/cli-v2]fix: scroll into view before click and replace fixed navigation delay

Scroll elements into the viewport via DOM.scrollIntoViewIfNeeded before
computing bounding-box coordinates, so clicks on off-screen elements
land correctly. Replace the hardcoded 500ms post-click sleep with a
polling loop that detects URL changes at 50ms intervals (2s timeout),
avoiding unnecessary delays for non-navigating clicks and catching
slow SPA transitions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 08:36:54 +08:00
mcfn 8beb389640 feat: implement browser title/url/viewport commands (§10.4/§10.5/§10.6)
Implement the three observation commands using CDP Runtime.evaluate:
- browser.title: document.title → data.value (string)
- browser.url: document.URL → data.value (string)
- browser.viewport: window.innerWidth/innerHeight → data.width + data.height (numbers)

All three use __ctx_url sideband so context.url is populated per §2.5.
context() updated from stub (url: None) to extract __ctx_url from data.

Also resolve merge conflicts with release/1.0.0:
- observation/mod.rs: include both snapshot_transform and title/url/viewport
- tests/e2e/main.rs: include both snapshot and page_info test modules
- output.rs: include both browser.snapshot and browser.title/url/viewport cases

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 23:11:20 +08:00
mcfn efd4b321b6 [packages/cli-v2] test: browser title/url/viewport E2E + UT baseline (TDD)
Add E2E tests (21) and UT (5) for three new observation commands:
- browser.title (§10.4): data.value = page title string
- browser.url (§10.5): data.value = current URL
- browser.viewport (§10.6): data.width + data.height integers, text = WxH

Test coverage per command:
- Happy path JSON (§2.4 envelope + data contract + context)
- Happy path text (§2.5 format: [sid tid] header + value directly)
- SESSION_NOT_FOUND → context null
- SESSION_NOT_FOUND text mode
- TAB_NOT_FOUND → context.tab_id null
- Missing --session / --tab args

UT: format_viewport() in viewport.rs (5 cases)

Stub implementations return NOT_IMPLEMENTED; happy-path E2E tests are
expected-fail until implementation lands. Error-path tests pass against
the stub (error handling runs before command logic).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 22:53:06 +08:00
mcfn c837cf0eaa [packages/cli-v2]test: add snapshot E2E tests per §10.1 contract
20 tests covering:
- JSON envelope: ok/command/context/data/error/meta (§2.4)
- data fields: format="snapshot", content with [ref=eN] labels,
  nodes with ref/role/name, stats with node_count/interactive_count
- Text output: [sid tid] url prefix + content directly (§2.5)
- Optional flags: --interactive, --compact, --depth, --selector
- Error paths: SESSION_NOT_FOUND (context=null), TAB_NOT_FOUND,
  missing --session/--tab args
- context.url + context.title present on success
- meta.truncated boolean

Current stub implementation will fail happy-path tests.
Error-path tests may pass since they run before snapshot logic.
--cursor flag test left as TODO pending implementation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 18:35:54 +08:00
mcfn 90ab6a74f2 [packages/cli-v2]test: add navigation E2E tests for goto/back/forward/reload
Adds strict api-reference.md §9 contract tests for all 4 navigation
commands. Tests cover JSON envelope (§2.4), data fields, text output
format (§2.5), context.url/title post-navigation update (§5.6), and
error paths (SESSION_NOT_FOUND, TAB_NOT_FOUND).

goto tests expected to pass (command is implemented).
back/forward/reload tests expected to fail until implementation lands.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 18:13:26 +08:00
mcfn.feng ce5e16cd9b [packages/cli-v2]test: add cloud mode E2E tests (45 test functions, 15 groups)
Cloud mode E2E tests covering:
- Session lifecycle, reuse, error cases, tab management
- Page operations (goto/snapshot/eval), headers, status/list-sessions
- Close semantics (browser stays alive), connection drop recovery
- Restart preserves endpoint+headers, daemon crash recovery
- Concurrent operations, double close, real cloud browser (Tier 2)

Two tiers: local Chrome simulation (RUN_E2E_TESTS) + real cloud (ACTIONBOOK_CLOUD_CDP_ENDPOINT)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 15:12:01 +08:00
mcfn.feng 01eb9dec94 [packages/cli-v2]test: add tab management E2E tests (list-tabs, new-tab, close-tab)
23 test cases covering §8 tab management API:
- JSON + text output format for list-tabs, new-tab, close-tab
- Error cases: SESSION_NOT_FOUND, TAB_NOT_FOUND, double close
- Concurrent: multi-tab same session, cross-session parallel ops
- Strict §2.4 envelope, §2.5 text protocol, §3 error compliance

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 10:09:40 +08:00
mcfn.feng fedc4ce5ec [packages/cli-v2]fix: remove api_commands E2E tests (search/get not in CLI)
search and get commands were removed from CLI. The api_commands.rs
test file was still calling them, causing E2E CI failure.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 02:20:19 +08:00
mcfn.feng c3d6fd157a [packages/cli-v2]feat: init project + lifecycle E2E tests (RED phase)
- Initialize independent Rust crate (binary: actionbook)
- Source structure: commands/{browser,daemon}, utils/{wire,client}
- E2E test harness: IsolatedEnv, SessionGuard, headless/headless_json runners
- 17 lifecycle tests covering JSON + text for start/status/list/close/restart
- 11 API tests for search/get/help/version (§6)
- 2 concurrent session tests with profile isolation
- All 28 tests RED (binary is stub only)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 23:31:48 +08:00