From 5913be6f320ea1c8c62c337c41cbb6a83f5ff4a1 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Fri, 20 Dec 2024 15:22:34 +0900 Subject: [PATCH] =?UTF-8?q?endpoints.csv=20=E3=81=AB=E8=A8=98=E8=BC=89?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=9FURL=E3=81=8C=E3=81=99=E3=81=B9?= =?UTF-8?q?=E3=81=A6=E8=A1=A8=E7=A4=BA=E3=81=95=E3=82=8C=E3=82=8B=E3=81=93?= =?UTF-8?q?=E3=81=A8=E3=82=92=E7=A2=BA=E8=AA=8D=E3=81=99=E3=82=8B=E3=83=86?= =?UTF-8?q?=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 --- e2e-tests/endpoints/README.md | 11 ++ e2e-tests/endpoints/endpoints.csv | 116 ++++++++++++++++++ e2e-tests/endpoints/exclude_endpoints.csv | 39 ++++++ e2e-tests/test/admin/all_page_crawler.test.ts | 14 +++ .../test/front_login/all_page_crawler.test.ts | 35 ++++++ e2e-tests/utils/EndpointReader.ts | 24 ++++ e2e-tests/utils/EndpointTests.ts | 13 ++ 7 files changed, 252 insertions(+) create mode 100644 e2e-tests/endpoints/README.md create mode 100644 e2e-tests/endpoints/endpoints.csv create mode 100644 e2e-tests/endpoints/exclude_endpoints.csv create mode 100644 e2e-tests/test/admin/all_page_crawler.test.ts create mode 100644 e2e-tests/test/front_login/all_page_crawler.test.ts create mode 100644 e2e-tests/utils/EndpointReader.ts create mode 100644 e2e-tests/utils/EndpointTests.ts diff --git a/e2e-tests/endpoints/README.md b/e2e-tests/endpoints/README.md new file mode 100644 index 0000000000..5c0696010d --- /dev/null +++ b/e2e-tests/endpoints/README.md @@ -0,0 +1,11 @@ +# all_page_crawler.test.ts で使用するエンドポイントのCSVファイル + +このディレクトリのCSVファイルは all_page_crawler.test.ts で使用します。 + +## endpoints.csv + +all_page_crawler.test.ts のテスト対象のエンポイントです。 + +## exclude_endpoints.csv + +endpoints.csv のうち、テストから除外するエンドポイントです。 diff --git a/e2e-tests/endpoints/endpoints.csv b/e2e-tests/endpoints/endpoints.csv new file mode 100644 index 0000000000..d696811fd2 --- /dev/null +++ b/e2e-tests/endpoints/endpoints.csv @@ -0,0 +1,116 @@ +/abouts/index.php +/admin/basis/delivery.php +/admin/basis/delivery_input.php +/admin/basis/holiday.php +/admin/basis/index.php +/admin/basis/kiyaku.php +/admin/basis/mail.php +/admin/basis/payment.php +/admin/basis/payment_input.php +/admin/basis/point.php +/admin/basis/tax.php +/admin/basis/tradelaw.php +/admin/basis/zip_install.php +/admin/contents/csv.php +/admin/contents/csv_sql.php +/admin/contents/file_manager.php +/admin/contents/file_view.php +/admin/contents/index.php +/admin/contents/recommend.php +/admin/contents/recommend_search.php +/admin/customer/edit.php +/admin/customer/index.php +/admin/customer/search_customer.php +/admin/design/bloc.php +/admin/design/css.php +/admin/design/header.php +/admin/design/index.php +/admin/design/main_edit.php +/admin/design/template.php +/admin/design/up_down.php +/admin/home.php +/admin/logout.php +/admin/mail/history.php +/admin/mail/index.php +/admin/mail/preview.php +/admin/mail/template.php +/admin/mail/template_input.php +/admin/order/disp.php +/admin/order/edit.php +/admin/order/index.php +/admin/order/mail.php +/admin/order/mail_view.php +/admin/order/multiple.php +/admin/order/pdf.php +/admin/order/product_select.php +/admin/order/status.php +/admin/ownersstore/index.php +/admin/ownersstore/log.php +/admin/ownersstore/module.php +/admin/ownersstore/plugin_hookpoint_list.php +/admin/ownersstore/settings.php +/admin/products/category.php +/admin/products/class.php +/admin/products/classcategory.php +/admin/products/index.php +/admin/products/maker.php +/admin/products/product.php +/admin/products/product_class.php +/admin/products/product_rank.php +/admin/products/product_select.php +/admin/products/review.php +/admin/products/review_edit.php +/admin/products/upload_csv.php +/admin/products/upload_csv_category.php +/admin/system/adminarea.php +/admin/system/bkup.php +/admin/system/delete.php +/admin/system/index.php +/admin/system/input.php +/admin/system/log.php +/admin/system/masterdata.php +/admin/system/parameter.php +/admin/system/rank.php +/admin/system/system.php +/admin/total/index.php +/cart/index.php +/contact/complete.php +/contact/index.php +/entry/complete.php +/entry/index.php +/entry/kiyaku.php +/forgot/index.php +/guide/privacy.php +/index.php +/mypage/change.php +/mypage/change_complete.php +/mypage/delivery.php +/mypage/delivery_addr.php +/mypage/download.php +/mypage/favorite.php +/mypage/history.php +/mypage/index.php +/mypage/login.php +/mypage/mail_view.php +/mypage/order.php +/mypage/refusal.php +/mypage/refusal_complete.php +/order/index.php +/products/category_list.php +/products/detail.php +/products/list.php +/products/review.php +/products/review_complete.php +/products/search.php +/regist/complete.php +/regist/index.php +/shopping/complete.php +/shopping/confirm.php +/shopping/deliv.php +/shopping/index.php +/shopping/load_payment_module.php +/shopping/multiple.php +/shopping/payment.php +/sitemap.php +/unsupported/index.php +/upgrade/index.php diff --git a/e2e-tests/endpoints/exclude_endpoints.csv b/e2e-tests/endpoints/exclude_endpoints.csv new file mode 100644 index 0000000000..a2b6d54490 --- /dev/null +++ b/e2e-tests/endpoints/exclude_endpoints.csv @@ -0,0 +1,39 @@ +/define.php +/admin/index.php +/admin/load_module_config.php +/admin/load_plugin_config.php +/admin/require.php +/admin/contents/file_view.php +/admin/logout.php +/admin/mail/preview.php +/admin/products/review_edit.php +/admin/system/delete.php +/admin/system/rank.php +/entry/email_mobile.php +/frontparts/bloc/calendar.php +/frontparts/bloc/cart.php +/frontparts/bloc/category.php +/frontparts/bloc/login.php +/frontparts/bloc/login_footer.php +/frontparts/bloc/login_header.php +/frontparts/bloc/navi_footer.php +/frontparts/bloc/navi_header.php +/frontparts/bloc/news.php +/frontparts/bloc/recommend.php +/frontparts/bloc/search_products.php +/frontparts/login_check.php +/input_zip.php +/preview/index.php +/require.php +/resize_image.php +/rss/index.php +/rss/product.php +/rss/products.php +/sitemap.php +/unsupported/index.php +/upgrade/index.php +/mypage/login.php +/mypage/download.php +/mypage/history.php +/mypage/mail_view.php +/mypage/order.php diff --git a/e2e-tests/test/admin/all_page_crawler.test.ts b/e2e-tests/test/admin/all_page_crawler.test.ts new file mode 100644 index 0000000000..b5dfaeeceb --- /dev/null +++ b/e2e-tests/test/admin/all_page_crawler.test.ts @@ -0,0 +1,14 @@ +import { test } from '../../fixtures/admin_login.fixture'; +import { EndpointReader } from '../../utils/EndpointReader'; +import { endpointTests } from '../../utils/EndpointTests'; + +/** + * endpoints.csv を読み込み、指定されたエンドポイントのテストを実行します。 + */ +const endpointReader = new EndpointReader(); +test('/admin 以下のエンポイントを確認します', async ({ adminLoginPage, page }) => { + const endpoints = endpointReader.filter('/admin'); + for (const endpoint of endpoints) { + await endpointTests(page, endpoint); + } +}); diff --git a/e2e-tests/test/front_login/all_page_crawler.test.ts b/e2e-tests/test/front_login/all_page_crawler.test.ts new file mode 100644 index 0000000000..57c52d3356 --- /dev/null +++ b/e2e-tests/test/front_login/all_page_crawler.test.ts @@ -0,0 +1,35 @@ +import { test, expect } from '../../fixtures/mypage_login.fixture'; +import { EndpointReader } from '../../utils/EndpointReader'; +import { endpointTests } from '../../utils/EndpointTests'; + +/** + * endpoints.csv を読み込み、指定されたエンドポイントのテストを実行します。 + */ +const endpointReader = new EndpointReader(); +test('/mypage 以下のエンポイントを確認します', async ({ mypageLoginPage, page }) => { + const endpoints = endpointReader.filter('/mypage'); + for (const endpoint of endpoints) { + await endpointTests(page, endpoint, null); + } +}); + +test('/abouts 以下のエンポイントを確認します', async ({ mypageLoginPage, page }) => { + const endpoints = endpointReader.filter('/abouts'); + for (const endpoint of endpoints) { + await endpointTests(page, endpoint, null); + } +}); + +test('/guide 以下のエンポイントを確認します', async ({ mypageLoginPage, page }) => { + const endpoints = endpointReader.filter('/guide'); + for (const endpoint of endpoints) { + await endpointTests(page, endpoint, null); + } +}); + +test('/order 以下のエンポイントを確認します', async ({ mypageLoginPage, page }) => { + const endpoints = endpointReader.filter('/order'); + for (const endpoint of endpoints) { + await endpointTests(page, endpoint, null); + } +}); diff --git a/e2e-tests/utils/EndpointReader.ts b/e2e-tests/utils/EndpointReader.ts new file mode 100644 index 0000000000..93d918300e --- /dev/null +++ b/e2e-tests/utils/EndpointReader.ts @@ -0,0 +1,24 @@ +import * as fs from 'fs'; +import * as path from "path"; + +export class EndpointReader { + endpoints: Array; + + constructor() { + this.read(); + } + + read() { + const excludes = fs.readFileSync(path.join(__dirname, '..', 'endpoints', 'exclude_endpoints.csv'), 'utf8').split('\n'); + this.endpoints = fs.readFileSync(path.join(__dirname, '..', 'endpoints', 'endpoints.csv'), 'utf8') + .split('\n') + .filter(line => !excludes.includes(line)) + .map(line => line.replace(/index.*/, '')); + + return this.endpoints; + } + + filter(prefix: string) { + return this.endpoints.filter(line => line.match(new RegExp(`^${prefix}`))); + } +} diff --git a/e2e-tests/utils/EndpointTests.ts b/e2e-tests/utils/EndpointTests.ts new file mode 100644 index 0000000000..85e1b35785 --- /dev/null +++ b/e2e-tests/utils/EndpointTests.ts @@ -0,0 +1,13 @@ +import { test, expect, Page } from '@playwright/test'; +export const endpointTests = async (page:Page, endpoint:string, title:string|null = 'EC') => { + await test.step(`${endpoint} を確認します`, async () => { + await page.goto(endpoint); + await expect(page, `toHaveURL: ${endpoint}`).toHaveURL(new RegExp(`${endpoint}`)); + if (title !== null) { + await expect(page).toHaveTitle(new RegExp(`${title}`)); + } + + await expect(page.locator('body'), 'ページの表示を確認').toBeVisible(); + await expect(page.locator('.error'), 'システムエラーの無いのを確認').not.toBeVisible(); + }); +};