Repository navigation
e2e test cases for create and remove existing menu - #2338
pavanpatil1 wants to merge 7 commits into
Conversation
JustinyAhin
left a comment
There was a problem hiding this comment.
Thanks for working on this test @pavanpatil1. I've added a few comments to improve it.
| @@ -0,0 +1,59 @@ | |||
| import { loginUser, visitAdminPage,activateTheme } from '@wordpress/e2e-test-utils'; | |||
There was a problem hiding this comment.
It might make sense to rename the test file to something like create-remove-menu.test.js or something similar. The idea is to keep consistency with existing tests files names.
Also, I'd move this test to a "Menu" folder as we might have others related tests in the future.
| } ); | ||
|
|
||
|
|
||
| it( 'Add a new menu', async () => { |
There was a problem hiding this comment.
This only adds a new menu, so it will make sense to add it as a helper function instead of a test.
| await visitAdminPage("nav-menus.php"); | ||
|
|
||
| //check if it's a first menu | ||
| await page.waitForSelector(".first-menu-message") |
There was a problem hiding this comment.
Can you clarify what this line does exactly? It looks like you are waiting for a selector that does not exist?
|
|
||
| await visitAdminPage("nav-menus.php"); | ||
|
|
||
| const createmenu = await page.$x("//a[normalize-space()='create a new menu']"); |
There was a problem hiding this comment.
Instead of using XPath here, maybe it will be easier to use a CSS selector? I'd do something like:
await page.click('.add-edit-menu-action a').
| const createmenu = await page.$x("//a[normalize-space()='create a new menu']"); | ||
| await createmenu[0].click(); | ||
|
|
||
| await page.waitForSelector("#menu-name", {timeout: 60000}) |
There was a problem hiding this comment.
I think we can simply wait for the selector without the timeout.
| await page.click("#locations-primary"); | ||
| await page.click("#save_menu_footer"); | ||
|
|
||
| await page.waitForSelector("#nav-menu-footer", {timeout: 60000}) |
There was a problem hiding this comment.
Same thing here, we can omit the timeout and just wait for the selector.
|
|
||
| await page.waitForSelector(".delete-action",{timeout: 60000}); | ||
| const deletemenu = await page.$x("//a[normalize-space()='Delete Menu']"); | ||
| await deletemenu[0].click(); |
There was a problem hiding this comment.
We can also use more clear selectors here.
We could do instead: await page.click( 'a.menu-delete' )
| await browser.close(); | ||
| }); | ||
|
|
||
| await page.waitForSelector(".add-edit-menu-action", {timeout: 60000}); |
There was a problem hiding this comment.
Same comment for the timeout here.
|
Hi @JustinyAhin, I hope you are doing well!. |
|
Hi @JustinyAhin @hellofromtonya, |
Trac ticket: https://core.trac.wordpress.org/ticket/54892