fix: remember downloaded cloud snippets after reload - #428
Merged
imantsk merged 6 commits intoAug 3, 2026
Conversation
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.
Restores the download state of community cloud snippets across a page load, and matches the two Playwright tests that have failed on
core-betasince74aba6f8to the plugin's actual behaviour.Downloaded cloud snippets forget themselves on reload
Downloading a snippet from the Community Cloud stores the remote identifier on the local snippet, and the card switches from Download to Edit. Reloading the page returned the card to Download: the search and featured responses never carried a
local_id, so nothing but the in-memory download record knew the snippet was already on the site.The REST controller now maps each cloud snippet to a local snippet through the
cloud_idrecorded at download time, for both search and featured results. Trashed snippets are excluded.Cloud_Snippet::local_idkeeps a null value instead of coercing it to0, so a snippet that was never downloaded is reported as such.Back navigation confirmation
The test asserted that
window.history.back()raises abeforeunloaddialog. Whether the browser raisesbeforeunloador the editor's ownpopstatehandler raiseswindow.confirmdepends on how the editor was reached, and both occur in practice, so the assertion failed in either direction depending on the run. The test now answers whichever prompt appears and asserts the outcome: dismissing keeps the editor open with the edit intact, accepting leaves it.Shared cloud download state
The test froze the search refresh that follows a download and failed it with a 500, then asserted that the preview still offered editing. A failed search clears the results, unmounting the cards and the preview rendered inside them, so the assertion ran against an empty page.
The refresh is now held open briefly instead of being failed, and the assertions run once the download response has been received rather than while it is resolving. The card is checked before the refresh returns and again after it reports the snippet as still not downloaded. The error notice assertions were dropped as the search-failure test above already covers them.
Assertions on the preview after the download were dropped as well. The preview is a
@wordpress/componentsmodal supplied by WordPress rather than bundled with the plugin, and replacing the focused download button with a link closes it on some WordPress versions while leaving it open on others. It stays open on 7.0.2 and closes on the version used by the Playwright workflow. Keeping focus on the snippet as the button changes would settle this, and is worth its own change.Verification