Skip to content

docs: add browser-actions interaction-probe cookbook example#313

Merged
chubes4 merged 1 commit into
mainfrom
feat-socials-crop-modal-probe
May 30, 2026
Merged

docs: add browser-actions interaction-probe cookbook example#313
chubes4 merged 1 commit into
mainfrom
feat-socials-crop-modal-probe

Conversation

@chubes4
Copy link
Copy Markdown
Collaborator

@chubes4 chubes4 commented May 30, 2026

Summary

Adds the reference cookbook example for the wordpress.browser-actions interaction probe shipped in #311. It boots WordPress trunk (so the editor stack runs on React 19), mounts a tiny vendor-neutral @wordpress/element demo plugin (no build step), and drives it with an ordered interaction script to prove the probe verifies a component works — not just that it renders.

This is the difference #311 was built for: a render-only probe ("the component mounts") would miss a regression where a component renders but its interaction is dead after a React major bump.

Scope note: an earlier revision of this PR shipped a plugin-specific recipe driving the data-machine-socials react-easy-crop modal. Per the platform's layer-purity convention (generic layers shouldn't hard-code vendor specifics), that worked consumer now lives in data-machine-socials' own repo, next to the code it guards. This PR keeps only the generic, swappable example.

What's added

  • examples/recipes/cookbook/browser-actions-demo.json — the recipe (WP trunk, mounts the demo plugin, runs the seed, then a wordpress.browser-actions step).
  • examples/recipes/cookbook/browser-actions-demo-plugin/browser-actions-demo.php — a tiny fixture plugin that renders a real @wordpress/element widget (click counter + bound range slider) into a Tools admin page. No build step.
  • examples/recipes/cookbook/browser-actions-demo-seed.php — activates the plugin, logs in admin, emits the demo URL.
  • examples/recipes/cookbook/README.md — documents the example and how to adapt it.

The interaction script (steps-json)

[
  { "kind": "navigate",   "url": "/wp-admin/tools.php?page=wp-codebox-browser-actions-demo", "waitFor": "load" },
  { "kind": "waitFor",    "selector": ".wpcb-increment" },
  { "kind": "screenshot", "name": "demo-loaded" },
  { "kind": "expect",     "selector": ".wpcb-count[data-count=\"0\"]", "state": "visible" },
  { "kind": "click",      "selector": ".wpcb-increment" },
  { "kind": "click",      "selector": ".wpcb-increment" },
  { "kind": "click",      "selector": ".wpcb-increment" },
  { "kind": "expect",     "selector": ".wpcb-count[data-count=\"3\"]", "state": "visible" },
  { "kind": "expect",     "selector": ".wpcb-threshold", "state": "visible" },
  { "kind": "evaluate",   "expression": "document.querySelector('.wpcb-count').getAttribute('data-count')", "assert": "3" },
  { "kind": "screenshot", "name": "after-increment" },
  { "kind": "fill",       "selector": ".wpcb-slider", "value": "80" },
  { "kind": "expect",     "selector": ".wpcb-slider-value[data-value=\"80\"]", "state": "visible" },
  { "kind": "evaluate",   "expression": "document.querySelector('.wpcb-slider-value').getAttribute('data-value')", "assert": "80" },
  { "kind": "screenshot", "name": "after-slider" }
]

Real run results (action-summary.json)

Ran end-to-end with npm run wp-codebox -- recipe-run --recipe ./examples/recipes/cookbook/browser-actions-demo.json --json on WordPress trunk / React 19:

success: true
steps: 15/15 ok
assertions: { "total": 6, "passed": 6, "failed": 0 }
errors: 0
# kind target passed
1 expect counter starts at 0
2 expect counter == 3 after 3 clicks
3 expect .wpcb-threshold message visible
4 evaluate data-count == "3"
5 expect slider output == 80
6 evaluate data-value == "80"

Adapting it

Swap inputs.mounts[0].source to your plugin and rewrite steps-json to drive your own UI (click/fill/drag to interact, expect/evaluate to assert, screenshot to capture). Keep steps-json inline (not @file) if it contains an evaluate step so the recipe auto-grants the wordpress.browser-actions.evaluate policy capability.

Consumes the capability added in #311.


Note: building the original socials-specific version surfaced a real latent bug in data-machine-socials (a double /wp-json/ prefix in apiFetch paths), filed as Extra-Chill/data-machine-socials#145.

Reference example for the wordpress.browser-actions interaction probe
(#311). Mounts a tiny vendor-neutral @wordpress/element demo plugin (no
build step) and drives it under WordPress trunk / React 19: clicks a
counter, asserts a threshold message, moves a slider, asserts the bound
value. Proves the probe verifies a component WORKS under interaction,
not just that it renders. A green run reports 6/6 assertions passed, 0
errors.

The plugin-specific consumer (driving the data-machine-socials
react-easy-crop modal) lives in that plugin's own repo, next to the
code it guards, to keep this generic cookbook example vendor-neutral.
@chubes4 chubes4 force-pushed the feat-socials-crop-modal-probe branch from 0fcb22a to db8b16f Compare May 30, 2026 16:37
@chubes4 chubes4 changed the title docs: add data-machine-socials crop-modal interaction recipe (first browser-actions consumer) docs: add browser-actions interaction-probe cookbook example May 30, 2026
@chubes4 chubes4 merged commit 5e73953 into main May 30, 2026
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