@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,267 +1,444 @@
|
|
|
1
|
-
import { describe, expect, it
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
2
|
import { hasAllIds, addAutoIds } from './index';
|
|
3
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
50
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
-
|
|
145
|
-
const
|
|
146
|
-
|
|
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
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
|
169
|
-
const
|
|
170
|
-
|
|
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
|
|
177
|
-
const
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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
|
|
190
|
-
const
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
|
203
|
-
const
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
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
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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
|
|
256
|
-
const
|
|
257
|
-
|
|
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
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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
|
-
|
|
265
|
-
|
|
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
|
});
|