Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into add-guest-shoppin…
Browse files Browse the repository at this point in the history
…g.test
  • Loading branch information
nanasess committed Feb 16, 2022
2 parents 4289c47 + 4b76107 commit 11b32e3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
5 changes: 2 additions & 3 deletions e2e-tests/test/front_guest/entry.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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');

Expand Down
6 changes: 3 additions & 3 deletions e2e-tests/test/front_login/contact.test.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
8 changes: 3 additions & 5 deletions e2e-tests/test/front_login/shopping.test.ts
Original file line number Diff line number Diff line change
@@ -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();

Expand All @@ -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');

Expand Down
5 changes: 3 additions & 2 deletions e2e-tests/utils/ZapClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ClientApi from 'zaproxy';
import PlaywrightConfig from '../../playwright.config';
export const Mode = {
Safe: 'safe',
Protect: 'protect',
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 11b32e3

Please sign in to comment.