Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Add regression E2E test for the classic block initialization issue #25169
Conversation
69f2e86
to
ba37a23
This is failing for me now with:
|
Some notes: The e2e test can be run locally via I can repro the issue Jon is seeing. Apparently, switching between Visual and Code Editor isn't working. This test should fail (earlier) if we revert 65c9f74 (that's #25162), and run This is a screenshot I took while running It appears that the Gutenberg plugin isn't active during this e2e test, and that we're thus testing against the editor version that comes with Core, rather than the current GB codebase |
Update, as Riad explained to me in Slack, the Gutenberg plugin has to be activated manually in the WP instance used for testing (at |
We've found that we need to disable Puppeteer cache before reloading the editor in order to repro the issue. The following works: diff --git a/packages/e2e-tests/specs/editor/blocks/classic.test.js b/packages/e2e-tests/specs/editor/blocks/classic.test.js
index ce450cd172..d2e9ee06df 100644
--- a/packages/e2e-tests/specs/editor/blocks/classic.test.js
+++ b/packages/e2e-tests/specs/editor/blocks/classic.test.js
@@ -131,6 +131,7 @@ describe( 'Classic', () => {
await saveDraft();
// reload
+ await page.setCacheEnabled( false );
await page.reload();
await clickClassic(); We need to investigate if that turns off caching for all subsequent tests, and if yes, how we can restore the previous caching state. |
ba37a23
to
b077a49
As @ockham mentioned, by disabling the cache, the regression is reproducible. It's not if the cache is left enabled (default). You can test it by reverting the commit I've chosen to go the simpler route of disabling, running the relevant steps to that reproduce the regression, then enabling the cache again. I assume it should work fine unless we have some kind of page object leakage in parallel tests, but I'm assuming that's not the case (I also don't know much about the Gutenberg testing infrastructure yet). If anyone knows a better way to solve this or why browser caching causes the regression not to manifest in the E2E testing environment, please share your thoughts, we'd be keen to better understand why disabling the cache is needed in this case. |
6795b88
to
1bd8f38
@@ -46,6 +47,7 @@ describe( 'Classic', () => { | |||
// Click the image button. | |||
await page.waitForSelector( 'div[aria-label^="Add Media"]' ); | |||
await page.click( 'div[aria-label^="Add Media"]' ); | |||
|
ockham
Sep 10, 2020
Contributor
Suggested change
// Might move to utils if this becomes useful enough for other tests | ||
const runWithoutCache = async ( cb ) => { | ||
await page.setCacheEnabled( false ); | ||
await cb(); | ||
await page.setCacheEnabled( true ); | ||
}; |
ockham
Sep 10, 2020
Contributor
TBH I was considering just inlining this, since it's really just two (fairly intuitive) commands. Might not make much sense to encapsulate them.
TBH I was considering just inlining this, since it's really just two (fairly intuitive) commands. Might not make much sense to encapsulate them.
sirreal
Sep 10, 2020
•
Member
We need to make sure that page.setCacheEnabled( true )
runs at the end even if the first bits throw or reject.
We need to make sure that page.setCacheEnabled( true )
runs at the end even if the first bits throw or reject.
ockham
Sep 10, 2020
Contributor
Ah, good point!
Ah, good point!
fullofcaffeine
Sep 10, 2020
Author
Member
Ah yes, good point indeed!
Ah yes, good point indeed!
fullofcaffeine
Sep 10, 2020
Author
Member
TBH I was considering just inlining this
Yeah, fine with me, we don't really use it anywhere else so you have a point.
TBH I was considering just inlining this
Yeah, fine with me, we don't really use it anywhere else so you have a point.
fullofcaffeine
Sep 10, 2020
•
Author
Member
Besides the actual method to disable and enable the cache is self-descriptive, the additional helper function doesn't add much in terms of meaning.
Besides the actual method to disable and enable the cache is self-descriptive, the additional helper function doesn't add much in terms of meaning.
I updated the PR desc with some step-by-step instructions. |
Thanks! |
Static Analysis job is failing. Fix: #25223 |
#25223 has been merged. I'll rebase this one. |
Considering commit 65c9f74 is reverted, the only actions needed to reproduce the issue are to: * Add the block to the editor, add some content; * Save; * Reload the editor; * Click it. It should error.
Co-authored-by: Bernie Reiter <[email protected]>
6469459
to
748c799
Thanks a lot for working on this, @fullofcaffeine! Let's merge this once all checks are green |
Congratulations on your first merged pull request, @fullofcaffeine! We'd like to credit you for your contribution in the post announcing the next WordPress release, but we can't find a WordPress.org profile associated with your GitHub account. When you have a moment, visit the following URL and click "link your GitHub account" under "GitHub Username" to link your accounts: https://profiles.wordpress.org/me/profile/edit/ And if you don't have a WordPress.org account, you can create one on this page: https://login.wordpress.org/register Kudos! |
Description
Adds a regression test in the client block E2E spec to avoid the regression of this issue: #24696, as suggested in #25162 (comment).
How has this been tested?
npm build
andnpm run wp-env-start
.localhost:8889
-- log into wp-admin to verify (credentials:admin
/password
)npm run test-e2e -- packages/e2e-tests/specs/editor/blocks/classic.test.js
. (To watch tests in interactive mode, append--puppeteer-interactive
).Classic › Should not fail after save/reload
test fails withTypeError: Cannot read property 'getContent' of null
.git checkout -- packages/block-library/src/classic/edit.js
), and rebuild (npm run build
).Types of changes
New E2E test.
Checklist: