-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add initial Playwright tests for WordPress navigation #41805
Conversation
Size Change: +1.77 kB (0%) Total Size: 1.25 MB
ℹ️ View Unchanged
|
*/ | ||
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); | ||
|
||
test.describe( 'Navigation block', () => { |
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.
I think this should be called something like 'Classic menus' or just 'Menus', as it doesn't involve the navigation block.
await admin.createNewPost( { | ||
postType: 'page', | ||
title: pageTitle, | ||
} ); | ||
await editor.publishPost(); |
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.
I think the requestUtils
can be used to create a new page via the REST API here. The response would then contain the URL for the created page, so you wouldn't have to find it in the UI.
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.
Oh, the created page should also be deleted after the test using a test.afterAll
block.
It could be an option to improve the existing deleteAllPosts
util to support a post type param, or alternatively copy its implementation but change 'page' to 'post'.
The test keeps failing unexpectedly. I will inspect the trace and fix the issue tomorrow. |
Hello @kevin940726, Do you have some time to inspect this run with me? https://github.com/WordPress/gutenberg/runs/6980889660?check_suite_focus=true Is keeps failing weirdly on CI, but I can't explain why. I can see in the trace (https://github.com/WordPress/gutenberg/suites/7019668149/artifacts/275833334) that the page is properly added to the menu, but when the test navigate to the page, the menu is not added. I might be missing something here, and would love some help :) |
Is it passing locally for you? Is this a new test? Could you add reproduction steps here so that we can try to see what happened on CI? |
A hunch - it might be because saving a menu is asynchronous, and the test isn't waiting for that to happen. It's navigating to the page before saving the menu has been completed. |
By the way, that PR seems to be for the navigation block, while this PR is testing classic menus. |
Yes, it passes locally for me. And yes, it is a new test. In the test, I'm checking that if we create are on a page which is in the navigation, the corresponding navigation item has the class name It works fine locally, but on CI, it fails at the menu creation step. I can see in the trace that the page is added, but it never appears in the menu in the frontend. |
The test passes now. But the preview test seem to be unstable. |
Closing in favor of #41912. |
What?
Part of #38851. Initial tests for the WordPress menu.
This should ultimately be part of WordPress Core.
Why?
See this post for an overview of the migration.
How?
By following the migration guide.
Testing Instructions
This PR will help to move #40778 (review) forward. It includes only the test for the
.current-menu-item
class.