@auto-engineer/narrative 0.13.0 → 0.13.2

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.
Files changed (89) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +22 -0
  3. package/dist/src/commands/export-schema-runner.js +1 -1
  4. package/dist/src/commands/export-schema-runner.js.map +1 -1
  5. package/dist/src/fluent-builder.js +3 -3
  6. package/dist/src/fluent-builder.js.map +1 -1
  7. package/dist/src/getNarratives.specs.js +149 -153
  8. package/dist/src/getNarratives.specs.js.map +1 -1
  9. package/dist/src/id/addAutoIds.d.ts.map +1 -1
  10. package/dist/src/id/addAutoIds.js +50 -12
  11. package/dist/src/id/addAutoIds.js.map +1 -1
  12. package/dist/src/id/addAutoIds.specs.js +396 -45
  13. package/dist/src/id/addAutoIds.specs.js.map +1 -1
  14. package/dist/src/id/hasAllIds.d.ts.map +1 -1
  15. package/dist/src/id/hasAllIds.js +28 -5
  16. package/dist/src/id/hasAllIds.js.map +1 -1
  17. package/dist/src/id/hasAllIds.specs.js +407 -214
  18. package/dist/src/id/hasAllIds.specs.js.map +1 -1
  19. package/dist/src/index.d.ts +6 -8
  20. package/dist/src/index.d.ts.map +1 -1
  21. package/dist/src/index.js +3 -3
  22. package/dist/src/index.js.map +1 -1
  23. package/dist/src/loader/graph.d.ts.map +1 -1
  24. package/dist/src/loader/graph.js +13 -6
  25. package/dist/src/loader/graph.js.map +1 -1
  26. package/dist/src/loader/ts-utils.d.ts +1 -0
  27. package/dist/src/loader/ts-utils.d.ts.map +1 -1
  28. package/dist/src/loader/ts-utils.js +95 -16
  29. package/dist/src/loader/ts-utils.js.map +1 -1
  30. package/dist/src/model-to-narrative.specs.js +531 -449
  31. package/dist/src/model-to-narrative.specs.js.map +1 -1
  32. package/dist/src/narrative-context.d.ts +8 -8
  33. package/dist/src/narrative-context.d.ts.map +1 -1
  34. package/dist/src/narrative-context.js +111 -301
  35. package/dist/src/narrative-context.js.map +1 -1
  36. package/dist/src/narrative-context.specs.js +15 -55
  37. package/dist/src/narrative-context.specs.js.map +1 -1
  38. package/dist/src/narrative.d.ts +19 -22
  39. package/dist/src/narrative.d.ts.map +1 -1
  40. package/dist/src/narrative.js +42 -71
  41. package/dist/src/narrative.js.map +1 -1
  42. package/dist/src/samples/test-with-ids.narrative.js +13 -29
  43. package/dist/src/samples/test-with-ids.narrative.js.map +1 -1
  44. package/dist/src/schema.d.ts +3205 -8287
  45. package/dist/src/schema.d.ts.map +1 -1
  46. package/dist/src/schema.js +29 -47
  47. package/dist/src/schema.js.map +1 -1
  48. package/dist/src/slice-builder.js +3 -3
  49. package/dist/src/slice-builder.js.map +1 -1
  50. package/dist/src/transformers/model-to-narrative/generators/flow.d.ts.map +1 -1
  51. package/dist/src/transformers/model-to-narrative/generators/flow.js +118 -74
  52. package/dist/src/transformers/model-to-narrative/generators/flow.js.map +1 -1
  53. package/dist/src/transformers/model-to-narrative/generators/gwt.d.ts +9 -1
  54. package/dist/src/transformers/model-to-narrative/generators/gwt.d.ts.map +1 -1
  55. package/dist/src/transformers/model-to-narrative/generators/gwt.js +112 -112
  56. package/dist/src/transformers/model-to-narrative/generators/gwt.js.map +1 -1
  57. package/dist/src/transformers/model-to-narrative/generators/imports.d.ts +1 -1
  58. package/dist/src/transformers/model-to-narrative/generators/imports.d.ts.map +1 -1
  59. package/dist/src/transformers/model-to-narrative/generators/imports.js +13 -9
  60. package/dist/src/transformers/model-to-narrative/generators/imports.js.map +1 -1
  61. package/dist/src/transformers/narrative-to-model/index.d.ts.map +1 -1
  62. package/dist/src/transformers/narrative-to-model/index.js +50 -23
  63. package/dist/src/transformers/narrative-to-model/index.js.map +1 -1
  64. package/dist/src/transformers/narrative-to-model/type-inference.specs.js +100 -90
  65. package/dist/src/transformers/narrative-to-model/type-inference.specs.js.map +1 -1
  66. package/dist/tsconfig.tsbuildinfo +1 -1
  67. package/package.json +5 -5
  68. package/src/commands/export-schema-runner.ts +3 -1
  69. package/src/fluent-builder.ts +3 -3
  70. package/src/getNarratives.specs.ts +168 -176
  71. package/src/id/addAutoIds.specs.ts +424 -47
  72. package/src/id/addAutoIds.ts +57 -13
  73. package/src/id/hasAllIds.specs.ts +400 -223
  74. package/src/id/hasAllIds.ts +32 -6
  75. package/src/index.ts +9 -12
  76. package/src/loader/graph.ts +23 -6
  77. package/src/loader/ts-utils.ts +169 -26
  78. package/src/model-to-narrative.specs.ts +531 -449
  79. package/src/narrative-context.specs.ts +73 -116
  80. package/src/narrative-context.ts +127 -374
  81. package/src/narrative.ts +70 -120
  82. package/src/samples/test-with-ids.narrative.ts +23 -31
  83. package/src/schema.ts +36 -52
  84. package/src/slice-builder.ts +3 -3
  85. package/src/transformers/model-to-narrative/generators/flow.ts +191 -85
  86. package/src/transformers/model-to-narrative/generators/gwt.ts +195 -178
  87. package/src/transformers/model-to-narrative/generators/imports.ts +13 -9
  88. package/src/transformers/narrative-to-model/index.ts +87 -26
  89. package/src/transformers/narrative-to-model/type-inference.specs.ts +100 -90
@@ -1,267 +1,444 @@
1
- import { describe, expect, it, beforeEach } from 'vitest';
1
+ import { describe, expect, it } from 'vitest';
2
2
  import { hasAllIds, addAutoIds } from './index';
3
- import { getNarratives } from '../getNarratives';
4
- import { InMemoryFileStore, type IFileStore } from '@auto-engineer/file-store';
5
- import * as flowApi from '../narrative';
6
- import * as fluent from '../fluent-builder';
7
- import * as dataBuilders from '../data-narrative-builders';
8
- import * as typesApi from '../types';
9
- import gql from 'graphql-tag';
10
-
11
- const importMap = {
12
- '../flow': flowApi,
13
- '../fluent-builder': fluent,
14
- '../data-flow-builders': dataBuilders,
15
- '../types': typesApi,
16
- 'graphql-tag': gql,
17
- };
3
+ import type { Model } from '../index';
18
4
 
19
5
  describe('hasAllIds', () => {
20
- let vfs: IFileStore;
21
- const root = '/test';
22
-
23
- beforeEach(async () => {
24
- vfs = new InMemoryFileStore();
25
-
26
- const flowWithoutIds = `
27
- import { flow, specs, rule, example } from '../narrative';
28
- import { command } from '../fluent-builder';
29
-
30
- flow('Test Flow Without IDs', () => {
31
- command('Test slice without ID')
32
- .server(() => {
33
- specs('Test specs', () => {
34
- rule('Test rule without ID', () => {
35
- example('Test example')
36
- .when({ test: 'data' })
37
- .then({ result: 'success' });
38
- });
39
- });
40
- });
41
- });`;
42
-
43
- const flowWithIds = `
44
- import { flow, specs, rule, example } from '../narrative';
45
- import { command } from '../fluent-builder';
46
-
47
- flow('Test Flow with IDs', 'FLOW-001', () => {
48
- command('Test slice with ID', 'SLICE-001')
49
- .server(() => {
50
- specs('Test specs', () => {
51
- rule('Test rule with ID', 'RULE-001', () => {
52
- example('Test example')
53
- .when({ test: 'data' })
54
- .then({ result: 'success' });
55
- });
56
- });
57
- });
58
- });`;
59
-
60
- const multipleFlowsSameSource = `
61
- import { flow, specs, it } from '../narrative';
62
- import { experience } from '../fluent-builder';
63
-
64
- flow('Home Screen', 'aifPcU3hw', () => {
65
- experience('Active Surveys Summary', 'slice1').client(() => {
66
- specs(() => {
67
- it('show active surveys summary');
68
- });
6
+ const createModelWithoutIds = (): Model => ({
7
+ variant: 'specs',
8
+ narratives: [
9
+ {
10
+ name: 'Test Flow Without IDs',
11
+ slices: [
12
+ {
13
+ type: 'command',
14
+ name: 'Test slice without ID',
15
+ client: { specs: [] },
16
+ server: {
17
+ description: 'Test server',
18
+ specs: [
19
+ {
20
+ type: 'gherkin',
21
+ feature: 'Test specs',
22
+ rules: [
23
+ {
24
+ name: 'Test rule without ID',
25
+ examples: [],
26
+ },
27
+ ],
28
+ },
29
+ ],
30
+ },
31
+ },
32
+ ],
33
+ },
34
+ ],
35
+ messages: [],
36
+ integrations: [],
69
37
  });
70
- });
71
38
 
72
- flow('Create Survey', 'MPviTMrQC', () => {
73
- experience('Create Survey Form', 'slice2').client(() => {
74
- specs(() => {
75
- it('allow entering survey title');
76
- });
39
+ const createModelWithIds = (): Model => ({
40
+ variant: 'specs',
41
+ narratives: [
42
+ {
43
+ name: 'Test Flow with IDs',
44
+ id: 'FLOW-001',
45
+ slices: [
46
+ {
47
+ type: 'command',
48
+ name: 'Test slice with ID',
49
+ id: 'SLICE-001',
50
+ client: { specs: [] },
51
+ server: {
52
+ description: 'Test server',
53
+ specs: [
54
+ {
55
+ id: 'SPEC-001',
56
+ type: 'gherkin',
57
+ feature: 'Test specs',
58
+ rules: [
59
+ {
60
+ id: 'RULE-001',
61
+ name: 'Test rule with ID',
62
+ examples: [],
63
+ },
64
+ ],
65
+ },
66
+ ],
67
+ },
68
+ },
69
+ ],
70
+ },
71
+ ],
72
+ messages: [],
73
+ integrations: [],
77
74
  });
78
- });
79
75
 
80
- flow('Response Analytics', 'eME978Euk', () => {
81
- experience('Response Rate Charts', 'slice3').client(() => {
82
- specs(() => {
83
- it('show daily response rate charts');
84
- });
76
+ const createModelWithFullIds = (): Model => ({
77
+ variant: 'specs',
78
+ narratives: [
79
+ {
80
+ name: 'Test Flow with Full IDs',
81
+ id: 'FLOW-001',
82
+ slices: [
83
+ {
84
+ type: 'command',
85
+ name: 'Test slice with ID',
86
+ id: 'SLICE-001',
87
+ client: { specs: [] },
88
+ server: {
89
+ description: 'Test server',
90
+ specs: [
91
+ {
92
+ id: 'SPEC-001',
93
+ type: 'gherkin',
94
+ feature: 'Test specs',
95
+ rules: [
96
+ {
97
+ id: 'RULE-001',
98
+ name: 'Test rule with ID',
99
+ examples: [
100
+ {
101
+ id: 'EXAMPLE-001',
102
+ name: 'Test example',
103
+ steps: [
104
+ {
105
+ id: 'STEP-001',
106
+ keyword: 'Given',
107
+ text: 'TestState',
108
+ docString: { value: 'test' },
109
+ },
110
+ {
111
+ id: 'STEP-002',
112
+ keyword: 'When',
113
+ text: 'TestCommand',
114
+ },
115
+ {
116
+ id: 'STEP-003',
117
+ keyword: 'Then',
118
+ text: 'TestEvent',
119
+ },
120
+ ],
121
+ },
122
+ ],
123
+ },
124
+ ],
125
+ },
126
+ ],
127
+ },
128
+ },
129
+ ],
130
+ },
131
+ ],
132
+ messages: [],
133
+ integrations: [],
85
134
  });
86
- });`;
87
-
88
- const multipleFlowsIncomplete = `
89
- import { flow, specs, it } from '../narrative';
90
- import { experience } from '../fluent-builder';
91
135
 
92
- flow('Home Screen', 'aifPcU3hw', () => {
93
- experience('Active Surveys Summary', 'slice1').client(() => {
94
- specs(() => {
95
- it('show active surveys summary');
96
- });
136
+ const createMultipleFlowsModel = (includeAllIds: boolean, includeAllSliceIds: boolean): Model => ({
137
+ variant: 'specs',
138
+ narratives: [
139
+ {
140
+ name: 'Home Screen',
141
+ id: 'aifPcU3hw',
142
+ sourceFile: '/path/to/homepage.narrative.ts',
143
+ slices: [
144
+ {
145
+ name: 'Active Surveys Summary',
146
+ id: 'slice1',
147
+ type: 'experience',
148
+ client: { specs: [{ type: 'it', id: 'it1', title: 'show active surveys summary' }] },
149
+ },
150
+ ],
151
+ },
152
+ {
153
+ name: 'Create Survey',
154
+ id: includeAllIds ? 'MPviTMrQC' : undefined,
155
+ sourceFile: '/path/to/homepage.narrative.ts',
156
+ slices: [
157
+ {
158
+ name: 'Create Survey Form',
159
+ id: includeAllSliceIds ? 'slice2' : undefined,
160
+ type: 'experience',
161
+ client: { specs: [{ type: 'it', id: 'it2', title: 'allow entering survey title' }] },
162
+ },
163
+ ],
164
+ },
165
+ {
166
+ name: 'Response Analytics',
167
+ id: 'eME978Euk',
168
+ sourceFile: '/path/to/homepage.narrative.ts',
169
+ slices: [
170
+ {
171
+ name: 'Response Rate Charts',
172
+ id: 'slice3',
173
+ type: 'experience',
174
+ client: { specs: [{ type: 'it', id: 'it3', title: 'show daily response rate charts' }] },
175
+ },
176
+ ],
177
+ },
178
+ ],
179
+ messages: [],
180
+ integrations: [],
97
181
  });
98
- });
99
182
 
100
- flow('Create Survey', () => {
101
- experience('Create Survey Form', 'slice2').client(() => {
102
- specs(() => {
103
- it('allow entering survey title');
104
- });
183
+ it('should return false for models without IDs', () => {
184
+ const model = createModelWithoutIds();
185
+ expect(hasAllIds(model)).toBe(false);
105
186
  });
106
- });
107
187
 
108
- flow('Response Analytics', 'eME978Euk', () => {
109
- experience('Response Rate Charts', 'slice3').client(() => {
110
- specs(() => {
111
- it('show daily response rate charts');
112
- });
188
+ it('should return true for models with complete IDs', () => {
189
+ const model = createModelWithoutIds();
190
+ const modelWithIds = addAutoIds(model);
191
+ expect(hasAllIds(modelWithIds)).toBe(true);
113
192
  });
114
- });`;
115
193
 
116
- const multipleFlowsSliceMissing = `
117
- import { flow, specs, it } from '../narrative';
118
- import { experience } from '../fluent-builder';
119
-
120
- flow('Home Screen', 'aifPcU3hw', () => {
121
- experience('Active Surveys Summary', 'slice1').client(() => {
122
- specs(() => {
123
- it('show active surveys summary');
124
- });
194
+ it('should return true for flows that already have IDs', () => {
195
+ const model = createModelWithIds();
196
+ expect(hasAllIds(model)).toBe(true);
125
197
  });
126
- });
127
198
 
128
- flow('Create Survey', 'MPviTMrQC', () => {
129
- experience('Create Survey Form').client(() => {
130
- specs(() => {
131
- it('allow entering survey title');
132
- });
199
+ it('should return false if any slice is missing an ID', () => {
200
+ const model = createModelWithIds();
201
+ const modifiedModel = structuredClone(model);
202
+ modifiedModel.narratives[0].slices[0].id = '';
203
+ expect(hasAllIds(modifiedModel)).toBe(false);
133
204
  });
134
- });
135
205
 
136
- flow('Response Analytics', 'eME978Euk', () => {
137
- experience('Response Rate Charts', 'slice3').client(() => {
138
- specs(() => {
139
- it('show daily response rate charts');
140
- });
206
+ it('should return false if any rule is missing an ID', () => {
207
+ const model = createModelWithIds();
208
+ const modifiedModel = structuredClone(model);
209
+ const slice = modifiedModel.narratives[0].slices[0];
210
+ if ('server' in slice && slice.server?.specs !== undefined && Array.isArray(slice.server.specs)) {
211
+ slice.server.specs[0].rules[0].id = '';
212
+ }
213
+ expect(hasAllIds(modifiedModel)).toBe(false);
141
214
  });
142
- });`;
143
215
 
144
- const flowContent1 = new TextEncoder().encode(flowWithoutIds);
145
- const flowContent2 = new TextEncoder().encode(flowWithIds);
146
- const flowContent3 = new TextEncoder().encode(multipleFlowsSameSource);
147
- const flowContent4 = new TextEncoder().encode(multipleFlowsIncomplete);
148
- const flowContent5 = new TextEncoder().encode(multipleFlowsSliceMissing);
149
- await vfs.write('/test/flow-without-ids.narrative.ts', flowContent1);
150
- await vfs.write('/test/flow-with-ids.narrative.ts', flowContent2);
151
- await vfs.write('/test/homepage.narrative.ts', flowContent3);
152
- await vfs.write('/test/homepage-incomplete.narrative.ts', flowContent4);
153
- await vfs.write('/test/homepage-slice-missing.narrative.ts', flowContent5);
216
+ it('should return true when multiple flows with same sourceFile all have IDs', () => {
217
+ const model = createMultipleFlowsModel(true, true);
218
+ expect(hasAllIds(model)).toBe(true);
154
219
  });
155
- it('should return false for models without IDs', async () => {
156
- const result = await getNarratives({ vfs, root, pattern: /\.(narrative)\.(ts)$/, fastFsScan: true, importMap });
157
- const model = result.toModel();
158
-
159
- const flowWithoutIds = model.narratives.find((f) => f.name === 'Test Flow Without IDs');
160
- expect(flowWithoutIds).toBeDefined();
161
220
 
162
- if (flowWithoutIds) {
163
- const modelWithoutIds = { ...model, narratives: [flowWithoutIds] };
164
- expect(hasAllIds(modelWithoutIds)).toBe(false);
165
- }
221
+ it('should return false when any flow in multiple flows with same sourceFile is missing ID', () => {
222
+ const model = createMultipleFlowsModel(false, true);
223
+ expect(hasAllIds(model)).toBe(false);
166
224
  });
167
225
 
168
- it('should return true for models with complete IDs', async () => {
169
- const result = await getNarratives({ vfs, root, pattern: /\.(narrative)\.(ts)$/, fastFsScan: true, importMap });
170
- const model = result.toModel();
171
-
172
- const modelWithIds = addAutoIds(model);
173
- expect(hasAllIds(modelWithIds)).toBe(true);
226
+ it('should return false when any slice in multiple flows with same sourceFile is missing ID', () => {
227
+ const model = createMultipleFlowsModel(true, false);
228
+ expect(hasAllIds(model)).toBe(false);
174
229
  });
175
230
 
176
- it('should return true for flows that already have IDs', async () => {
177
- const result = await getNarratives({ vfs, root, pattern: /\.(narrative)\.(ts)$/, fastFsScan: true, importMap });
178
- const model = result.toModel();
179
-
180
- const testFlowWithIds = model.narratives.find((f) => f.name === 'Test Flow with IDs');
181
- expect(testFlowWithIds).toBeDefined();
182
-
183
- if (testFlowWithIds) {
184
- const modelWithExistingIds = { ...model, narratives: [testFlowWithIds] };
185
- expect(hasAllIds(modelWithExistingIds)).toBe(true);
231
+ it('should return false if any spec is missing an ID', () => {
232
+ const model = createModelWithFullIds();
233
+ const modifiedModel = structuredClone(model);
234
+ const slice = modifiedModel.narratives[0].slices[0];
235
+ if ('server' in slice && slice.server?.specs !== undefined && Array.isArray(slice.server.specs)) {
236
+ slice.server.specs[0].id = '';
186
237
  }
238
+ expect(hasAllIds(modifiedModel)).toBe(false);
187
239
  });
188
240
 
189
- it('should return false if any slice is missing an ID', async () => {
190
- const result = await getNarratives({ vfs, root, pattern: /\.(narrative)\.(ts)$/, fastFsScan: true, importMap });
191
- const model = result.toModel();
192
-
193
- const modelWithIds = addAutoIds(model);
194
- expect(modelWithIds.narratives.length).toBeGreaterThan(0);
195
- expect(modelWithIds.narratives[0].slices.length).toBeGreaterThan(0);
196
-
197
- const modifiedModel = structuredClone(modelWithIds);
198
- modifiedModel.narratives[0].slices[0].id = '';
241
+ it('should return false if any example is missing an ID', () => {
242
+ const model = createModelWithFullIds();
243
+ const modifiedModel = structuredClone(model);
244
+ const slice = modifiedModel.narratives[0].slices[0];
245
+ if ('server' in slice && slice.server?.specs !== undefined && Array.isArray(slice.server.specs)) {
246
+ slice.server.specs[0].rules[0].examples[0].id = '';
247
+ }
199
248
  expect(hasAllIds(modifiedModel)).toBe(false);
200
249
  });
201
250
 
202
- it('should return false if any rule is missing an ID', async () => {
203
- const result = await getNarratives({ vfs, root, pattern: /\.(narrative)\.(ts)$/, fastFsScan: true, importMap });
204
- const model = result.toModel();
205
-
206
- const modelWithIds = addAutoIds(model);
207
-
208
- let found = false;
209
- for (const flow of modelWithIds.narratives) {
210
- for (const slice of flow.slices) {
211
- if ('server' in slice && slice.server?.specs?.rules !== undefined && slice.server.specs.rules.length > 0) {
212
- const modifiedModel = structuredClone(modelWithIds);
213
- const modifiedFlow = modifiedModel.narratives.find((f) => f.name === flow.name);
214
- const modifiedSlice = modifiedFlow?.slices.find((s) => s.name === slice.name);
215
- if (modifiedSlice && 'server' in modifiedSlice && modifiedSlice.server?.specs?.rules !== undefined) {
216
- modifiedSlice.server.specs.rules[0].id = '';
217
- expect(hasAllIds(modifiedModel)).toBe(false);
218
- found = true;
219
- break;
220
- }
221
- }
222
- }
223
- if (found) break;
251
+ it('should return false if any step is missing an ID', () => {
252
+ const model = createModelWithFullIds();
253
+ const modifiedModel = structuredClone(model);
254
+ const slice = modifiedModel.narratives[0].slices[0];
255
+ if ('server' in slice && slice.server?.specs !== undefined && Array.isArray(slice.server.specs)) {
256
+ slice.server.specs[0].rules[0].examples[0].steps[0].id = '';
224
257
  }
225
-
226
- expect(found).toBe(true);
258
+ expect(hasAllIds(modifiedModel)).toBe(false);
227
259
  });
228
260
 
229
- it('should return true when multiple flows with same sourceFile all have IDs', async () => {
230
- const result = await getNarratives({ vfs, root, pattern: /\.(narrative)\.(ts)$/, fastFsScan: true, importMap });
231
- const model = result.toModel();
232
-
233
- const homepageFlows = model.narratives.filter(
234
- (f) => f.sourceFile !== undefined && f.sourceFile.includes('homepage.narrative.ts'),
235
- );
236
- expect(homepageFlows.length).toBe(3);
237
-
238
- const homepageModel = { ...model, narratives: homepageFlows };
239
- expect(hasAllIds(homepageModel)).toBe(true);
261
+ it('should return false if step with error is missing an ID', () => {
262
+ const model: Model = {
263
+ variant: 'specs',
264
+ narratives: [
265
+ {
266
+ name: 'Test Flow',
267
+ id: 'FLOW-001',
268
+ slices: [
269
+ {
270
+ type: 'command',
271
+ name: 'Test slice',
272
+ id: 'SLICE-001',
273
+ client: { specs: [] },
274
+ server: {
275
+ description: 'Test server',
276
+ specs: [
277
+ {
278
+ id: 'SPEC-001',
279
+ type: 'gherkin',
280
+ feature: 'Test specs',
281
+ rules: [
282
+ {
283
+ id: 'RULE-001',
284
+ name: 'Test rule',
285
+ examples: [
286
+ {
287
+ id: 'EXAMPLE-001',
288
+ name: 'Error example',
289
+ steps: [
290
+ {
291
+ id: 'STEP-001',
292
+ keyword: 'Given',
293
+ text: 'TestState',
294
+ },
295
+ {
296
+ keyword: 'Then',
297
+ error: { type: 'ValidationError', message: 'Invalid input' },
298
+ },
299
+ ],
300
+ },
301
+ ],
302
+ },
303
+ ],
304
+ },
305
+ ],
306
+ },
307
+ },
308
+ ],
309
+ },
310
+ ],
311
+ messages: [],
312
+ integrations: [],
313
+ };
314
+ expect(hasAllIds(model)).toBe(false);
240
315
  });
241
316
 
242
- it('should return false when any flow in multiple flows with same sourceFile is missing ID', async () => {
243
- const result = await getNarratives({ vfs, root, pattern: /\.(narrative)\.(ts)$/, fastFsScan: true, importMap });
244
- const model = result.toModel();
245
-
246
- const homepageFlows = model.narratives.filter(
247
- (f) => f.sourceFile !== undefined && f.sourceFile.includes('homepage-incomplete.narrative.ts'),
248
- );
249
- expect(homepageFlows.length).toBe(3);
250
-
251
- const homepageModel = { ...model, narratives: homepageFlows };
252
- expect(hasAllIds(homepageModel)).toBe(false);
317
+ it('should return false if client it spec is missing an ID', () => {
318
+ const model: Model = {
319
+ variant: 'specs',
320
+ narratives: [
321
+ {
322
+ name: 'Test Flow',
323
+ id: 'FLOW-001',
324
+ slices: [
325
+ {
326
+ name: 'Test slice',
327
+ id: 'SLICE-001',
328
+ type: 'experience',
329
+ client: {
330
+ specs: [{ type: 'it', title: 'test without id' }],
331
+ },
332
+ },
333
+ ],
334
+ },
335
+ ],
336
+ messages: [],
337
+ integrations: [],
338
+ };
339
+ expect(hasAllIds(model)).toBe(false);
253
340
  });
254
341
 
255
- it('should return false when any slice in multiple flows with same sourceFile is missing ID', async () => {
256
- const result = await getNarratives({ vfs, root, pattern: /\.(narrative)\.(ts)$/, fastFsScan: true, importMap });
257
- const model = result.toModel();
342
+ it('should return false if client describe spec is missing an ID', () => {
343
+ const model: Model = {
344
+ variant: 'specs',
345
+ narratives: [
346
+ {
347
+ name: 'Test Flow',
348
+ id: 'FLOW-001',
349
+ slices: [
350
+ {
351
+ name: 'Test slice',
352
+ id: 'SLICE-001',
353
+ type: 'experience',
354
+ client: {
355
+ specs: [
356
+ {
357
+ type: 'describe',
358
+ title: 'test describe without id',
359
+ children: [{ type: 'it', id: 'IT-001', title: 'nested it with id' }],
360
+ },
361
+ ],
362
+ },
363
+ },
364
+ ],
365
+ },
366
+ ],
367
+ messages: [],
368
+ integrations: [],
369
+ };
370
+ expect(hasAllIds(model)).toBe(false);
371
+ });
258
372
 
259
- const homepageFlows = model.narratives.filter(
260
- (f) => f.sourceFile !== undefined && f.sourceFile.includes('homepage-slice-missing.narrative.ts'),
261
- );
262
- expect(homepageFlows.length).toBe(3);
373
+ it('should return false if nested client it spec is missing an ID', () => {
374
+ const model: Model = {
375
+ variant: 'specs',
376
+ narratives: [
377
+ {
378
+ name: 'Test Flow',
379
+ id: 'FLOW-001',
380
+ slices: [
381
+ {
382
+ name: 'Test slice',
383
+ id: 'SLICE-001',
384
+ type: 'experience',
385
+ client: {
386
+ specs: [
387
+ {
388
+ type: 'describe',
389
+ id: 'DESC-001',
390
+ title: 'test describe with id',
391
+ children: [{ type: 'it', title: 'nested it without id' }],
392
+ },
393
+ ],
394
+ },
395
+ },
396
+ ],
397
+ },
398
+ ],
399
+ messages: [],
400
+ integrations: [],
401
+ };
402
+ expect(hasAllIds(model)).toBe(false);
403
+ });
263
404
 
264
- const homepageModel = { ...model, narratives: homepageFlows };
265
- expect(hasAllIds(homepageModel)).toBe(false);
405
+ it('should return true for client specs with all IDs', () => {
406
+ const model: Model = {
407
+ variant: 'specs',
408
+ narratives: [
409
+ {
410
+ name: 'Test Flow',
411
+ id: 'FLOW-001',
412
+ slices: [
413
+ {
414
+ name: 'Test slice',
415
+ id: 'SLICE-001',
416
+ type: 'experience',
417
+ client: {
418
+ specs: [
419
+ {
420
+ type: 'describe',
421
+ id: 'DESC-001',
422
+ title: 'test describe',
423
+ children: [
424
+ { type: 'it', id: 'IT-001', title: 'first it' },
425
+ {
426
+ type: 'describe',
427
+ id: 'DESC-002',
428
+ title: 'nested describe',
429
+ children: [{ type: 'it', id: 'IT-002', title: 'nested it' }],
430
+ },
431
+ ],
432
+ },
433
+ ],
434
+ },
435
+ },
436
+ ],
437
+ },
438
+ ],
439
+ messages: [],
440
+ integrations: [],
441
+ };
442
+ expect(hasAllIds(model)).toBe(true);
266
443
  });
267
444
  });