From 0f6656dd320a11172dacab803acad135c949836c Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Fri, 19 Apr 2024 00:07:45 +0900 Subject: [PATCH] Apply yarn lint:typescript --- e2e-tests/fixtures/admin_login.fixture.ts | 6 +- e2e-tests/fixtures/mypage_login.fixture.ts | 2 +- e2e-tests/pages/admin/login.page.ts | 6 +- e2e-tests/pages/cart.page.ts | 8 +- e2e-tests/pages/contact.page.ts | 4 +- e2e-tests/pages/mypage/login.page.ts | 2 +- e2e-tests/pages/products/detail.page.ts | 2 +- e2e-tests/pages/shopping/deliv.page.ts | 2 +- e2e-tests/pages/shopping/payment.page.ts | 4 +- .../admin/contents/recommendsearch.test.ts | 18 +- e2e-tests/test/admin/customer/edit.test.ts | 2 +- e2e-tests/test/admin/home.test.ts | 2 +- .../admin/ownersstore/plugin_install.test.ts | 2 +- e2e-tests/test/admin/system/index.test.ts | 18 +- e2e-tests/test/admin/total/total.test.ts | 164 +++++++++--------- e2e-tests/test/front_guest/entry.test.ts | 6 +- e2e-tests/test/front_guest/shopping.test.ts | 4 +- e2e-tests/test/front_login/cart/cart.test.ts | 13 +- .../test/front_login/cart/cart_delete.test.ts | 7 +- e2e-tests/test/front_login/contact.test.ts | 31 ++-- .../test/front_login/mypage/change.test.ts | 2 +- .../test/front_login/products_list.test.ts | 14 +- e2e-tests/test/front_login/shopping.test.ts | 4 +- .../shopping/shopping_complete.test.ts | 2 +- .../shopping/shopping_confirm.test.ts | 4 +- .../shopping/shopping_deliv.test.ts | 9 +- .../shopping/shopping_payment.test.ts | 10 +- e2e-tests/test/front_login/welcome.test.ts | 2 +- e2e-tests/test/installer/installer.test.ts | 4 +- e2e-tests/utils/Progress.ts | 2 +- e2e-tests/utils/ZapClient.ts | 13 +- 31 files changed, 195 insertions(+), 174 deletions(-) diff --git a/e2e-tests/fixtures/admin_login.fixture.ts b/e2e-tests/fixtures/admin_login.fixture.ts index e8daa99842..f9f7199b16 100644 --- a/e2e-tests/fixtures/admin_login.fixture.ts +++ b/e2e-tests/fixtures/admin_login.fixture.ts @@ -12,7 +12,7 @@ export const test = base.extend({ loginPage: async ({ page }, use) => { const loginPage = new AdminLoginPage(page); if (PlaywrightConfig.use?.proxy === undefined) { - await page.goto(`/${ADMIN_DIR}`); + await page.goto(`/${ ADMIN_DIR }`); await loginPage.login(ECCUBE_ADMIN_USER, ECCUBE_ADMIN_PASS); } else { const zapClient = loginPage.getZapClient(); @@ -24,10 +24,10 @@ export const test = base.extend({ await zapClient.setForcedUserModeEnabled(); expect(await zapClient.isForcedUserModeEnabled()).toBeTruthy(); } - await page.goto(`/${ADMIN_DIR}home.php`); + await page.goto(`/${ ADMIN_DIR }home.php`); } await use(loginPage); - }, + } }); export { expect } from "@playwright/test"; diff --git a/e2e-tests/fixtures/mypage_login.fixture.ts b/e2e-tests/fixtures/mypage_login.fixture.ts index a9225a80e9..492c295904 100644 --- a/e2e-tests/fixtures/mypage_login.fixture.ts +++ b/e2e-tests/fixtures/mypage_login.fixture.ts @@ -23,7 +23,7 @@ export const test = base.extend({ await page.goto(`/mypage/index.php`); } use(page); - }, + } }); export { expect } from "@playwright/test"; diff --git a/e2e-tests/pages/admin/login.page.ts b/e2e-tests/pages/admin/login.page.ts index 7774f3c39c..d0b5f70f37 100644 --- a/e2e-tests/pages/admin/login.page.ts +++ b/e2e-tests/pages/admin/login.page.ts @@ -13,11 +13,11 @@ export class AdminLoginPage { constructor(page: Page) { this.page = page; - this.url = `/${ADMIN_DIR}index.php`; + this.url = `/${ ADMIN_DIR }index.php`; this.loginId = page.locator('input[name=login_id]'); this.password = page.locator('input[name=password]'); - this.loginButton = page.getByRole('link', { name: 'LOGIN' }) + this.loginButton = page.getByRole('link', { name: 'LOGIN' }); this.zapClient = new ZapClient(); } @@ -32,7 +32,7 @@ export class AdminLoginPage { } async logout() { - await this.page.goto(`/${ADMIN_DIR}/logout.php`); + await this.page.goto(`/${ ADMIN_DIR }/logout.php`); } getZapClient() { diff --git a/e2e-tests/pages/cart.page.ts b/e2e-tests/pages/cart.page.ts index a360fc1e91..20d2a4719b 100644 --- a/e2e-tests/pages/cart.page.ts +++ b/e2e-tests/pages/cart.page.ts @@ -11,7 +11,7 @@ export class CartPage { constructor(page: Page) { this.page = page; - this.url = `${PlaywrightConfig.use?.baseURL ?? ""}/cart/index.php`; + this.url = `${ PlaywrightConfig.use?.baseURL ?? "" }/cart/index.php`; this.nextButton = page.locator('input[name=confirm][alt=購入手続きへ]'); this.zapClient = new ZapClient(); } @@ -25,15 +25,15 @@ export class CartPage { } getAdditionButton(row?: number) { - return this.page.locator(`table[summary=商品情報] >> tr >> nth=${row ?? 1} >> td >> nth=4 >> [alt="+"]`); + return this.page.locator(`table[summary=商品情報] >> tr >> nth=${ row ?? 1 } >> td >> nth=4 >> [alt="+"]`); } getSubtructionButton(row?: number) { - return this.page.locator(`table[summary=商品情報] >> tr >> nth=${row ?? 1} >> td >> nth=4 >> [alt="-"]`); + return this.page.locator(`table[summary=商品情報] >> tr >> nth=${ row ?? 1 } >> td >> nth=4 >> [alt="-"]`); } getQuantity(row?: number) { - return this.page.locator(`table[summary=商品情報] >> tr >> nth=${row ?? 1} >> td >> nth=4`); + return this.page.locator(`table[summary=商品情報] >> tr >> nth=${ row ?? 1 } >> td >> nth=4`); } async addition(row?: number) { diff --git a/e2e-tests/pages/contact.page.ts b/e2e-tests/pages/contact.page.ts index 16f18fbb2d..b6951ca672 100644 --- a/e2e-tests/pages/contact.page.ts +++ b/e2e-tests/pages/contact.page.ts @@ -28,7 +28,7 @@ export class ContactPage { // 'name01', 'name02', 'kana01', 'kana02', 'zip01', 'zip02', 'addr01', 'addr02', 'tel01', 'tel02', 'tel03' constructor(page: Page) { this.page = page; - this.url = `${PlaywrightConfig.use?.baseURL ?? ""}/contact/index.php`; + this.url = `${ PlaywrightConfig.use?.baseURL ?? "" }/contact/index.php`; this.confirmButton = page.locator('input[name=confirm][alt=確認ページへ]'); this.submitButton = page.locator('input[name=send][alt=送信]'); this.name01 = page.locator('input[name=name01]'); @@ -81,7 +81,7 @@ export class ContactPage { this.tel02, this.tel03, this.email, - this.emailConfirm, + this.emailConfirm ]; } getZapClient() { diff --git a/e2e-tests/pages/mypage/login.page.ts b/e2e-tests/pages/mypage/login.page.ts index aca4b26f36..5161c71d54 100644 --- a/e2e-tests/pages/mypage/login.page.ts +++ b/e2e-tests/pages/mypage/login.page.ts @@ -16,7 +16,7 @@ export class MypageLoginPage { this.url = '/mypage/login.php'; this.loginEmail = page.getByRole('textbox', { name: 'メールアドレスを入力して下さい' }); - this.loginPass = page.getByRole('textbox', { name: 'パスワードを入力して下さい' }) + this.loginPass = page.getByRole('textbox', { name: 'パスワードを入力して下さい' }); this.loginButton = page.locator('id=header_login_form').getByRole('button'); this.logoutButton = page.getByRole('button', { name: 'ログアウト' }).first(); this.zapClient = new ZapClient(); diff --git a/e2e-tests/pages/products/detail.page.ts b/e2e-tests/pages/products/detail.page.ts index 119348b123..c5bb5bef7f 100644 --- a/e2e-tests/pages/products/detail.page.ts +++ b/e2e-tests/pages/products/detail.page.ts @@ -17,7 +17,7 @@ export class ProductsDetailPage { } async goto(productId: number) { - await this.page.goto(`${PlaywrightConfig.use.baseURL}/products/detail.php?product_id=${productId}`); + await this.page.goto(`${ PlaywrightConfig.use.baseURL }/products/detail.php?product_id=${ productId }`); } async cartIn(quantity?: number, classCategory1?: string, classCategory2?: string) { diff --git a/e2e-tests/pages/shopping/deliv.page.ts b/e2e-tests/pages/shopping/deliv.page.ts index 07ae7e2de1..03f0d29eb9 100644 --- a/e2e-tests/pages/shopping/deliv.page.ts +++ b/e2e-tests/pages/shopping/deliv.page.ts @@ -15,7 +15,7 @@ export class ShoppingDelivPage { } async goto() { - await this.page.goto(`${PlaywrightConfig.use.baseURL}/shopping/deliv.php`); + await this.page.goto(`${ PlaywrightConfig.use.baseURL }/shopping/deliv.php`); } async gotoNext() { diff --git a/e2e-tests/pages/shopping/payment.page.ts b/e2e-tests/pages/shopping/payment.page.ts index 2a50717cb7..b89eafe930 100644 --- a/e2e-tests/pages/shopping/payment.page.ts +++ b/e2e-tests/pages/shopping/payment.page.ts @@ -28,7 +28,7 @@ export class ShoppingPaymentPage { } async goto() { - await this.page.goto(`${PlaywrightConfig.use?.baseURL}/shopping/payment.php`); + await this.page.goto(`${ PlaywrightConfig.use?.baseURL }/shopping/payment.php`); } async gotoNext() { @@ -36,7 +36,7 @@ export class ShoppingPaymentPage { } async selectPaymentMethod(label: string) { - await this.paymentMethod.locator(`text=${label}`).click(); + await this.paymentMethod.locator(`text=${ label }`).click(); } async selectDeliveryDate(index: number) { diff --git a/e2e-tests/test/admin/contents/recommendsearch.test.ts b/e2e-tests/test/admin/contents/recommendsearch.test.ts index c72799ce14..1277bb0534 100644 --- a/e2e-tests/test/admin/contents/recommendsearch.test.ts +++ b/e2e-tests/test/admin/contents/recommendsearch.test.ts @@ -2,7 +2,7 @@ import { test, expect } from '../../../fixtures/admin_login.fixture'; import { Page } from '@playwright/test'; import { ADMIN_DIR } from '../../../config/default.config'; -const url = `/${ADMIN_DIR}contents/recommend.php`; +const url = `/${ ADMIN_DIR }contents/recommend.php`; test.describe('おすすめ商品管理を確認します', () => { let page: Page; @@ -20,7 +20,7 @@ test.describe('おすすめ商品管理を確認します', () => { page.on('dialog', dialog => dialog.accept()); [ popup ] = await Promise.all([ page.waitForEvent('popup'), - page.click(`.recommend-product >> nth=${nth} >> a >> text=編集`) + page.click(`.recommend-product >> nth=${ nth } >> a >> text=編集`) ]); }); @@ -29,7 +29,7 @@ test.describe('おすすめ商品管理を確認します', () => { page.on('dialog', dialog => dialog.accept()); [ popup ] = await Promise.all([ page.waitForEvent('popup'), - page.click(`.recommend-product >> nth=${nth} >> a >> text=編集`) + page.click(`.recommend-product >> nth=${ nth } >> a >> text=編集`) ]); await popup.waitForLoadState('load'); await expect(popup.locator('#popup-container')).toContainText('カテゴリ'); @@ -38,8 +38,8 @@ test.describe('おすすめ商品管理を確認します', () => { await expect(popup.locator('#recommend-search-results >> tr >> nth=1')).toContainText('アイスクリーム'); await popup.click('#recommend-search-results >> tr >> nth=1 >> text=決定'); - await expect(page.locator(`.recommend-product >> nth=${nth}`)).toContainText('アイスクリーム'); - await page.click(`.recommend-product >> nth=${nth} >> text=この内容で登録する`); + await expect(page.locator(`.recommend-product >> nth=${ nth }`)).toContainText('アイスクリーム'); + await page.click(`.recommend-product >> nth=${ nth } >> text=この内容で登録する`); }); }); @@ -51,7 +51,7 @@ test.describe('おすすめ商品管理を確認します', () => { page.on('dialog', dialog => dialog.accept()); [ popup ] = await Promise.all([ page.waitForEvent('popup'), - page.click(`.recommend-product >> nth=${nth} >> a >> text=編集`) + page.click(`.recommend-product >> nth=${ nth } >> a >> text=編集`) ]); }); @@ -60,7 +60,7 @@ test.describe('おすすめ商品管理を確認します', () => { page.on('dialog', dialog => dialog.accept()); [ popup ] = await Promise.all([ page.waitForEvent('popup'), - page.click(`.recommend-product >> nth=${nth} >> a >> text=編集`) + page.click(`.recommend-product >> nth=${ nth } >> a >> text=編集`) ]); await popup.waitForLoadState('load'); await expect(popup.locator('#popup-container')).toContainText('商品コード'); @@ -69,8 +69,8 @@ test.describe('おすすめ商品管理を確認します', () => { await expect(popup.locator('#recommend-search-results >> tr >> nth=1')).toContainText('おなべレシピ'); await popup.click('#recommend-search-results >> tr >> nth=1 >> text=決定'); - await expect(page.locator(`.recommend-product >> nth=${nth}`)).toContainText('おなべレシピ'); - await page.click(`.recommend-product >> nth=${nth} >> text=この内容で登録する`); + await expect(page.locator(`.recommend-product >> nth=${ nth }`)).toContainText('おなべレシピ'); + await page.click(`.recommend-product >> nth=${ nth } >> text=この内容で登録する`); }); }); }); diff --git a/e2e-tests/test/admin/customer/edit.test.ts b/e2e-tests/test/admin/customer/edit.test.ts index e577b4d6b9..2014c1a168 100644 --- a/e2e-tests/test/admin/customer/edit.test.ts +++ b/e2e-tests/test/admin/customer/edit.test.ts @@ -1,7 +1,7 @@ import { test, expect } from '../../../fixtures/admin_login.fixture'; import { ADMIN_DIR } from '../../../config/default.config'; -const url = `/${ADMIN_DIR}/customer/edit.php`; +const url = `/${ ADMIN_DIR }/customer/edit.php`; test.describe('会員登録画面のテストをします', () => { test('会員登録画面のテストをします', async ( { loginPage, page }) => { diff --git a/e2e-tests/test/admin/home.test.ts b/e2e-tests/test/admin/home.test.ts index 550793f5aa..bd330ec350 100644 --- a/e2e-tests/test/admin/home.test.ts +++ b/e2e-tests/test/admin/home.test.ts @@ -2,7 +2,7 @@ import { test, expect } from '../../fixtures/admin_login.fixture'; import { Page } from '@playwright/test'; import { ADMIN_DIR } from '../../config/default.config'; -const url = `/${ADMIN_DIR}/home.php`; +const url = `/${ ADMIN_DIR }/home.php`; test.describe('管理画面Homeの確認をします', () => { let page: Page; diff --git a/e2e-tests/test/admin/ownersstore/plugin_install.test.ts b/e2e-tests/test/admin/ownersstore/plugin_install.test.ts index 3be08717c0..79413607a2 100644 --- a/e2e-tests/test/admin/ownersstore/plugin_install.test.ts +++ b/e2e-tests/test/admin/ownersstore/plugin_install.test.ts @@ -6,7 +6,7 @@ import fs from 'fs'; import { ADMIN_DIR } from '../../../config/default.config'; -const url = `/${ADMIN_DIR}ownersstore/index.php`; +const url = `/${ ADMIN_DIR }ownersstore/index.php`; const pluginPath = path.join(__dirname, '..', '..', '..', '..', 'tests', 'class', 'fixtures', 'plugin', 'PrefilterTransformPlugin'); diff --git a/e2e-tests/test/admin/system/index.test.ts b/e2e-tests/test/admin/system/index.test.ts index 57eb276927..277b36061f 100644 --- a/e2e-tests/test/admin/system/index.test.ts +++ b/e2e-tests/test/admin/system/index.test.ts @@ -5,18 +5,18 @@ import { faker as fakerEn } from '@faker-js/faker/locale/en'; import { ADMIN_DIR } from '../../../config/default.config'; -const url = `/${ADMIN_DIR}system/index.php`; +const url = `/${ ADMIN_DIR }system/index.php`; test.describe.serial('システム設定>メンバー管理画面を確認をします', () => { let page: Page; - test('メンバー管理画面を開きます', async( { loginPage, page } ) => { + test('メンバー管理画面を開きます', async ( { loginPage, page } ) => { await page.goto(url); await expect(page.locator('h1')).toContainText('システム設定>メンバー管理'); }); let popup: Page; - test('メンバー登録画面を開きます', async( { loginPage, page } ) => { + test('メンバー登録画面を開きます', async ( { loginPage, page } ) => { await page.goto(url); [ popup ] = await Promise.all([ page.waitForEvent('popup'), @@ -32,7 +32,7 @@ test.describe.serial('システム設定>メンバー管理画面を確認を const password = fakerEn.helpers.fake('{{internet.password}}{{datatype.number}}'); let edit: Page; - test('メンバー登録を確認します', async( { loginPage, page } ) => { + test('メンバー登録を確認します', async ( { loginPage, page } ) => { await page.goto(url); [ popup ] = await Promise.all([ page.waitForEvent('popup'), @@ -57,28 +57,28 @@ test.describe.serial('システム設定>メンバー管理画面を確認を ]); edit.on('dialog', dialog => dialog.accept()); expect(await edit.inputValue('input[name=name]')).toBe(name); - await edit.fill('input[name=department]', `${department} 変更`); + await edit.fill('input[name=department]', `${ department } 変更`); expect(await edit.inputValue('input[name=login_id]')).toBe(user); await edit.fill('input[name=password]', password); await edit.fill('input[name=password02]', password); await edit.click('text=この内容で登録する'); - await expect(page.locator('table.list >> tr >> nth=1')).toContainText(`${department} 変更`); + await expect(page.locator('table.list >> tr >> nth=1')).toContainText(`${ department } 変更`); }); - test('下へ移動を確認します', async( { loginPage, page } ) => { + test('下へ移動を確認します', async ( { loginPage, page } ) => { await page.goto(url); await page.click('table.list >> tr >> nth=1 >> text=下へ'); await expect(page.locator('table.list >> tr >> nth=2')).toContainText(name); }); - test('上へ移動を確認します', async( { loginPage, page } ) => { + test('上へ移動を確認します', async ( { loginPage, page } ) => { await page.goto(url); await page.click('table.list >> tr >> nth=2 >> text=上へ'); await expect(page.locator('table.list >> tr >> nth=1')).toContainText(name); }); - test('メンバー削除を確認します', async( { loginPage, page } ) => { + test('メンバー削除を確認します', async ( { loginPage, page } ) => { await page.goto(url); page.on('dialog', dialog => dialog.accept()); await page.click('table.list >> tr >> nth=1 >> text=削除'); diff --git a/e2e-tests/test/admin/total/total.test.ts b/e2e-tests/test/admin/total/total.test.ts index 5d7adcced6..188e6a2a6a 100644 --- a/e2e-tests/test/admin/total/total.test.ts +++ b/e2e-tests/test/admin/total/total.test.ts @@ -6,7 +6,7 @@ import fs from 'fs/promises'; import { ADMIN_DIR } from '../../../config/default.config'; -const url = `/${ADMIN_DIR}total/index.php`; +const url = `/${ ADMIN_DIR }total/index.php`; test.describe('売上集計画面を確認をします', () => { let page: Page; @@ -15,12 +15,12 @@ test.describe('売上集計画面を確認をします', () => { test.describe('期間別集計の確認をします', () => { const method = 'term'; test('期間別集計画面を開きます', async ( { loginPage, page } ) => { - await page.goto(`${url}?page=${method}`); + await page.goto(`${ url }?page=${ method }`); await expect(page.locator('h1')).toContainText('売上集計>期間別集計'); }); test('日付の初期値を確認します', async ( { loginPage, page } ) => { - await page.goto(`${url}?page=${method}`); + await page.goto(`${ url }?page=${ method }`); expect(await page.inputValue('select[name=search_startyear_m]')).toBe(String(current.getFullYear())); expect(await page.inputValue('select[name=search_startmonth_m]')).toBe(String(current.getMonth() + 1)); @@ -34,52 +34,52 @@ test.describe('売上集計画面を確認をします', () => { test('月度集計の確認をします', async ( { loginPage, page } ) => { await page.goto(url); - await page.goto(`${url}?page=${method}`); + await page.goto(`${ url }?page=${ method }`); await page.click('text=月度で集計する'); - await expect(page.locator(`#total-${method}`)).toBeEnabled(); + await expect(page.locator(`#total-${ method }`)).toBeEnabled(); }); - test('期間集計の確認をします', async( { loginPage, page } ) => { + test('期間集計の確認をします', async ( { loginPage, page } ) => { await page.goto(url); - await page.goto(`${url}?page=${method}`); + await page.goto(`${ url }?page=${ method }`); await page.click('text=期間で集計する'); - await expect(page.locator(`#total-${method}`)).toBeEnabled(); + await expect(page.locator(`#total-${ method }`)).toBeEnabled(); }); - test('月別集計の確認をします', async( { loginPage, page } ) => { + test('月別集計の確認をします', async ( { loginPage, page } ) => { await page.goto(url); - await page.goto(`${url}?page=${method}`); + await page.goto(`${ url }?page=${ method }`); await page.click('text=月度で集計する'); await page.click('text=月別'); - await expect(page.locator(`#total-${method}`)).toBeEnabled(); + await expect(page.locator(`#total-${ method }`)).toBeEnabled(); }); - test('年別集計の確認をします', async( { loginPage, page } ) => { + test('年別集計の確認をします', async ( { loginPage, page } ) => { await page.goto(url); - await page.goto(`${url}?page=${method}`); + await page.goto(`${ url }?page=${ method }`); await page.click('text=月度で集計する'); await page.click('text=年別'); - await expect(page.locator(`#total-${method}`)).toBeEnabled(); + await expect(page.locator(`#total-${ method }`)).toBeEnabled(); }); - test('曜日別集計の確認をします', async( { loginPage, page } ) => { + test('曜日別集計の確認をします', async ( { loginPage, page } ) => { await page.goto(url); - await page.goto(`${url}?page=${method}`); + await page.goto(`${ url }?page=${ method }`); await page.click('text=月度で集計する'); await page.click('text=曜日別'); - await expect(page.locator(`#total-${method}`)).toBeEnabled(); + await expect(page.locator(`#total-${ method }`)).toBeEnabled(); }); - test('時間別集計の確認をします', async( { loginPage, page } ) => { + test('時間別集計の確認をします', async ( { loginPage, page } ) => { await page.goto(url); - await page.goto(`${url}?page=${method}`); + await page.goto(`${ url }?page=${ method }`); await page.click('text=月度で集計する'); await page.click('text=時間別'); - await expect(page.locator(`#total-${method}`)).toBeEnabled(); + await expect(page.locator(`#total-${ method }`)).toBeEnabled(); }); - test('2行以上のCSVダウンロードできるか確認をします', async( { loginPage, page } ) => { - await page.goto(`${url}?page=${method}`); + test('2行以上のCSVダウンロードできるか確認をします', async ( { loginPage, page } ) => { + await page.goto(`${ url }?page=${ method }`); await page.click('text=月度で集計する'); const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -93,13 +93,13 @@ test.describe('売上集計画面を確認をします', () => { test.describe('商品別集計の確認をします', () => { const method = 'products'; - test('商品別集計画面を開きます', async( { loginPage, page } ) => { - await page.goto(`${url}?page=${method}`); + test('商品別集計画面を開きます', async ( { loginPage, page } ) => { + await page.goto(`${ url }?page=${ method }`); await expect(page.locator('h1')).toContainText('売上集計>商品別集計'); }); - test('日付の初期値を確認します', async( { loginPage, page } ) => { - await page.goto(`${url}?page=${method}`); + test('日付の初期値を確認します', async ( { loginPage, page } ) => { + await page.goto(`${ url }?page=${ method }`); expect(await page.inputValue('select[name=search_startyear_m]')).toBe(String(current.getFullYear())); expect(await page.inputValue('select[name=search_startmonth_m]')).toBe(String(current.getMonth() + 1)); @@ -111,38 +111,38 @@ test.describe('売上集計画面を確認をします', () => { expect(await page.inputValue('select[name=search_endday]')).toBe(String(current.getDate())); }); - test('月度集計の確認をします', async( { loginPage, page } ) => { + test('月度集計の確認をします', async ( { loginPage, page } ) => { await page.goto(url); - await page.goto(`${url}?page=${method}`); + await page.goto(`${ url }?page=${ method }`); await page.click('text=月度で集計する'); - await expect(page.locator(`#total-${method}`)).toBeEnabled(); + await expect(page.locator(`#total-${ method }`)).toBeEnabled(); }); - test('期間集計の確認をします', async( { loginPage, page } ) => { + test('期間集計の確認をします', async ( { loginPage, page } ) => { await page.goto(url); - await page.goto(`${url}?page=${method}`); + await page.goto(`${ url }?page=${ method }`); await page.click('text=期間で集計する'); - await expect(page.locator(`#total-${method}`)).toBeEnabled(); + await expect(page.locator(`#total-${ method }`)).toBeEnabled(); }); - test('会員集計の確認をします', async( { loginPage, page } ) => { + test('会員集計の確認をします', async ( { loginPage, page } ) => { await page.goto(url); - await page.goto(`${url}?page=${method}`); + await page.goto(`${ url }?page=${ method }`); await page.click('text=月度で集計する'); await page.click('text="会員"'); - await expect(page.locator(`#total-${method}`)).toBeEnabled(); + await expect(page.locator(`#total-${ method }`)).toBeEnabled(); }); - test('非会員集計の確認をします', async( { loginPage, page } ) => { + test('非会員集計の確認をします', async ( { loginPage, page } ) => { await page.goto(url); - await page.goto(`${url}?page=${method}`); + await page.goto(`${ url }?page=${ method }`); await page.click('text=月度で集計する'); await page.click('text=非会員'); - await expect(page.locator(`#total-${method}`)).toBeEnabled(); + await expect(page.locator(`#total-${ method }`)).toBeEnabled(); }); - test('2行以上のCSVダウンロードできるか確認をします', async( { loginPage, page } ) => { - await page.goto(`${url}?page=${method}`); + test('2行以上のCSVダウンロードできるか確認をします', async ( { loginPage, page } ) => { + await page.goto(`${ url }?page=${ method }`); await page.click('text=月度で集計する'); const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -156,13 +156,13 @@ test.describe('売上集計画面を確認をします', () => { test.describe('年代別集計の確認をします', () => { const method = 'age'; - test('年内別集計画面を開きます', async( { loginPage, page } ) => { - await page.goto(`${url}?page=${method}`); + test('年内別集計画面を開きます', async ( { loginPage, page } ) => { + await page.goto(`${ url }?page=${ method }`); await expect(page.locator('h1')).toContainText('売上集計>年代別集計'); }); - test('日付の初期値を確認します', async( { loginPage, page } ) => { - await page.goto(`${url}?page=${method}`); + test('日付の初期値を確認します', async ( { loginPage, page } ) => { + await page.goto(`${ url }?page=${ method }`); expect(await page.inputValue('select[name=search_startyear_m]')).toBe(String(current.getFullYear())); expect(await page.inputValue('select[name=search_startmonth_m]')).toBe(String(current.getMonth() + 1)); @@ -174,38 +174,38 @@ test.describe('売上集計画面を確認をします', () => { expect(await page.inputValue('select[name=search_endday]')).toBe(String(current.getDate())); }); - test('月度集計の確認をします', async( { loginPage, page } ) => { + test('月度集計の確認をします', async ( { loginPage, page } ) => { await page.goto(url); - await page.goto(`${url}?page=${method}`); + await page.goto(`${ url }?page=${ method }`); await page.click('text=月度で集計する'); - await expect(page.locator(`#total-${method}`)).toBeEnabled(); + await expect(page.locator(`#total-${ method }`)).toBeEnabled(); }); - test('期間集計の確認をします', async( { loginPage, page } ) => { + test('期間集計の確認をします', async ( { loginPage, page } ) => { await page.goto(url); - await page.goto(`${url}?page=${method}`); + await page.goto(`${ url }?page=${ method }`); await page.click('text=期間で集計する'); - await expect(page.locator(`#total-${method}`)).toBeEnabled(); + await expect(page.locator(`#total-${ method }`)).toBeEnabled(); }); - test('会員集計の確認をします', async( { loginPage, page } ) => { + test('会員集計の確認をします', async ( { loginPage, page } ) => { await page.goto(url); - await page.goto(`${url}?page=${method}`); + await page.goto(`${ url }?page=${ method }`); await page.click('text=月度で集計する'); await page.click('text="会員"'); - await expect(page.locator(`#total-${method}`)).toBeEnabled(); + await expect(page.locator(`#total-${ method }`)).toBeEnabled(); }); - test('非会員集計の確認をします', async( { loginPage, page } ) => { + test('非会員集計の確認をします', async ( { loginPage, page } ) => { await page.goto(url); - await page.goto(`${url}?page=${method}`); + await page.goto(`${ url }?page=${ method }`); await page.click('text=月度で集計する'); await page.click('text=非会員'); - await expect(page.locator(`#total-${method}`)).toBeEnabled(); + await expect(page.locator(`#total-${ method }`)).toBeEnabled(); }); - test('2行以上のCSVダウンロードできるか確認をします', async( { loginPage, page } ) => { - await page.goto(`${url}?page=${method}`); + test('2行以上のCSVダウンロードできるか確認をします', async ( { loginPage, page } ) => { + await page.goto(`${ url }?page=${ method }`); await page.click('text=月度で集計する'); const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -219,13 +219,13 @@ test.describe('売上集計画面を確認をします', () => { test.describe('職業別集計の確認をします', () => { const method = 'job'; - test('職業別集計画面を開きます', async( { loginPage, page } ) => { - await page.goto(`${url}?page=${method}`); + test('職業別集計画面を開きます', async ( { loginPage, page } ) => { + await page.goto(`${ url }?page=${ method }`); await expect(page.locator('h1')).toContainText('売上集計>職業別集計'); }); - test('日付の初期値を確認します', async( { loginPage, page } ) => { - await page.goto(`${url}?page=${method}`); + test('日付の初期値を確認します', async ( { loginPage, page } ) => { + await page.goto(`${ url }?page=${ method }`); expect(await page.inputValue('select[name=search_startyear_m]')).toBe(String(current.getFullYear())); expect(await page.inputValue('select[name=search_startmonth_m]')).toBe(String(current.getMonth() + 1)); @@ -237,22 +237,22 @@ test.describe('売上集計画面を確認をします', () => { expect(await page.inputValue('select[name=search_endday]')).toBe(String(current.getDate())); }); - test('月度集計の確認をします', async( { loginPage, page } ) => { + test('月度集計の確認をします', async ( { loginPage, page } ) => { await page.goto(url); - await page.goto(`${url}?page=${method}`); + await page.goto(`${ url }?page=${ method }`); await page.click('text=月度で集計する'); - await expect(page.locator(`#total-${method}`)).toBeEnabled(); + await expect(page.locator(`#total-${ method }`)).toBeEnabled(); }); - test('期間集計の確認をします', async( { loginPage, page } ) => { + test('期間集計の確認をします', async ( { loginPage, page } ) => { await page.goto(url); - await page.goto(`${url}?page=${method}`); + await page.goto(`${ url }?page=${ method }`); await page.click('text=期間で集計する'); - await expect(page.locator(`#total-${method}`)).toBeEnabled(); + await expect(page.locator(`#total-${ method }`)).toBeEnabled(); }); - test('2行以上のCSVダウンロードできるか確認をします', async( { loginPage, page } ) => { - await page.goto(`${url}?page=${method}`); + test('2行以上のCSVダウンロードできるか確認をします', async ( { loginPage, page } ) => { + await page.goto(`${ url }?page=${ method }`); await page.click('text=期間で集計する'); const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -266,13 +266,13 @@ test.describe('売上集計画面を確認をします', () => { test.describe('会員別集計の確認をします', () => { const method = 'member'; - test('会員別集計画面を開きます', async( { loginPage, page } ) => { - await page.goto(`${url}?page=${method}`); + test('会員別集計画面を開きます', async ( { loginPage, page } ) => { + await page.goto(`${ url }?page=${ method }`); await expect(page.locator('h1')).toContainText('売上集計>会員別集計'); }); - test('日付の初期値を確認します', async( { loginPage, page } ) => { - await page.goto(`${url}?page=${method}`); + test('日付の初期値を確認します', async ( { loginPage, page } ) => { + await page.goto(`${ url }?page=${ method }`); expect(await page.inputValue('select[name=search_startyear_m]')).toBe(String(current.getFullYear())); expect(await page.inputValue('select[name=search_startmonth_m]')).toBe(String(current.getMonth() + 1)); @@ -284,22 +284,22 @@ test.describe('売上集計画面を確認をします', () => { expect(await page.inputValue('select[name=search_endday]')).toBe(String(current.getDate())); }); - test('月度集計の確認をします', async( { loginPage, page } ) => { + test('月度集計の確認をします', async ( { loginPage, page } ) => { await page.goto(url); - await page.goto(`${url}?page=${method}`); + await page.goto(`${ url }?page=${ method }`); await page.click('text=月度で集計する'); - await expect(page.locator(`#total-${method}`)).toBeEnabled(); + await expect(page.locator(`#total-${ method }`)).toBeEnabled(); }); - test('期間集計の確認をします', async( { loginPage, page } ) => { + test('期間集計の確認をします', async ( { loginPage, page } ) => { await page.goto(url); - await page.goto(`${url}?page=${method}`); + await page.goto(`${ url }?page=${ method }`); await page.click('text=期間で集計する'); - await expect(page.locator(`#total-${method}`)).toBeEnabled(); + await expect(page.locator(`#total-${ method }`)).toBeEnabled(); }); - test('2行以上のCSVダウンロードできるか確認をします', async( { loginPage, page } ) => { - await page.goto(`${url}?page=${method}`); + test('2行以上のCSVダウンロードできるか確認をします', async ( { loginPage, page } ) => { + await page.goto(`${ url }?page=${ method }`); await page.click('text=期間で集計する'); const [ download ] = await Promise.all([ page.waitForEvent('download'), diff --git a/e2e-tests/test/front_guest/entry.test.ts b/e2e-tests/test/front_guest/entry.test.ts index 4cf2a507cb..16039eefe7 100644 --- a/e2e-tests/test/front_guest/entry.test.ts +++ b/e2e-tests/test/front_guest/entry.test.ts @@ -68,7 +68,7 @@ test.describe.serial('会員登録のテストをします', () => { await page.fill('input[name=password]', password); await page.fill('input[name=password02]', password); const sex = faker.datatype.number({ min: 1, max: 2 }); - await page.check(`input[name=sex][value="${sex}"]`); + await page.check(`input[name=sex][value="${ sex }"]`); const job = faker.datatype.number({ min: 1, max: 18 }); await page.selectOption('select[name=job]', { value: String(job) }); const birth = faker.date.past(20, addYears(new Date(), -20).toISOString()); @@ -79,7 +79,7 @@ test.describe.serial('会員登録のテストをします', () => { await page.selectOption('select[name=reminder]', String(reminder)); await page.fill('input[name=reminder_answer]', faker.lorem.word()); const mailmaga_flg = faker.datatype.number({ min: 1, max: 3 }); - await page.check(`input[name=mailmaga_flg][value="${mailmaga_flg}"]`); + await page.check(`input[name=mailmaga_flg][value="${ mailmaga_flg }"]`); await page.click('[alt=確認ページへ]'); }); @@ -116,7 +116,7 @@ test.describe.serial('会員登録のテストをします', () => { await expect(await messages.json()).toContainEqual(expect.objectContaining( { subject: expect.stringContaining('会員登録のご完了'), - recipients: expect.arrayContaining([ `<${email}>` ]) + recipients: expect.arrayContaining([ `<${ email }>` ]) } )); }); diff --git a/e2e-tests/test/front_guest/shopping.test.ts b/e2e-tests/test/front_guest/shopping.test.ts index ffdffb3377..19abbfd936 100644 --- a/e2e-tests/test/front_guest/shopping.test.ts +++ b/e2e-tests/test/front_guest/shopping.test.ts @@ -65,7 +65,7 @@ test.describe.serial('購入フロー(ゲスト)のテストをします', () => await page.fill('input[name=order_email]', email); await page.fill('input[name=order_email02]', email); const sex = faker.datatype.number({ min: 1, max: 2 }); - await page.check(`input[name=order_sex][value="${sex}"]`); + await page.check(`input[name=order_sex][value="${ sex }"]`); const job = faker.datatype.number({ min: 1, max: 18 }); await page.selectOption('select[name=order_job]', { value: String(job) }); const birth = faker.date.past(20, addYears(new Date(), -20).toISOString()); @@ -115,7 +115,7 @@ test.describe.serial('購入フロー(ゲスト)のテストをします', () => await expect(await messages.json()).toContainEqual(expect.objectContaining( { subject: expect.stringContaining('ご注文ありがとうございます'), - recipients: expect.arrayContaining([ `<${email}>` ]) + recipients: expect.arrayContaining([ `<${ email }>` ]) } )); }); diff --git a/e2e-tests/test/front_login/cart/cart.test.ts b/e2e-tests/test/front_login/cart/cart.test.ts index 6ce051047a..e14c9730dc 100644 --- a/e2e-tests/test/front_login/cart/cart.test.ts +++ b/e2e-tests/test/front_login/cart/cart.test.ts @@ -3,7 +3,7 @@ import PlaywrightConfig from '../../../../playwright.config'; import { Risk } from '../../../utils/ZapClient'; import { intervalRepeater } from '../../../utils/Progress'; -const url = `${PlaywrightConfig.use?.baseURL ?? ""}/cart/index.php`; +const url = `${ PlaywrightConfig.use?.baseURL ?? "" }/cart/index.php`; import { CartPage } from '../../../pages/cart.page'; // 商品をカートに入れて購入手続きへ進むフィクスチャ @@ -36,8 +36,8 @@ test.describe.serial('カートページのテストをします', () => { const result = await zapClient.getMessages(url, await zapClient.getNumberOfMessages(url) - 1, 1); const message = result.pop(); const transactionid = await page.locator('input[name=transactionid]').first().inputValue(); - const requestBody = message?.requestBody.replace(/transactionid=[a-z0-9]+/, `transactionid=${transactionid}`); - await zapClient.sendRequest(`${message?.requestHeader}${requestBody}${additionParams}`); + const requestBody = message?.requestBody.replace(/transactionid=[a-z0-9]+/, `transactionid=${ transactionid }`); + await zapClient.sendRequest(`${ message?.requestHeader }${ requestBody }${ additionParams }`); return await zapClient.getLastMessage(url); }; @@ -80,12 +80,13 @@ test.describe.serial('カートページのテストをします', () => { const cartPage = new CartPage(page); await cartPage.goto(); const transactionid = await page.locator('input[name=transactionid]').first().inputValue(); + // JavaScript でカートの数量を増やしておく await page.evaluate(async (transactionid: string) => { - await (async () => { + await(async () => { const searchParams = data => { const params = new URLSearchParams(); - Object.keys(data).forEach(key => params.append(key, data[key])); + Object.keys(data).forEach(key => params.append(key, data[ key ])); return params; }; const response = await fetch('/cart/index.php', { @@ -103,7 +104,7 @@ test.describe.serial('カートページのテストをします', () => { }) }); - return response.body + return response.body; })(); }, transactionid); diff --git a/e2e-tests/test/front_login/cart/cart_delete.test.ts b/e2e-tests/test/front_login/cart/cart_delete.test.ts index 853a54bd19..73f6b1e42b 100644 --- a/e2e-tests/test/front_login/cart/cart_delete.test.ts +++ b/e2e-tests/test/front_login/cart/cart_delete.test.ts @@ -5,15 +5,16 @@ import { intervalRepeater } from '../../../utils/Progress'; // 商品をカートに入れて購入手続きへ進むフィクスチャ import { test, expect } from '../../../fixtures/cartin.fixture'; -const url = `${PlaywrightConfig.use?.baseURL ?? ''}/cart/index.php`; +const url = `${ PlaywrightConfig.use?.baseURL ?? '' }/cart/index.php`; import { CartPage } from '../../../pages/cart.page'; // zap/patches/0009-cart_delete.patch を適用する必要があります test.describe.serial('カートページのテストをします', () => { - const detailURL = `${PlaywrightConfig.use?.baseURL ?? ''}/products/detail.php?product_id=1`; + const detailURL = `${ PlaywrightConfig.use?.baseURL ?? '' }/products/detail.php?product_id=1`; test('カートの削除をテストします', async ( { page } ) => { await page.goto(detailURL); await expect(page.locator('#detailrightbloc > h2')).toContainText('アイスクリーム'); + // 商品をカートに入れます await page.selectOption('select[name=classcategory_id1]', { label: '抹茶' }); await page.selectOption('select[name=classcategory_id2]', { label: 'S' }); @@ -23,6 +24,7 @@ test.describe.serial('カートページのテストをします', () => { // カートの内容を確認します await expect(page.locator('h2.title')).toContainText('現在のカゴの中'); await expect(page.locator('table[summary=商品情報] >> tr >> nth=1')).toContainText('アイスクリーム'); + // カートを削除します page.on('dialog', dialog => dialog.accept()); await page.reload(); @@ -38,6 +40,7 @@ test.describe.serial('カートページのテストをします', () => { const message = result.pop(); let scanId: number; + // アクティブスキャンを実行します expect(message?.requestBody).toContain('mode=delete'); scanId = await zapClient.activeScanAsUser(url, 2, 110, false, null, 'POST', message?.requestBody); diff --git a/e2e-tests/test/front_login/contact.test.ts b/e2e-tests/test/front_login/contact.test.ts index 29aeb80709..dcd3c3d72a 100644 --- a/e2e-tests/test/front_login/contact.test.ts +++ b/e2e-tests/test/front_login/contact.test.ts @@ -10,13 +10,13 @@ const inputNames = [ 'tel01', 'tel02', 'tel03' ] as const; -const url = `${PlaywrightConfig?.use?.baseURL ?? ''}/contact/index.php`; +const url = `${ PlaywrightConfig?.use?.baseURL ?? '' }/contact/index.php`; test.describe.serial('お問い合わせページのテストをします', () => { let page: Page; - test('お問い合わせページを表示します', async( { page } ) => { - const contactPage = new ContactPage(page) + test('お問い合わせページを表示します', async ( { page } ) => { + const contactPage = new ContactPage(page); await contactPage.goto(); await expect(page).toHaveTitle(/お問い合わせ/); await expect(page.locator('h2.title')).toContainText('お問い合わせ'); @@ -24,11 +24,11 @@ test.describe.serial('お問い合わせページのテストをします', () = test.describe('テストを実行します[GET] @attack', () => { let scanId: number; - test('アクティブスキャンを実行します', async() => { - const contactPage = new ContactPage(page) + test('アクティブスキャンを実行します', async () => { + const contactPage = new ContactPage(page); const zapClient = contactPage.getZapClient(); scanId = await zapClient.activeScanAsUser(url, 2, 110, false, null, 'GET'); - await intervalRepeater(async( { page } ) => await zapClient.getActiveScanStatus(scanId), 5000, page); + await intervalRepeater(async ( { page } ) => await zapClient.getActiveScanStatus(scanId), 5000, page); await zapClient.getAlerts(url, 0, 1, Risk.High) .then(alerts => expect(alerts).toEqual([])); @@ -39,7 +39,7 @@ test.describe.serial('お問い合わせページのテストをします', () = 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()); + 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'); }); @@ -47,7 +47,7 @@ test.describe.serial('お問い合わせページのテストをします', () = let confirmMessage: HttpMessage; let completeMessage: HttpMessage; test('お問い合わせ内容を入力します', async ({ page }) => { - const contactPage = new ContactPage(page) + const contactPage = new ContactPage(page); await contactPage.goto(); const zapClient = contactPage.getZapClient(); await page.fill('textarea[name=contents]', 'お問い合わせ入力'); @@ -60,8 +60,8 @@ test.describe.serial('お問い合わせページのテストをします', () = // 入力内容を確認します await expect(page.locator('h2.title')).toContainText('お問い合わせ(確認ページ)'); inputNames.forEach(async (name) => { - await expect(page.locator(`input[name=${name}]`)).toBeHidden(); - await expect(page.locator(`input[name=${name}]`)).not.toBeEmpty(); + await expect(page.locator(`input[name=${ name }]`)).toBeHidden(); + 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'); @@ -91,31 +91,34 @@ test.describe.serial('お問い合わせページのテストをします', () = let requestBody: string; test('アクティブスキャンを実行します', async ({ page }) => { - const contactPage = new ContactPage(page) + const contactPage = new ContactPage(page); const zapClient = contactPage.getZapClient(); completeMessage = await zapClient.getLastMessage(url); + // transactionid を取得し直します await page.goto(url); const transactionid = await page.locator('input[name=transactionid]').first().inputValue(); - requestBody = confirmMessage.requestBody.replace(/transactionid=[a-z0-9]+/, `transactionid=${transactionid}`); + requestBody = confirmMessage.requestBody.replace(/transactionid=[a-z0-9]+/, `transactionid=${ transactionid }`); expect(requestBody).toContain('mode=confirm'); const scanId = await zapClient.activeScanAsUser(url, 2, 110, false, null, 'POST', requestBody); await intervalRepeater(async () => await zapClient.getActiveScanStatus(scanId), 5000, page); + // 結果を確認します await zapClient.getAlerts(url, 0, 1, Risk.High) .then(alerts => expect(alerts).toEqual([])); }); - }) + }); test.describe('テストを実行します[POST][確認→完了] @attack', () => { let requestBody: string; test('アクティブスキャンを実行します', async () => { + // transactionid を取得し直します await page.goto(url); const transactionid = await page.locator('input[name=transactionid]').first().inputValue(); - requestBody = completeMessage.requestBody.replace(/transactionid=[a-z0-9]+/, `transactionid=${transactionid}`); + requestBody = completeMessage.requestBody.replace(/transactionid=[a-z0-9]+/, `transactionid=${ transactionid }`); expect(completeMessage.responseHeader).toContain('HTTP/1.1 302 Found'); expect(requestBody).toContain('mode=complete'); const scanId = await zapClient.activeScanAsUser(url, 2, 110, false, null, 'POST', requestBody); diff --git a/e2e-tests/test/front_login/mypage/change.test.ts b/e2e-tests/test/front_login/mypage/change.test.ts index eeb8894b69..b13c8beb97 100644 --- a/e2e-tests/test/front_login/mypage/change.test.ts +++ b/e2e-tests/test/front_login/mypage/change.test.ts @@ -1,7 +1,7 @@ import { test, expect } from '../../../fixtures/mypage_login.fixture'; import PlaywrightConfig from '../../../../playwright.config'; -const url = `${PlaywrightConfig.use?.baseURL ?? ''}/mypage/change.php`; +const url = `${ PlaywrightConfig.use?.baseURL ?? '' }/mypage/change.php`; test.describe.serial('会員登録内容変更画面のテストをします', () => { test('会員登録内容変更画面のテストをします', async ( { page }) => { await page.goto(url); diff --git a/e2e-tests/test/front_login/products_list.test.ts b/e2e-tests/test/front_login/products_list.test.ts index 6029a7260d..b634384d7e 100644 --- a/e2e-tests/test/front_login/products_list.test.ts +++ b/e2e-tests/test/front_login/products_list.test.ts @@ -22,19 +22,19 @@ test.describe('商品一覧のテストをします', () => { if (all_products < 50) { - await expect(page.locator('#undercolumn > div > span.attention')).toContainText(`${all_products}件`); + await expect(page.locator('#undercolumn > div > span.attention')).toContainText(`${ all_products }件`); } else { const hasPager = await page.locator('#page_navi_top .navi > strong').isVisible(); if (hasPager) { - await expect(page.locator('#undercolumn > div > span.attention')).not.toContainText(`${all_products}件`); + await expect(page.locator('#undercolumn > div > span.attention')).not.toContainText(`${ all_products }件`); } else { - await expect(page.locator('#undercolumn > div > span.attention')).toContainText(`${all_products}件`); + await expect(page.locator('#undercolumn > div > span.attention')).toContainText(`${ all_products }件`); } } }); test('食品のカテゴリを確認します', async ( { page } ) => { - await page.goto(`${url}?category_id=3`); + await page.goto(`${ url }?category_id=3`); await page.selectOption('#page_navi_top select', { label: '50件' }); await page.waitForSelector('#undercolumn > form > div > div.listrightbloc > h3 > a'); const all_products = await page.locator('#undercolumn > form > div > div.listrightbloc > h3 > a').count(); @@ -45,13 +45,13 @@ test.describe('商品一覧のテストをします', () => { await expect(page.locator('#undercolumn > form > div > div.listrightbloc > h3 > a')).not.toContainText('おなべ'); if (all_products < 50) { - await expect(page.locator('#undercolumn > div > span.attention')).toContainText(`${all_products}件`); + await expect(page.locator('#undercolumn > div > span.attention')).toContainText(`${ all_products }件`); } else { const hasPager = await page.locator('#page_navi_top .navi > strong').isVisible(); if (hasPager) { - await expect(page.locator('#undercolumn > div > span.attention')).not.toContainText(`${all_products}件`); + await expect(page.locator('#undercolumn > div > span.attention')).not.toContainText(`${ all_products }件`); } else { - await expect(page.locator('#undercolumn > div > span.attention')).toContainText(`${all_products}件`); + await expect(page.locator('#undercolumn > div > span.attention')).toContainText(`${ all_products }件`); } } }); diff --git a/e2e-tests/test/front_login/shopping.test.ts b/e2e-tests/test/front_login/shopping.test.ts index 5eb275fe12..83dd8d39c3 100644 --- a/e2e-tests/test/front_login/shopping.test.ts +++ b/e2e-tests/test/front_login/shopping.test.ts @@ -18,6 +18,7 @@ test.describe.serial('購入フロー(ログイン)のテストをします', () test('商品を購入します', async ({ page }) => { await page.goto(url); await expect(page.locator('#detailrightbloc > h2')).toContainText('アイスクリーム'); + // 商品をカートに入れます await page.selectOption('select[name=classcategory_id1]', { label: '抹茶' }); await page.selectOption('select[name=classcategory_id2]', { label: 'S' }); @@ -47,6 +48,7 @@ test.describe.serial('購入フロー(ログイン)のテストをします', () await page.click('[alt=ご注文完了ページへ]'); const email = 'zap_user@example.com'; + // 注文完了を確認します await expect(page.locator('h2.title')).toContainText('ご注文完了'); @@ -55,7 +57,7 @@ test.describe.serial('購入フロー(ログイン)のテストをします', () await expect(await messages.json()).toContainEqual(expect.objectContaining( { subject: expect.stringContaining('ご注文ありがとうございます'), - recipients: expect.arrayContaining([ `<${email}>` ]) + recipients: expect.arrayContaining([ `<${ email }>` ]) } )); }); diff --git a/e2e-tests/test/front_login/shopping/shopping_complete.test.ts b/e2e-tests/test/front_login/shopping/shopping_complete.test.ts index 9032afe383..30b443ee9d 100644 --- a/e2e-tests/test/front_login/shopping/shopping_complete.test.ts +++ b/e2e-tests/test/front_login/shopping/shopping_complete.test.ts @@ -2,7 +2,7 @@ import PlaywrightConfig from '../../../../playwright.config'; import { Risk } from '../../../utils/ZapClient'; import { intervalRepeater } from '../../../utils/Progress'; -const url = `${PlaywrightConfig.use?.baseURL ?? ''}/shopping/complete.php`; +const url = `${ PlaywrightConfig.use?.baseURL ?? '' }/shopping/complete.php`; import { ShoppingPaymentPage } from '../../../pages/shopping/payment.page'; // ご注文確認画面へ進むフィクスチャ diff --git a/e2e-tests/test/front_login/shopping/shopping_confirm.test.ts b/e2e-tests/test/front_login/shopping/shopping_confirm.test.ts index 9373943458..b8ee820874 100644 --- a/e2e-tests/test/front_login/shopping/shopping_confirm.test.ts +++ b/e2e-tests/test/front_login/shopping/shopping_confirm.test.ts @@ -2,7 +2,7 @@ import PlaywrightConfig from '../../../../playwright.config'; import { Risk } from '../../../utils/ZapClient'; import { intervalRepeater } from '../../../utils/Progress'; -const url = `${PlaywrightConfig.use?.baseURL ?? ''}/shopping/confirm.php`; +const url = `${ PlaywrightConfig.use?.baseURL ?? '' }/shopping/confirm.php`; import { ShoppingPaymentPage } from '../../../pages/shopping/payment.page'; // ご注文確認画面へ進むフィクスチャ @@ -42,7 +42,7 @@ test.describe.serial('ご注文確認画面のテストをします', () => { const paymentPage = new ShoppingPaymentPage(page); const zapClient = paymentPage.getZapClient(); const message = await zapClient.getLastMessage(url); - expect(message.requestHeader).toContain(`POST ${url}`); + expect(message.requestHeader).toContain(`POST ${ url }`); expect(message.responseHeader).toContain('HTTP/1.1 302 Found'); scanId = await zapClient.activeScanAsUser(url, 2, 110, false, null, 'POST', message.requestBody); await intervalRepeater(async () => await zapClient.getActiveScanStatus(scanId), 5000, page); diff --git a/e2e-tests/test/front_login/shopping/shopping_deliv.test.ts b/e2e-tests/test/front_login/shopping/shopping_deliv.test.ts index 81a0fc8efb..acb32bc74b 100644 --- a/e2e-tests/test/front_login/shopping/shopping_deliv.test.ts +++ b/e2e-tests/test/front_login/shopping/shopping_deliv.test.ts @@ -2,7 +2,7 @@ import PlaywrightConfig from '../../../../playwright.config'; import { Risk } from '../../../utils/ZapClient'; import { intervalRepeater } from '../../../utils/Progress'; -const url = `${PlaywrightConfig.use?.baseURL ?? ''}/shopping/deliv.php`; +const url = `${ PlaywrightConfig.use?.baseURL ?? '' }/shopping/deliv.php`; // 商品をカートに入れて購入手続きへ進むフィクスチャ import { test, expect } from '../../../fixtures/cartin.fixture'; @@ -41,14 +41,15 @@ test.describe.serial('お届け先指定画面のテストをします', () => { const cartPage = new CartPage(page); const zapClient = cartPage.getZapClient(); const message = await zapClient.getLastMessage(url); - expect(message.requestHeader).toContain(`POST ${url}`); + expect(message.requestHeader).toContain(`POST ${ url }`); expect(message.responseHeader).toContain('HTTP/1.1 302 Found'); const getMessage = async () => { + // transactionid を取得し直して置換します const transactionid = await page.locator('input[name=transactionid]').first().inputValue(); - const requestBody = message.requestBody.replace(/transactionid=[a-z0-9]+/, `transactionid=${transactionid}`); - await zapClient.sendRequest(`${message.requestHeader}${requestBody}&mode_dummy=dummy`); + const requestBody = message.requestBody.replace(/transactionid=[a-z0-9]+/, `transactionid=${ transactionid }`); + await zapClient.sendRequest(`${ message.requestHeader }${ requestBody }&mode_dummy=dummy`); return await zapClient.getLastMessage(url); }; scanId = await zapClient.activeScanAsUser(url, 2, 110, false, null, 'POST', await getMessage().then(httpMessage => httpMessage.requestBody)); diff --git a/e2e-tests/test/front_login/shopping/shopping_payment.test.ts b/e2e-tests/test/front_login/shopping/shopping_payment.test.ts index 2665d3d3a3..d2df42af99 100644 --- a/e2e-tests/test/front_login/shopping/shopping_payment.test.ts +++ b/e2e-tests/test/front_login/shopping/shopping_payment.test.ts @@ -3,7 +3,7 @@ import PlaywrightConfig from '../../../../playwright.config'; import { Risk } from '../../../utils/ZapClient'; import { intervalRepeater } from '../../../utils/Progress'; -const url = `${PlaywrightConfig.use?.baseURL ?? ''}/shopping/payment.php`; +const url = `${ PlaywrightConfig.use?.baseURL ?? '' }/shopping/payment.php`; import { CartPage } from '../../../pages/cart.page'; import { ShoppingPaymentPage } from '../../../pages/shopping/payment.page'; @@ -24,6 +24,7 @@ test.describe.serial('お支払方法・お届け時間等の指定画面のテ const zapClient = cartPage.getZapClient(); scanId = await zapClient.activeScanAsUser(url, 2, 110, false, null, 'GET'); await intervalRepeater(async () => await zapClient.getActiveScanStatus(scanId), 5000, page); + // 結果を確認します await zapClient.getAlerts(url, 0, 1, Risk.High) .then(alerts => expect(alerts).toEqual([])); @@ -44,8 +45,8 @@ test.describe.serial('お支払方法・お届け時間等の指定画面のテ const zapClient = cartPage.getZapClient(); const message = await zapClient.getLastMessage(url); const transactionid = await page.locator('input[name=transactionid]').first().inputValue(); - const requestBody = message.requestBody.replace(/transactionid=[a-z0-9]+/, `transactionid=${transactionid}`); - await zapClient.sendRequest(`${message.requestHeader}${requestBody}&mode_confirm=dummy`); + const requestBody = message.requestBody.replace(/transactionid=[a-z0-9]+/, `transactionid=${ transactionid }`); + await zapClient.sendRequest(`${ message.requestHeader }${ requestBody }&mode_confirm=dummy`); return await zapClient.getLastMessage(url); }; @@ -60,10 +61,11 @@ test.describe.serial('お支払方法・お届け時間等の指定画面のテ const zapClient = paymentPage.getZapClient(); const message = await getMessage(page); - expect(message.requestHeader).toContain(`POST ${url}`); + expect(message.requestHeader).toContain(`POST ${ url }`); expect(message.responseHeader).toContain('HTTP/1.1 302 Found'); scanId = await zapClient.activeScanAsUser(url, 2, 110, false, null, 'POST', message.requestBody); await intervalRepeater(async () => await zapClient.getActiveScanStatus(scanId), 5000, page); + // 結果を確認します await zapClient.getAlerts(url, 0, 1, Risk.High) .then(alerts => expect(alerts).toEqual([])); diff --git a/e2e-tests/test/front_login/welcome.test.ts b/e2e-tests/test/front_login/welcome.test.ts index 1c869fb2c6..b3873b9f25 100644 --- a/e2e-tests/test/front_login/welcome.test.ts +++ b/e2e-tests/test/front_login/welcome.test.ts @@ -2,7 +2,7 @@ import { test, expect } from '../../fixtures/mypage_login.fixture'; import { Page } from '@playwright/test'; const url = '/index.php'; -import { MypageLoginPage } from '../../pages/mypage/login.page' +import { MypageLoginPage } from '../../pages/mypage/login.page'; test.describe('トップページのテストをします', () => { let page: Page; diff --git a/e2e-tests/test/installer/installer.test.ts b/e2e-tests/test/installer/installer.test.ts index 368eebb59c..62c87bd364 100644 --- a/e2e-tests/test/installer/installer.test.ts +++ b/e2e-tests/test/installer/installer.test.ts @@ -45,8 +45,8 @@ test.describe.serial('インストーラのテストをします', () => { await page.fill('input[name=login_pass]', password); await page.fill('input[name=admin_dir]', adminDirectory); await page.check('text=SSLを強制する'); - await page.fill('input[name=normal_url]', `${baseURL}/`); - await page.fill('input[name=secure_url]', `${baseURL}/`); + await page.fill('input[name=normal_url]', `${ baseURL }/`); + await page.fill('input[name=secure_url]', `${ baseURL }/`); await page.click('#options'); await page.check('text=SMTP'); await page.fill('input[name=smtp_host]', 'mailcatcher'); diff --git a/e2e-tests/utils/Progress.ts b/e2e-tests/utils/Progress.ts index c995339630..f9445e25f0 100644 --- a/e2e-tests/utils/Progress.ts +++ b/e2e-tests/utils/Progress.ts @@ -5,7 +5,7 @@ export const intervalRepeater = async (callback: any, interval: number, page: Pa console.log('\n::group::Active Scan progress...'); while (progress < 100) { progress = await callback(); - console.log(`${progress}%`); + console.log(`${ progress }%`); await page.waitForTimeout(interval); } console.log('::endgroup::'); diff --git a/e2e-tests/utils/ZapClient.ts b/e2e-tests/utils/ZapClient.ts index e1dade4798..e713a9d35e 100644 --- a/e2e-tests/utils/ZapClient.ts +++ b/e2e-tests/utils/ZapClient.ts @@ -7,12 +7,16 @@ import PlaywrightConfig from '../../playwright.config'; * @enum */ export const Mode = { + /** セーフモード - 潜在的に危険な操作を行うことを許可しません. */ Safe: 'safe', + /** プロテクトモード - スコープ内のアイテム上のみ潜在的に危険な操作を行うことを許可します. */ Protect: 'protect', + /** 標準モード - どんな潜在的に危険な操作を行うことでも許可します. */ - Standard: 'standard', + Standard: 'standard' + /** 攻撃モード - 危険なので使用しないでください! */ // Attack: 'attack' denger!! } as const; @@ -25,10 +29,13 @@ type Mode = typeof Mode[keyof typeof Mode]; * @enum */ export const ContextType = { + /** フロント画面/ログイン状態のコンテキスト. */ FrontLogin: 'front_login.context', + /** フロント画面/非会員状態のコンテキスト. */ FrontGuest: 'front_guest.context', + /** 管理画面のコンテキスト. */ Admin: 'admin.context' } as const; @@ -110,8 +117,10 @@ export class ZapClient { /** APIキー. */ private apiKey: string | null; + /** プロキシサーバーのホスト名. */ private proxy: string | undefined; + /** ClientApi のインスタンス. */ private readonly zaproxy; @@ -320,7 +329,7 @@ export class ZapClient { */ public async startSession(contextType: ContextType, sessionName: string): Promise { await this.setMode(Mode.Protect); - await this.newSession(`/zap/wrk/sessions/${sessionName}`, true); + await this.newSession(`/zap/wrk/sessions/${ sessionName }`, true); await this.importContext(contextType); switch (contextType) {