Skip to content

Commit ea7859b

Browse files
committed
refactor authFile definition
1 parent ce16379 commit ea7859b

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

browser-testing/playwright.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import './support/env.js'
2+
import { authFile } from './support/testHelpers.js'
23
import { defineConfig, devices } from '@playwright/test'
34

45
const testDir = '.'
56
const baseURL = `http://${process.env.WP_DOMAIN}`
67
process.env.WP_BASE_URL = baseURL
7-
const adminStorageStatePath = '.auth/state.json'
88

99
const browsers = [
1010
{ name: 'chrome', device: 'Desktop Chrome' },
@@ -42,7 +42,7 @@ const browserProjects = browsers.flatMap(browser =>
4242
testMatch: config.testMatch,
4343
use: {
4444
...devices[browser.device],
45-
storageState: adminStorageStatePath
45+
storageState: authFile
4646
},
4747
dependencies: config.dependencies
4848
}))
@@ -59,7 +59,7 @@ export default defineConfig({
5959
testDir,
6060
testMatch: 'setup/reset.js',
6161
use: {
62-
storageState: adminStorageStatePath
62+
storageState: authFile
6363
},
6464
dependencies: ['wp-login']
6565
},
@@ -68,7 +68,7 @@ export default defineConfig({
6868
testDir,
6969
testMatch: 'setup/realProKit.js',
7070
use: {
71-
storageState: adminStorageStatePath
71+
storageState: authFile
7272
},
7373
dependencies: ['wp-login', 'reset']
7474
},
@@ -77,7 +77,7 @@ export default defineConfig({
7777
testDir,
7878
testMatch: 'setup/mockApiAndKitToken.js',
7979
use: {
80-
storageState: adminStorageStatePath
80+
storageState: authFile
8181
},
8282
dependencies: ['wp-login', 'reset']
8383
},

browser-testing/setup/wpLogin.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { test as setup } from '@wordpress/e2e-test-utils-playwright'
22
import '../support/env.js'
3-
4-
const authFile = '.auth/state.json'
3+
import { authFile } from '../support/testHelpers.js'
54

65
setup('WordPress admin login', async ({ page }) => {
76
await page.goto('/wp-login.php')

browser-testing/support/testHelpers.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { request } from '@playwright/test'
22
import { RequestUtils } from '@wordpress/e2e-test-utils-playwright'
33

4+
export const authFile = '.auth/state.json'
5+
46
export async function prepareRestApi({ baseURL, storageState }) {
57
const requestContext = await request.newContext({
68
baseURL

0 commit comments

Comments
 (0)