From ca3e3dd11b2354cd3e2c51c3e4a354fce54064b0 Mon Sep 17 00:00:00 2001 From: Kato Hiroki Date: Fri, 20 Mar 2026 01:48:48 +0000 Subject: [PATCH 1/3] docs: Add plan for renaming tests/ to e2e/ Co-Authored-By: Claude Sonnet 4.6 --- .../2026-03-20/rename-tests-to-e2e/plan.md | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 docs/dev-notes/2026-03-20/rename-tests-to-e2e/plan.md diff --git a/docs/dev-notes/2026-03-20/rename-tests-to-e2e/plan.md b/docs/dev-notes/2026-03-20/rename-tests-to-e2e/plan.md new file mode 100644 index 000000000..6ee87604b --- /dev/null +++ b/docs/dev-notes/2026-03-20/rename-tests-to-e2e/plan.md @@ -0,0 +1,67 @@ +# rename tests/ → e2e/ + +最新の SvelteKit プロジェクト構成に合わせ、E2E テストディレクトリ・ファイル命名を統一する。 + +- `tests/` → `e2e/` +- E2E テストファイル: `.test.ts` → `.spec.ts`、ハイフン → アンダースコア +- スクリプト: `test:integration` → `test:e2e` + +関連 Issue: https://github.com/AtCoder-NoviSteps/AtCoderNoviSteps/issues/3288 + +--- + +## Phase 1: ドキュメント・ルール更新(ランタイム影響なし) + +- [ ] `.claude/rules/testing.md` + - `paths: 'tests/**'` → `'e2e/**'` + - テーブル: `tests/` → `e2e/`、`pnpm test:integration` → `pnpm test:e2e` +- [ ] `AGENTS.md` + - `pnpm test:integration` → `pnpm test:e2e` + - `tests/ # E2E tests (Playwright)` → `e2e/ # E2E tests (Playwright)` + - `tests/global-setup.ts` の記述を削除(ファイル削除済み) +- [ ] `docs/guides/architecture.md` + - `E2E テスト(\`tests/\`)`→`E2E テスト(\`e2e/\`)` +- [ ] `docs/guides/claude-code.md` + - `paths: 'tests/**'` → `'e2e/**'` + - テーブル: `` `*.test.ts`, `tests/**` のテストパターン `` → `` `*.test.ts`, `e2e/**` のテストパターン `` +- [ ] `.claude/skills/session-close/instructions.md` + - `pnpm test:integration` → `pnpm test:e2e` +- [ ] `.github/workflows/ci.yml` + - コメント内 `pnpm test:integration` → `pnpm test:e2e` + +## Phase 2: ファイルリネーム + +`tests/` ディレクトリ以下を `e2e/` に移動し、同時にファイル名を変更する。 + +| 変更前 | 変更後 | +| ------------------------------ | ---------------------------- | +| `tests/about_page.test.ts` | `e2e/about_page.spec.ts` | +| `tests/custom-colors.spec.ts` | `e2e/custom_colors.spec.ts` | +| `tests/dark-mode.spec.ts` | `e2e/dark_mode.spec.ts` | +| `tests/navbar.spec.ts` | `e2e/navbar.spec.ts` | +| `tests/robots.test.ts` | `e2e/robots.spec.ts` | +| `tests/signin.test.ts` | `e2e/signin.spec.ts` | +| `tests/sitemap.test.ts` | `e2e/sitemap.spec.ts` | +| `tests/toppage.test.ts` | `e2e/toppage.spec.ts` | +| `tests/workbook_order.test.ts` | `e2e/workbook_order.spec.ts` | +| `tests/workbooks_list.test.ts` | `e2e/workbooks_list.spec.ts` | +| `tests/helpers/auth.ts` | `e2e/helpers/auth.ts` | + +- [ ] 上記ファイルを移動・リネーム +- [ ] `tests/` ディレクトリが空になったことを確認 + +## Phase 4: 設定ファイル更新 + +- [ ] `playwright.config.ts` + - `testDir: 'tests'` → `testDir: 'e2e'` + - `testMatch: /(.+\.)?(test|spec)\.[jt]s/` → `testMatch: /(.+\.)?spec\.[jt]s/` + - コメントアウトされた `global.setup.ts` / `global.teardown.ts` ブロックを削除 +- [ ] `package.json` + - `"test:integration": "playwright test"` → `"test:e2e": "playwright test"` + - `"test": "npm run test:integration && ..."` → `"test": "npm run test:e2e && ..."` + +## Phase 5: 検証 + +- [ ] `pnpm check` — 型エラーなし +- [ ] `pnpm lint` — lint エラーなし +- [ ] `pnpm test:e2e` — Playwright がテストを検出・実行できること From 0e5ce6af6f951bc8a48b3b388d13c7e291aa9cdc Mon Sep 17 00:00:00 2001 From: Kato Hiroki Date: Fri, 20 Mar 2026 01:55:12 +0000 Subject: [PATCH 2/3] refactor: Rename tests/ to e2e/ and migrate to .spec.ts convention MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Move all E2E tests from tests/ to e2e/, renaming files to snake_case .spec.ts - Update playwright.config.ts: testDir, testMatch (spec only), remove dead commented blocks - Rename package.json script test:integration → test:e2e - Update AGENTS.md, .claude/rules/testing.md, docs, CI workflow accordingly Closes #3288 Co-Authored-By: Claude Sonnet 4.6 --- .claude/rules/testing.md | 12 ++-- .claude/skills/session-close/instructions.md | 2 +- .github/workflows/ci.yml | 2 +- AGENTS.md | 6 +- .../2026-03-20/rename-tests-to-e2e/plan.md | 67 ------------------- docs/guides/architecture.md | 2 +- docs/guides/claude-code.md | 4 +- .../about_page.spec.ts | 0 .../custom_colors.spec.ts | 0 .../dark_mode.spec.ts | 0 {tests => e2e}/helpers/auth.ts | 0 {tests => e2e}/navbar.spec.ts | 0 tests/robots.test.ts => e2e/robots.spec.ts | 0 tests/signin.test.ts => e2e/signin.spec.ts | 0 tests/sitemap.test.ts => e2e/sitemap.spec.ts | 0 tests/toppage.test.ts => e2e/toppage.spec.ts | 0 .../workbook_order.spec.ts | 0 .../workbooks_list.spec.ts | 0 package.json | 4 +- playwright.config.ts | 14 +--- 20 files changed, 19 insertions(+), 94 deletions(-) delete mode 100644 docs/dev-notes/2026-03-20/rename-tests-to-e2e/plan.md rename tests/about_page.test.ts => e2e/about_page.spec.ts (100%) rename tests/custom-colors.spec.ts => e2e/custom_colors.spec.ts (100%) rename tests/dark-mode.spec.ts => e2e/dark_mode.spec.ts (100%) rename {tests => e2e}/helpers/auth.ts (100%) rename {tests => e2e}/navbar.spec.ts (100%) rename tests/robots.test.ts => e2e/robots.spec.ts (100%) rename tests/signin.test.ts => e2e/signin.spec.ts (100%) rename tests/sitemap.test.ts => e2e/sitemap.spec.ts (100%) rename tests/toppage.test.ts => e2e/toppage.spec.ts (100%) rename tests/workbook_order.test.ts => e2e/workbook_order.spec.ts (100%) rename tests/workbooks_list.test.ts => e2e/workbooks_list.spec.ts (100%) diff --git a/.claude/rules/testing.md b/.claude/rules/testing.md index 753060db1..85f4b5d72 100644 --- a/.claude/rules/testing.md +++ b/.claude/rules/testing.md @@ -3,7 +3,7 @@ description: Testing rules and patterns paths: - '**/*.test.ts' - '**/*.spec.ts' - - 'tests/**' + - 'e2e/**' - 'src/test/**' --- @@ -20,10 +20,12 @@ Write all test titles in English. Use descriptive sentences that state the expec ## Test Types -| Type | Tool | Location | Run Command | -| ---- | ---------- | ----------------------------------------------------------------- | ----------------------- | -| Unit | Vitest | `src/test/` (mirrors `src/lib/`) or co-located in `src/features/` | `pnpm test:unit` | -| E2E | Playwright | `tests/` | `pnpm test:integration` | +| Type | Tool | Location | Run Command | +| ---- | ---------- | ----------------------------------------------------------------- | ---------------- | +| Unit | Vitest | `src/test/` (mirrors `src/lib/`) or co-located in `src/features/` | `pnpm test:unit` | +| E2E | Playwright | `e2e/` | `pnpm test:e2e` | + +E2E test files must use the `.spec.ts` extension. `playwright.config.ts` matches only `*.spec.ts`, so `.test.ts` files will not be detected. ## Assertions diff --git a/.claude/skills/session-close/instructions.md b/.claude/skills/session-close/instructions.md index 78cfaae6a..a32a3850d 100644 --- a/.claude/skills/session-close/instructions.md +++ b/.claude/skills/session-close/instructions.md @@ -6,7 +6,7 @@ Run both checks and fix any failures before proceeding: ```bash pnpm test:unit -pnpm test:integration +pnpm test:e2e pnpm check ``` diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa368956e..1acd28af5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,7 @@ jobs: # TODO: Run integration test # - name: Integration test - # run: pnpm test:integration + # run: pnpm test:e2e preview: if: ${{ github.ref != 'refs/heads/main' }} diff --git a/AGENTS.md b/AGENTS.md index 154104ccc..1185172f9 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -25,7 +25,7 @@ pnpm dev # Start dev server (localhost:5174) pnpm build # Build for production pnpm test # Run all tests pnpm test:unit # Vitest unit tests -pnpm test:integration # Playwright E2E tests +pnpm test:e2e # Playwright E2E tests pnpm coverage # Report test coverage pnpm lint # ESLint check pnpm format # Prettier format @@ -61,7 +61,7 @@ src/features/ # Feature-scoped code (single domain) │ └── utils/ # Feature utilities │ └── _.test.ts # Tests co-located next to source src/test/ # Unit tests (mirrors src/lib/) -tests/ # E2E tests (Playwright) +e2e/ # E2E tests (Playwright) prisma/schema.prisma # Database schema ``` @@ -71,7 +71,7 @@ prisma/schema.prisma # Database schema - **Service layer**: Services return data or `null`; never call `error()` or `redirect()`. HTTP error translation belongs in the route handler — the service must stay framework-agnostic and unit-testable. - **Server data**: `+page.server.ts` → `+page.svelte` via `data` prop - **Forms**: Superforms + Zod validation -- **Tests**: Write tests before implementation (TDD). Use `@quramy/prisma-fabbrica` for factories only in `prisma/seed.ts` and Playwright global setup (`tests/global-setup.ts`). For service-layer unit tests, mock the DB with `vi.mock('$lib/server/database', ...)` — do not use fabbrica there. Use Nock for HTTP mocking +- **Tests**: Write tests before implementation (TDD). Use `@quramy/prisma-fabbrica` for factories only in `prisma/seed.ts`. For service-layer unit tests, mock the DB with `vi.mock('$lib/server/database', ...)` — do not use fabbrica there. Use Nock for HTTP mocking - **Naming**: `camelCase` variables, `PascalCase` types/components, `snake_case` files/routes, `kebab-case` directories - **Pre-commit**: Lefthook runs Prettier + ESLint (bypass: `LEFTHOOK=0 git commit`) diff --git a/docs/dev-notes/2026-03-20/rename-tests-to-e2e/plan.md b/docs/dev-notes/2026-03-20/rename-tests-to-e2e/plan.md deleted file mode 100644 index 6ee87604b..000000000 --- a/docs/dev-notes/2026-03-20/rename-tests-to-e2e/plan.md +++ /dev/null @@ -1,67 +0,0 @@ -# rename tests/ → e2e/ - -最新の SvelteKit プロジェクト構成に合わせ、E2E テストディレクトリ・ファイル命名を統一する。 - -- `tests/` → `e2e/` -- E2E テストファイル: `.test.ts` → `.spec.ts`、ハイフン → アンダースコア -- スクリプト: `test:integration` → `test:e2e` - -関連 Issue: https://github.com/AtCoder-NoviSteps/AtCoderNoviSteps/issues/3288 - ---- - -## Phase 1: ドキュメント・ルール更新(ランタイム影響なし) - -- [ ] `.claude/rules/testing.md` - - `paths: 'tests/**'` → `'e2e/**'` - - テーブル: `tests/` → `e2e/`、`pnpm test:integration` → `pnpm test:e2e` -- [ ] `AGENTS.md` - - `pnpm test:integration` → `pnpm test:e2e` - - `tests/ # E2E tests (Playwright)` → `e2e/ # E2E tests (Playwright)` - - `tests/global-setup.ts` の記述を削除(ファイル削除済み) -- [ ] `docs/guides/architecture.md` - - `E2E テスト(\`tests/\`)`→`E2E テスト(\`e2e/\`)` -- [ ] `docs/guides/claude-code.md` - - `paths: 'tests/**'` → `'e2e/**'` - - テーブル: `` `*.test.ts`, `tests/**` のテストパターン `` → `` `*.test.ts`, `e2e/**` のテストパターン `` -- [ ] `.claude/skills/session-close/instructions.md` - - `pnpm test:integration` → `pnpm test:e2e` -- [ ] `.github/workflows/ci.yml` - - コメント内 `pnpm test:integration` → `pnpm test:e2e` - -## Phase 2: ファイルリネーム - -`tests/` ディレクトリ以下を `e2e/` に移動し、同時にファイル名を変更する。 - -| 変更前 | 変更後 | -| ------------------------------ | ---------------------------- | -| `tests/about_page.test.ts` | `e2e/about_page.spec.ts` | -| `tests/custom-colors.spec.ts` | `e2e/custom_colors.spec.ts` | -| `tests/dark-mode.spec.ts` | `e2e/dark_mode.spec.ts` | -| `tests/navbar.spec.ts` | `e2e/navbar.spec.ts` | -| `tests/robots.test.ts` | `e2e/robots.spec.ts` | -| `tests/signin.test.ts` | `e2e/signin.spec.ts` | -| `tests/sitemap.test.ts` | `e2e/sitemap.spec.ts` | -| `tests/toppage.test.ts` | `e2e/toppage.spec.ts` | -| `tests/workbook_order.test.ts` | `e2e/workbook_order.spec.ts` | -| `tests/workbooks_list.test.ts` | `e2e/workbooks_list.spec.ts` | -| `tests/helpers/auth.ts` | `e2e/helpers/auth.ts` | - -- [ ] 上記ファイルを移動・リネーム -- [ ] `tests/` ディレクトリが空になったことを確認 - -## Phase 4: 設定ファイル更新 - -- [ ] `playwright.config.ts` - - `testDir: 'tests'` → `testDir: 'e2e'` - - `testMatch: /(.+\.)?(test|spec)\.[jt]s/` → `testMatch: /(.+\.)?spec\.[jt]s/` - - コメントアウトされた `global.setup.ts` / `global.teardown.ts` ブロックを削除 -- [ ] `package.json` - - `"test:integration": "playwright test"` → `"test:e2e": "playwright test"` - - `"test": "npm run test:integration && ..."` → `"test": "npm run test:e2e && ..."` - -## Phase 5: 検証 - -- [ ] `pnpm check` — 型エラーなし -- [ ] `pnpm lint` — lint エラーなし -- [ ] `pnpm test:e2e` — Playwright がテストを検出・実行できること diff --git a/docs/guides/architecture.md b/docs/guides/architecture.md index 187906a6d..68f58054c 100644 --- a/docs/guides/architecture.md +++ b/docs/guides/architecture.md @@ -177,7 +177,7 @@ features/workbooks/services/ - テストファクトリ(`@quramy/prisma-fabbrica`) - テストヘルパー・フィクスチャ -- E2E テスト(`tests/`) +- E2E テスト(`e2e/`) ### Vitest 設定 diff --git a/docs/guides/claude-code.md b/docs/guides/claude-code.md index 25785677c..0484cd4ce 100644 --- a/docs/guides/claude-code.md +++ b/docs/guides/claude-code.md @@ -31,7 +31,7 @@ Claude Code の拡張ポイントの使い分けをまとめる。 description: Testing rules and patterns paths: - '**/*.test.ts' - - 'tests/**' + - 'e2e/**' --- ``` @@ -45,7 +45,7 @@ paths: | ファイル | スコープ | | ---------------------- | -------------------------------------------------------- | | `coding-style.md` | 言語レベルの記述スタイル(ブレース・命名・型エイリアス) | -| `testing.md` | `*.test.ts`, `tests/**` のテストパターン | +| `testing.md` | `*.test.ts`, `e2e/**` のテストパターン | | `svelte-components.md` | `*.svelte` コンポーネント設計方針 | | `prisma-db.md` | `prisma/**`, `src/lib/server/**` の DB・サービス層規約 | | `auth.md` | 認証関連 | diff --git a/tests/about_page.test.ts b/e2e/about_page.spec.ts similarity index 100% rename from tests/about_page.test.ts rename to e2e/about_page.spec.ts diff --git a/tests/custom-colors.spec.ts b/e2e/custom_colors.spec.ts similarity index 100% rename from tests/custom-colors.spec.ts rename to e2e/custom_colors.spec.ts diff --git a/tests/dark-mode.spec.ts b/e2e/dark_mode.spec.ts similarity index 100% rename from tests/dark-mode.spec.ts rename to e2e/dark_mode.spec.ts diff --git a/tests/helpers/auth.ts b/e2e/helpers/auth.ts similarity index 100% rename from tests/helpers/auth.ts rename to e2e/helpers/auth.ts diff --git a/tests/navbar.spec.ts b/e2e/navbar.spec.ts similarity index 100% rename from tests/navbar.spec.ts rename to e2e/navbar.spec.ts diff --git a/tests/robots.test.ts b/e2e/robots.spec.ts similarity index 100% rename from tests/robots.test.ts rename to e2e/robots.spec.ts diff --git a/tests/signin.test.ts b/e2e/signin.spec.ts similarity index 100% rename from tests/signin.test.ts rename to e2e/signin.spec.ts diff --git a/tests/sitemap.test.ts b/e2e/sitemap.spec.ts similarity index 100% rename from tests/sitemap.test.ts rename to e2e/sitemap.spec.ts diff --git a/tests/toppage.test.ts b/e2e/toppage.spec.ts similarity index 100% rename from tests/toppage.test.ts rename to e2e/toppage.spec.ts diff --git a/tests/workbook_order.test.ts b/e2e/workbook_order.spec.ts similarity index 100% rename from tests/workbook_order.test.ts rename to e2e/workbook_order.spec.ts diff --git a/tests/workbooks_list.test.ts b/e2e/workbooks_list.spec.ts similarity index 100% rename from tests/workbooks_list.test.ts rename to e2e/workbooks_list.spec.ts diff --git a/package.json b/package.json index 92f801eeb..5f2a2b0e6 100644 --- a/package.json +++ b/package.json @@ -10,12 +10,12 @@ "dev": "vite dev", "build": "prisma generate && vite build", "preview": "vite preview", - "test": "npm run test:integration && npm run test:unit", + "test": "npm run test:e2e && npm run test:unit", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "lint": "prettier --check . && eslint .", "format": "prettier --write .", - "test:integration": "playwright test", + "test:e2e": "playwright test", "test:unit": "vitest", "postinstall": "prisma generate", "db:seed": "pnpm exec tsx ./prisma/seed.ts", diff --git a/playwright.config.ts b/playwright.config.ts index 5b7a63069..aa8050b72 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -9,21 +9,11 @@ const config: PlaywrightTestConfig = { use: { baseURL: process.env.BASE_URL ?? 'http://localhost:4173', }, - testDir: 'tests', + testDir: 'e2e', projects: [ - //{ - // name: 'setup db', - // testMatch: /global\.setup\.ts/, - // teardown:'cleanup db', - //}, - //{ - // name: 'cleanup db', - // testMatch: /global\.teardown\.ts/, - //}, { name: 'all', - testMatch: /(.+\.)?(test|spec)\.[jt]s/, - //dependencies: ['setup db'], + testMatch: /(.+\.)?spec\.[jt]s/, }, ], }; From ee1bdf09fbb69667cfa1872e897e7d190a3f5206 Mon Sep 17 00:00:00 2001 From: Kato Hiroki Date: Fri, 20 Mar 2026 02:03:17 +0000 Subject: [PATCH 3/3] docs: Add *.spec.ts to testing.md scope description in claude-code.md Co-Authored-By: Claude Sonnet 4.6 --- docs/guides/claude-code.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/claude-code.md b/docs/guides/claude-code.md index 0484cd4ce..633c6f375 100644 --- a/docs/guides/claude-code.md +++ b/docs/guides/claude-code.md @@ -45,7 +45,7 @@ paths: | ファイル | スコープ | | ---------------------- | -------------------------------------------------------- | | `coding-style.md` | 言語レベルの記述スタイル(ブレース・命名・型エイリアス) | -| `testing.md` | `*.test.ts`, `e2e/**` のテストパターン | +| `testing.md` | `*.test.ts`, `*.spec.ts`, `e2e/**` のテストパターン | | `svelte-components.md` | `*.svelte` コンポーネント設計方針 | | `prisma-db.md` | `prisma/**`, `src/lib/server/**` の DB・サービス層規約 | | `auth.md` | 認証関連 |