Skip to content

Commit

Permalink
Fix flaky 'Post publish button' e2e test (#57407)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka authored Dec 28, 2023
1 parent a50e4c7 commit d7c222c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions test/e2e/specs/editor/various/publish-button.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,20 @@ test.describe( 'Post publish button', () => {
topBar.getByRole( 'button', { name: 'Publish' } )
).toBeEnabled();

const postId = new URL( page.url() ).searchParams.get( 'post' );
const deferred = defer();

await page.route(
( url ) =>
url.searchParams.has(
'rest_route',
encodeURIComponent( `/wp/v2/posts/${ postId }` )
url.href.includes(
`rest_route=${ encodeURIComponent( '/wp/v2/posts/' ) }`
),
async ( route ) => {
await deferred;
await route.continue();
async ( route, request ) => {
if ( request.method() === 'POST' ) {
await deferred;
await route.continue();
} else {
await route.continue();
}
}
);

Expand Down

0 comments on commit d7c222c

Please sign in to comment.