diff --git a/e2e-tests/test/front_guest/entry.test.ts b/e2e-tests/test/front_guest/entry.test.ts index 8360d3277c..e0c33a30ea 100644 --- a/e2e-tests/test/front_guest/entry.test.ts +++ b/e2e-tests/test/front_guest/entry.test.ts @@ -1,4 +1,5 @@ import { test, expect, chromium, Page, request, APIRequestContext } from '@playwright/test'; +import PlaywrightConfig from '../../../playwright.config'; import * as faker from 'faker/locale/ja'; import * as fakerEN from 'faker/locale/en_US'; import { addYears } from 'date-fns'; @@ -13,9 +14,7 @@ test.describe.serial('会員登録のテストをします', () => { const browser = await chromium.launch(); mailcatcher = await request.newContext({ baseURL: 'http://mailcatcher:1080', - proxy: { - server: process.env.HTTP_PROXY - } + proxy: PlaywrightConfig.use.proxy }); await mailcatcher.delete('/messages'); diff --git a/e2e-tests/test/front_login/contact.test.ts b/e2e-tests/test/front_login/contact.test.ts index 421f06defb..4649273734 100644 --- a/e2e-tests/test/front_login/contact.test.ts +++ b/e2e-tests/test/front_login/contact.test.ts @@ -1,4 +1,5 @@ import { test, expect, chromium, Page } from '@playwright/test'; +import PlaywrightConfig from '../../../playwright.config'; import { ZapClient, Mode, ContextType, Risk, HttpMessage } from '../../utils/ZapClient'; import { intervalRepeater } from '../../utils/Progress'; const zapClient = new ZapClient(); @@ -8,8 +9,7 @@ const inputNames = [ 'tel01', 'tel02', 'tel03' ] as const; -const baseURL = 'https://ec-cube'; -const url = baseURL + '/contact/index.php'; +const url = `${PlaywrightConfig.use.baseURL}/contact/index.php`; test.describe.serial('お問い合わせページのテストをします', () => { let page: Page; @@ -46,7 +46,7 @@ test.describe.serial('お問い合わせページのテストをします', () = }); test('ログイン状態を確認します', async () => { - await page.goto(baseURL); // ログアウトしてしまう場合があるので一旦トップへ遷移する + await page.goto(PlaywrightConfig.use.baseURL); // ログアウトしてしまう場合があるので一旦トップへ遷移する await page.goto(url); await expect(page.locator('#header')).toContainText('ようこそ'); inputNames.forEach(async (name) => expect(page.locator(`input[name=${name}]`)).not.toBeEmpty()); diff --git a/e2e-tests/test/front_login/shopping.test.ts b/e2e-tests/test/front_login/shopping.test.ts index 0a44a2f9a1..e978d1aaa8 100644 --- a/e2e-tests/test/front_login/shopping.test.ts +++ b/e2e-tests/test/front_login/shopping.test.ts @@ -1,5 +1,5 @@ import { test, expect, chromium, Page, request, APIRequestContext } from '@playwright/test'; - +import PlaywrightConfig from '../../../playwright.config'; import { ZapClient, Mode, ContextType } from '../../utils/ZapClient'; const zapClient = new ZapClient(); @@ -18,11 +18,9 @@ test.describe.serial('購入フロー(ログイン)のテストをします', () expect(await zapClient.isForcedUserModeEnabled()).toBeTruthy(); } const browser = await chromium.launch(); - mailcatcher = await request.newContext({ + mailcatcher = await request.newContext({ baseURL: 'http://mailcatcher:1080', - proxy: { - server: process.env.HTTP_PROXY - } + proxy: PlaywrightConfig.use.proxy }); await mailcatcher.delete('/messages'); diff --git a/e2e-tests/utils/ZapClient.ts b/e2e-tests/utils/ZapClient.ts index 579a1d2239..f00c763994 100644 --- a/e2e-tests/utils/ZapClient.ts +++ b/e2e-tests/utils/ZapClient.ts @@ -1,4 +1,5 @@ import ClientApi from 'zaproxy'; +import PlaywrightConfig from '../../playwright.config'; export const Mode = { Safe: 'safe', Protect: 'protect', @@ -77,8 +78,8 @@ export class ZapClient { private proxy: string; private readonly zaproxy; - constructor(proxy?: string, apiKey?: string | null) { - this.proxy = proxy !== undefined ? proxy : `http://${process.env.HTTP_PROXY}`; + constructor(proxy?: string | null, apiKey?: string | null) { + this.proxy = proxy ?? PlaywrightConfig.use.proxy.server; this.apiKey = apiKey !== undefined ? apiKey : null; this.zaproxy = new ClientApi({ apiKey: this.apiKey, diff --git a/playwright.config.ts b/playwright.config.ts index 953028f541..da9591142e 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -46,7 +46,10 @@ const config: PlaywrightTestConfig = { screenshot: 'only-on-failure', video: 'retain-on-failure', ignoreHTTPSErrors: true, - acceptDownloads: true + acceptDownloads: true, + proxy: { + server: process.env.HTTP_PROXY ? `http://${process.env.HTTP_PROXY}` : 'http://localhost:8090' + } }, /* Configure projects for major browsers */ diff --git a/yarn.lock b/yarn.lock index 21b36c5e89..9534f4c62f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3254,9 +3254,9 @@ ms@^2.1.1, ms@^2.1.2: integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== nanoid@^3.1.30: - version "3.1.30" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.30.tgz#63f93cc548d2a113dc5dfbc63bfa09e2b9b64362" - integrity sha512-zJpuPDwOv8D2zq2WRoMe1HsfZthVewpel9CAvTfc/2mBD1uUT/agc5f7GHGWXlYkFvi1mVxe4IjvP2HNrop7nQ== + version "3.2.0" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.2.0.tgz#62667522da6673971cca916a6d3eff3f415ff80c" + integrity sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA== natural-compare@^1.4.0: version "1.4.0"