@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.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +22 -0
- package/dist/src/commands/export-schema-runner.js +1 -1
- package/dist/src/commands/export-schema-runner.js.map +1 -1
- package/dist/src/fluent-builder.js +3 -3
- package/dist/src/fluent-builder.js.map +1 -1
- package/dist/src/getNarratives.specs.js +149 -153
- package/dist/src/getNarratives.specs.js.map +1 -1
- package/dist/src/id/addAutoIds.d.ts.map +1 -1
- package/dist/src/id/addAutoIds.js +50 -12
- package/dist/src/id/addAutoIds.js.map +1 -1
- package/dist/src/id/addAutoIds.specs.js +396 -45
- package/dist/src/id/addAutoIds.specs.js.map +1 -1
- package/dist/src/id/hasAllIds.d.ts.map +1 -1
- package/dist/src/id/hasAllIds.js +28 -5
- package/dist/src/id/hasAllIds.js.map +1 -1
- package/dist/src/id/hasAllIds.specs.js +407 -214
- package/dist/src/id/hasAllIds.specs.js.map +1 -1
- package/dist/src/index.d.ts +6 -8
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/loader/graph.d.ts.map +1 -1
- package/dist/src/loader/graph.js +13 -6
- package/dist/src/loader/graph.js.map +1 -1
- package/dist/src/loader/ts-utils.d.ts +1 -0
- package/dist/src/loader/ts-utils.d.ts.map +1 -1
- package/dist/src/loader/ts-utils.js +95 -16
- package/dist/src/loader/ts-utils.js.map +1 -1
- package/dist/src/model-to-narrative.specs.js +531 -449
- package/dist/src/model-to-narrative.specs.js.map +1 -1
- package/dist/src/narrative-context.d.ts +8 -8
- package/dist/src/narrative-context.d.ts.map +1 -1
- package/dist/src/narrative-context.js +111 -301
- package/dist/src/narrative-context.js.map +1 -1
- package/dist/src/narrative-context.specs.js +15 -55
- package/dist/src/narrative-context.specs.js.map +1 -1
- package/dist/src/narrative.d.ts +19 -22
- package/dist/src/narrative.d.ts.map +1 -1
- package/dist/src/narrative.js +42 -71
- package/dist/src/narrative.js.map +1 -1
- package/dist/src/samples/test-with-ids.narrative.js +13 -29
- package/dist/src/samples/test-with-ids.narrative.js.map +1 -1
- package/dist/src/schema.d.ts +3205 -8287
- package/dist/src/schema.d.ts.map +1 -1
- package/dist/src/schema.js +29 -47
- package/dist/src/schema.js.map +1 -1
- package/dist/src/slice-builder.js +3 -3
- package/dist/src/slice-builder.js.map +1 -1
- package/dist/src/transformers/model-to-narrative/generators/flow.d.ts.map +1 -1
- package/dist/src/transformers/model-to-narrative/generators/flow.js +118 -74
- package/dist/src/transformers/model-to-narrative/generators/flow.js.map +1 -1
- package/dist/src/transformers/model-to-narrative/generators/gwt.d.ts +9 -1
- package/dist/src/transformers/model-to-narrative/generators/gwt.d.ts.map +1 -1
- package/dist/src/transformers/model-to-narrative/generators/gwt.js +112 -112
- package/dist/src/transformers/model-to-narrative/generators/gwt.js.map +1 -1
- package/dist/src/transformers/model-to-narrative/generators/imports.d.ts +1 -1
- package/dist/src/transformers/model-to-narrative/generators/imports.d.ts.map +1 -1
- package/dist/src/transformers/model-to-narrative/generators/imports.js +13 -9
- package/dist/src/transformers/model-to-narrative/generators/imports.js.map +1 -1
- package/dist/src/transformers/narrative-to-model/index.d.ts.map +1 -1
- package/dist/src/transformers/narrative-to-model/index.js +50 -23
- package/dist/src/transformers/narrative-to-model/index.js.map +1 -1
- package/dist/src/transformers/narrative-to-model/type-inference.specs.js +100 -90
- package/dist/src/transformers/narrative-to-model/type-inference.specs.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/commands/export-schema-runner.ts +3 -1
- package/src/fluent-builder.ts +3 -3
- package/src/getNarratives.specs.ts +168 -176
- package/src/id/addAutoIds.specs.ts +424 -47
- package/src/id/addAutoIds.ts +57 -13
- package/src/id/hasAllIds.specs.ts +400 -223
- package/src/id/hasAllIds.ts +32 -6
- package/src/index.ts +9 -12
- package/src/loader/graph.ts +23 -6
- package/src/loader/ts-utils.ts +169 -26
- package/src/model-to-narrative.specs.ts +531 -449
- package/src/narrative-context.specs.ts +73 -116
- package/src/narrative-context.ts +127 -374
- package/src/narrative.ts +70 -120
- package/src/samples/test-with-ids.narrative.ts +23 -31
- package/src/schema.ts +36 -52
- package/src/slice-builder.ts +3 -3
- package/src/transformers/model-to-narrative/generators/flow.ts +191 -85
- package/src/transformers/model-to-narrative/generators/gwt.ts +195 -178
- package/src/transformers/model-to-narrative/generators/imports.ts +13 -9
- package/src/transformers/narrative-to-model/index.ts +87 -26
- package/src/transformers/narrative-to-model/type-inference.specs.ts +100 -90
|
@@ -1,231 +1,424 @@
|
|
|
1
|
-
import { describe, expect, it
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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',
|
|
157
|
-
const
|
|
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',
|
|
163
|
-
const
|
|
164
|
-
|
|
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',
|
|
173
|
-
const
|
|
174
|
-
const
|
|
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',
|
|
183
|
-
const
|
|
184
|
-
const
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
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(
|
|
205
|
-
});
|
|
206
|
-
it('should return true when multiple flows with same sourceFile all have IDs',
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const
|
|
212
|
-
expect(hasAllIds(
|
|
213
|
-
});
|
|
214
|
-
it('should return false when any
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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
|