From 03664ad81e96df1209a8099f5e60d9985e8e7821 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Mon, 1 Aug 2022 17:45:41 +0900 Subject: [PATCH] =?UTF-8?q?*=5FEx=20=E3=82=AF=E3=83=A9=E3=82=B9=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=9F=E5=A0=B4=E5=90=88=E3=81=AE?= =?UTF-8?q?=20E2E=20=E3=83=86=E3=82=B9=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/e2e-tests.yml | 9 +++++- e2e-tests/test/admin/customer/edit.test.ts | 22 ++++++++++++++ e2e-tests/test/admin/home.test.ts | 24 +++++++-------- e2e-tests/test/admin/index.test.ts | 28 +++++++++++++++++ e2e-tests/test/admin/total/total.test.ts | 5 ++++ e2e-tests/test/front_guest/welcome.test.ts | 30 +++++++++++++++++++ .../test/front_login/mypage/change.test.ts | 22 ++++++++++++++ e2e-tests/test/front_login/welcome.test.ts | 5 ++++ package.json | 5 ++-- .../page_extends/LC_Page_Index_Ex.php | 14 +++++++++ .../admin/LC_Page_Admin_Home_Ex.php | 21 +++++++++++++ .../LC_Page_Admin_Customer_Edit_Ex.php | 14 +++++++++ .../admin/total/LC_Page_Admin_Total_Ex.php | 14 +++++++++ .../mypage/LC_Page_Mypage_Change_Ex.php | 14 +++++++++ 14 files changed, 212 insertions(+), 15 deletions(-) create mode 100644 e2e-tests/test/admin/customer/edit.test.ts create mode 100644 e2e-tests/test/admin/index.test.ts create mode 100644 e2e-tests/test/front_guest/welcome.test.ts create mode 100644 e2e-tests/test/front_login/mypage/change.test.ts create mode 100644 tests/class/fixtures/page_extends/LC_Page_Index_Ex.php create mode 100644 tests/class/fixtures/page_extends/admin/LC_Page_Admin_Home_Ex.php create mode 100644 tests/class/fixtures/page_extends/admin/customer/LC_Page_Admin_Customer_Edit_Ex.php create mode 100644 tests/class/fixtures/page_extends/admin/total/LC_Page_Admin_Total_Ex.php create mode 100644 tests/class/fixtures/page_extends/mypage/LC_Page_Mypage_Change_Ex.php diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 0efbb29d95..8bf9a4008e 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -19,6 +19,9 @@ jobs: strategy: fail-fast: false matrix: + pattern: + - 'test:e2e' + - 'test:e2e-extends' group: - 'test/front_login' - 'test/front_guest' @@ -35,6 +38,9 @@ jobs: - name: Setup environment run: echo "COMPOSE_FILE=docker-compose.yml:docker-compose.pgsql.yml:docker-compose.dev.yml:docker-compose.owaspzap.yml:docker-compose.owaspzap.daemon.yml" >> $GITHUB_ENV + - if: matrix.pattern == 'test:e2e-extends' + run: cp -rp tests/class/fixtures/page_extends/* data/class_extends/page_extends + - name: Setup to EC-CUBE env: HTTP_URL: https://127.0.0.1:8085/ @@ -57,11 +63,12 @@ jobs: - name: Run to E2E testing env: GROUP: ${{ matrix.group }} + PATTERN: ${{ matrix.pattern }} HTTPS_PROXY: 'localhost:8090' HTTP_PROXY: 'localhost:8090' CI: 1 FORCE_COLOR: 1 - run: yarn test:e2e e2e-tests/${GROUP} + run: yarn ${PATTERN} e2e-tests/${GROUP} - name: Upload evidence if: failure() diff --git a/e2e-tests/test/admin/customer/edit.test.ts b/e2e-tests/test/admin/customer/edit.test.ts new file mode 100644 index 0000000000..6629dae6f0 --- /dev/null +++ b/e2e-tests/test/admin/customer/edit.test.ts @@ -0,0 +1,22 @@ +import { test, expect } from '@playwright/test'; +import PlaywrightConfig from '../../../../playwright.config'; +import { ZapClient, ContextType } from '../../../utils/ZapClient'; +const zapClient = new ZapClient(); + +const url = `${PlaywrightConfig.use.baseURL}/admin/customer/edit.php`; +test.describe.serial('会員登録画面のテストをします', () => { + test.beforeAll(async () => { + await zapClient.startSession(ContextType.Admin, 'admin_customer_edit') + .then(async () => expect(await zapClient.isForcedUserModeEnabled()).toBeTruthy()); + }); + + test('会員登録画面のテストをします', async ( { page }) => { + await page.goto(url); + await expect(page.locator('h1')).toContainText(/会員登録/); + }); + + test('LC_Page_Admin_Customer_Edit_Ex クラスのテストをします @extends', async ( { page }) => { + await page.goto(url); + await expect(page.locator('h1')).toContainText(/カスタマイズ/); + }); +}); diff --git a/e2e-tests/test/admin/home.test.ts b/e2e-tests/test/admin/home.test.ts index 4e6bde2349..24efb02199 100644 --- a/e2e-tests/test/admin/home.test.ts +++ b/e2e-tests/test/admin/home.test.ts @@ -1,28 +1,28 @@ import { test, expect, chromium, Page } from '@playwright/test'; import { ADMIN_DIR } from '../../config/default.config'; +import { ZapClient, ContextType } from '../../utils/ZapClient'; +const zapClient = new ZapClient(); -const url = `/${ADMIN_DIR}index.php`; +const url = `/${ADMIN_DIR}/home.php`; -test.describe.serial('管理画面に正常にログインできるか確認します', () => { +test.describe.serial('管理画面Homeの確認をします', () => { let page: Page; test.beforeAll(async () => { + await zapClient.startSession(ContextType.Admin, 'admin_home') + .then(async () => expect(await zapClient.isForcedUserModeEnabled()).toBeTruthy()); const browser = await chromium.launch(); page = await browser.newPage(); await page.goto(url); }); - test('ログイン画面を確認します', async () => { - await expect(page.locator('#login-form')).toContainText(/LOGIN/); - }); - - test('ログインします', async () => { - await page.fill('input[name=login_id]', 'admin'); - await page.fill('input[name=password]', 'password'); - await page.click('text=LOGIN'); + test('システム情報を確認します', async ({ page }) => { + await page.goto(url); + await expect(page.locator('.shop-info >> nth=0 >> tr >> nth=0 >> td')).toContainText('2.17'); }); - test('ログインしたのを確認します', async () => { - await expect(page.locator('#site-check')).toContainText('ログイン : 管理者 様'); + test('LC_Page_Admin_Home_Ex クラスのテストをします @extends', async ({ page }) => { + await page.goto(url); + await expect(page.locator('.shop-info >> nth=0 >> tr >> nth=1 >> td')).toContainText('PHP_VERSION_ID'); }); }); diff --git a/e2e-tests/test/admin/index.test.ts b/e2e-tests/test/admin/index.test.ts new file mode 100644 index 0000000000..4e6bde2349 --- /dev/null +++ b/e2e-tests/test/admin/index.test.ts @@ -0,0 +1,28 @@ +import { test, expect, chromium, Page } from '@playwright/test'; +import { ADMIN_DIR } from '../../config/default.config'; + +const url = `/${ADMIN_DIR}index.php`; + +test.describe.serial('管理画面に正常にログインできるか確認します', () => { + let page: Page; + test.beforeAll(async () => { + const browser = await chromium.launch(); + + page = await browser.newPage(); + await page.goto(url); + }); + + test('ログイン画面を確認します', async () => { + await expect(page.locator('#login-form')).toContainText(/LOGIN/); + }); + + test('ログインします', async () => { + await page.fill('input[name=login_id]', 'admin'); + await page.fill('input[name=password]', 'password'); + await page.click('text=LOGIN'); + }); + + test('ログインしたのを確認します', async () => { + await expect(page.locator('#site-check')).toContainText('ログイン : 管理者 様'); + }); +}); diff --git a/e2e-tests/test/admin/total/total.test.ts b/e2e-tests/test/admin/total/total.test.ts index b41b36604e..e0ad3ad824 100644 --- a/e2e-tests/test/admin/total/total.test.ts +++ b/e2e-tests/test/admin/total/total.test.ts @@ -313,4 +313,9 @@ test.describe.serial('売上集計画面を確認をします', () => { .then(file => expect(file.split('\r\n').length).toBeGreaterThanOrEqual(2)); }); }); + + test('LC_Page_Admin_Total_Ex クラスのテストをします @extends', async ( { page }) => { + await page.goto(url); + await expect(page.locator('h1')).toContainText(/カスタマイズ/); + }); }); diff --git a/e2e-tests/test/front_guest/welcome.test.ts b/e2e-tests/test/front_guest/welcome.test.ts new file mode 100644 index 0000000000..94477161ac --- /dev/null +++ b/e2e-tests/test/front_guest/welcome.test.ts @@ -0,0 +1,30 @@ +import { test, expect, chromium, Page } from '@playwright/test'; + +const url = '/index.php'; + +test.describe.serial('トップページのテストをします', () => { + let page: Page; + test.beforeAll(async () => { + const browser = await chromium.launch(); + page = await browser.newPage(); + await page.goto(url); + }); + + test('TOPページが正常に見られているかを確認します', async () => { + await expect(page.locator('#site_description')).toHaveText('EC-CUBE発!世界中を旅して見つけた立方体グルメを立方隊長が直送!'); + await expect(page.locator('#main_image')).toBeVisible(); + }); + + test('body の class 名出力を確認します', async () => { + await expect(page.locator('body')).toHaveAttribute('class', 'LC_Page_Index'); + }); + + test('システムエラーが出ていないのを確認します', async () => { + await expect(page.locator('.error')).not.toBeVisible(); + }); + + test('LC_Page_Index_Ex クラスのテストをします @extends', async ( { page }) => { + await page.goto(url); + await expect(page).toHaveTitle(/カスタマイズ/); + }); +}); diff --git a/e2e-tests/test/front_login/mypage/change.test.ts b/e2e-tests/test/front_login/mypage/change.test.ts new file mode 100644 index 0000000000..d7345787f7 --- /dev/null +++ b/e2e-tests/test/front_login/mypage/change.test.ts @@ -0,0 +1,22 @@ +import { test, expect } from '@playwright/test'; +import PlaywrightConfig from '../../../../playwright.config'; +import { ZapClient, ContextType } from '../../../utils/ZapClient'; +const zapClient = new ZapClient(); + +const url = `${PlaywrightConfig.use.baseURL}/mypage/change.php`; +test.describe.serial('会員登録内容変更画面のテストをします', () => { + test.beforeAll(async () => { + await zapClient.startSession(ContextType.FrontLogin, 'front_login_mypage_change') + .then(async () => expect(await zapClient.isForcedUserModeEnabled()).toBeTruthy()); + }); + + test('会員登録内容変更画面のテストをします', async ( { page }) => { + await page.goto(url); + await expect(page).toHaveTitle(/会員登録内容変更/); + }); + + test('LC_Page_Mypage_Change_Ex クラスのテストをします @extends', async ( { page }) => { + await page.goto(url); + await expect(page).toHaveTitle(/カスタマイズ/); + }); +}); diff --git a/e2e-tests/test/front_login/welcome.test.ts b/e2e-tests/test/front_login/welcome.test.ts index 26aa1b0148..94477161ac 100644 --- a/e2e-tests/test/front_login/welcome.test.ts +++ b/e2e-tests/test/front_login/welcome.test.ts @@ -22,4 +22,9 @@ test.describe.serial('トップページのテストをします', () => { test('システムエラーが出ていないのを確認します', async () => { await expect(page.locator('.error')).not.toBeVisible(); }); + + test('LC_Page_Index_Ex クラスのテストをします @extends', async ( { page }) => { + await page.goto(url); + await expect(page).toHaveTitle(/カスタマイズ/); + }); }); diff --git a/package.json b/package.json index c9c54add69..7370a92a0e 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "scripts": { "lint:javascript": "eslint --fix data/*.js", "lint:typescript": "eslint --fix --ext .ts e2e-tests", - "test:e2e": "playwright test --grep-invert @attack", - "test:attack": "playwright test" + "test:e2e": "playwright test --grep-invert '(@attack|@extends)'", + "test:e2e-extends": "playwright test --grep @extends", + "test:attack": "playwright test --grep-invert @extends" } } diff --git a/tests/class/fixtures/page_extends/LC_Page_Index_Ex.php b/tests/class/fixtures/page_extends/LC_Page_Index_Ex.php new file mode 100644 index 0000000000..440737ead7 --- /dev/null +++ b/tests/class/fixtures/page_extends/LC_Page_Index_Ex.php @@ -0,0 +1,14 @@ +tpl_subtitle = '(カスタマイズ)'; + } + + public function process() + { + parent::process(); + } +} diff --git a/tests/class/fixtures/page_extends/admin/LC_Page_Admin_Home_Ex.php b/tests/class/fixtures/page_extends/admin/LC_Page_Admin_Home_Ex.php new file mode 100644 index 0000000000..9a75c4cbaf --- /dev/null +++ b/tests/class/fixtures/page_extends/admin/LC_Page_Admin_Home_Ex.php @@ -0,0 +1,21 @@ +tpl_subtitle = '会員登録(カスタマイズ)'; + } + + public function process() + { + parent::process(); + } +} diff --git a/tests/class/fixtures/page_extends/admin/total/LC_Page_Admin_Total_Ex.php b/tests/class/fixtures/page_extends/admin/total/LC_Page_Admin_Total_Ex.php new file mode 100644 index 0000000000..4c30c5dfa4 --- /dev/null +++ b/tests/class/fixtures/page_extends/admin/total/LC_Page_Admin_Total_Ex.php @@ -0,0 +1,14 @@ +tpl_maintitle = '売上集計(カスタマイズ)'; + } + + public function process() + { + parent::process(); + } +} diff --git a/tests/class/fixtures/page_extends/mypage/LC_Page_Mypage_Change_Ex.php b/tests/class/fixtures/page_extends/mypage/LC_Page_Mypage_Change_Ex.php new file mode 100644 index 0000000000..642499f265 --- /dev/null +++ b/tests/class/fixtures/page_extends/mypage/LC_Page_Mypage_Change_Ex.php @@ -0,0 +1,14 @@ +tpl_subtitle = '会員登録内容変更(カスタマイズ)'; + } + + public function process() + { + parent::process(); + } +}