@@ -17,6 +17,15 @@ import {chromium} from '@playwright/test'
1717import * as path from 'path'
1818import * as fs from 'fs'
1919
20+ function isAccountsShopifyUrl ( rawUrl : string ) : boolean {
21+ try {
22+ return new URL ( rawUrl ) . hostname === 'accounts.shopify.com'
23+ // eslint-disable-next-line no-catch-all/no-catch-all
24+ } catch {
25+ return false
26+ }
27+ }
28+
2029export default async function globalSetup ( ) {
2130 const email = process . env . E2E_ACCOUNT_EMAIL
2231 const password = process . env . E2E_ACCOUNT_PASSWORD
@@ -105,7 +114,7 @@ export default async function globalSetup() {
105114 await page . waitForTimeout ( BROWSER_TIMEOUT . medium )
106115
107116 // Handle account picker if shown
108- if ( page . url ( ) . includes ( 'accounts.shopify.com' ) ) {
117+ if ( isAccountsShopifyUrl ( page . url ( ) ) ) {
109118 const accountButton = page . locator ( `text=${ email } ` ) . first ( )
110119 if ( await accountButton . isVisible ( { timeout : BROWSER_TIMEOUT . long } ) . catch ( ( ) => false ) ) {
111120 await accountButton . click ( )
@@ -117,7 +126,7 @@ export default async function globalSetup() {
117126 await page . goto ( `https://dev.shopify.com/dashboard/${ orgId } /apps` , { waitUntil : 'domcontentloaded' } )
118127 await page . waitForTimeout ( BROWSER_TIMEOUT . medium )
119128
120- if ( page . url ( ) . includes ( 'accounts.shopify.com' ) ) {
129+ if ( isAccountsShopifyUrl ( page . url ( ) ) ) {
121130 const accountButton = page . locator ( `text=${ email } ` ) . first ( )
122131 if ( await accountButton . isVisible ( { timeout : BROWSER_TIMEOUT . long } ) . catch ( ( ) => false ) ) {
123132 await accountButton . click ( )
0 commit comments