diff --git a/e2e-tests/fixtures/mypage_login.fixture.ts b/e2e-tests/fixtures/mypage_login.fixture.ts index 9c7901588d..6eb9a3e4ec 100644 --- a/e2e-tests/fixtures/mypage_login.fixture.ts +++ b/e2e-tests/fixtures/mypage_login.fixture.ts @@ -1,8 +1,10 @@ import { test as base, expect } from "@playwright/test"; import { MypageLoginPage } from "../pages/mypage/login.page"; +import { EntryPage } from "../pages/entry/entry.page"; import { Mode, ContextType } from '../utils/ZapClient'; import { ECCUBE_DEFAULT_USER, ECCUBE_DEFAULT_PASS } from "../config/default.config"; import PlaywrightConfig from '../../playwright.config'; +import { FakerUtils } from "../utils/FakerUtils"; type MypageLoginFixtures = { mypageLoginPage: MypageLoginPage; @@ -10,10 +12,19 @@ type MypageLoginFixtures = { export const test = base.extend({ mypageLoginPage: async ({ page }, use) => { - const loginPage = new MypageLoginPage(page); + const email = FakerUtils.createEmail(); + const password = FakerUtils.createPassword(); + const loginPage = new MypageLoginPage(page, email, password); if (PlaywrightConfig.use?.proxy === undefined) { + const entryPage = new EntryPage(page, email, password); + await entryPage.goto(); + await entryPage.agree(); + await entryPage.fill(); + await entryPage.confirm(); + await entryPage.register(); await loginPage.goto(); - await loginPage.login(ECCUBE_DEFAULT_USER, ECCUBE_DEFAULT_PASS); + await loginPage.logout(); + await loginPage.login(); } else { const zapClient = loginPage.getZapClient(); await zapClient.setMode(Mode.Protect); diff --git a/e2e-tests/pages/entry/entry.page.ts b/e2e-tests/pages/entry/entry.page.ts index 5752cab1a7..e3772db5a9 100644 --- a/e2e-tests/pages/entry/entry.page.ts +++ b/e2e-tests/pages/entry/entry.page.ts @@ -1,6 +1,6 @@ import { Locator, Page } from '@playwright/test'; import { PersonalInputPage } from '../personal_input.page'; -import { faker } from '@faker-js/faker/locale/ja'; +import { FakerUtils } from '../../utils/FakerUtils'; export class EntryPage { readonly page: Page; @@ -14,7 +14,7 @@ export class EntryPage { constructor(page: Page, email?: string, password?: string, url?: string) { this.page = page; - this.password = password ?? faker.string.uuid(); + this.password = password ?? FakerUtils.createPassword(); this.url = url ?? '/entry/kiyaku.php'; this.registerButton = page.locator('[alt=会員登録をする]'); this.confirmButton = page.locator('[alt=確認ページへ]'); diff --git a/e2e-tests/pages/mypage/login.page.ts b/e2e-tests/pages/mypage/login.page.ts index 5161c71d54..ab7992a266 100644 --- a/e2e-tests/pages/mypage/login.page.ts +++ b/e2e-tests/pages/mypage/login.page.ts @@ -4,6 +4,8 @@ import { ZapClient } from '../../utils/ZapClient'; export class MypageLoginPage { readonly page: Page; readonly url: string; + readonly email: string; + readonly password: string; readonly loginEmail: Locator; readonly loginPass: Locator; @@ -11,9 +13,11 @@ export class MypageLoginPage { readonly logoutButton: Locator; zapClient: ZapClient; - constructor(page: Page) { + constructor(page: Page, email: string, password: string) { this.page = page; this.url = '/mypage/login.php'; + this.email = email; + this.password = password; this.loginEmail = page.getByRole('textbox', { name: 'メールアドレスを入力して下さい' }); this.loginPass = page.getByRole('textbox', { name: 'パスワードを入力して下さい' }); @@ -26,9 +30,9 @@ export class MypageLoginPage { await this.page.goto(this.url); } - async login(email: string, password: string) { - await this.loginEmail.fill(email); - await this.loginPass.fill(password); + async login() { + await this.loginEmail.fill(this.email); + await this.loginPass.fill(this.password); await this.loginButton.click(); } diff --git a/e2e-tests/test/front_guest/entry.test.ts b/e2e-tests/test/front_guest/entry.test.ts index be4698eb78..3a279b6ff5 100644 --- a/e2e-tests/test/front_guest/entry.test.ts +++ b/e2e-tests/test/front_guest/entry.test.ts @@ -2,7 +2,6 @@ import { test, expect, request, APIRequestContext } from '@playwright/test'; import { EntryPage } from '../../pages/entry/entry.page'; import PlaywrightConfig from '../../../playwright.config'; -import { faker } from '@faker-js/faker/locale/ja'; import { FakerUtils } from '../../utils/FakerUtils'; const url = '/entry/kiyaku.php'; @@ -24,7 +23,7 @@ test.describe.serial('会員登録のテストをします', () => { test('会員登録のテストをします', async ({ page }) => { await page.goto(url); - const password = faker.string.uuid(); + const password = FakerUtils.createPassword(); const email = FakerUtils.createEmail(); const entryPage = new EntryPage(page, email, password, url); diff --git a/e2e-tests/test/front_login/contact.test.ts b/e2e-tests/test/front_login/contact.test.ts index aa6b593fb1..3dcc23c2a8 100644 --- a/e2e-tests/test/front_login/contact.test.ts +++ b/e2e-tests/test/front_login/contact.test.ts @@ -24,7 +24,7 @@ test.describe.serial('お問い合わせページのテストをします', () = test.describe('テストを実行します[GET] @attack', () => { let scanId: number; - test('アクティブスキャンを実行します', async () => { + test('アクティブスキャンを実行します', async ({ page }) => { const contactPage = new ContactPage(page); const zapClient = contactPage.getZapClient(); scanId = await zapClient.activeScanAsUser(url, 2, 110, false, null, 'GET'); @@ -40,8 +40,8 @@ test.describe.serial('お問い合わせページのテストをします', () = await page.goto(url); await expect(page.locator('#header')).toContainText('ようこそ'); inputNames.forEach(async (name) => expect(page.locator(`input[name=${ name }]`)).not.toBeEmpty()); - await expect(page.locator('input[name=email]')).toHaveValue('zap_user@example.com'); - await expect(page.locator('input[name=email02]')).toHaveValue('zap_user@example.com'); + await expect(page.locator('input[name=email]')).toHaveValue(mypageLoginPage.email); + await expect(page.locator('input[name=email02]')).toHaveValue(mypageLoginPage.email); }); let confirmMessage: HttpMessage; @@ -64,7 +64,7 @@ test.describe.serial('お問い合わせページのテストをします', () = await expect(page.locator(`input[name=${ name }]`)).not.toBeEmpty(); }); await expect(page.locator('input[name=email]')).toBeHidden(); - await expect(page.locator('input[name=email]')).toHaveValue('zap_user@example.com'); + await expect(page.locator('input[name=email]')).toHaveValue(mypageLoginPage.email); await expect(page.locator('input[name=contents]')).toBeHidden(); await expect(page.locator('input[name=contents]')).toHaveValue('お問い合わせ入力'); @@ -79,7 +79,7 @@ test.describe.serial('お問い合わせページのテストをします', () = await expect(page.locator('#form1 >> tr:nth-child(5) > td')).toContainText(await page.locator('input[name=tel01]').inputValue()); await expect(page.locator('#form1 >> tr:nth-child(5) > td')).toContainText(await page.locator('input[name=tel02]').inputValue()); await expect(page.locator('#form1 >> tr:nth-child(5) > td')).toContainText(await page.locator('input[name=tel03]').inputValue()); - await expect(page.locator('#form1 >> tr:nth-child(6) > td')).toContainText('zap_user@example.com'); + await expect(page.locator('#form1 >> tr:nth-child(6) > td')).toContainText(mypageLoginPage.email); await expect(page.locator('#form1 >> tr:nth-child(7) > td')).toContainText('お問い合わせ入力'); // お問い合わせ内容を送信します @@ -112,7 +112,7 @@ test.describe.serial('お問い合わせページのテストをします', () = test.describe('テストを実行します[POST][確認→完了] @attack', () => { let requestBody: string; - test('アクティブスキャンを実行します', async () => { + test('アクティブスキャンを実行します', async ({ page }) => { // transactionid を取得し直します await page.goto(url); diff --git a/e2e-tests/utils/FakerUtils.ts b/e2e-tests/utils/FakerUtils.ts index 1da1f546c2..c7e4a19f13 100644 --- a/e2e-tests/utils/FakerUtils.ts +++ b/e2e-tests/utils/FakerUtils.ts @@ -8,4 +8,7 @@ export class FakerUtils { static dummyImage() { return path.join(__dirname, '..', 'fixtures', 'images', 'main.jpg'); } + static createPassword() { + return faker.string.uuid(); + } }