summaryrefslogtreecommitdiff
path: root/internal/api/elaborate_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api/elaborate_test.go')
-rw-r--r--internal/api/elaborate_test.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/internal/api/elaborate_test.go b/internal/api/elaborate_test.go
index 32cec3c..34269e9 100644
--- a/internal/api/elaborate_test.go
+++ b/internal/api/elaborate_test.go
@@ -477,6 +477,50 @@ func TestElaborateTask_NoRawNarrativeWithoutExplicitProjectDir(t *testing.T) {
}
}
+func TestElaboratedStoryValidation_AcceptanceCriteriaSchema(t *testing.T) {
+ raw := `{
+ "type": "test",
+ "acceptance_criteria": [
+ {"name": "API returns 200", "verification": "curl /health returns 200", "test_ref": "TestHealthCheck"},
+ {"name": "DB migrates cleanly", "verification": "migration runs without error"}
+ ],
+ "success_criteria": "all checks pass"
+ }`
+
+ var v elaboratedStoryValidation
+ if err := json.Unmarshal([]byte(raw), &v); err != nil {
+ t.Fatalf("unmarshal failed: %v", err)
+ }
+
+ if len(v.AcceptanceCriteria) != 2 {
+ t.Fatalf("expected 2 acceptance_criteria, got %d", len(v.AcceptanceCriteria))
+ }
+
+ ac0 := v.AcceptanceCriteria[0]
+ if ac0.Name != "API returns 200" {
+ t.Errorf("ac[0].name: want %q, got %q", "API returns 200", ac0.Name)
+ }
+ if ac0.Verification != "curl /health returns 200" {
+ t.Errorf("ac[0].verification: want %q, got %q", "curl /health returns 200", ac0.Verification)
+ }
+ if ac0.TestRef != "TestHealthCheck" {
+ t.Errorf("ac[0].test_ref: want %q, got %q", "TestHealthCheck", ac0.TestRef)
+ }
+
+ ac1 := v.AcceptanceCriteria[1]
+ if ac1.Name != "DB migrates cleanly" {
+ t.Errorf("ac[1].name: want %q, got %q", "DB migrates cleanly", ac1.Name)
+ }
+ // test_ref omitted — backward compat: must be empty string, not an error
+ if ac1.TestRef != "" {
+ t.Errorf("ac[1].test_ref: want empty (omitempty), got %q", ac1.TestRef)
+ }
+
+ if v.SuccessCriteria != "all checks pass" {
+ t.Errorf("success_criteria: want %q, got %q", "all checks pass", v.SuccessCriteria)
+ }
+}
+
func TestElaborateTask_AppendsRawNarrative(t *testing.T) {
srv, _ := testServer(t)