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