Run the Cypress suite with pretty permalinks, fixing the Preview panel poll spec - #619
Open
galbus wants to merge 8 commits into
Open
Run the Cypress suite with pretty permalinks, fixing the Preview panel poll spec#619galbus wants to merge 8 commits into
galbus wants to merge 8 commits into
Conversation
…spec apiFetch percent-encodes the REST path into `rest_route` under plain permalinks, so the slash glob never matched and the poll request reached the real endpoint. Stub the player SDK before boot too, so assertions no longer depend on intercepting a cacheable CDN script. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
✅ WordPress Plugin Check Report
📊 ReportAll checks passed! No errors or warnings found. 🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check |
The content ID is the one part of the URL unaffected by whether apiFetch percent-encodes the path, so matching on it drops the separator alternation. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Matching the ID alone left the helper's name promising a route its body no longer described. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
wp-reset restores plain permalinks, so the workflow's own permalink step was wiped by the first spec and every spec ran a configuration almost no real site uses: REST served as `?rest_route=` rather than `/wp-json/`. Setting the structure in setupDatabase makes it stick, and lets the preview poll be matched with a plain path glob again. `php -S` cannot rewrite, so CI needs a router to hand non-file requests to WordPress the way Apache's .htaccess does. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
galbus
marked this pull request as draft
August 11, 2026 17:38
The spec appended `&=1` to the permalink, which only parsed while the test site ran plain permalinks and every post URL already had a query string. Pretty permalinks made it a 404. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
galbus
marked this pull request as ready for review
August 11, 2026 19:54
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Problem
tests/cypress/e2e/block-editor/preview-panel.cy.jsfails onmain:Cause
The test environment was running plain permalinks, which almost no real site does.
The workflow already sets a permalink structure before starting Cypress:
…but the first spec's
setupDatabasetask runswp reset reset --yes(wp-reset), whichrestores WordPress defaults and wipes it. So from spec 1 onwards, every spec ran against
plain permalinks, and that step was dead configuration.
Under plain permalinks
get_rest_url()returns the query-string form, so the poll insrc/editor/components/play-audio/hooks.js—apiFetch( { path } )— requests:The spec's glob (
**/beyondwords/v1/projects/<id>/content/<id>*) has no slashes to matchagainst, so the intercept never fired,
cy.wait( '@statusCheck' )timed out, and the pollhit the real endpoint instead of the stub. Classic-editor specs use the same glob shape and
pass because that code builds URLs as
restUrl + 'beyondwords/v1/…', keeping the slashesliteral.
Fix
Test-only — no source change.
setupDatabase, after the reset that was wiping it, sothe suite exercises the
/wp-json/…routes real sites use. The dead workflow step isremoved, with a comment recording what owns the structure now.
tests/cypress/scripts/router.phpfor the CI web server. CI serves the site withphp -S, which has no rewrite support, so pretty URLs would 404 wholesale; the routerhands non-file requests to
index.phpthe way Apache's.htaccessfallback does.it. No separator-encoding workaround in the spec.
window:before:loadinstead of intercepting the CDN script.With the namespace already defined the plugin never appends the script, so the assertions
no longer depend on intercepting a cross-origin request that an earlier spec may have left
in the browser cache — which is how the real player ended up running in the CI failure.
One other spec depended on the old structure:
plugins/amp.cy.jsbuilt its AMP URL as`${ url }&=1`, which only parsed while every post URL already carried a query string(
/?p=123). It now sets the query var throughURL/searchParams, so it is correct undereither structure.
Note that
embeds a voice-customised preview once it has finished processinghad neveractually executed in CI:
cypress-fail-fastskipped it behind the failing test. It runs andpasses here, so both sides of the poll-then-embed behaviour are now covered.
Verification
Because the permalink change is environment-wide, the full suite was also run locally with
fail-fast disabled (
--expose failFastEnabled=false) so that every permalink-related failuresurfaced rather than being skipped behind the first one:
plugins/amp.cy.jspasses with that spec fixed; no other spec was affected.The router was verified standalone against a stub docroot:
/,/my-post/and/wp-json/…?_locale=userreach WordPress, while/style.cssand/wp-admin/are serveddirectly.
🤖 Generated with Claude Code