Skip to content

Commit

Permalink
Navigation block e2e tests: default to my most recently created menu (#…
Browse files Browse the repository at this point in the history
…48132)

* initial commit with test structure

* wait 2 sec in between menu creations

* renamed menus and removed delay between them

* renamed in the assertion too

* added timeout and comment
  • Loading branch information
MaggieCabrera authored Mar 13, 2023
1 parent 3f62a6d commit a2e91a4
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions test/e2e/specs/editor/blocks/navigation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,57 @@ test.describe(
)
).toBeVisible();
} );

test( 'default to my most recently created menu', async ( {
admin,
page,
editor,
requestUtils,
} ) => {
await admin.createNewPost();
await requestUtils.createNavigationMenu( {
title: 'Test Menu 1',
content:
'<!-- wp:navigation-link {"label":"Menu 1 Link","type":"custom","url":"http://localhost:8889/#menu-1-link","kind":"custom","isTopLevelLink":true} /-->',
} );

//FIXME this is needed because if the two menus are created at the same time, the API will return them in the wrong order.
//https://core.trac.wordpress.org/ticket/57914
await editor.page.waitForTimeout( 1000 );

const latestMenu = await requestUtils.createNavigationMenu( {
title: 'Test Menu 2',
content:
'<!-- wp:navigation-link {"label":"Menu 2 Link","type":"custom","url":"http://localhost:8889/#menu-2-link","kind":"custom","isTopLevelLink":true} /-->',
} );

await editor.insertBlock( { name: 'core/navigation' } );

// Check the markup of the block is correct.
await editor.publishPost();
await expect.poll( editor.getBlocks ).toMatchObject( [
{
name: 'core/navigation',
attributes: { ref: latestMenu.id },
},
] );
await page.locator( 'role=button[name="Close panel"i]' ).click();

// Check the block in the canvas.
await expect(
editor.canvas.locator(
`role=textbox[name="Navigation link text"i] >> text="Menu 2 Link"`
)
).toBeVisible();

// Check the block in the frontend.
await page.goto( '/' );
await expect(
page.locator(
`role=navigation >> role=link[name="Menu 2 Link"i]`
)
).toBeVisible();
} );
}
);

Expand Down

1 comment on commit a2e91a4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in a2e91a4.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4406967269
📝 Reported issues:

Please sign in to comment.