Add gallery lightbox default experiment#78937
Conversation
|
Size Change: +48 B (0%) Total Size: 8.21 MB 📦 View Changed
ℹ️ View Unchanged
|
|
Flaky tests detected in e40368b. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/26941338140
|
## What changed - `/wordpress.html` and `/gutenberg.html` now validate the entered PR value before calling `plugin-proxy.php`. - Pasting a Gutenberg PR URL on `/wordpress.html` (and vice versa) shows a clear message with a link to the correct previewer page. - Any other non-numeric input shows a repo-specific *"Please enter a valid `<repo>` PR number or URL."* message instead of the generic "unexpected error" surfaced by the backend. - `/gutenberg.html` now extracts the PR number inside `previewPr()` so the `?pr=<github-url>` entry point gets the same treatment as the form submit path. ## Root cause The standalone previewers are single-repo pages. Their URL-extraction `if` only matches their own repo path (`wordpress-develop/pull` or `gutenberg/pull`), so a URL pointing at the *other* repo falls through unchanged. The full URL is then forwarded as the `pr=` query value to `plugin-proxy.php`, which appends it to a GitHub API path: ``` /repos/WordPress/wordpress-develop/pulls/WordPress/gutenberg#78937 ``` GitHub responds non-2xx, PHP's `file_get_contents` returns `false`, and `PluginDownloader::gitHubRequest()` throws `ApiException('Request failed')`. The catch in `plugin-proxy.php` returns HTTP 400 with `{"error":"Request failed"}`. The client doesn't recognize that error code, falls into the catch-all branch, and renders: > The PR WordPress/gutenberg#78937 couldn't be previewed due to an unexpected error. Please try again later or file an issue in the WordPress Playground repository. The actual problem — the user is on the wrong previewer page — is never mentioned, and the original URL is awkwardly embedded in a generic "unexpected error" message. ## Reproduction (before) 1. Open `https://playground.wordpress.net/wordpress.html`. 2. Paste `https://github.com/WordPress/gutenberg/pull/78937`. 3. Click *Go*. 4. Observe the opaque error message above. After this change, the user instead sees: > This looks like a Gutenberg PR. Use the [Gutenberg PR previewer](./gutenberg.html) instead. ## Testing `packages/playground/website/playwright/e2e/standalone-pr-previewers.spec.ts` adds six cases: - Pasted Gutenberg URL on `/wordpress.html` → link to `gutenberg.html`. - Non-PR input on `/wordpress.html` → wordpress-develop-specific message. - Numeric PR on `/wordpress.html` → request reaches `plugin-proxy.php` with `repo=wordpress-develop&pr=12345`. - Pasted wordpress-develop URL on `/gutenberg.html` → link to `wordpress.html`. - Non-PR input on `/gutenberg.html` → gutenberg-specific message. - `?pr=<gutenberg-url>` on `/gutenberg.html` → URL is extracted to `pr=78937` before reaching `plugin-proxy.php`. ```bash npx playwright test \ --config=packages/playground/website/playwright/playwright.config.ts \ standalone-pr-previewers.spec.ts --project=chromium ``` All 6 tests pass locally on Chromium; Firefox and WebKit run in CI. --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Ashish Kumar <ashfame@users.noreply.github.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @codeCraft-Ritik. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
codeCraft-Ritik
left a comment
There was a problem hiding this comment.
Nice approach! Introducing the Gallery lightbox default behind an experiment flag is a sensible way to gather feedback and validate the UX before making it the default behavior for everyone. The focused test coverage is a nice addition as well.
What?
No issue.
Adds a Media experiment that makes newly created Gallery blocks use the lightbox by default.
Why?
This lets us test the Gallery lightbox default behind an experiment flag before enabling or refining the behavior more broadly.
How?
The experiment registers
gutenberg-gallery-lightbox-default, exposeswindow.__experimentalGalleryLightboxDefault, and uses that flag when initializing GallerylinkToand new inner Image block attributes. Focused Gallery utility tests cover the default-link behavior and lightbox attribute mapping.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
N/A
Use of AI Tools
This PR was authored with assistance from OpenAI Codex. I reviewed the generated changes and test coverage.