phasegate 0.16.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 +71 -39
- package/README.md +69 -9
- package/docs/ADR/ADR-013-story-reflection-gate.md +100 -0
- package/docs/guide/configuration.md +244 -7
- package/package.json +4 -2
- 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 +108 -2
- 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 +21 -4
- 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/file-system-story-reflection-query-adapter.ts +122 -0
- 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/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 +1 -0
- 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 +1 -0
- package/scripts/harness/harness-api/domain/services/command-registry.ts +1 -0
- 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 +1 -0
- 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 +1 -0
- package/scripts/harness/harness-api/presentation/handlers/check-ready-handler.ts +1 -0
- package/scripts/harness/harness-api/presentation/handlers/ci-check-handler.ts +1 -0
- package/scripts/harness/harness-api/presentation/handlers/complete-check-handler.ts +1 -0
- package/scripts/harness/harness-api/presentation/handlers/detect-drift-handler.ts +1 -0
- package/scripts/harness/harness-api/presentation/handlers/impact-analysis-handler.ts +1 -0
- package/scripts/harness/harness-api/presentation/handlers/lint-handler.ts +1 -0
- package/scripts/harness/harness-api/presentation/handlers/status-handler.ts +1 -0
- 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 +154 -34
- 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/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/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
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# Repository テストパターン・テンプレート
|
|
2
|
+
|
|
3
|
+
本ファイルは `it-test-logic-designer` スキルで使用するRepositoryレイヤーのテストテンプレート集。
|
|
4
|
+
シードデータ設計・トランザクション・クリーンアップ戦略を含む。
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## テストヘルパーのインポート
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
import { target, context } from '../../helpers/common-helper.js';
|
|
12
|
+
import { getTestClient, cleanupTestData } from '../../helpers/supabase-test-helper.js';
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## シードデータ設計テンプレート
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
// backend/test/seeds/{context}/{seed-name}.ts
|
|
19
|
+
|
|
20
|
+
export const {SEED_NAME}_SEED = {
|
|
21
|
+
// テストデータ定義
|
|
22
|
+
organizations: [
|
|
23
|
+
{ id: 'org-001', name: 'テスト組織' },
|
|
24
|
+
],
|
|
25
|
+
users: [
|
|
26
|
+
{ id: 'user-001', organizationId: 'org-001', name: 'テストユーザー' },
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export async function seed{SeedName}(client: SupabaseClient): Promise<void> {
|
|
31
|
+
// INSERT処理
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function cleanup{SeedName}(client: SupabaseClient): Promise<void> {
|
|
35
|
+
// DELETE処理
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Repository テストテンプレート
|
|
42
|
+
|
|
43
|
+
### ファイル: `{repository}.test.ts`
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { describe, it, expect, beforeAll, afterEach } from 'vitest';
|
|
47
|
+
import { target, context } from '../../helpers/common-helper.js';
|
|
48
|
+
import { getTestClient, cleanupTestData } from '../../helpers/supabase-test-helper.js';
|
|
49
|
+
import { {Repository} } from '../../../src/{context}/infrastructure/repositories/{repository}.js';
|
|
50
|
+
|
|
51
|
+
target('{Repository}', () => {
|
|
52
|
+
let repository: {Repository};
|
|
53
|
+
const idsToCleanup: string[] = [];
|
|
54
|
+
|
|
55
|
+
beforeAll(() => {
|
|
56
|
+
repository = new {Repository}(getTestClient());
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
afterEach(async () => {
|
|
60
|
+
for (const id of idsToCleanup) {
|
|
61
|
+
await cleanupTestData(id);
|
|
62
|
+
}
|
|
63
|
+
idsToCleanup.length = 0;
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// IT-REPO-{Name}-001: 保存テスト
|
|
67
|
+
describe('save', () => {
|
|
68
|
+
context('新規エンティティを保存する場合', () => {
|
|
69
|
+
it('DBに永続化される', async () => {
|
|
70
|
+
// Arrange
|
|
71
|
+
const entity = create{Entity}({
|
|
72
|
+
// テストデータ
|
|
73
|
+
});
|
|
74
|
+
idsToCleanup.push(entity.id);
|
|
75
|
+
|
|
76
|
+
// Act
|
|
77
|
+
await repository.save(entity);
|
|
78
|
+
|
|
79
|
+
// Assert — DBから直接確認
|
|
80
|
+
const client = getTestClient();
|
|
81
|
+
const { data: row } = await client
|
|
82
|
+
.from('{table_name}')
|
|
83
|
+
.select('*')
|
|
84
|
+
.eq('id', entity.id)
|
|
85
|
+
.single();
|
|
86
|
+
|
|
87
|
+
expect(row).not.toBeNull();
|
|
88
|
+
expect(row!.{column}).toBe({expectedValue});
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// IT-REPO-{Name}-002: 取得テスト
|
|
94
|
+
describe('findById', () => {
|
|
95
|
+
context('存在するIDで取得する場合', () => {
|
|
96
|
+
it('エンティティが再構築される', async () => {
|
|
97
|
+
// Arrange
|
|
98
|
+
const entity = create{Entity}({ /* ... */ });
|
|
99
|
+
await repository.save(entity);
|
|
100
|
+
idsToCleanup.push(entity.id);
|
|
101
|
+
|
|
102
|
+
// Act
|
|
103
|
+
const actual = await repository.findById(entity.id);
|
|
104
|
+
|
|
105
|
+
// Assert
|
|
106
|
+
expect(actual).not.toBeNull();
|
|
107
|
+
expect(actual!.id).toBe(entity.id);
|
|
108
|
+
expect(actual!.{property}).toBe({expectedValue});
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
context('存在しないIDで取得する場合', () => {
|
|
113
|
+
it('nullが返される', async () => {
|
|
114
|
+
// Act
|
|
115
|
+
const actual = await repository.findById(to{Entity}Id('non-existent-id'));
|
|
116
|
+
|
|
117
|
+
// Assert
|
|
118
|
+
expect(actual).toBeNull();
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// IT-REPO-{Name}-003: 更新テスト
|
|
124
|
+
describe('update', () => {
|
|
125
|
+
it('既存エンティティが更新される', async () => {
|
|
126
|
+
// Arrange
|
|
127
|
+
const entity = create{Entity}({ /* 初期値 */ });
|
|
128
|
+
await repository.save(entity);
|
|
129
|
+
idsToCleanup.push(entity.id);
|
|
130
|
+
|
|
131
|
+
// Act
|
|
132
|
+
entity.updateXxx({newValue});
|
|
133
|
+
await repository.save(entity);
|
|
134
|
+
|
|
135
|
+
// Assert
|
|
136
|
+
const actual = await repository.findById(entity.id);
|
|
137
|
+
expect(actual!.{property}).toBe({newValue});
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## トランザクション・クリーンアップ戦略
|
|
146
|
+
|
|
147
|
+
### クリーンアップパターン
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
// テスト毎にクリーンアップ
|
|
151
|
+
afterEach(async () => {
|
|
152
|
+
for (const id of idsToCleanup) {
|
|
153
|
+
await cleanupTestData(id);
|
|
154
|
+
}
|
|
155
|
+
idsToCleanup.length = 0;
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### トランザクション分離
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
// トランザクション内でテスト実行(ロールバック)
|
|
163
|
+
describe('トランザクションテスト', () => {
|
|
164
|
+
it('エラー時にロールバックされる', async () => {
|
|
165
|
+
// Arrange
|
|
166
|
+
const client = getTestClient();
|
|
167
|
+
|
|
168
|
+
// Act
|
|
169
|
+
try {
|
|
170
|
+
await client.rpc('test_transaction', { /* ... */ });
|
|
171
|
+
} catch (e) {
|
|
172
|
+
// Expected error
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Assert — ロールバックされていることを確認
|
|
176
|
+
const { data } = await client.from('{table}').select('*');
|
|
177
|
+
expect(data).toHaveLength(0);
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### DB直接確認パターン
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
// Assert — DBから直接確認
|
|
186
|
+
const client = getTestClient();
|
|
187
|
+
const { data: row } = await client
|
|
188
|
+
.from('{table}')
|
|
189
|
+
.select('*')
|
|
190
|
+
.eq('id', entity.id)
|
|
191
|
+
.single();
|
|
192
|
+
expect(row).not.toBeNull();
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## テスト実行コマンド
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# 全ITテスト実行
|
|
199
|
+
pnpm --filter backend test:integration
|
|
200
|
+
|
|
201
|
+
# 特定ファイルのみ
|
|
202
|
+
pnpm --filter backend test:integration -- {repository}.test.ts
|
|
203
|
+
|
|
204
|
+
# watchモード
|
|
205
|
+
pnpm --filter backend test:integration -- --watch
|
|
206
|
+
```
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# UseCase テストパターン・テンプレート
|
|
2
|
+
|
|
3
|
+
本ファイルは `it-test-logic-designer` スキルで使用するUseCaseレイヤーのテストテンプレート集。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## UseCase テストテンプレート
|
|
8
|
+
|
|
9
|
+
### ファイル: `{usecase}.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 { {UseCase} } from '../../../src/{context}/application/usecases/{usecase}.js';
|
|
15
|
+
import { {Repository}Port } from '../../../src/{context}/application/ports/{repository}-port.js';
|
|
16
|
+
|
|
17
|
+
target('{UseCase}', () => {
|
|
18
|
+
let useCase: {UseCase};
|
|
19
|
+
let mockRepository: {Repository}Port;
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
// モックRepository作成
|
|
23
|
+
mockRepository = {
|
|
24
|
+
save: vi.fn(),
|
|
25
|
+
findById: vi.fn(),
|
|
26
|
+
// ...
|
|
27
|
+
};
|
|
28
|
+
useCase = new {UseCase}(mockRepository);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// IT-UC-{Name}-001: 正常系
|
|
32
|
+
describe('execute', () => {
|
|
33
|
+
context('有効な入力の場合', () => {
|
|
34
|
+
it('処理が成功し結果が返される', async () => {
|
|
35
|
+
// Arrange
|
|
36
|
+
const input = {
|
|
37
|
+
// UseCaseへの入力
|
|
38
|
+
};
|
|
39
|
+
mockRepository.findById.mockResolvedValue(create{Entity}({}));
|
|
40
|
+
|
|
41
|
+
// Act
|
|
42
|
+
const actual = await useCase.execute(input);
|
|
43
|
+
|
|
44
|
+
// Assert
|
|
45
|
+
expect(actual.isSuccess()).toBe(true);
|
|
46
|
+
expect(actual.value.{property}).toBe({expectedValue});
|
|
47
|
+
expect(mockRepository.save).toHaveBeenCalledWith(
|
|
48
|
+
expect.objectContaining({ /* 期待されるエンティティ */ })
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// IT-UC-{Name}-002: 異常系(バリデーションエラー)
|
|
54
|
+
context('無効な入力の場合', () => {
|
|
55
|
+
it('バリデーションエラーが返される', async () => {
|
|
56
|
+
// Arrange
|
|
57
|
+
const invalidInput = {
|
|
58
|
+
// 無効な入力
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// Act
|
|
62
|
+
const actual = await useCase.execute(invalidInput);
|
|
63
|
+
|
|
64
|
+
// Assert
|
|
65
|
+
expect(actual.isFailure()).toBe(true);
|
|
66
|
+
expect(actual.error.code).toBe('{ERROR_CODE}');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// IT-UC-{Name}-003: 異常系(リソース不存在)
|
|
71
|
+
context('対象リソースが存在しない場合', () => {
|
|
72
|
+
it('NotFoundエラーが返される', async () => {
|
|
73
|
+
// Arrange
|
|
74
|
+
mockRepository.findById.mockResolvedValue(null);
|
|
75
|
+
const input = { id: 'non-existent-id' };
|
|
76
|
+
|
|
77
|
+
// Act
|
|
78
|
+
const actual = await useCase.execute(input);
|
|
79
|
+
|
|
80
|
+
// Assert
|
|
81
|
+
expect(actual.isFailure()).toBe(true);
|
|
82
|
+
expect(actual.error.code).toBe('NOT_FOUND');
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: pointer-validator
|
|
3
|
-
description: 設計文書内のファイルポインタ(相対パス参照)の有効性を検証するスキル(L4バリデータ拡張)。`
|
|
3
|
+
description: 設計文書内のファイルポインタ(相対パス参照)の有効性を検証するスキル(L4バリデータ拡張)。`phasegate validate-pointers` CLIを使い、ドキュメント内で参照されているファイルパスが実際に存在するかチェックする。使用タイミング: 「ドキュメントのリンク切れを確認して」「ポインタ検証を実行して」「broken pointer を探して」「設計文書の参照が正しいか確認して」など。
|
|
4
4
|
model: sonnet
|
|
5
5
|
review: opus
|
|
6
6
|
---
|
|
@@ -8,7 +8,7 @@ review: opus
|
|
|
8
8
|
# Pointer Validator
|
|
9
9
|
|
|
10
10
|
設計文書内のファイルパス参照(ポインタ)の有効性を検証するスキル。
|
|
11
|
-
`
|
|
11
|
+
`phasegate validate-pointers` CLIをラップし、broken pointer を検出・修正案を提示する。
|
|
12
12
|
|
|
13
13
|
## CLIの動作
|
|
14
14
|
|
|
@@ -27,7 +27,7 @@ review: opus
|
|
|
27
27
|
### Step 1: CLIの実行
|
|
28
28
|
|
|
29
29
|
```bash
|
|
30
|
-
|
|
30
|
+
npx phasegate validate-pointers
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
オプション:
|
|
@@ -75,7 +75,7 @@ pnpm run p2:validate-pointers
|
|
|
75
75
|
## 次のアクション
|
|
76
76
|
(brokenがある場合)
|
|
77
77
|
1. 上記テーブルの broken pointer を修正
|
|
78
|
-
2. `
|
|
78
|
+
2. `npx phasegate validate-pointers` を再実行して0件を確認
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
---
|
|
@@ -112,37 +112,9 @@ story-implementor ← TDD実装
|
|
|
112
112
|
|
|
113
113
|
### 計画ファイルの構成
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
# シナリオテスト設計計画: {ストーリーID}
|
|
117
|
-
|
|
118
|
-
## 1. スコープ
|
|
119
|
-
- 対象ストーリーと受け入れ基準
|
|
120
|
-
- テスト対象の画面・機能
|
|
121
|
-
|
|
122
|
-
## 2. テストシナリオ概要(ドラフト)
|
|
123
|
-
| シナリオID | シナリオ名 | 検証観点 |
|
|
124
|
-
|-----------|----------|---------|
|
|
125
|
-
|
|
126
|
-
## 3. 前提条件
|
|
127
|
-
- 必要なテストデータ
|
|
128
|
-
- 認証状態・権限
|
|
129
|
-
|
|
130
|
-
## 4. テスト実行環境
|
|
131
|
-
- 使用するテストフレームワーク(Playwright等)
|
|
132
|
-
- データセットアップ方針
|
|
133
|
-
|
|
134
|
-
## 5. QA(不明点・確認事項)
|
|
115
|
+
詳細なテンプレートは [references/scenario-test-plan-template.md](references/scenario-test-plan-template.md) を参照。
|
|
135
116
|
|
|
136
|
-
|
|
137
|
-
{質問の詳細と背景}
|
|
138
|
-
**推奨案:** {AIの推奨案}
|
|
139
|
-
|
|
140
|
-
[Answer]
|
|
141
|
-
(人間が回答を記入)
|
|
142
|
-
|
|
143
|
-
## 6. 前提条件・リスク
|
|
144
|
-
- ...
|
|
145
|
-
```
|
|
117
|
+
主要セクション: スコープ / テストシナリオ概要 / 前提条件 / テスト実行環境 / QA(不明点) / 前提条件・リスク
|
|
146
118
|
|
|
147
119
|
### Phase 1 完了条件
|
|
148
120
|
- 計画ファイルを出力した
|
|
@@ -186,45 +158,9 @@ story-implementor ← TDD実装
|
|
|
186
158
|
|
|
187
159
|
### scenario_test_design.md の構成
|
|
188
160
|
|
|
189
|
-
|
|
190
|
-
# シナリオテスト設計: {ストーリーID}
|
|
191
|
-
|
|
192
|
-
## 1. 対象ストーリー
|
|
193
|
-
- ストーリーID: {story_id}
|
|
194
|
-
- 概要: {ストーリー概要}
|
|
195
|
-
- 受け入れ基準: ...
|
|
161
|
+
詳細なテンプレートは [references/scenario-test-design-template.md](references/scenario-test-design-template.md) を参照。
|
|
196
162
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
### SC-001: {シナリオ名}
|
|
200
|
-
|
|
201
|
-
#### 前提条件
|
|
202
|
-
- ...
|
|
203
|
-
|
|
204
|
-
#### テストステップ
|
|
205
|
-
| # | 操作 | 期待結果 |
|
|
206
|
-
|---|------|---------|
|
|
207
|
-
| 1 | ... | ... |
|
|
208
|
-
|
|
209
|
-
#### 検証ポイント
|
|
210
|
-
- ...
|
|
211
|
-
|
|
212
|
-
### SC-002: ...
|
|
213
|
-
|
|
214
|
-
## 3. テストデータ要件
|
|
215
|
-
- 必要なシードデータ
|
|
216
|
-
- テストユーザー定義
|
|
217
|
-
|
|
218
|
-
## 4. 異常系・エッジケース
|
|
219
|
-
| ケースID | 概要 | 入力条件 | 期待結果 |
|
|
220
|
-
|---------|------|---------|---------|
|
|
221
|
-
|
|
222
|
-
## 5. 実装時の注意点
|
|
223
|
-
- data-testid命名規約
|
|
224
|
-
- 非同期処理の待機方法
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
---
|
|
163
|
+
主要セクション: 対象ストーリー / テストシナリオ(SC-XXX) / テストデータ要件 / 異常系・エッジケース / 実装時の注意点
|
|
228
164
|
|
|
229
165
|
---
|
|
230
166
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# scenario_test_design.md テンプレート
|
|
2
|
+
|
|
3
|
+
Phase 2 の成果物として出力する `docs/inception/{unit}/{story_id}/scenario_test_design.md` の構成テンプレート。
|
|
4
|
+
|
|
5
|
+
```markdown
|
|
6
|
+
# シナリオテスト設計: {ストーリーID}
|
|
7
|
+
|
|
8
|
+
## 1. 対象ストーリー
|
|
9
|
+
- ストーリーID: {story_id}
|
|
10
|
+
- 概要: {ストーリー概要}
|
|
11
|
+
- 受け入れ基準: ...
|
|
12
|
+
|
|
13
|
+
## 2. テストシナリオ
|
|
14
|
+
|
|
15
|
+
### SC-001: {シナリオ名}
|
|
16
|
+
|
|
17
|
+
#### 前提条件
|
|
18
|
+
- ...
|
|
19
|
+
|
|
20
|
+
#### テストステップ
|
|
21
|
+
| # | 操作 | 期待結果 |
|
|
22
|
+
|---|------|---------|
|
|
23
|
+
| 1 | ... | ... |
|
|
24
|
+
|
|
25
|
+
#### 検証ポイント
|
|
26
|
+
- ...
|
|
27
|
+
|
|
28
|
+
### SC-002: ...
|
|
29
|
+
|
|
30
|
+
## 3. テストデータ要件
|
|
31
|
+
- 必要なシードデータ
|
|
32
|
+
- テストユーザー定義
|
|
33
|
+
|
|
34
|
+
## 4. 異常系・エッジケース
|
|
35
|
+
| ケースID | 概要 | 入力条件 | 期待結果 |
|
|
36
|
+
|---------|------|---------|---------|
|
|
37
|
+
|
|
38
|
+
## 5. 実装時の注意点
|
|
39
|
+
- data-testid命名規約
|
|
40
|
+
- 非同期処理の待機方法
|
|
41
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# scenario_test_plan.md テンプレート
|
|
2
|
+
|
|
3
|
+
Phase 1 の成果物として出力する `docs/inception/{unit}/{story_id}/scenario_test_plan.md` の構成テンプレート。
|
|
4
|
+
|
|
5
|
+
```markdown
|
|
6
|
+
# シナリオテスト設計計画: {ストーリーID}
|
|
7
|
+
|
|
8
|
+
## 1. スコープ
|
|
9
|
+
- 対象ストーリーと受け入れ基準
|
|
10
|
+
- テスト対象の画面・機能
|
|
11
|
+
|
|
12
|
+
## 2. テストシナリオ概要(ドラフト)
|
|
13
|
+
| シナリオID | シナリオ名 | 検証観点 |
|
|
14
|
+
|-----------|----------|---------|
|
|
15
|
+
|
|
16
|
+
## 3. 前提条件
|
|
17
|
+
- 必要なテストデータ
|
|
18
|
+
- 認証状態・権限
|
|
19
|
+
|
|
20
|
+
## 4. テスト実行環境
|
|
21
|
+
- 使用するテストフレームワーク(Playwright等)
|
|
22
|
+
- データセットアップ方針
|
|
23
|
+
|
|
24
|
+
## 5. QA(不明点・確認事項)
|
|
25
|
+
|
|
26
|
+
### [Question] Q1: {質問タイトル}
|
|
27
|
+
{質問の詳細と背景}
|
|
28
|
+
**推奨案:** {AIの推奨案}
|
|
29
|
+
|
|
30
|
+
[Answer]
|
|
31
|
+
(人間が回答を記入)
|
|
32
|
+
|
|
33
|
+
## 6. 前提条件・リスク
|
|
34
|
+
- ...
|
|
35
|
+
```
|