@cucumber/query 5.0.0 → 7.0.1
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/.eslintrc.json +3 -1
- package/.idea/aws.xml +11 -0
- package/.idea/javascript.iml +1 -4
- package/.idea/misc.xml +3 -0
- package/.idea/workspace.xml +36 -285
- package/default.mk +17 -0
- package/dist/src/Query.d.ts +14 -4
- package/dist/src/Query.js +68 -11
- package/dist/src/Query.js.map +1 -1
- package/dist/src/QueryStream.js +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/test/QueryTest.js +285 -56
- package/dist/test/QueryTest.js.map +1 -1
- package/package-lock.json +1281 -1296
- package/package.json +21 -19
- package/src/Query.ts +116 -22
- package/test/QueryTest.ts +334 -50
- package/tsconfig.json +1 -5
- package/.idea/codeStyles/Project.xml +0 -45
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/compiler.xml +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cucumber/query",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"description": "Cucumber Query - query messages",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -26,30 +26,32 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/cucumber/cucumber#readme",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@cucumber/fake-cucumber": "^
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"@
|
|
34
|
-
"eslint": "^
|
|
35
|
-
"eslint
|
|
29
|
+
"@cucumber/fake-cucumber": "^9.0.0",
|
|
30
|
+
"@cucumber/gherkin": "^16.0.0",
|
|
31
|
+
"@cucumber/gherkin-utils": "^2.1.1",
|
|
32
|
+
"@types/mocha": "^8.2.0",
|
|
33
|
+
"@types/node": "^14.14.14",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^4.10.0",
|
|
35
|
+
"@typescript-eslint/parser": "^4.10.0",
|
|
36
|
+
"core-js": "^3.8.1",
|
|
37
|
+
"eslint": "^7.15.0",
|
|
38
|
+
"eslint-config-prettier": "^7.0.0",
|
|
36
39
|
"eslint-plugin-node": "^11.1.0",
|
|
37
|
-
"eslint-plugin-prettier": "^3.
|
|
38
|
-
"eslint-plugin-react": "^7.
|
|
39
|
-
"mocha": "^
|
|
40
|
-
"nyc": "^15.
|
|
41
|
-
"prettier": "^2.
|
|
42
|
-
"source-map-support": "^0.5.
|
|
43
|
-
"ts-loader": "^
|
|
44
|
-
"ts-node": "^
|
|
45
|
-
"typescript": "^
|
|
40
|
+
"eslint-plugin-prettier": "^3.3.0",
|
|
41
|
+
"eslint-plugin-react": "^7.21.5",
|
|
42
|
+
"mocha": "^8.2.1",
|
|
43
|
+
"nyc": "^15.1.0",
|
|
44
|
+
"prettier": "^2.2.1",
|
|
45
|
+
"source-map-support": "^0.5.19",
|
|
46
|
+
"ts-loader": "^8.0.12",
|
|
47
|
+
"ts-node": "^9.1.1",
|
|
48
|
+
"typescript": "^4.1.3"
|
|
46
49
|
},
|
|
47
50
|
"files": [
|
|
48
51
|
"*"
|
|
49
52
|
],
|
|
50
53
|
"dependencies": {
|
|
51
|
-
"@cucumber/
|
|
52
|
-
"@cucumber/messages": "^11.1.1",
|
|
54
|
+
"@cucumber/messages": "^13.2.1",
|
|
53
55
|
"@teppeis/multimaps": "^1.1.0"
|
|
54
56
|
},
|
|
55
57
|
"directories": {
|
package/src/Query.ts
CHANGED
|
@@ -4,17 +4,27 @@ import { ArrayMultimap } from '@teppeis/multimaps'
|
|
|
4
4
|
export default class Query {
|
|
5
5
|
private readonly testStepResultByPickleId = new ArrayMultimap<
|
|
6
6
|
string,
|
|
7
|
-
messages.ITestStepResult
|
|
7
|
+
messages.TestStepFinished.ITestStepResult
|
|
8
8
|
>()
|
|
9
9
|
private readonly testStepResultsByPickleStepId = new ArrayMultimap<
|
|
10
10
|
string,
|
|
11
|
-
messages.ITestStepResult
|
|
11
|
+
messages.TestStepFinished.ITestStepResult
|
|
12
12
|
>()
|
|
13
13
|
private readonly testStepById = new Map<string, messages.TestCase.ITestStep>()
|
|
14
|
+
private readonly testCaseByPickleId = new Map<string, messages.ITestCase>()
|
|
14
15
|
private readonly pickleIdByTestStepId = new Map<string, string>()
|
|
15
16
|
private readonly pickleStepIdByTestStepId = new Map<string, string>()
|
|
17
|
+
private readonly testStepResultsbyTestStepId = new ArrayMultimap<
|
|
18
|
+
string,
|
|
19
|
+
messages.TestStepFinished.ITestStepResult
|
|
20
|
+
>()
|
|
21
|
+
private readonly testStepIdsByPickleStepId = new ArrayMultimap<
|
|
22
|
+
string,
|
|
23
|
+
string
|
|
24
|
+
>()
|
|
25
|
+
private readonly hooksById = new Map<string, messages.IHook>()
|
|
16
26
|
|
|
17
|
-
private readonly
|
|
27
|
+
private readonly attachmentsByTestStepId = new ArrayMultimap<
|
|
18
28
|
string,
|
|
19
29
|
messages.IAttachment
|
|
20
30
|
>()
|
|
@@ -26,10 +36,12 @@ export default class Query {
|
|
|
26
36
|
|
|
27
37
|
public update(envelope: messages.IEnvelope) {
|
|
28
38
|
if (envelope.testCase) {
|
|
39
|
+
this.testCaseByPickleId.set(envelope.testCase.pickleId, envelope.testCase)
|
|
29
40
|
for (const testStep of envelope.testCase.testSteps) {
|
|
30
41
|
this.testStepById.set(testStep.id, testStep)
|
|
31
42
|
this.pickleIdByTestStepId.set(testStep.id, envelope.testCase.pickleId)
|
|
32
43
|
this.pickleStepIdByTestStepId.set(testStep.id, testStep.pickleStepId)
|
|
44
|
+
this.testStepIdsByPickleStepId.put(testStep.pickleStepId, testStep.id)
|
|
33
45
|
this.stepMatchArgumentsListsByPickleStepId.set(
|
|
34
46
|
testStep.pickleStepId,
|
|
35
47
|
testStep.stepMatchArgumentsLists
|
|
@@ -53,13 +65,21 @@ export default class Query {
|
|
|
53
65
|
testStep.pickleStepId,
|
|
54
66
|
envelope.testStepFinished.testStepResult
|
|
55
67
|
)
|
|
68
|
+
this.testStepResultsbyTestStepId.put(
|
|
69
|
+
testStep.id,
|
|
70
|
+
envelope.testStepFinished.testStepResult
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (envelope.hook) {
|
|
75
|
+
this.hooksById.set(envelope.hook.id, envelope.hook)
|
|
56
76
|
}
|
|
57
77
|
|
|
58
78
|
if (envelope.attachment) {
|
|
59
|
-
|
|
60
|
-
envelope.attachment.testStepId
|
|
79
|
+
this.attachmentsByTestStepId.put(
|
|
80
|
+
envelope.attachment.testStepId,
|
|
81
|
+
envelope.attachment
|
|
61
82
|
)
|
|
62
|
-
this.attachmentsByPickleStepId.put(pickleStepId, envelope.attachment)
|
|
63
83
|
}
|
|
64
84
|
}
|
|
65
85
|
|
|
@@ -69,17 +89,20 @@ export default class Query {
|
|
|
69
89
|
*/
|
|
70
90
|
public getPickleStepTestStepResults(
|
|
71
91
|
pickleStepIds: ReadonlyArray<string>
|
|
72
|
-
): ReadonlyArray<messages.ITestStepResult> {
|
|
92
|
+
): ReadonlyArray<messages.TestStepFinished.ITestStepResult> {
|
|
73
93
|
if (pickleStepIds.length === 0) {
|
|
74
94
|
return [
|
|
75
|
-
new messages.TestStepResult({
|
|
76
|
-
status: messages.TestStepResult.Status.UNKNOWN,
|
|
95
|
+
new messages.TestStepFinished.TestStepResult({
|
|
96
|
+
status: messages.TestStepFinished.TestStepResult.Status.UNKNOWN,
|
|
77
97
|
duration: TimeConversion.millisecondsToDuration(0),
|
|
78
98
|
}),
|
|
79
99
|
]
|
|
80
100
|
}
|
|
81
101
|
return pickleStepIds.reduce(
|
|
82
|
-
(
|
|
102
|
+
(
|
|
103
|
+
testStepResults: messages.TestStepFinished.ITestStepResult[],
|
|
104
|
+
pickleId
|
|
105
|
+
) => {
|
|
83
106
|
return testStepResults.concat(
|
|
84
107
|
this.testStepResultsByPickleStepId.get(pickleId)
|
|
85
108
|
)
|
|
@@ -94,17 +117,20 @@ export default class Query {
|
|
|
94
117
|
*/
|
|
95
118
|
public getPickleTestStepResults(
|
|
96
119
|
pickleIds: ReadonlyArray<string>
|
|
97
|
-
): ReadonlyArray<messages.ITestStepResult> {
|
|
120
|
+
): ReadonlyArray<messages.TestStepFinished.ITestStepResult> {
|
|
98
121
|
if (pickleIds.length === 0) {
|
|
99
122
|
return [
|
|
100
|
-
new messages.TestStepResult({
|
|
101
|
-
status: messages.TestStepResult.Status.UNKNOWN,
|
|
123
|
+
new messages.TestStepFinished.TestStepResult({
|
|
124
|
+
status: messages.TestStepFinished.TestStepResult.Status.UNKNOWN,
|
|
102
125
|
duration: TimeConversion.millisecondsToDuration(0),
|
|
103
126
|
}),
|
|
104
127
|
]
|
|
105
128
|
}
|
|
106
129
|
return pickleIds.reduce(
|
|
107
|
-
(
|
|
130
|
+
(
|
|
131
|
+
testStepResults: messages.TestStepFinished.ITestStepResult[],
|
|
132
|
+
pickleId
|
|
133
|
+
) => {
|
|
108
134
|
return testStepResults.concat(
|
|
109
135
|
this.testStepResultByPickleId.get(pickleId)
|
|
110
136
|
)
|
|
@@ -118,12 +144,12 @@ export default class Query {
|
|
|
118
144
|
* @param testStepResults
|
|
119
145
|
*/
|
|
120
146
|
public getWorstTestStepResult(
|
|
121
|
-
testStepResults: ReadonlyArray<messages.ITestStepResult>
|
|
122
|
-
): messages.ITestStepResult {
|
|
147
|
+
testStepResults: ReadonlyArray<messages.TestStepFinished.ITestStepResult>
|
|
148
|
+
): messages.TestStepFinished.ITestStepResult {
|
|
123
149
|
return (
|
|
124
150
|
testStepResults.slice().sort((r1, r2) => r2.status - r1.status)[0] ||
|
|
125
|
-
new messages.TestStepResult({
|
|
126
|
-
status: messages.TestStepResult.Status.UNKNOWN,
|
|
151
|
+
new messages.TestStepFinished.TestStepResult({
|
|
152
|
+
status: messages.TestStepFinished.TestStepResult.Status.UNKNOWN,
|
|
127
153
|
duration: TimeConversion.millisecondsToDuration(0),
|
|
128
154
|
})
|
|
129
155
|
)
|
|
@@ -136,11 +162,21 @@ export default class Query {
|
|
|
136
162
|
public getPickleStepAttachments(
|
|
137
163
|
pickleStepIds: ReadonlyArray<string>
|
|
138
164
|
): ReadonlyArray<messages.IAttachment> {
|
|
139
|
-
return
|
|
140
|
-
(
|
|
141
|
-
return
|
|
142
|
-
this.
|
|
165
|
+
return this.getTestStepsAttachments(
|
|
166
|
+
pickleStepIds.reduce((testStepIds: string[], pickleStepId: string) => {
|
|
167
|
+
return testStepIds.concat(
|
|
168
|
+
this.testStepIdsByPickleStepId.get(pickleStepId)
|
|
143
169
|
)
|
|
170
|
+
}, [])
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
public getTestStepsAttachments(
|
|
175
|
+
testStepIds: ReadonlyArray<string>
|
|
176
|
+
): ReadonlyArray<messages.IAttachment> {
|
|
177
|
+
return testStepIds.reduce(
|
|
178
|
+
(attachments: messages.IAttachment[], testStepId) => {
|
|
179
|
+
return attachments.concat(this.attachmentsByTestStepId.get(testStepId))
|
|
144
180
|
},
|
|
145
181
|
[]
|
|
146
182
|
)
|
|
@@ -157,4 +193,62 @@ export default class Query {
|
|
|
157
193
|
| undefined {
|
|
158
194
|
return this.stepMatchArgumentsListsByPickleStepId.get(pickleStepId)
|
|
159
195
|
}
|
|
196
|
+
|
|
197
|
+
public getHook(hookId: string): messages.IHook {
|
|
198
|
+
return this.hooksById.get(hookId)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
public getBeforeHookSteps(
|
|
202
|
+
pickleId: string
|
|
203
|
+
): ReadonlyArray<messages.TestCase.ITestStep> {
|
|
204
|
+
const hookSteps: messages.TestCase.ITestStep[] = []
|
|
205
|
+
|
|
206
|
+
this.identifyHookSteps(
|
|
207
|
+
pickleId,
|
|
208
|
+
(hook) => hookSteps.push(hook),
|
|
209
|
+
() => null
|
|
210
|
+
)
|
|
211
|
+
return hookSteps
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
public getAfterHookSteps(
|
|
215
|
+
pickleId: string
|
|
216
|
+
): ReadonlyArray<messages.TestCase.ITestStep> {
|
|
217
|
+
const hookSteps: messages.TestCase.ITestStep[] = []
|
|
218
|
+
|
|
219
|
+
this.identifyHookSteps(
|
|
220
|
+
pickleId,
|
|
221
|
+
() => null,
|
|
222
|
+
(hook) => hookSteps.push(hook)
|
|
223
|
+
)
|
|
224
|
+
return hookSteps
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
private identifyHookSteps(
|
|
228
|
+
pickleId: string,
|
|
229
|
+
onBeforeHookFound: (hook: messages.TestCase.ITestStep) => void,
|
|
230
|
+
onAfterHookFound: (hook: messages.TestCase.ITestStep) => void
|
|
231
|
+
): void {
|
|
232
|
+
const testCase = this.testCaseByPickleId.get(pickleId)
|
|
233
|
+
|
|
234
|
+
if (!testCase) {
|
|
235
|
+
return
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
let pickleStepFound = false
|
|
239
|
+
|
|
240
|
+
for (const step of testCase.testSteps) {
|
|
241
|
+
if (step.hookId) {
|
|
242
|
+
pickleStepFound ? onAfterHookFound(step) : onBeforeHookFound(step)
|
|
243
|
+
} else {
|
|
244
|
+
pickleStepFound = true
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
public getTestStepResults(
|
|
250
|
+
testStepId: string
|
|
251
|
+
): messages.TestStepFinished.ITestStepResult[] {
|
|
252
|
+
return this.testStepResultsbyTestStepId.get(testStepId)
|
|
253
|
+
}
|
|
160
254
|
}
|