1- import { TestCase } from "./types" ;
21import * as jsYaml from "js-yaml" ;
2+ import { TestCase } from "./types" ;
33import { fromYaml , toYaml } from "./yaml_helper" ;
44import { expect } from "chai" ;
55
@@ -23,7 +23,8 @@ const TEST_CASES: TestCase[] = [
2323 } ,
2424 {
2525 displayName : "minimal-case" ,
26- aiInstructions : { steps : [ { goal : "test-goal" } ] } ,
26+ name : "projects/12345/apps/1:12345:android:beef/testCases/minimal-id" ,
27+ aiInstructions : { steps : [ { goal : "win" } ] } ,
2728 } ,
2829] ;
2930
@@ -34,31 +35,58 @@ const YAML_STRING = `- displayName: test-display-name
3435 - goal: test-goal
3536 hint: test-hint
3637 successCriteria: test-success-criteria
38+ - displayName: minimal-case
39+ id: minimal-id
40+ steps:
41+ - goal: win
3742` ;
3843
39- const YAML_DATA = {
40- displayName : "test-display-name" ,
41- id : "test-case-id" ,
42- prerequisiteTestCaseId : "prerequisite-test-case-id" ,
43- steps : [
44- {
45- goal : "test-goal" ,
46- hint : "test-hint" ,
47- successCriteria : "test-success-criteria" ,
48- } ,
49- ] ,
50- } ;
44+ const YAML_DATA = [
45+ {
46+ displayName : "test-display-name" ,
47+ id : "test-case-id" ,
48+ prerequisiteTestCaseId : "prerequisite-test-case-id" ,
49+ steps : [
50+ {
51+ goal : "test-goal" ,
52+ hint : "test-hint" ,
53+ successCriteria : "test-success-criteria" ,
54+ } ,
55+ ] ,
56+ } ,
57+ {
58+ displayName : "minimal-case" ,
59+ id : "minimal-id" ,
60+ steps : [ { goal : "win" } ] ,
61+ } ,
62+ ] ;
5163
5264describe ( "YamlHelper" , ( ) => {
5365 it ( "converts TestCase[] to YAML string" , ( ) => {
54- const yamlString = toYaml ( [ TEST_CASE ] ) ;
66+ const yamlString = toYaml ( TEST_CASES ) ;
67+ expect ( jsYaml . safeLoad ( yamlString ) ) . to . eql ( YAML_DATA ) ;
5568 expect ( yamlString ) . to . eq ( YAML_STRING ) ; // brittle ¯\_(ツ)_/¯
56- expect ( jsYaml . safeLoad ( yamlString ) ) . to . eql ( [ YAML_DATA ] ) ;
5769 } ) ;
5870
5971 it ( "converts YAML string to TestCase[]" , ( ) => {
6072 const testCases = fromYaml ( APP_NAME , YAML_STRING ) ;
61- expect ( testCases ) . to . eql ( [ TEST_CASE ] ) ;
73+ expect ( testCases ) . to . eql ( TEST_CASES ) ;
74+ } ) ;
75+
76+ it ( "converts YAML without ID" , ( ) => {
77+ const testCases = fromYaml (
78+ APP_NAME ,
79+ `- displayName: minimal-case
80+ steps:
81+ - goal: win
82+ ` ,
83+ ) ;
84+ expect ( testCases ) . to . eql ( [
85+ {
86+ displayName : "minimal-case" ,
87+ aiInstructions : { steps : [ { goal : "win" } ] } ,
88+ } ,
89+ ] ) ;
6290 } ) ;
6391
6492 it ( "throws error if displayName is missing" , ( ) => {
0 commit comments