From 482c18803ed9becccc57d1b23632438e1afc1d67 Mon Sep 17 00:00:00 2001 From: Carlos Bravo <37012961+cbravobernal@users.noreply.github.com> Date: Tue, 27 Aug 2024 09:38:07 +0200 Subject: [PATCH] Flaky Test: Fix "Sorting" test in new-templates-list.spec.js (#64776) * Use claude AI to fix flaky * Cleaner approach * Comment cleaning --- .../e2e/specs/site-editor/new-templates-list.spec.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/e2e/specs/site-editor/new-templates-list.spec.js b/test/e2e/specs/site-editor/new-templates-list.spec.js index 31dbe9af814d2e..6faa85a2659cf1 100644 --- a/test/e2e/specs/site-editor/new-templates-list.spec.js +++ b/test/e2e/specs/site-editor/new-templates-list.spec.js @@ -22,9 +22,11 @@ test.describe( 'Templates', () => { test( 'Sorting', async ( { admin, page } ) => { await admin.visitSiteEditor( { postType: 'wp_template' } ); - // Descending by title. - await page.getByRole( 'button', { name: 'View options' } ).click(); - await page.getByRole( 'radio', { name: 'Sort descending' } ).click(); + // Wait for the template list to be visible. + await expect( + page.locator( '[aria-label="Templates"]' ) + ).toBeVisible(); + const firstTitle = page .getByRole( 'region', { name: 'Template', @@ -32,6 +34,10 @@ test.describe( 'Templates', () => { } ) .getByRole( 'link', { includeHidden: true } ) .first(); + + // Descending by title. + await page.getByRole( 'button', { name: 'View options' } ).click(); + await page.getByRole( 'radio', { name: 'Sort descending' } ).click(); await expect( firstTitle ).toHaveText( 'Tag Archives' ); // Ascending by title.