docs: add browser-actions interaction-probe cookbook example#313
Merged
Conversation
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.
0fcb22a to
db8b16f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the reference cookbook example for the
wordpress.browser-actionsinteraction probe shipped in #311. It boots WordPress trunk (so the editor stack runs on React 19), mounts a tiny vendor-neutral@wordpress/elementdemo 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.
What's added
examples/recipes/cookbook/browser-actions-demo.json— the recipe (WP trunk, mounts the demo plugin, runs the seed, then awordpress.browser-actionsstep).examples/recipes/cookbook/browser-actions-demo-plugin/browser-actions-demo.php— a tiny fixture plugin that renders a real@wordpress/elementwidget (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 --jsonon WordPress trunk / React 19:.wpcb-thresholdmessage visibledata-count== "3"data-value== "80"Adapting it
Swap
inputs.mounts[0].sourceto your plugin and rewritesteps-jsonto drive your own UI (click/fill/dragto interact,expect/evaluateto assert,screenshotto capture). Keepsteps-jsoninline (not@file) if it contains anevaluatestep so the recipe auto-grants thewordpress.browser-actions.evaluatepolicy 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 inapiFetchpaths), filed as Extra-Chill/data-machine-socials#145.