phasegate 0.15.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +103 -71
- package/README.md +73 -13
- package/bin/{harness → phasegate} +1 -1
- package/docs/ADR/ADR-013-story-reflection-gate.md +100 -0
- package/docs/guide/cli-reference.md +9 -9
- package/docs/guide/configuration.md +245 -8
- package/docs/guide/hooks-integration.md +1 -1
- package/docs/guide/installation.md +6 -6
- package/docs/guide/layer-model.md +5 -5
- package/docs/guide/skills-overview.md +1 -1
- package/package.json +12 -10
- package/scripts/harness/adr-foundation/domain/ports/adr-document-parser-port.ts +1 -0
- package/scripts/harness/adr-foundation/domain/ports/adr-frontmatter-parser-port.ts +1 -0
- package/scripts/harness/adr-foundation/domain/ports/adr-repository-port.ts +1 -0
- package/scripts/harness/adr-foundation/domain/value-objects/adr-status.ts +6 -6
- package/scripts/harness/agent-integration/application/dto/handle-pre-tool-use-dto.ts +3 -1
- package/scripts/harness/agent-integration/application/usecases/handle-pre-tool-use-usecase.ts +109 -3
- package/scripts/harness/agent-integration/application/usecases/handle-stop-usecase.ts +1 -1
- package/scripts/harness/agent-integration/domain/ports/config-query-port.ts +2 -0
- package/scripts/harness/agent-integration/domain/ports/phase-gate-query-port.ts +1 -1
- package/scripts/harness/agent-integration/domain/ports/story-reflection-query-port.ts +8 -0
- package/scripts/harness/agent-integration/domain/services/bash-write-target-extractor.ts +258 -0
- package/scripts/harness/agent-integration/domain/services/hook-to-cli-translator.ts +25 -8
- package/scripts/harness/agent-integration/domain/value-objects/protected-file-list.ts +20 -0
- package/scripts/harness/agent-integration/domain/value-objects/story-reflection-query-result.ts +63 -0
- package/scripts/harness/agent-integration/infrastructure/adapters/child-process-cli-executor-adapter.ts +2 -2
- package/scripts/harness/agent-integration/infrastructure/adapters/file-system-story-reflection-query-adapter.ts +122 -0
- package/scripts/harness/agent-integration/infrastructure/adapters/harness-api-cli-command-registry-adapter.ts +10 -10
- package/scripts/harness/agent-integration/infrastructure/adapters/harness-config-config-query-adapter.ts +20 -0
- package/scripts/harness/agent-integration/infrastructure/adapters/phase-gate-query-adapter.ts +17 -3
- package/scripts/harness/agent-integration/presentation/pre-tool-use-hook.ts +29 -2
- package/scripts/harness/biome-ast-engine/domain/services/lint-runner.ts +24 -0
- package/scripts/harness/biome-ast-engine/domain/services/rule-definition-registry.ts +1 -1
- package/scripts/harness/biome-ast-engine/domain/value-objects/source-module-snapshot.ts +5 -2
- package/scripts/harness/biome-ast-engine/infrastructure/adapters/node-workspace-file-adapter.ts +1 -1
- package/scripts/harness/biome-ast-engine/infrastructure/adapters/typescript-source-module-analyzer-adapter.ts +1 -1
- package/scripts/harness/biome-ast-engine/infrastructure/parsers/unit-comment-parser.ts +12 -7
- package/scripts/harness/ci-governance/composition-root.ts +1 -0
- package/scripts/harness/ci-governance/infrastructure/adapters/agents-md-file-adapter.ts +2 -2
- package/scripts/harness/ci-governance/infrastructure/adapters/yaml-template-renderer-adapter.ts +2 -2
- package/scripts/harness/config-foundation/application/mappers/phase-config-section-mapper.ts +44 -0
- package/scripts/harness/config-foundation/application/usecases/load-resolved-config-use-case.ts +20 -1
- package/scripts/harness/config-foundation/domain/harness-config.ts +2 -1
- package/scripts/harness/config-foundation/domain/value-objects/phase-dependencies-config.ts +18 -4
- package/scripts/harness/config-foundation/infrastructure/schemas/harness-config-v2.schema.json +185 -10
- package/scripts/harness/config-foundation/infrastructure/validators/ajv-config-schema-validator.ts +2 -1
- package/scripts/harness/harness-api/application/dto/command-dispatch-input.ts +1 -0
- package/scripts/harness/harness-api/application/dto/command-dispatch-output.ts +1 -0
- package/scripts/harness/harness-api/application/dto/exit-code-decision-input.ts +1 -0
- package/scripts/harness/harness-api/application/dto/exit-code-decision-output.ts +1 -0
- package/scripts/harness/harness-api/application/dto/harness-api-response-contract.ts +1 -0
- package/scripts/harness/harness-api/application/dto/initialize-registry-input.ts +1 -0
- package/scripts/harness/harness-api/application/dto/registry-summary-output.ts +1 -0
- package/scripts/harness/harness-api/application/dto/status-derivation-input.ts +1 -0
- package/scripts/harness/harness-api/application/mappers/harness-api-response-mapper.ts +1 -0
- package/scripts/harness/harness-api/application/usecases/decide-exit-code-usecase.ts +4 -3
- package/scripts/harness/harness-api/application/usecases/derive-harness-status-usecase.ts +1 -0
- package/scripts/harness/harness-api/application/usecases/dispatch-command-usecase.ts +1 -0
- package/scripts/harness/harness-api/application/usecases/initialize-command-registry-usecase.ts +1 -0
- package/scripts/harness/harness-api/composition-root.ts +1 -0
- package/scripts/harness/harness-api/domain/ports/artifact-scanner-port.ts +1 -0
- package/scripts/harness/harness-api/domain/ports/biome-lint-port.ts +1 -0
- package/scripts/harness/harness-api/domain/ports/config-query-port.ts +1 -0
- package/scripts/harness/harness-api/domain/ports/impact-analysis-port.ts +1 -0
- package/scripts/harness/harness-api/domain/ports/phase-gate-query-port.ts +1 -0
- package/scripts/harness/harness-api/domain/ports/validator-execution-port.ts +1 -0
- package/scripts/harness/harness-api/domain/services/command-dispatch-service.ts +17 -16
- package/scripts/harness/harness-api/domain/services/command-registry.ts +4 -3
- package/scripts/harness/harness-api/domain/services/status-derivation-service.ts +1 -0
- package/scripts/harness/harness-api/domain/value-objects/artifact-scan-result.ts +1 -0
- package/scripts/harness/harness-api/domain/value-objects/check-ready-result.ts +1 -0
- package/scripts/harness/harness-api/domain/value-objects/ci-check-result.ts +1 -0
- package/scripts/harness/harness-api/domain/value-objects/cli-command-definition.ts +11 -10
- package/scripts/harness/harness-api/domain/value-objects/command-input-spec.ts +1 -0
- package/scripts/harness/harness-api/domain/value-objects/drift-report-summary.ts +1 -0
- package/scripts/harness/harness-api/domain/value-objects/exit-code-spec.ts +1 -0
- package/scripts/harness/harness-api/domain/value-objects/harness-api-response.ts +1 -0
- package/scripts/harness/harness-api/domain/value-objects/harness-status-summary.ts +1 -0
- package/scripts/harness/harness-api/domain/value-objects/layer-health.ts +1 -0
- package/scripts/harness/harness-api/domain/value-objects/phase-info.ts +1 -0
- package/scripts/harness/harness-api/index.ts +1 -0
- package/scripts/harness/harness-api/infrastructure/adapters/biome-ast-engine-lint-adapter.ts +1 -0
- package/scripts/harness/harness-api/infrastructure/adapters/file-system-artifact-scanner-adapter.ts +1 -0
- package/scripts/harness/harness-api/infrastructure/adapters/harness-config-query-adapter.ts +1 -0
- package/scripts/harness/harness-api/infrastructure/adapters/nyquist-validation-impact-analysis-adapter.ts +1 -0
- package/scripts/harness/harness-api/infrastructure/adapters/phase-dependency-model-query-adapter.ts +1 -0
- package/scripts/harness/harness-api/infrastructure/adapters/validator-system-execution-adapter.ts +1 -0
- package/scripts/harness/harness-api/presentation/dto/cli-output-options.ts +1 -0
- package/scripts/harness/harness-api/presentation/formatters/harness-api-json-formatter.ts +1 -0
- package/scripts/harness/harness-api/presentation/handlers/check-phase-handler.ts +2 -1
- package/scripts/harness/harness-api/presentation/handlers/check-ready-handler.ts +2 -1
- package/scripts/harness/harness-api/presentation/handlers/ci-check-handler.ts +2 -1
- package/scripts/harness/harness-api/presentation/handlers/complete-check-handler.ts +2 -1
- package/scripts/harness/harness-api/presentation/handlers/detect-drift-handler.ts +2 -1
- package/scripts/harness/harness-api/presentation/handlers/impact-analysis-handler.ts +2 -1
- package/scripts/harness/harness-api/presentation/handlers/lint-handler.ts +2 -1
- package/scripts/harness/harness-api/presentation/handlers/status-handler.ts +4 -3
- package/scripts/harness/harness-error/infrastructure/adapters/legacy-error-reporter-adapter.ts +7 -1
- package/scripts/harness/integrations/pre-commit.ts +1 -0
- package/scripts/harness/main.ts +173 -53
- package/scripts/harness/phase-dependency-model/application/dto/resolve-gate-result-dto.ts +14 -0
- package/scripts/harness/phase-dependency-model/application/services/phase-gate-result-mapper.ts +20 -0
- package/scripts/harness/phase-dependency-model/application/usecases/check-story-reflection-usecase.ts +42 -0
- package/scripts/harness/phase-dependency-model/application/usecases/resolve-gate-usecase.ts +161 -0
- package/scripts/harness/phase-dependency-model/composition-root.ts +57 -1
- package/scripts/harness/phase-dependency-model/domain/definitions/{default-phase-dependencies.ts → full-phase-dependencies.ts} +3 -3
- package/scripts/harness/phase-dependency-model/domain/definitions/{default-phase-nodes.ts → full-phase-nodes.ts} +1 -1
- package/scripts/harness/phase-dependency-model/domain/definitions/full-story-reflection-defaults.ts +28 -0
- package/scripts/harness/phase-dependency-model/domain/definitions/minimal-phase-dependencies.ts +32 -0
- package/scripts/harness/phase-dependency-model/domain/definitions/minimal-phase-nodes.ts +50 -0
- package/scripts/harness/phase-dependency-model/domain/definitions/minimal-story-reflection-defaults.ts +8 -0
- package/scripts/harness/phase-dependency-model/domain/definitions/standard-phase-dependencies.ts +39 -0
- package/scripts/harness/phase-dependency-model/domain/definitions/standard-phase-nodes.ts +118 -0
- package/scripts/harness/phase-dependency-model/domain/definitions/standard-story-reflection-defaults.ts +23 -0
- package/scripts/harness/phase-dependency-model/domain/models/phase-structure.ts +95 -23
- package/scripts/harness/phase-dependency-model/domain/ports/glob-matcher-port.ts +8 -0
- package/scripts/harness/phase-dependency-model/domain/ports/phase-config-provider-port.ts +2 -0
- package/scripts/harness/phase-dependency-model/domain/ports/story-annotation-verifier-port.ts +14 -0
- package/scripts/harness/phase-dependency-model/domain/ports/story-reflection-file-system-port.ts +16 -0
- package/scripts/harness/phase-dependency-model/domain/services/gate-graph.ts +223 -0
- package/scripts/harness/phase-dependency-model/domain/services/story-reflection-checker.ts +66 -0
- package/scripts/harness/phase-dependency-model/domain/values/gate-definition.ts +127 -0
- package/scripts/harness/phase-dependency-model/domain/values/gate-name.ts +40 -0
- package/scripts/harness/phase-dependency-model/domain/values/gate-story-annotation.ts +39 -0
- package/scripts/harness/phase-dependency-model/domain/values/phase-customization-policy.ts +16 -4
- package/scripts/harness/phase-dependency-model/domain/values/story-reflection-config.ts +44 -0
- package/scripts/harness/phase-dependency-model/domain/values/story-reflection-mapping.ts +91 -0
- package/scripts/harness/phase-dependency-model/domain/values/story-reflection-result.ts +55 -0
- package/scripts/harness/phase-dependency-model/infrastructure/adapters/picomatch-glob-matcher.ts +17 -0
- package/scripts/harness/phase-dependency-model/infrastructure/adapters/story-annotation-verifier-adapter.ts +46 -0
- package/scripts/harness/phase-dependency-model/infrastructure/config/custom-gates-config-parser.ts +22 -0
- package/scripts/harness/phase-dependency-model/infrastructure/config/harness-config-phase-config-provider.ts +78 -2
- package/scripts/harness/phase-dependency-model/infrastructure/filesystem/file-system-story-reflection-adapter.ts +94 -0
- package/scripts/harness/phase-dependency-model/presentation/cli/check-phase-gate-command-handler.ts +12 -4
- package/scripts/harness/phase-dependency-model/presentation/cli/story-reflection-status-presenter.ts +87 -0
- package/scripts/harness/quick-mode/application/usecases/execute-quick-ci-check-usecase.ts +1 -1
- package/scripts/harness/quick-mode/presentation/handlers/ci-check-quick-mode-handler.ts +1 -1
- package/scripts/harness/regression-suite/application/dto/analyze-migration-input.ts +1 -0
- package/scripts/harness/regression-suite/application/dto/analyze-migration-output.ts +1 -0
- package/scripts/harness/regression-suite/application/dto/configure-ci-gate-input.ts +1 -0
- package/scripts/harness/regression-suite/application/dto/configure-ci-gate-output.ts +1 -0
- package/scripts/harness/regression-suite/application/dto/migrate-v0-tests-input.ts +1 -0
- package/scripts/harness/regression-suite/application/dto/migrate-v0-tests-output.ts +1 -0
- package/scripts/harness/regression-suite/application/dto/run-regression-suite-input.ts +1 -0
- package/scripts/harness/regression-suite/application/dto/run-regression-suite-output.ts +1 -0
- package/scripts/harness/regression-suite/application/mappers/migration-mapping-mapper.ts +1 -0
- package/scripts/harness/regression-suite/application/mappers/test-execution-summary-mapper.ts +1 -0
- package/scripts/harness/regression-suite/application/usecases/analyze-v0-migration-usecase.ts +1 -0
- package/scripts/harness/regression-suite/application/usecases/configure-ci-gate-usecase.ts +1 -0
- package/scripts/harness/regression-suite/application/usecases/migrate-v0-tests-usecase.ts +1 -0
- package/scripts/harness/regression-suite/application/usecases/run-agent-independence-guard-usecase.ts +1 -0
- package/scripts/harness/regression-suite/application/usecases/run-gng-gate-regression-usecase.ts +1 -0
- package/scripts/harness/regression-suite/application/usecases/run-k-requirements-regression-usecase.ts +1 -0
- package/scripts/harness/regression-suite/application/usecases/run-k14-k15-regression-usecase.ts +1 -0
- package/scripts/harness/regression-suite/composition-root.ts +1 -0
- package/scripts/harness/regression-suite/domain/aggregates/v0-test-migration.ts +1 -0
- package/scripts/harness/regression-suite/domain/ports/ci-gate-result-writer-port.ts +1 -0
- package/scripts/harness/regression-suite/domain/ports/config-query-port.ts +1 -0
- package/scripts/harness/regression-suite/domain/ports/import-analyzer-port.ts +1 -0
- package/scripts/harness/regression-suite/domain/ports/migration-mapping-repository-port.ts +1 -0
- package/scripts/harness/regression-suite/domain/ports/suite-registry-port.ts +1 -0
- package/scripts/harness/regression-suite/domain/ports/test-runner-port.ts +1 -0
- package/scripts/harness/regression-suite/domain/ports/v0-spec-reader-port.ts +1 -0
- package/scripts/harness/regression-suite/domain/services/import-guard-service.ts +1 -0
- package/scripts/harness/regression-suite/domain/services/migration-analyzer.ts +1 -0
- package/scripts/harness/regression-suite/domain/services/regression-runner.ts +1 -0
- package/scripts/harness/regression-suite/domain/value-objects/agent-independence-test.ts +1 -0
- package/scripts/harness/regression-suite/domain/value-objects/biome-modification-spec.ts +1 -0
- package/scripts/harness/regression-suite/domain/value-objects/ci-gate-config.ts +1 -0
- package/scripts/harness/regression-suite/domain/value-objects/coverage-rate.ts +1 -0
- package/scripts/harness/regression-suite/domain/value-objects/gng-condition-test.ts +1 -0
- package/scripts/harness/regression-suite/domain/value-objects/import-violation.ts +1 -0
- package/scripts/harness/regression-suite/domain/value-objects/k-requirement-test.ts +1 -0
- package/scripts/harness/regression-suite/domain/value-objects/migration-mapping.ts +1 -0
- package/scripts/harness/regression-suite/domain/value-objects/regression-suite-definition.ts +1 -0
- package/scripts/harness/regression-suite/domain/value-objects/suite-id.ts +1 -0
- package/scripts/harness/regression-suite/domain/value-objects/test-execution-summary.ts +1 -0
- package/scripts/harness/regression-suite/domain/value-objects/test-failure-detail.ts +1 -0
- package/scripts/harness/regression-suite/domain/value-objects/v0-test-id.ts +1 -0
- package/scripts/harness/regression-suite/domain/value-objects/v1-test-path.ts +1 -0
- package/scripts/harness/regression-suite/infrastructure/adapters/biome-ast-import-analyzer-adapter.ts +1 -0
- package/scripts/harness/regression-suite/infrastructure/adapters/file-system-v0-spec-reader-adapter.ts +1 -0
- package/scripts/harness/regression-suite/infrastructure/adapters/harness-config-query-adapter.ts +1 -0
- package/scripts/harness/regression-suite/infrastructure/adapters/json-ci-gate-result-writer-adapter.ts +1 -0
- package/scripts/harness/regression-suite/infrastructure/adapters/markdown-migration-mapping-repository-adapter.ts +1 -0
- package/scripts/harness/regression-suite/infrastructure/adapters/static-suite-registry-adapter.ts +1 -0
- package/scripts/harness/regression-suite/infrastructure/adapters/vitest-test-runner-adapter.ts +1 -0
- package/scripts/harness/regression-suite/infrastructure/registry/agent-independence-suite-definition.ts +1 -0
- package/scripts/harness/regression-suite/infrastructure/registry/gng-gate-suite-definition.ts +1 -0
- package/scripts/harness/regression-suite/infrastructure/registry/k-requirements-suite-definition.ts +1 -0
- package/scripts/harness/regression-suite/infrastructure/registry/v0-migration-suite-definition.ts +1 -0
- package/scripts/harness/setup/skill-deployer.ts +82 -5
- package/scripts/harness/shared-kernel/harness-api.ts +1 -0
- package/scripts/harness/skill-quality/composition-root.ts +1 -0
- package/scripts/harness/skill-quality/infrastructure/adapters/ajv-lesson-artifact-schema-adapter.ts +5 -4
- package/scripts/harness/traceability-model/domain/services/metadata-validator.ts +12 -10
- package/scripts/harness/traceability-model/infrastructure/parsers/source-metadata-parser.ts +16 -2
- package/scripts/harness/validator-system/composition-root.ts +3 -3
- package/skills/cascade-updater/SKILL.md +16 -3
- package/skills/codebase-mapper/SKILL.md +9 -9
- package/skills/codex-delegator/SKILL.md +5 -56
- package/skills/consistency-checker/SKILL.md +5 -9
- package/skills/consistency-checker/references//343/203/201/343/202/247/343/203/203/343/202/257/343/203/252/343/202/271/343/203/210.md +6 -3
- package/skills/doc-freshness-checker/SKILL.md +6 -6
- package/skills/engineering-perspective/SKILL.md +2 -58
- package/skills/engineering-perspective/references/domain-model.md +4 -135
- package/skills/implementation-readiness-checker/SKILL.md +18 -72
- package/skills/it-test-designer/SKILL.md +25 -161
- package/skills/it-test-designer/references/it-test-design-template.md +131 -0
- package/skills/it-test-logic-designer/SKILL.md +13 -388
- package/skills/it-test-logic-designer/references/controller-test-patterns.md +100 -0
- package/skills/it-test-logic-designer/references/repository-test-patterns.md +206 -0
- package/skills/it-test-logic-designer/references/usecase-test-patterns.md +87 -0
- package/skills/pointer-validator/SKILL.md +4 -4
- package/skills/scenario-test-designer/SKILL.md +4 -68
- package/skills/scenario-test-designer/references/scenario-test-design-template.md +41 -0
- package/skills/scenario-test-designer/references/scenario-test-plan-template.md +35 -0
- package/skills/scenario-test-logic-designer/SKILL.md +21 -304
- package/skills/scenario-test-logic-designer/references/msw-patterns.md +36 -0
- package/skills/scenario-test-logic-designer/references/playwright-patterns.md +237 -0
- package/skills/test-coverage-checker/SKILL.md +39 -121
- package/skills/test-coverage-checker/references/coverage-report-template.md +99 -0
- package/skills/uiux-designer/SKILL.md +27 -92
- package/skills/uiux-designer/references/data-testid-convention.md +38 -0
- package/skills/uiux-designer/references/uiux-design-template.md +105 -0
- package/skills/unit-test-designer/SKILL.md +5 -106
- package/skills/unit-test-designer/references/unit-test-design-template.md +127 -0
- package/skills/unit-test-logic-designer/SKILL.md +28 -250
- package/skills/unit-test-logic-designer/references/test-patterns.md +207 -0
|
@@ -168,385 +168,21 @@ TDD実装フェーズ
|
|
|
168
168
|
|
|
169
169
|
### it_test_logic.md の構成
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
# ITテストロジック設計: {Unit名}
|
|
173
|
-
|
|
174
|
-
## 1. テストファイル構成
|
|
175
|
-
|
|
176
|
-
| ファイルパス | 対象コンポーネント | ケース数 |
|
|
177
|
-
|------------|------------------|---------|
|
|
178
|
-
| `backend/test/integration/{context}/{usecase}.test.ts` | {UseCase名} | X |
|
|
179
|
-
| `backend/test/integration/{context}/{repository}.test.ts` | {Repository名} | X |
|
|
180
|
-
| `backend/test/integration/{context}/{controller}.test.ts` | {Controller名} | X |
|
|
181
|
-
|
|
182
|
-
## 2. テストヘルパー・シードデータ
|
|
183
|
-
|
|
184
|
-
### テストヘルパーのインポート
|
|
185
|
-
|
|
186
|
-
```typescript
|
|
187
|
-
import { target, context } from '../../helpers/common-helper.js';
|
|
188
|
-
import { getTestClient, cleanupTestData } from '../../helpers/supabase-test-helper.js';
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### シードデータ設計
|
|
171
|
+
出力する `it_test_logic.md` は以下のセクションで構成する:
|
|
192
172
|
|
|
193
|
-
|
|
194
|
-
|
|
173
|
+
1. **テストファイル構成** — ファイルパス・対象コンポーネント・ケース数の一覧表
|
|
174
|
+
2. **テストヘルパー・シードデータ** — インポートとシードデータ定義
|
|
175
|
+
3. **Repositoryテスト詳細ロジック** — CRUD操作の疑似コード
|
|
176
|
+
4. **UseCaseテスト詳細ロジック** — ビジネスロジック統合の疑似コード
|
|
177
|
+
5. **Controllerテスト詳細ロジック** — 認証・認可・バリデーションの疑似コード
|
|
178
|
+
6. **トランザクション・クリーンアップ戦略** — データ独立性の担保方法
|
|
179
|
+
7. **テスト実行コマンド** — 実行方法
|
|
195
180
|
|
|
196
|
-
|
|
197
|
-
// テストデータ定義
|
|
198
|
-
organizations: [
|
|
199
|
-
{ id: 'org-001', name: 'テスト組織' },
|
|
200
|
-
],
|
|
201
|
-
users: [
|
|
202
|
-
{ id: 'user-001', organizationId: 'org-001', name: 'テストユーザー' },
|
|
203
|
-
],
|
|
204
|
-
};
|
|
181
|
+
各セクションのテンプレート・疑似コードは以下の参照ファイルに従う:
|
|
205
182
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
export async function cleanup{SeedName}(client: SupabaseClient): Promise<void> {
|
|
211
|
-
// DELETE処理
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
## 3. Repositoryテスト詳細ロジック
|
|
216
|
-
|
|
217
|
-
### {Repository名} テスト
|
|
218
|
-
|
|
219
|
-
#### ファイル: `{repository}.test.ts`
|
|
220
|
-
|
|
221
|
-
```typescript
|
|
222
|
-
import { describe, it, expect, beforeAll, afterEach } from 'vitest';
|
|
223
|
-
import { target, context } from '../../helpers/common-helper.js';
|
|
224
|
-
import { getTestClient, cleanupTestData } from '../../helpers/supabase-test-helper.js';
|
|
225
|
-
import { {Repository} } from '../../../src/{context}/infrastructure/repositories/{repository}.js';
|
|
226
|
-
|
|
227
|
-
target('{Repository}', () => {
|
|
228
|
-
let repository: {Repository};
|
|
229
|
-
const idsToCleanup: string[] = [];
|
|
230
|
-
|
|
231
|
-
beforeAll(() => {
|
|
232
|
-
repository = new {Repository}(getTestClient());
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
afterEach(async () => {
|
|
236
|
-
for (const id of idsToCleanup) {
|
|
237
|
-
await cleanupTestData(id);
|
|
238
|
-
}
|
|
239
|
-
idsToCleanup.length = 0;
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
// IT-REPO-{Name}-001: 保存テスト
|
|
243
|
-
describe('save', () => {
|
|
244
|
-
context('新規エンティティを保存する場合', () => {
|
|
245
|
-
it('DBに永続化される', async () => {
|
|
246
|
-
// Arrange
|
|
247
|
-
const entity = create{Entity}({
|
|
248
|
-
// テストデータ
|
|
249
|
-
});
|
|
250
|
-
idsToCleanup.push(entity.id);
|
|
251
|
-
|
|
252
|
-
// Act
|
|
253
|
-
await repository.save(entity);
|
|
254
|
-
|
|
255
|
-
// Assert — DBから直接確認
|
|
256
|
-
const client = getTestClient();
|
|
257
|
-
const { data: row } = await client
|
|
258
|
-
.from('{table_name}')
|
|
259
|
-
.select('*')
|
|
260
|
-
.eq('id', entity.id)
|
|
261
|
-
.single();
|
|
262
|
-
|
|
263
|
-
expect(row).not.toBeNull();
|
|
264
|
-
expect(row!.{column}).toBe({expectedValue});
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
// IT-REPO-{Name}-002: 取得テスト
|
|
270
|
-
describe('findById', () => {
|
|
271
|
-
context('存在するIDで取得する場合', () => {
|
|
272
|
-
it('エンティティが再構築される', async () => {
|
|
273
|
-
// Arrange
|
|
274
|
-
const entity = create{Entity}({ /* ... */ });
|
|
275
|
-
await repository.save(entity);
|
|
276
|
-
idsToCleanup.push(entity.id);
|
|
277
|
-
|
|
278
|
-
// Act
|
|
279
|
-
const actual = await repository.findById(entity.id);
|
|
280
|
-
|
|
281
|
-
// Assert
|
|
282
|
-
expect(actual).not.toBeNull();
|
|
283
|
-
expect(actual!.id).toBe(entity.id);
|
|
284
|
-
expect(actual!.{property}).toBe({expectedValue});
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
context('存在しないIDで取得する場合', () => {
|
|
289
|
-
it('nullが返される', async () => {
|
|
290
|
-
// Act
|
|
291
|
-
const actual = await repository.findById(to{Entity}Id('non-existent-id'));
|
|
292
|
-
|
|
293
|
-
// Assert
|
|
294
|
-
expect(actual).toBeNull();
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
// IT-REPO-{Name}-003: 更新テスト
|
|
300
|
-
describe('update', () => {
|
|
301
|
-
it('既存エンティティが更新される', async () => {
|
|
302
|
-
// Arrange
|
|
303
|
-
const entity = create{Entity}({ /* 初期値 */ });
|
|
304
|
-
await repository.save(entity);
|
|
305
|
-
idsToCleanup.push(entity.id);
|
|
306
|
-
|
|
307
|
-
// Act
|
|
308
|
-
entity.updateXxx({newValue});
|
|
309
|
-
await repository.save(entity);
|
|
310
|
-
|
|
311
|
-
// Assert
|
|
312
|
-
const actual = await repository.findById(entity.id);
|
|
313
|
-
expect(actual!.{property}).toBe({newValue});
|
|
314
|
-
});
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
## 4. UseCaseテスト詳細ロジック
|
|
320
|
-
|
|
321
|
-
### {UseCase名} テスト
|
|
322
|
-
|
|
323
|
-
#### ファイル: `{usecase}.test.ts`
|
|
324
|
-
|
|
325
|
-
```typescript
|
|
326
|
-
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
327
|
-
import { target, context } from '../../helpers/common-helper.js';
|
|
328
|
-
import { {UseCase} } from '../../../src/{context}/application/usecases/{usecase}.js';
|
|
329
|
-
import { {Repository}Port } from '../../../src/{context}/application/ports/{repository}-port.js';
|
|
330
|
-
|
|
331
|
-
target('{UseCase}', () => {
|
|
332
|
-
let useCase: {UseCase};
|
|
333
|
-
let mockRepository: {Repository}Port;
|
|
334
|
-
|
|
335
|
-
beforeEach(() => {
|
|
336
|
-
// モックRepository作成
|
|
337
|
-
mockRepository = {
|
|
338
|
-
save: vi.fn(),
|
|
339
|
-
findById: vi.fn(),
|
|
340
|
-
// ...
|
|
341
|
-
};
|
|
342
|
-
useCase = new {UseCase}(mockRepository);
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
// IT-UC-{Name}-001: 正常系
|
|
346
|
-
describe('execute', () => {
|
|
347
|
-
context('有効な入力の場合', () => {
|
|
348
|
-
it('処理が成功し結果が返される', async () => {
|
|
349
|
-
// Arrange
|
|
350
|
-
const input = {
|
|
351
|
-
// UseCaseへの入力
|
|
352
|
-
};
|
|
353
|
-
mockRepository.findById.mockResolvedValue(create{Entity}({}));
|
|
354
|
-
|
|
355
|
-
// Act
|
|
356
|
-
const actual = await useCase.execute(input);
|
|
357
|
-
|
|
358
|
-
// Assert
|
|
359
|
-
expect(actual.isSuccess()).toBe(true);
|
|
360
|
-
expect(actual.value.{property}).toBe({expectedValue});
|
|
361
|
-
expect(mockRepository.save).toHaveBeenCalledWith(
|
|
362
|
-
expect.objectContaining({ /* 期待されるエンティティ */ })
|
|
363
|
-
);
|
|
364
|
-
});
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
// IT-UC-{Name}-002: 異常系(バリデーションエラー)
|
|
368
|
-
context('無効な入力の場合', () => {
|
|
369
|
-
it('バリデーションエラーが返される', async () => {
|
|
370
|
-
// Arrange
|
|
371
|
-
const invalidInput = {
|
|
372
|
-
// 無効な入力
|
|
373
|
-
};
|
|
374
|
-
|
|
375
|
-
// Act
|
|
376
|
-
const actual = await useCase.execute(invalidInput);
|
|
377
|
-
|
|
378
|
-
// Assert
|
|
379
|
-
expect(actual.isFailure()).toBe(true);
|
|
380
|
-
expect(actual.error.code).toBe('{ERROR_CODE}');
|
|
381
|
-
});
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
// IT-UC-{Name}-003: 異常系(リソース不存在)
|
|
385
|
-
context('対象リソースが存在しない場合', () => {
|
|
386
|
-
it('NotFoundエラーが返される', async () => {
|
|
387
|
-
// Arrange
|
|
388
|
-
mockRepository.findById.mockResolvedValue(null);
|
|
389
|
-
const input = { id: 'non-existent-id' };
|
|
390
|
-
|
|
391
|
-
// Act
|
|
392
|
-
const actual = await useCase.execute(input);
|
|
393
|
-
|
|
394
|
-
// Assert
|
|
395
|
-
expect(actual.isFailure()).toBe(true);
|
|
396
|
-
expect(actual.error.code).toBe('NOT_FOUND');
|
|
397
|
-
});
|
|
398
|
-
});
|
|
399
|
-
});
|
|
400
|
-
});
|
|
401
|
-
```
|
|
402
|
-
|
|
403
|
-
## 5. Controllerテスト詳細ロジック
|
|
404
|
-
|
|
405
|
-
### {Controller名} テスト
|
|
406
|
-
|
|
407
|
-
#### ファイル: `{controller}.test.ts`
|
|
408
|
-
|
|
409
|
-
```typescript
|
|
410
|
-
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
411
|
-
import { target, context } from '../../helpers/common-helper.js';
|
|
412
|
-
import { {Controller} } from '../../../src/{context}/interfaces/controllers/{controller}.js';
|
|
413
|
-
import { createMockCallableContext } from '../../helpers/firebase-test-helper.js';
|
|
414
|
-
|
|
415
|
-
target('{Controller}', () => {
|
|
416
|
-
let controller: {Controller};
|
|
417
|
-
let mockUseCase: {UseCase};
|
|
418
|
-
|
|
419
|
-
beforeEach(() => {
|
|
420
|
-
mockUseCase = {
|
|
421
|
-
execute: vi.fn(),
|
|
422
|
-
};
|
|
423
|
-
controller = new {Controller}(mockUseCase);
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
// IT-API-{Name}-001: 認証テスト
|
|
427
|
-
describe('認証', () => {
|
|
428
|
-
context('未認証ユーザーの場合', () => {
|
|
429
|
-
it('UNAUTHENTICATEDエラーが返される', async () => {
|
|
430
|
-
// Arrange
|
|
431
|
-
const ctx = createMockCallableContext({ auth: null });
|
|
432
|
-
const data = { /* リクエストデータ */ };
|
|
433
|
-
|
|
434
|
-
// Act & Assert
|
|
435
|
-
await expect(controller.handle(data, ctx))
|
|
436
|
-
.rejects.toThrow('UNAUTHENTICATED');
|
|
437
|
-
});
|
|
438
|
-
});
|
|
439
|
-
});
|
|
440
|
-
|
|
441
|
-
// IT-API-{Name}-002: 認可テスト
|
|
442
|
-
describe('認可', () => {
|
|
443
|
-
context('権限のないユーザーの場合', () => {
|
|
444
|
-
it('PERMISSION_DENIEDエラーが返される', async () => {
|
|
445
|
-
// Arrange
|
|
446
|
-
const ctx = createMockCallableContext({
|
|
447
|
-
auth: { uid: 'user-001', role: 'VIEWER' },
|
|
448
|
-
});
|
|
449
|
-
const data = { /* リクエストデータ */ };
|
|
450
|
-
|
|
451
|
-
// Act & Assert
|
|
452
|
-
await expect(controller.handle(data, ctx))
|
|
453
|
-
.rejects.toThrow('PERMISSION_DENIED');
|
|
454
|
-
});
|
|
455
|
-
});
|
|
456
|
-
});
|
|
457
|
-
|
|
458
|
-
// IT-API-{Name}-003: バリデーションテスト
|
|
459
|
-
describe('バリデーション', () => {
|
|
460
|
-
context('必須フィールドが欠落している場合', () => {
|
|
461
|
-
it('INVALID_ARGUMENTエラーが返される', async () => {
|
|
462
|
-
// Arrange
|
|
463
|
-
const ctx = createMockCallableContext({
|
|
464
|
-
auth: { uid: 'user-001', role: 'ADMIN' },
|
|
465
|
-
});
|
|
466
|
-
const data = { /* 不完全なデータ */ };
|
|
467
|
-
|
|
468
|
-
// Act & Assert
|
|
469
|
-
await expect(controller.handle(data, ctx))
|
|
470
|
-
.rejects.toThrow('INVALID_ARGUMENT');
|
|
471
|
-
});
|
|
472
|
-
});
|
|
473
|
-
});
|
|
474
|
-
|
|
475
|
-
// IT-API-{Name}-004: 正常系
|
|
476
|
-
describe('正常系', () => {
|
|
477
|
-
it('UseCaseが実行され結果が返される', async () => {
|
|
478
|
-
// Arrange
|
|
479
|
-
const ctx = createMockCallableContext({
|
|
480
|
-
auth: { uid: 'user-001', role: 'ADMIN' },
|
|
481
|
-
});
|
|
482
|
-
const data = { /* 有効なリクエストデータ */ };
|
|
483
|
-
mockUseCase.execute.mockResolvedValue(
|
|
484
|
-
Result.ok({ /* UseCase結果 */ })
|
|
485
|
-
);
|
|
486
|
-
|
|
487
|
-
// Act
|
|
488
|
-
const actual = await controller.handle(data, ctx);
|
|
489
|
-
|
|
490
|
-
// Assert
|
|
491
|
-
expect(mockUseCase.execute).toHaveBeenCalledWith(
|
|
492
|
-
expect.objectContaining({ /* 期待される入力 */ })
|
|
493
|
-
);
|
|
494
|
-
expect(actual).toEqual({ /* 期待されるレスポンス */ });
|
|
495
|
-
});
|
|
496
|
-
});
|
|
497
|
-
});
|
|
498
|
-
```
|
|
499
|
-
|
|
500
|
-
## 6. トランザクション・クリーンアップ戦略
|
|
501
|
-
|
|
502
|
-
### クリーンアップパターン
|
|
503
|
-
|
|
504
|
-
```typescript
|
|
505
|
-
// テスト毎にクリーンアップ
|
|
506
|
-
afterEach(async () => {
|
|
507
|
-
for (const id of idsToCleanup) {
|
|
508
|
-
await cleanupTestData(id);
|
|
509
|
-
}
|
|
510
|
-
idsToCleanup.length = 0;
|
|
511
|
-
});
|
|
512
|
-
```
|
|
513
|
-
|
|
514
|
-
### トランザクション分離
|
|
515
|
-
|
|
516
|
-
```typescript
|
|
517
|
-
// トランザクション内でテスト実行(ロールバック)
|
|
518
|
-
describe('トランザクションテスト', () => {
|
|
519
|
-
it('エラー時にロールバックされる', async () => {
|
|
520
|
-
// Arrange
|
|
521
|
-
const client = getTestClient();
|
|
522
|
-
|
|
523
|
-
// Act
|
|
524
|
-
try {
|
|
525
|
-
await client.rpc('test_transaction', { /* ... */ });
|
|
526
|
-
} catch (e) {
|
|
527
|
-
// Expected error
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
// Assert — ロールバックされていることを確認
|
|
531
|
-
const { data } = await client.from('{table}').select('*');
|
|
532
|
-
expect(data).toHaveLength(0);
|
|
533
|
-
});
|
|
534
|
-
});
|
|
535
|
-
```
|
|
536
|
-
|
|
537
|
-
## 7. テスト実行コマンド
|
|
538
|
-
|
|
539
|
-
```bash
|
|
540
|
-
# 全ITテスト実行
|
|
541
|
-
pnpm --filter backend test:integration
|
|
542
|
-
|
|
543
|
-
# 特定ファイルのみ
|
|
544
|
-
pnpm --filter backend test:integration -- {repository}.test.ts
|
|
545
|
-
|
|
546
|
-
# watchモード
|
|
547
|
-
pnpm --filter backend test:integration -- --watch
|
|
548
|
-
```
|
|
549
|
-
```
|
|
183
|
+
- **Repository + シード + クリーンアップ**: [references/repository-test-patterns.md](references/repository-test-patterns.md)
|
|
184
|
+
- **UseCase**: [references/usecase-test-patterns.md](references/usecase-test-patterns.md)
|
|
185
|
+
- **Controller**: [references/controller-test-patterns.md](references/controller-test-patterns.md)
|
|
550
186
|
|
|
551
187
|
---
|
|
552
188
|
|
|
@@ -558,16 +194,7 @@ pnpm --filter backend test:integration -- --watch
|
|
|
558
194
|
- **Assert**: 結果の検証(DB状態確認含む)
|
|
559
195
|
|
|
560
196
|
### 2. DB直接確認パターン
|
|
561
|
-
|
|
562
|
-
// Assert — DBから直接確認
|
|
563
|
-
const client = getTestClient();
|
|
564
|
-
const { data: row } = await client
|
|
565
|
-
.from('{table}')
|
|
566
|
-
.select('*')
|
|
567
|
-
.eq('id', entity.id)
|
|
568
|
-
.single();
|
|
569
|
-
expect(row).not.toBeNull();
|
|
570
|
-
```
|
|
197
|
+
Repositoryテストでは、`getTestClient()` でDBに直接クエリし永続化を検証する。テンプレートは [references/repository-test-patterns.md](references/repository-test-patterns.md) を参照。
|
|
571
198
|
|
|
572
199
|
### 3. モック戦略
|
|
573
200
|
- **Repository**: 実DB使用(統合テストの本質)
|
|
@@ -581,8 +208,6 @@ expect(row).not.toBeNull();
|
|
|
581
208
|
|
|
582
209
|
---
|
|
583
210
|
|
|
584
|
-
---
|
|
585
|
-
|
|
586
211
|
## Phase 3: レビュー(Opus review)
|
|
587
212
|
|
|
588
213
|
### 実行主体
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Controller テストパターン・テンプレート
|
|
2
|
+
|
|
3
|
+
本ファイルは `it-test-logic-designer` スキルで使用するController/APIレイヤーのテストテンプレート集。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Controller テストテンプレート
|
|
8
|
+
|
|
9
|
+
### ファイル: `{controller}.test.ts`
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
13
|
+
import { target, context } from '../../helpers/common-helper.js';
|
|
14
|
+
import { {Controller} } from '../../../src/{context}/interfaces/controllers/{controller}.js';
|
|
15
|
+
import { createMockCallableContext } from '../../helpers/firebase-test-helper.js';
|
|
16
|
+
|
|
17
|
+
target('{Controller}', () => {
|
|
18
|
+
let controller: {Controller};
|
|
19
|
+
let mockUseCase: {UseCase};
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
mockUseCase = {
|
|
23
|
+
execute: vi.fn(),
|
|
24
|
+
};
|
|
25
|
+
controller = new {Controller}(mockUseCase);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// IT-API-{Name}-001: 認証テスト
|
|
29
|
+
describe('認証', () => {
|
|
30
|
+
context('未認証ユーザーの場合', () => {
|
|
31
|
+
it('UNAUTHENTICATEDエラーが返される', async () => {
|
|
32
|
+
// Arrange
|
|
33
|
+
const ctx = createMockCallableContext({ auth: null });
|
|
34
|
+
const data = { /* リクエストデータ */ };
|
|
35
|
+
|
|
36
|
+
// Act & Assert
|
|
37
|
+
await expect(controller.handle(data, ctx))
|
|
38
|
+
.rejects.toThrow('UNAUTHENTICATED');
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// IT-API-{Name}-002: 認可テスト
|
|
44
|
+
describe('認可', () => {
|
|
45
|
+
context('権限のないユーザーの場合', () => {
|
|
46
|
+
it('PERMISSION_DENIEDエラーが返される', async () => {
|
|
47
|
+
// Arrange
|
|
48
|
+
const ctx = createMockCallableContext({
|
|
49
|
+
auth: { uid: 'user-001', role: 'VIEWER' },
|
|
50
|
+
});
|
|
51
|
+
const data = { /* リクエストデータ */ };
|
|
52
|
+
|
|
53
|
+
// Act & Assert
|
|
54
|
+
await expect(controller.handle(data, ctx))
|
|
55
|
+
.rejects.toThrow('PERMISSION_DENIED');
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// IT-API-{Name}-003: バリデーションテスト
|
|
61
|
+
describe('バリデーション', () => {
|
|
62
|
+
context('必須フィールドが欠落している場合', () => {
|
|
63
|
+
it('INVALID_ARGUMENTエラーが返される', async () => {
|
|
64
|
+
// Arrange
|
|
65
|
+
const ctx = createMockCallableContext({
|
|
66
|
+
auth: { uid: 'user-001', role: 'ADMIN' },
|
|
67
|
+
});
|
|
68
|
+
const data = { /* 不完全なデータ */ };
|
|
69
|
+
|
|
70
|
+
// Act & Assert
|
|
71
|
+
await expect(controller.handle(data, ctx))
|
|
72
|
+
.rejects.toThrow('INVALID_ARGUMENT');
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// IT-API-{Name}-004: 正常系
|
|
78
|
+
describe('正常系', () => {
|
|
79
|
+
it('UseCaseが実行され結果が返される', async () => {
|
|
80
|
+
// Arrange
|
|
81
|
+
const ctx = createMockCallableContext({
|
|
82
|
+
auth: { uid: 'user-001', role: 'ADMIN' },
|
|
83
|
+
});
|
|
84
|
+
const data = { /* 有効なリクエストデータ */ };
|
|
85
|
+
mockUseCase.execute.mockResolvedValue(
|
|
86
|
+
Result.ok({ /* UseCase結果 */ })
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
// Act
|
|
90
|
+
const actual = await controller.handle(data, ctx);
|
|
91
|
+
|
|
92
|
+
// Assert
|
|
93
|
+
expect(mockUseCase.execute).toHaveBeenCalledWith(
|
|
94
|
+
expect.objectContaining({ /* 期待される入力 */ })
|
|
95
|
+
);
|
|
96
|
+
expect(actual).toEqual({ /* 期待されるレスポンス */ });
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
```
|