-
Notifications
You must be signed in to change notification settings - Fork 798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Boost: Refactor and add new e2e tests #21819
Conversation
* master: (28 commits) Prepare for 10.4-a.7 (#21797) Check if maxwidth exists before trying to call .length (#21785) Podcast Player: Increase podcast shown (#21661) licensing: jetpack-js-test-runner is a dev dependency (#21794) Update dependency @mdn/browser-compat-data to v4.0.11 (#21792) Tests: Fix unit tests for wpcom (#21649) SSO: Fix Button Text Alignment on Mobile (#18770) Add/my jetpack skeleton (#21464) Identity Crisis: add unit tests for has_identity_crisis and get_mismatched_urls (#21754) Remove special cases for calling changelogger on packages/changelogger (#21783) eslint-config-target-es: Release 1.0.0! (#21766) Revert "WPCOM no longer forces home_urls to be http" (#21769) WPCOM no longer forces home_urls to be http (#21747) Revert and fix "Revert "Assets: do not use the new method yet (#21760)"" (#21763) eslint-config-target-es: Fix README.md (#21743) codesniffer: Disable CI on PHP 8.1 (#21742) RNA Pricing card component: Fix case where prices before and after match (#21757) Janitorial: update Jetpack version for 10.4-a.6 cycle (#21762) Releases: prepare changelog for 10.4-a.5 release (#21758) Assets: do not use the new method yet (#21760) ...
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Boost plugin:
|
* master: (45 commits) Prepare for Boost 1.3.1-beta (#21853) Add 'View all purchases' and 'Activate a product' buttons in My Plan card footer. (#21824) Move Woop menu item method to parent class so filter can be used in WPCOMSH. (#21717) Dismiss licenses activation notice when license is activated. (#21844) assets: Stop `_doing_it_wrong` wrong (#21852) Update/jetpack backup version 1.0.1 (#21851) assets: Release 1.13.0 (#21847) Verification tools: remove old Tools interface (#21846) Connection: deactivate the Connection Manager UI (#21828) assets: Have `register_script()` take a textdomain (#21831) Update/inform first connected plugin (#21672) Analyzer: Handle more code tokens (#21652) Post List: Release version 0.2.4 (#21820) New workflow to push Boost issues to Project Board (#21800) Gist Shortcode: refactor unit tests (#21781) REST API: Return user ID for comment author if present. (#21834) Add License Activation Flow to Jetpack Plugin (#21764) Update wordpress monorepo (#21832) docs: Add some tips about handling merge issues (#21825) Update error screens and detect backup retry (#21735) ...
# By Jeremy Herve (5) and others # Via GitHub * master: (26 commits) Colors: update Primary green reference to match latest brand book (#21741) JS Connection: Moves registerSite logic to the store (#21732) Search: Add essential scaffolding for package (#21814) Search: avoid registering the widget when the module is not active (#21588) Add Video Tracks Support to VideoPress Block (#21578) Add deprecated to VideoPress block (#21802) Admin Menu: Make API tests compatible with WPCOM (#21850) External Media: Short-circuit requests earlier in the stack (#21854) Add Busy State to License Activation Flow Button (#21861) Fixed an issue with screen resolutions of under 783px that caused the content to not be properly displayed when the nav-unification is expanded on wp-admin. (#21869) E2E tests: migrate from Jest to Playwright runner (#21848) Update reCAPTCHA constants to match Google's Verbage (#12289) JITM: Sideload Jetpack Boost functionality (#21860) Connection: properly add GET-parameters for the `fetchAuthorizationUrl` API call (#21750) License Flow: Assorted Styling Improvements (#21859) JITM: Sideload Jetpack Backup (#21719) Widget Visibility: Apply widget filtering to customizer preview (#21505) jetpack: Avoid generating unused JS for static-site-generator assets (#21789) Nav Unification: Support absolute URLs in upsell nudges (#21821) RePublicize: Enable the block editor UI by default (#21855) ... # Conflicts: # projects/plugins/boost/tests/e2e/lib/env/prerequisites.js # projects/plugins/boost/tests/e2e/lib/setupTests.js
* master: (22 commits) Update storybook monorepo to v6.4.0 (#21897) Refresh the site's modules and settings after successful product activation (#21886) Plugin Install: Bump MC stat on success or fail. (#21893) Nav Unification: Use correct user capability for the Inbox menu item (#21882) Jetpack: Extend disconnection dialog component to handle multiple steps and accept more props (#21048) Disable CSSTidy property shorthand optimization in the editor or headstart (#21891) Connection UI: Update Composer instructions in README.md (#21890) Partner Compatibility: Adding a unique connection screen for customers who receive a coupon from a Jetpack partner (#21813) Search package: move search dashboard to package - the base (#21865) JITM: wrap CTA below text on small viewports (#21688) Licensing JS Package – fix icon positioning and width (#21878) JITM: new JS and CSS builder (#21874) Support site_intent for `/me/sites` endpoint (#21880) Don't render Critical CSS while generating CritCSS. (#21879) ConnectScreen: make button full width on small screens (#21683) Improve the copy of the license activation banner (#21876) Rename Webpack-built files back from `.min.js` and remove hashes (#21748) Search: Migrate more helper classes to package (#21751) Search: migrate/add search rest API (#21584) Add initial state to the connection package (#21864) ...
* master: Added a custom composer installer to use a separate vendor folder. (#21877) Masterbar: rewrite tracks-events.js without jQuery (#21907) pre-commit: Run `eslint --fix` like we do `phpcbf` (#21923) Hide licenses activation route when user account not linked. (#21919) Beta: Handle exception when no Internet connection (#21915) Update wordpress monorepo (#21918) Pin dependency automattic/wordbless to 0.3.1 (#21920) Use new GitHub secret to manage pushing to Project Boards (#21838) Backup: provide additional disconnect info in backup plugin (#21421) IDC: Event tracking for the new screen (#21900) Releases: add testing list for Jetpack 10.4 (#21909) Jetpack 10.5-a.0 Cycle Start (#21912) Jetpack 10.4: Changelog (#21908) Add/contextualized jetpack connection (#21815) Fix masterbar not being displayed entirely for resolutions of under 660px. (#21871) Handle the intermittent occurrence of null in `columnWidths[ rowIndex ]` array in TiledGallery (#21892) Add to My Plan's header section a small licensing-related piece of copy (#21899) Sharing: ask search engines to not index pages with query string. (#21843) PR Template: Indicate use of milestone (#21898) Likes: add some extra checks to queuehandler.js (#21896)
# By Adnan Haque # Via GitHub * master: Boost: fix inconsistent lazy load (#21921) # Conflicts: # projects/plugins/boost/tests/e2e/specs/jetpack-boost/modules-common.test.js
@thingalon, I pushed a couple of commits since your last review to fix a typo and also to improve (a little) some of the horrific names of the Jetpack Boost page methods. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @davidlonjon, Thanks for this PR!
I was reviewing and testing this PR. Everything works great (again thanks for the testing instructions) with PWDEBUG=true
.
However, when I run in headless mode some tests fail. Eg: specs/modules-common.test.js:44:3 › Modules › The render-blocking-js module state should revert back to original state
. Adding some dummy timeouts solved the issue. Maybe this is something specific to my setup. So, I will leave it for others to review this as well.
Overall, it is amazing to see a developed test suite for Boost!!
@davidlonjon, this looks great! I have two concerns though:
|
I've fixed a couple of issues which affected stability:
Since applying these fixes, I'm finding it a lot more stable. @adimoldovan, really hoping to get this merged soon so that other members of my team can implement some additional tests while David is still here to help us through it. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great!
I've tidied up a few inconsistency issues, and now it seems to reliably succeed every time for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thingalon, @davidlonjon Let's merge it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test.describe.serial
is actually needed on Modules
test suit @thingalon.
I have also found that sometimes the lazy-images
revert fails for me as the waitForApiResponse
is not effective in its case. I am pushing a couple of changes to fix these issues.
@@ -10,7 +10,7 @@ const modules = [ | |||
[ 'render-blocking-js', 'disabled' ], | |||
]; | |||
|
|||
test.describe.serial( 'Modules', () => { | |||
test.describe( 'Modules', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, serial makes sense here. The default, toggle and revert depend on the sequence for each module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just cc'ing @adimoldovan to make sure that makes sense :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To add some context, serial
was used in multiple tests, and @adimoldovan's objection is valid. I only found on one test suit Modules
where using serial
was appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it looks like it. It's pretty confusing and I strongly suggest moving away from it.
I suggest merging the 3 tests into a single one and using steps for each action:
test( 'Toggle modules', async () => {
test.step( `The ${ moduleSlug } module should be ${ moduleState } by default`, async () => {}
test.step( `The ${ moduleSlug } module state should toggle to an inverse state`, async () => {}
test.step( `The ${ moduleSlug } module state should revert back to original state, async () => {}
}
test.describe
can be removed completely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or better:
test( 'Toggle ${ moduleSlug } module', async () => {
test.step( `The module should be ${ moduleState } by default`, async () => {}
test.step( `The module state should toggle to an inverse state`, async () => {}
test.step( `The module state should revert back to original state, async () => {}
}
New endpoints to make waitForApiResponse to be effective for lazy-images and render-blocking-js status
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼
Thank you all for the contribution to this PR and particularly @adimoldovan for having supported me all the way on this E2E journey for Boost. I am truly thankful for the guidance and kindness 🙏 |
Fixes #21756
Changes proposed in this Pull Request:
This PR implements the core E2E tests described in #21756. It is important to note there is not exactly a 1-1 relationship between the tests in this PR and the tests scenarios highlighted in #21756 but the tests in this PR will cover scenarios by doing a combination of steps and checks.
It adds some new Jetpack Boost WP CLI commands to allow managing tests prerequisites more easily. These commands
It creates a new prerequisite allowing setting up some test posts useful to test the Lazy Images and Defer JS modules. These test post pages can be accessed during a test via a new
projects/plugins/boost/tests/e2e/lib/pages/TestContentPage.js
. The appropriate test post page is retrieved using its id number which is retrieved using the post title. This is to avoid messing out and changing the permalinks structure since the repo files and therefore the.htaccess
file are shared between the local development environment and the test environment. This might not be ideal but it seems to work pretty well.This PR also make some refactoring and additions to the E2E Common files package to support the Jetpack Boost E2E tests. I tried to make them generic so they could be re-used in other plugins. These changes are:
selectJetpackBoost
method totools/e2e-commons/pages/wp-admin/sidebar.js
to allow accessing the Jetpack Boost settings page. It could be contained inside the jetpack Boost E2E files but I thought it makes sense to keep all sidebar actions in that file.tools/e2e-commons/pages/wp-admin/plugins.js
to make them more generic so they can be used to activate and inactivate any plugins.tools/e2e-commons/env/prerequisites.js
files to allow activating and deactivating plugins using the WP-CLI commands.Jetpack product discussion
N/A
Does this pull request change what data or activity we track or use?
N/A
Testing instructions:
Locally it can be tested doing the following:
pnpm install
at the root of the repojetpack install plugins/jetpack
jetpack install plugins/boost
projects/plugins/boost/tests/e2e
runpnpm install
pnpm run test-decrypt-config
pnpm run env-start && pnpm run tunnel-on
run pnpm run test-e2e
Also individual specs file can be run using for the command
pnpm run test-e2e -- path/to/the/spec/file
for examplepnpm run test-e2e -- specs/speed-score.test.j
.Also the debug mode can be activated using the following command
PWDEBUG=1 pnpm run test-e2e -- path/to/the/spec/file
orPWDEBUG=1 pnpm run test-e2e
for the whole test suite. ThePWDEBUG=1
statement makes sure Chromium becomes visible so you can see the actual tests being executed. You will have to manually move some tests step forward from the Playwright Inspector window. See the video below:CleanShot.2021-12-09.at.14.40.15.mp4
Finally, you once you did the original
pnpm run env-start && pnpm run tunnel-on
command, you can access your test site from any browser using the tunnel URL provided by thepnpm run tunnel-on
command.