Skip to content

Test every public Page method; check client actions against their services - #88

Merged
AdamMusa merged 2 commits into
mainfrom
test/page-api-contracts
Nov 20, 2026
Merged

AdamMusa merged 2 commits into
mainfrom
test/page-api-contracts

Conversation

@AdamMusa

Copy link
Copy Markdown
Owner

Part of the release-readiness test pass, alongside #86 (controls) and #87 (control and service methods). It adds tests only; no lib changes.

Page APIs

PageApiCoverageTest fails for any public Ruflet::Page method that isn't tested. A method counts as tested in one of two ways:

  • it appears in a table in test/support/page_api_contract.rb, whose tests PageApiContractTest generates;
  • it is named in COVERED_BY, and the meta-test checks that the named test exists and calls the method.
Table Methods Each test asserts
INVOKES 43 (page.get_battery_level, page.launch_url, page.close_drawer, …) target (service type, page 1 or view), method name, args, call id, and that the reply reaches on_result
SERVICES 26 accessors (page.battery, page.local_auth, …) service type, mounted once in the registry, props applied; the four proxy accessors still return their proxy
VISUAL camera, screenshot built but not mounted
PROPS 18 properties, reader and writer read back; page.update sends the value on the page (title, alignments) or on its view

16 methods had no test calling them. They now have new tests:

  • the bottom sheet and snack bar writers, and show_snack_bar;
  • pop_dialog, go, on_view_pop=, patch_page;
  • invoke_sync, covering both the reply and the error;
  • remove_service by control, id or type;
  • services=, replay_route_after_reload!, session_id;
  • the page props handled through method_missing.

Coverage: of 181 public Page methods, 13 had no test mentioning them, and nothing enforced coverage. Now all 181 are covered and enforced.

Client actions

ClientActionContractTest covers each of the six actions. The renderer runs a client action through the same service handler that a Ruby call reaches, so the test checks that each action:

  • names a service and method Ruby can call;
  • sends each option under its wire arg;
  • uses only args that the matching Ruby service method also sends.

They all agree today.

Found, not fixed here

page.can_launch_url(url, timeout:) takes no on_result:. The client's answer therefore never reaches the caller. The fix goes in page.rb, which #82 changes, so it follows once #82 has merged.

Verified

  • Ruby 4.0.5, all files in one process: 1165 runs, 0 failures (1 skip, already on main).
  • Ruby 3.4.5, one process per file: 190 files, 0 failing.

… services

PageApiCoverageTest fails for any public Ruflet::Page method that is not
tested. A method is tested either through a table in
test/support/page_api_contract.rb, whose tests PageApiContractTest
generates, or by a test named in COVERED_BY, which must exist and call
the method.

The tables:
- the 43 methods that call the client (page.get_battery_level,
  page.launch_url, page.close_drawer, ...): target service, page or view,
  method name, args, and the reply reaching on_result;
- the 26 service accessors (page.battery, page.local_auth, ...): mounted
  once in the service registry, with the four proxy accessors still
  returning their proxy;
- camera and screenshot, built but not mounted;
- 18 page properties: read back, and sent on the page or on its view by
  page.update.

New tests for the 16 methods no test called: the bottom sheet and snack
bar writers, show_snack_bar, pop_dialog, go, on_view_pop=, patch_page,
invoke_sync (reply and error), remove_service, services=,
replay_route_after_reload!, session_id and method_missing's page props.

ClientActionContractTest checks that each client action names a service
and method Ruby can call. It also checks that each option is sent under
the arg the matching Ruby service method sends it under, since the
renderer runs both through the same handler.
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