From c90e11ea3dbe52c5586de78c90b8cc91cf0341a7 Mon Sep 17 00:00:00 2001 From: Lucas Bustamante Date: Mon, 28 Feb 2022 17:09:19 -0300 Subject: [PATCH 1/2] Refactor merchant logout --- packages/js/e2e-utils/src/flows/merchant.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/js/e2e-utils/src/flows/merchant.js b/packages/js/e2e-utils/src/flows/merchant.js index 858b43edac6..f8da8c396bf 100644 --- a/packages/js/e2e-utils/src/flows/merchant.js +++ b/packages/js/e2e-utils/src/flows/merchant.js @@ -72,17 +72,14 @@ const merchant = { }, logout: async () => { - // Log out link in admin bar is not visible so can't be clicked directly. - const logoutLinks = await page.$$eval( - '#wp-admin-bar-logout a', - ( am ) => am.filter( ( e ) => e.href ).map( ( e ) => e.href ) - ); + await page.goto( WP_ADMIN_LOGIN + '?action=logout', { + waitUntil: 'networkidle0', + } ); - if ( logoutLinks && logoutLinks[0] ) { - await page.goto(logoutLinks[0], { - waitUntil: 'networkidle0', - }); - } + // Confirm logout using XPath, which works on all languages. + await expect( page ).toClick( '//a[contains(@href,\'action=logout\')]' ); + + await page.waitForNavigation( { waitUntil: 'networkidle0' } ); }, openAllOrdersView: async () => { From 31fae36caafd8177820eab3878fd4b93203bcd16 Mon Sep 17 00:00:00 2001 From: Lucas Bustamante Date: Mon, 28 Feb 2022 17:41:00 -0300 Subject: [PATCH 2/2] Update XPath syntax --- packages/js/e2e-utils/src/flows/merchant.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/js/e2e-utils/src/flows/merchant.js b/packages/js/e2e-utils/src/flows/merchant.js index f8da8c396bf..e8a0b60af4b 100644 --- a/packages/js/e2e-utils/src/flows/merchant.js +++ b/packages/js/e2e-utils/src/flows/merchant.js @@ -77,7 +77,8 @@ const merchant = { } ); // Confirm logout using XPath, which works on all languages. - await expect( page ).toClick( '//a[contains(@href,\'action=logout\')]' ); + const elements = await page.$x('//a[contains(@href,\'action=logout\')]') + await elements[0].click() await page.waitForNavigation( { waitUntil: 'networkidle0' } ); },