diff --git a/packages/e2e-tests/specs/experiments/blocks/comments-query.test.js b/packages/e2e-tests/specs/experiments/blocks/comments-query.test.js index 55c6b4b07af96..d3b8c880a998c 100644 --- a/packages/e2e-tests/specs/experiments/blocks/comments-query.test.js +++ b/packages/e2e-tests/specs/experiments/blocks/comments-query.test.js @@ -48,12 +48,13 @@ describe( 'Comment Query Loop', () => { `This is an automated comment - ${ i }` ); await pressKeyTimes( 'Tab', 1 ); - await page.keyboard.press( 'Enter' ); - await page.waitForNavigation(); + await Promise.all( [ + page.keyboard.press( 'Enter' ), + page.waitForNavigation( { waitUntil: 'networkidle0' } ), + ] ); } // We check that there is a previous comments page link. - await page.waitForSelector( '.wp-block-comments-pagination-previous' ); expect( await page.$( '.wp-block-comments-pagination-previous' ) ).not.toBeNull(); @@ -61,21 +62,25 @@ describe( 'Comment Query Loop', () => { await page.$( '.wp-block-comments-pagination-next' ) ).toBeNull(); - await page.click( '.wp-block-comments-pagination-previous' ); + await Promise.all( [ + page.click( '.wp-block-comments-pagination-previous' ), + page.waitForNavigation( { waitUntil: 'networkidle0' } ), + ] ); // We check that there are a previous and a next link. - await page.waitForSelector( '.wp-block-comments-pagination-previous' ); - await page.waitForSelector( '.wp-block-comments-pagination-next' ); expect( await page.$( '.wp-block-comments-pagination-previous' ) ).not.toBeNull(); expect( await page.$( '.wp-block-comments-pagination-next' ) ).not.toBeNull(); - await page.click( '.wp-block-comments-pagination-previous' ); + + await Promise.all( [ + page.click( '.wp-block-comments-pagination-previous' ), + page.waitForNavigation( { waitUntil: 'networkidle0' } ), + ] ); // We check that there is only have a next link - await page.waitForSelector( '.wp-block-comments-pagination-next' ); expect( await page.$( '.wp-block-comments-pagination-previous' ) ).toBeNull();