@cucumber/query 12.2.0 → 13.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/dist/src/Lineage.d.ts +30 -0
- package/dist/src/Lineage.d.ts.map +1 -0
- package/dist/src/Lineage.js +78 -0
- package/dist/src/Lineage.js.map +1 -0
- package/dist/src/Query.d.ts +46 -2
- package/dist/src/Query.d.ts.map +1 -1
- package/dist/src/Query.js +258 -32
- package/dist/src/Query.js.map +1 -1
- package/dist/src/helpers.d.ts +9 -0
- package/dist/src/helpers.d.ts.map +1 -0
- package/dist/src/helpers.js +39 -0
- package/dist/src/helpers.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +15 -0
- package/dist/src/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +28 -20
- package/src/Lineage.ts +110 -0
- package/{test/QueryTest.ts → src/Query.spec.ts} +1 -1
- package/src/Query.ts +348 -42
- package/src/acceptance.spec.ts +164 -0
- package/src/helpers.spec.ts +15 -0
- package/src/helpers.ts +41 -0
- package/src/index.ts +2 -0
- package/tsconfig.build.json +6 -1
- package/dist/package.json +0 -69
- package/dist/test/QueryTest.d.ts +0 -2
- package/dist/test/QueryTest.d.ts.map +0 -1
- package/dist/test/QueryTest.js +0 -447
- package/dist/test/QueryTest.js.map +0 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Examples, Feature, GherkinDocument, Pickle, Rule, Scenario, TableRow } from '@cucumber/messages';
|
|
2
|
+
export interface Lineage {
|
|
3
|
+
gherkinDocument?: GherkinDocument;
|
|
4
|
+
feature?: Feature;
|
|
5
|
+
rule?: Rule;
|
|
6
|
+
scenario?: Scenario;
|
|
7
|
+
examples?: Examples;
|
|
8
|
+
examplesIndex?: number;
|
|
9
|
+
example?: TableRow;
|
|
10
|
+
exampleIndex?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface LineageReducer<T> {
|
|
13
|
+
reduce: (lineage: Lineage, pickle: Pickle) => T;
|
|
14
|
+
}
|
|
15
|
+
export type NamingStrategy = LineageReducer<string>;
|
|
16
|
+
export declare enum NamingStrategyLength {
|
|
17
|
+
LONG = "LONG",
|
|
18
|
+
SHORT = "SHORT"
|
|
19
|
+
}
|
|
20
|
+
export declare enum NamingStrategyFeatureName {
|
|
21
|
+
INCLUDE = "INCLUDE",
|
|
22
|
+
EXCLUDE = "EXCLUDE"
|
|
23
|
+
}
|
|
24
|
+
export declare enum NamingStrategyExampleName {
|
|
25
|
+
NUMBER = "NUMBER",
|
|
26
|
+
PICKLE = "PICKLE",
|
|
27
|
+
NUMBER_AND_PICKLE_IF_PARAMETERIZED = "NUMBER_AND_PICKLE_IF_PARAMETERIZED"
|
|
28
|
+
}
|
|
29
|
+
export declare function namingStrategy(length: NamingStrategyLength, featureName?: NamingStrategyFeatureName, exampleName?: NamingStrategyExampleName): NamingStrategy;
|
|
30
|
+
//# sourceMappingURL=Lineage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Lineage.d.ts","sourceRoot":"","sources":["../../src/Lineage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,OAAO,EACP,eAAe,EACf,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,QAAQ,EACT,MAAM,oBAAoB,CAAA;AAE3B,MAAM,WAAW,OAAO;IACtB,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,EAAE,QAAQ,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC,CAAA;CAChD;AAED,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC,MAAM,CAAC,CAAA;AAEnD,oBAAY,oBAAoB;IAC9B,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED,oBAAY,yBAAyB;IACnC,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AAED,oBAAY,yBAAyB;IACnC,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,kCAAkC,uCAAuC;CAC1E;AA8DD,wBAAgB,cAAc,CAC5B,MAAM,EAAE,oBAAoB,EAC5B,WAAW,GAAE,yBAA6D,EAC1E,WAAW,GAAE,yBAAwF,GACpG,cAAc,CAEhB"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NamingStrategyExampleName = exports.NamingStrategyFeatureName = exports.NamingStrategyLength = void 0;
|
|
4
|
+
exports.namingStrategy = namingStrategy;
|
|
5
|
+
var NamingStrategyLength;
|
|
6
|
+
(function (NamingStrategyLength) {
|
|
7
|
+
NamingStrategyLength["LONG"] = "LONG";
|
|
8
|
+
NamingStrategyLength["SHORT"] = "SHORT";
|
|
9
|
+
})(NamingStrategyLength || (exports.NamingStrategyLength = NamingStrategyLength = {}));
|
|
10
|
+
var NamingStrategyFeatureName;
|
|
11
|
+
(function (NamingStrategyFeatureName) {
|
|
12
|
+
NamingStrategyFeatureName["INCLUDE"] = "INCLUDE";
|
|
13
|
+
NamingStrategyFeatureName["EXCLUDE"] = "EXCLUDE";
|
|
14
|
+
})(NamingStrategyFeatureName || (exports.NamingStrategyFeatureName = NamingStrategyFeatureName = {}));
|
|
15
|
+
var NamingStrategyExampleName;
|
|
16
|
+
(function (NamingStrategyExampleName) {
|
|
17
|
+
NamingStrategyExampleName["NUMBER"] = "NUMBER";
|
|
18
|
+
NamingStrategyExampleName["PICKLE"] = "PICKLE";
|
|
19
|
+
NamingStrategyExampleName["NUMBER_AND_PICKLE_IF_PARAMETERIZED"] = "NUMBER_AND_PICKLE_IF_PARAMETERIZED";
|
|
20
|
+
})(NamingStrategyExampleName || (exports.NamingStrategyExampleName = NamingStrategyExampleName = {}));
|
|
21
|
+
class BuiltinNamingStrategy {
|
|
22
|
+
constructor(length, featureName, exampleName) {
|
|
23
|
+
this.length = length;
|
|
24
|
+
this.featureName = featureName;
|
|
25
|
+
this.exampleName = exampleName;
|
|
26
|
+
}
|
|
27
|
+
reduce(lineage, pickle) {
|
|
28
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
29
|
+
const parts = [];
|
|
30
|
+
if (((_a = lineage.feature) === null || _a === void 0 ? void 0 : _a.name) && this.featureName === NamingStrategyFeatureName.INCLUDE) {
|
|
31
|
+
parts.push(lineage.feature.name);
|
|
32
|
+
}
|
|
33
|
+
if ((_b = lineage.rule) === null || _b === void 0 ? void 0 : _b.name) {
|
|
34
|
+
parts.push(lineage.rule.name);
|
|
35
|
+
}
|
|
36
|
+
if ((_c = lineage.scenario) === null || _c === void 0 ? void 0 : _c.name) {
|
|
37
|
+
parts.push(lineage.scenario.name);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
parts.push(pickle.name);
|
|
41
|
+
}
|
|
42
|
+
if ((_d = lineage.examples) === null || _d === void 0 ? void 0 : _d.name) {
|
|
43
|
+
parts.push(lineage.examples.name);
|
|
44
|
+
}
|
|
45
|
+
if (lineage.example) {
|
|
46
|
+
const exampleNumber = [
|
|
47
|
+
'#',
|
|
48
|
+
((_e = lineage.examplesIndex) !== null && _e !== void 0 ? _e : 0) + 1,
|
|
49
|
+
'.',
|
|
50
|
+
((_f = lineage.exampleIndex) !== null && _f !== void 0 ? _f : 0) + 1,
|
|
51
|
+
].join('');
|
|
52
|
+
switch (this.exampleName) {
|
|
53
|
+
case NamingStrategyExampleName.NUMBER:
|
|
54
|
+
parts.push(exampleNumber);
|
|
55
|
+
break;
|
|
56
|
+
case NamingStrategyExampleName.NUMBER_AND_PICKLE_IF_PARAMETERIZED:
|
|
57
|
+
if (((_g = lineage.scenario) === null || _g === void 0 ? void 0 : _g.name) !== pickle.name) {
|
|
58
|
+
parts.push(exampleNumber + ': ' + pickle.name);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
parts.push(exampleNumber);
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
case NamingStrategyExampleName.PICKLE:
|
|
65
|
+
parts.push(pickle.name);
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (this.length === NamingStrategyLength.SHORT) {
|
|
70
|
+
return parts.at(-1);
|
|
71
|
+
}
|
|
72
|
+
return parts.filter((part) => !!part).join(' - ');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function namingStrategy(length, featureName = NamingStrategyFeatureName.INCLUDE, exampleName = NamingStrategyExampleName.NUMBER_AND_PICKLE_IF_PARAMETERIZED) {
|
|
76
|
+
return new BuiltinNamingStrategy(length, featureName, exampleName);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=Lineage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Lineage.js","sourceRoot":"","sources":["../../src/Lineage.ts"],"names":[],"mappings":";;;AAuGA,wCAMC;AAlFD,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,qCAAa,CAAA;IACb,uCAAe,CAAA;AACjB,CAAC,EAHW,oBAAoB,oCAApB,oBAAoB,QAG/B;AAED,IAAY,yBAGX;AAHD,WAAY,yBAAyB;IACnC,gDAAmB,CAAA;IACnB,gDAAmB,CAAA;AACrB,CAAC,EAHW,yBAAyB,yCAAzB,yBAAyB,QAGpC;AAED,IAAY,yBAIX;AAJD,WAAY,yBAAyB;IACnC,8CAAiB,CAAA;IACjB,8CAAiB,CAAA;IACjB,sGAAyE,CAAA;AAC3E,CAAC,EAJW,y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CAAC;aAChC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YAEV,QAAQ,IAAI,CAAC,WAAW,EAAE,CAAC;gBACzB,KAAK,yBAAyB,CAAC,MAAM;oBACnC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;oBACzB,MAAK;gBACP,KAAK,yBAAyB,CAAC,kCAAkC;oBAC/D,IAAI,CAAA,MAAA,OAAO,CAAC,QAAQ,0CAAE,IAAI,MAAK,MAAM,CAAC,IAAI,EAAE,CAAC;wBAC3C,KAAK,CAAC,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;oBAChD,CAAC;yBAAM,CAAC;wBACN,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;oBAC3B,CAAC;oBACD,MAAK;gBACP,KAAK,yBAAyB,CAAC,MAAM;oBACnC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;oBACvB,MAAK;YACT,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,KAAK,oBAAoB,CAAC,KAAK,EAAE,CAAC;YAC/C,OAAO,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAW,CAAA;QAC/B,CAAC;QACD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACnD,CAAC;CACF;AAED,SAAgB,cAAc,CAC5B,MAA4B,EAC5B,cAAyC,yBAAyB,CAAC,OAAO,EAC1E,cAAyC,yBAAyB,CAAC,kCAAkC;IAErG,OAAO,IAAI,qBAAqB,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,CAAC,CAAA;AACpE,CAAC","sourcesContent":["import {\n Examples,\n Feature,\n GherkinDocument,\n Pickle,\n Rule,\n Scenario,\n TableRow,\n} from '@cucumber/messages'\n\nexport interface Lineage {\n gherkinDocument?: GherkinDocument\n feature?: Feature\n rule?: Rule\n scenario?: Scenario\n examples?: Examples\n examplesIndex?: number\n example?: TableRow\n exampleIndex?: number\n}\n\nexport interface LineageReducer<T> {\n reduce: (lineage: Lineage, pickle: Pickle) => T\n}\n\nexport type NamingStrategy = LineageReducer<string>\n\nexport enum NamingStrategyLength {\n LONG = 'LONG',\n SHORT = 'SHORT',\n}\n\nexport enum NamingStrategyFeatureName {\n INCLUDE = 'INCLUDE',\n EXCLUDE = 'EXCLUDE',\n}\n\nexport enum NamingStrategyExampleName {\n NUMBER = 'NUMBER',\n PICKLE = 'PICKLE',\n NUMBER_AND_PICKLE_IF_PARAMETERIZED = 'NUMBER_AND_PICKLE_IF_PARAMETERIZED',\n}\n\nclass BuiltinNamingStrategy implements NamingStrategy {\n constructor(\n private readonly length: NamingStrategyLength,\n private readonly featureName: NamingStrategyFeatureName,\n private readonly exampleName: NamingStrategyExampleName\n ) {}\n\n reduce(lineage: Lineage, pickle: Pickle): string {\n const parts: string[] = []\n\n if (lineage.feature?.name && this.featureName === NamingStrategyFeatureName.INCLUDE) {\n parts.push(lineage.feature.name)\n }\n\n if (lineage.rule?.name) {\n parts.push(lineage.rule.name)\n }\n\n if (lineage.scenario?.name) {\n parts.push(lineage.scenario.name)\n } else {\n parts.push(pickle.name)\n }\n\n if (lineage.examples?.name) {\n parts.push(lineage.examples.name)\n }\n\n if (lineage.example) {\n const exampleNumber = [\n '#',\n (lineage.examplesIndex ?? 0) + 1,\n '.',\n (lineage.exampleIndex ?? 0) + 1,\n ].join('')\n\n switch (this.exampleName) {\n case NamingStrategyExampleName.NUMBER:\n parts.push(exampleNumber)\n break\n case NamingStrategyExampleName.NUMBER_AND_PICKLE_IF_PARAMETERIZED:\n if (lineage.scenario?.name !== pickle.name) {\n parts.push(exampleNumber + ': ' + pickle.name)\n } else {\n parts.push(exampleNumber)\n }\n break\n case NamingStrategyExampleName.PICKLE:\n parts.push(pickle.name)\n break\n }\n }\n\n if (this.length === NamingStrategyLength.SHORT) {\n return parts.at(-1) as string\n }\n return parts.filter((part) => !!part).join(' - ')\n }\n}\n\nexport function namingStrategy(\n length: NamingStrategyLength,\n featureName: NamingStrategyFeatureName = NamingStrategyFeatureName.INCLUDE,\n exampleName: NamingStrategyExampleName = NamingStrategyExampleName.NUMBER_AND_PICKLE_IF_PARAMETERIZED\n): NamingStrategy {\n return new BuiltinNamingStrategy(length, featureName, exampleName)\n}\n"]}
|
package/dist/src/Query.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as messages from '@cucumber/messages';
|
|
2
|
+
import { Duration, Feature, Pickle, PickleStep, Step, TestCase, TestCaseFinished, TestCaseStarted, TestRunFinished, TestRunStarted, TestStep, TestStepFinished, TestStepResult, TestStepResultStatus } from '@cucumber/messages';
|
|
3
|
+
import { NamingStrategy } from "./Lineage";
|
|
2
4
|
export default class Query {
|
|
3
5
|
private readonly testStepResultByPickleId;
|
|
4
6
|
private readonly testStepResultsByPickleStepId;
|
|
5
|
-
private readonly testStepById;
|
|
6
7
|
private readonly testCaseByPickleId;
|
|
7
|
-
private readonly testCaseByTestCaseId;
|
|
8
8
|
private readonly pickleIdByTestStepId;
|
|
9
9
|
private readonly pickleStepIdByTestStepId;
|
|
10
10
|
private readonly testStepResultsbyTestStepId;
|
|
@@ -12,7 +12,28 @@ export default class Query {
|
|
|
12
12
|
private readonly hooksById;
|
|
13
13
|
private readonly attachmentsByTestStepId;
|
|
14
14
|
private readonly stepMatchArgumentsListsByPickleStepId;
|
|
15
|
+
private testRunStarted;
|
|
16
|
+
private testRunFinished;
|
|
17
|
+
private readonly testCaseStarted;
|
|
18
|
+
private readonly lineageById;
|
|
19
|
+
private readonly stepById;
|
|
20
|
+
private readonly pickleById;
|
|
21
|
+
private readonly pickleStepById;
|
|
22
|
+
private readonly testCaseById;
|
|
23
|
+
private readonly testStepById;
|
|
24
|
+
private readonly testCaseFinishedByTestCaseStartedId;
|
|
25
|
+
private readonly testStepFinishedByTestCaseStartedId;
|
|
15
26
|
update(envelope: messages.Envelope): void;
|
|
27
|
+
private updateGherkinDocument;
|
|
28
|
+
private updateFeature;
|
|
29
|
+
private updateRule;
|
|
30
|
+
private updateScenario;
|
|
31
|
+
private updateSteps;
|
|
32
|
+
private updatePickle;
|
|
33
|
+
private updateTestCase;
|
|
34
|
+
private updateTestCaseStarted;
|
|
35
|
+
private updateTestStepFinished;
|
|
36
|
+
private updateTestCaseFinished;
|
|
16
37
|
/**
|
|
17
38
|
* Gets all the results for multiple pickle steps
|
|
18
39
|
* @param pickleStepIds
|
|
@@ -40,5 +61,28 @@ export default class Query {
|
|
|
40
61
|
private identifyHookSteps;
|
|
41
62
|
getTestStepResults(testStepId: string): messages.TestStepResult[];
|
|
42
63
|
getStatusCounts(pickleIds: readonly string[]): Partial<Record<messages.TestStepResultStatus, number>>;
|
|
64
|
+
countMostSevereTestStepResultStatus(): Record<TestStepResultStatus, number>;
|
|
65
|
+
countTestCasesStarted(): number;
|
|
66
|
+
findAllPickles(): ReadonlyArray<Pickle>;
|
|
67
|
+
findAllPickleSteps(): ReadonlyArray<PickleStep>;
|
|
68
|
+
findAllTestCaseStarted(): ReadonlyArray<TestCaseStarted>;
|
|
69
|
+
findAllTestCaseStartedGroupedByFeature(): Map<Feature | undefined, ReadonlyArray<TestCaseStarted>>;
|
|
70
|
+
findAllTestSteps(): ReadonlyArray<TestStep>;
|
|
71
|
+
findFeatureBy(testCaseStarted: TestCaseStarted): Feature | undefined;
|
|
72
|
+
findMostSevereTestStepResultBy(testCaseStarted: TestCaseStarted): TestStepResult | undefined;
|
|
73
|
+
findNameOf(pickle: Pickle, namingStrategy: NamingStrategy): string;
|
|
74
|
+
findPickleBy(testCaseStarted: TestCaseStarted): Pickle | undefined;
|
|
75
|
+
findPickleStepBy(testStep: TestStep): PickleStep | undefined;
|
|
76
|
+
findStepBy(pickleStep: PickleStep): Step | undefined;
|
|
77
|
+
findTestCaseBy(testCaseStarted: TestCaseStarted): TestCase | undefined;
|
|
78
|
+
findTestCaseDurationBy(testCaseStarted: TestCaseStarted): Duration | undefined;
|
|
79
|
+
findTestCaseFinishedBy(testCaseStarted: TestCaseStarted): TestCaseFinished | undefined;
|
|
80
|
+
findTestRunDuration(): Duration | undefined;
|
|
81
|
+
findTestRunFinished(): TestRunFinished | undefined;
|
|
82
|
+
findTestRunStarted(): TestRunStarted | undefined;
|
|
83
|
+
findTestStepBy(testStepFinished: TestStepFinished): TestStep | undefined;
|
|
84
|
+
findTestStepsFinishedBy(testCaseStarted: TestCaseStarted): ReadonlyArray<TestStepFinished>;
|
|
85
|
+
findTestStepFinishedAndTestStepBy(testCaseStarted: TestCaseStarted): ReadonlyArray<[TestStepFinished, TestStep]>;
|
|
86
|
+
private findLineageBy;
|
|
43
87
|
}
|
|
44
88
|
//# sourceMappingURL=Query.d.ts.map
|
package/dist/src/Query.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Query.d.ts","sourceRoot":"","sources":["../../src/Query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"Query.d.ts","sourceRoot":"","sources":["../../src/Query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EACL,QAAQ,EACR,OAAO,EAGP,MAAM,EACN,UAAU,EAGV,IAAI,EACJ,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EAErB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAU,cAAc,EAAC,MAAM,WAAW,CAAC;AAIlD,MAAM,CAAC,OAAO,OAAO,KAAK;IACxB,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAuD;IAChG,OAAO,CAAC,QAAQ,CAAC,6BAA6B,CAG3C;IACH,OAAO,CAAC,QAAQ,CAAC,kBAAkB,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eAAe,EAAE,eAAe,GAAG,OAAO,GAAG,SAAS;IAIpE,8BAA8B,CAAC,eAAe,EAAE,eAAe,GAAG,cAAc,GAAG,SAAS;IAO5F,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,GAAG,MAAM;IAKlE,YAAY,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS;IAMlE,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS;IAK5D,UAAU,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS;IAMpD,cAAc,CAAC,eAAe,EAAE,eAAe,GAAG,QAAQ,GAAG,SAAS;IAItE,sBAAsB,CAAC,eAAe,EAAE,eAAe,GAAG,QAAQ,GAAG,SAAS;IAW9E,sBAAsB,CAAC,eAAe,EAAE,eAAe,GAAG,gBAAgB,GAAG,SAAS;IAItF,mBAAmB,IAAI,QAAQ,GAAG,SAAS;IAU3C,mBAAmB,IAAI,eAAe,GAAG,SAAS;IAIlD,kBAAkB,IAAI,cAAc,GAAG,SAAS;IAIhD,cAAc,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,QAAQ,GAAG,SAAS;IAIxE,uBAAuB,CAAC,eAAe,EAAE,eAAe,GAAG,aAAa,CAAC,gBAAgB,CAAC;IAK1F,iCAAiC,CACpC,eAAe,EAAE,eAAe,GACjC,aAAa,CAAC,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;IAU9C,OAAO,CAAC,aAAa;CAMtB"}
|
package/dist/src/Query.js
CHANGED
|
@@ -22,17 +22,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
29
|
const messages = __importStar(require("@cucumber/messages"));
|
|
27
30
|
const messages_1 = require("@cucumber/messages");
|
|
28
31
|
const multimaps_1 = require("@teppeis/multimaps");
|
|
32
|
+
const assert_1 = __importDefault(require("assert"));
|
|
33
|
+
const helpers_1 = require("./helpers");
|
|
29
34
|
class Query {
|
|
30
35
|
constructor() {
|
|
31
36
|
this.testStepResultByPickleId = new multimaps_1.ArrayMultimap();
|
|
32
37
|
this.testStepResultsByPickleStepId = new multimaps_1.ArrayMultimap();
|
|
33
|
-
this.testStepById = new Map();
|
|
34
38
|
this.testCaseByPickleId = new Map();
|
|
35
|
-
this.testCaseByTestCaseId = new Map();
|
|
36
39
|
this.pickleIdByTestStepId = new Map();
|
|
37
40
|
this.pickleStepIdByTestStepId = new Map();
|
|
38
41
|
this.testStepResultsbyTestStepId = new multimaps_1.ArrayMultimap();
|
|
@@ -40,46 +43,137 @@ class Query {
|
|
|
40
43
|
this.hooksById = new Map();
|
|
41
44
|
this.attachmentsByTestStepId = new multimaps_1.ArrayMultimap();
|
|
42
45
|
this.stepMatchArgumentsListsByPickleStepId = new Map();
|
|
46
|
+
this.testCaseStarted = [];
|
|
47
|
+
this.lineageById = new Map();
|
|
48
|
+
this.stepById = new Map();
|
|
49
|
+
this.pickleById = new Map();
|
|
50
|
+
this.pickleStepById = new Map();
|
|
51
|
+
this.testCaseById = new Map();
|
|
52
|
+
this.testStepById = new Map();
|
|
53
|
+
this.testCaseFinishedByTestCaseStartedId = new Map();
|
|
54
|
+
this.testStepFinishedByTestCaseStartedId = new multimaps_1.ArrayMultimap();
|
|
43
55
|
}
|
|
44
56
|
update(envelope) {
|
|
45
|
-
if (envelope.
|
|
46
|
-
this.
|
|
47
|
-
this.testCaseByPickleId.set(envelope.testCase.pickleId, envelope.testCase);
|
|
48
|
-
for (const testStep of envelope.testCase.testSteps) {
|
|
49
|
-
this.testStepById.set(testStep.id, testStep);
|
|
50
|
-
this.pickleIdByTestStepId.set(testStep.id, envelope.testCase.pickleId);
|
|
51
|
-
this.pickleStepIdByTestStepId.set(testStep.id, testStep.pickleStepId);
|
|
52
|
-
this.testStepIdsByPickleStepId.put(testStep.pickleStepId, testStep.id);
|
|
53
|
-
this.stepMatchArgumentsListsByPickleStepId.set(testStep.pickleStepId, testStep.stepMatchArgumentsLists);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/*
|
|
57
|
-
when a test case attempt starts besides the first one, clear all existing results
|
|
58
|
-
and attachments for that test case, so we always report on the latest attempt
|
|
59
|
-
TODO keep track of results and attachments from all attempts, expand API accordingly
|
|
60
|
-
*/
|
|
61
|
-
if (envelope.testCaseStarted && envelope.testCaseStarted.attempt > 0) {
|
|
62
|
-
const testCase = this.testCaseByTestCaseId.get(envelope.testCaseStarted.testCaseId);
|
|
63
|
-
this.testStepResultByPickleId.delete(testCase.pickleId);
|
|
64
|
-
for (const testStep of testCase.testSteps) {
|
|
65
|
-
this.testStepResultsByPickleStepId.delete(testStep.pickleStepId);
|
|
66
|
-
this.testStepResultsbyTestStepId.delete(testStep.id);
|
|
67
|
-
this.attachmentsByTestStepId.delete(testStep.id);
|
|
68
|
-
}
|
|
57
|
+
if (envelope.gherkinDocument) {
|
|
58
|
+
this.updateGherkinDocument(envelope.gherkinDocument);
|
|
69
59
|
}
|
|
70
|
-
if (envelope.
|
|
71
|
-
|
|
72
|
-
this.testStepResultByPickleId.put(pickleId, envelope.testStepFinished.testStepResult);
|
|
73
|
-
const testStep = this.testStepById.get(envelope.testStepFinished.testStepId);
|
|
74
|
-
this.testStepResultsByPickleStepId.put(testStep.pickleStepId, envelope.testStepFinished.testStepResult);
|
|
75
|
-
this.testStepResultsbyTestStepId.put(testStep.id, envelope.testStepFinished.testStepResult);
|
|
60
|
+
if (envelope.pickle) {
|
|
61
|
+
this.updatePickle(envelope.pickle);
|
|
76
62
|
}
|
|
77
63
|
if (envelope.hook) {
|
|
78
64
|
this.hooksById.set(envelope.hook.id, envelope.hook);
|
|
79
65
|
}
|
|
66
|
+
if (envelope.testRunStarted) {
|
|
67
|
+
this.testRunStarted = envelope.testRunStarted;
|
|
68
|
+
}
|
|
69
|
+
if (envelope.testCase) {
|
|
70
|
+
this.updateTestCase(envelope.testCase);
|
|
71
|
+
}
|
|
72
|
+
if (envelope.testCaseStarted) {
|
|
73
|
+
this.updateTestCaseStarted(envelope.testCaseStarted);
|
|
74
|
+
}
|
|
80
75
|
if (envelope.attachment) {
|
|
81
76
|
this.attachmentsByTestStepId.put(envelope.attachment.testStepId, envelope.attachment);
|
|
82
77
|
}
|
|
78
|
+
if (envelope.testStepFinished) {
|
|
79
|
+
this.updateTestStepFinished(envelope.testStepFinished);
|
|
80
|
+
}
|
|
81
|
+
if (envelope.testCaseFinished) {
|
|
82
|
+
this.updateTestCaseFinished(envelope.testCaseFinished);
|
|
83
|
+
}
|
|
84
|
+
if (envelope.testRunFinished) {
|
|
85
|
+
this.testRunFinished = envelope.testRunFinished;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
updateGherkinDocument(gherkinDocument) {
|
|
89
|
+
if (gherkinDocument.feature) {
|
|
90
|
+
this.updateFeature(gherkinDocument.feature, {
|
|
91
|
+
gherkinDocument,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
updateFeature(feature, lineage) {
|
|
96
|
+
feature.children.forEach((featureChild) => {
|
|
97
|
+
if (featureChild.background) {
|
|
98
|
+
this.updateSteps(featureChild.background.steps);
|
|
99
|
+
}
|
|
100
|
+
if (featureChild.scenario) {
|
|
101
|
+
this.updateScenario(featureChild.scenario, Object.assign(Object.assign({}, lineage), { feature }));
|
|
102
|
+
}
|
|
103
|
+
if (featureChild.rule) {
|
|
104
|
+
this.updateRule(featureChild.rule, Object.assign(Object.assign({}, lineage), { feature }));
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
updateRule(rule, lineage) {
|
|
109
|
+
rule.children.forEach((ruleChild) => {
|
|
110
|
+
if (ruleChild.background) {
|
|
111
|
+
this.updateSteps(ruleChild.background.steps);
|
|
112
|
+
}
|
|
113
|
+
if (ruleChild.scenario) {
|
|
114
|
+
this.updateScenario(ruleChild.scenario, Object.assign(Object.assign({}, lineage), { rule }));
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
updateScenario(scenario, lineage) {
|
|
119
|
+
this.lineageById.set(scenario.id, Object.assign(Object.assign({}, lineage), { scenario }));
|
|
120
|
+
scenario.examples.forEach((examples, examplesIndex) => {
|
|
121
|
+
this.lineageById.set(examples.id, Object.assign(Object.assign({}, lineage), { scenario,
|
|
122
|
+
examples,
|
|
123
|
+
examplesIndex }));
|
|
124
|
+
examples.tableBody.forEach((example, exampleIndex) => {
|
|
125
|
+
this.lineageById.set(example.id, Object.assign(Object.assign({}, lineage), { scenario,
|
|
126
|
+
examples,
|
|
127
|
+
examplesIndex,
|
|
128
|
+
example,
|
|
129
|
+
exampleIndex }));
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
this.updateSteps(scenario.steps);
|
|
133
|
+
}
|
|
134
|
+
updateSteps(steps) {
|
|
135
|
+
steps.forEach((step) => this.stepById.set(step.id, step));
|
|
136
|
+
}
|
|
137
|
+
updatePickle(pickle) {
|
|
138
|
+
this.pickleById.set(pickle.id, pickle);
|
|
139
|
+
pickle.steps.forEach((pickleStep) => this.pickleStepById.set(pickleStep.id, pickleStep));
|
|
140
|
+
}
|
|
141
|
+
updateTestCase(testCase) {
|
|
142
|
+
this.testCaseById.set(testCase.id, testCase);
|
|
143
|
+
this.testCaseByPickleId.set(testCase.pickleId, testCase);
|
|
144
|
+
testCase.testSteps.forEach((testStep) => {
|
|
145
|
+
this.testStepById.set(testStep.id, testStep);
|
|
146
|
+
this.pickleIdByTestStepId.set(testStep.id, testCase.pickleId);
|
|
147
|
+
this.pickleStepIdByTestStepId.set(testStep.id, testStep.pickleStepId);
|
|
148
|
+
this.testStepIdsByPickleStepId.put(testStep.pickleStepId, testStep.id);
|
|
149
|
+
this.stepMatchArgumentsListsByPickleStepId.set(testStep.pickleStepId, testStep.stepMatchArgumentsLists);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
updateTestCaseStarted(testCaseStarted) {
|
|
153
|
+
this.testCaseStarted.push(testCaseStarted);
|
|
154
|
+
/*
|
|
155
|
+
when a test case attempt starts besides the first one, clear all existing results
|
|
156
|
+
and attachments for that test case, so we always report on the latest attempt
|
|
157
|
+
(applies to legacy pickle-oriented query methods only)
|
|
158
|
+
*/
|
|
159
|
+
const testCase = this.testCaseById.get(testCaseStarted.testCaseId);
|
|
160
|
+
this.testStepResultByPickleId.delete(testCase.pickleId);
|
|
161
|
+
for (const testStep of testCase.testSteps) {
|
|
162
|
+
this.testStepResultsByPickleStepId.delete(testStep.pickleStepId);
|
|
163
|
+
this.testStepResultsbyTestStepId.delete(testStep.id);
|
|
164
|
+
this.attachmentsByTestStepId.delete(testStep.id);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
updateTestStepFinished(testStepFinished) {
|
|
168
|
+
this.testStepFinishedByTestCaseStartedId.put(testStepFinished.testCaseStartedId, testStepFinished);
|
|
169
|
+
const pickleId = this.pickleIdByTestStepId.get(testStepFinished.testStepId);
|
|
170
|
+
this.testStepResultByPickleId.put(pickleId, testStepFinished.testStepResult);
|
|
171
|
+
const testStep = this.testStepById.get(testStepFinished.testStepId);
|
|
172
|
+
this.testStepResultsByPickleStepId.put(testStep.pickleStepId, testStepFinished.testStepResult);
|
|
173
|
+
this.testStepResultsbyTestStepId.put(testStep.id, testStepFinished.testStepResult);
|
|
174
|
+
}
|
|
175
|
+
updateTestCaseFinished(testCaseFinished) {
|
|
176
|
+
this.testCaseFinishedByTestCaseStartedId.set(testCaseFinished.testCaseStartedId, testCaseFinished);
|
|
83
177
|
}
|
|
84
178
|
/**
|
|
85
179
|
* Gets all the results for multiple pickle steps
|
|
@@ -176,6 +270,138 @@ class Query {
|
|
|
176
270
|
}
|
|
177
271
|
return result;
|
|
178
272
|
}
|
|
273
|
+
/* new common interface with Java starts here */
|
|
274
|
+
countMostSevereTestStepResultStatus() {
|
|
275
|
+
const result = {
|
|
276
|
+
[messages_1.TestStepResultStatus.AMBIGUOUS]: 0,
|
|
277
|
+
[messages_1.TestStepResultStatus.FAILED]: 0,
|
|
278
|
+
[messages_1.TestStepResultStatus.PASSED]: 0,
|
|
279
|
+
[messages_1.TestStepResultStatus.PENDING]: 0,
|
|
280
|
+
[messages_1.TestStepResultStatus.SKIPPED]: 0,
|
|
281
|
+
[messages_1.TestStepResultStatus.UNDEFINED]: 0,
|
|
282
|
+
[messages_1.TestStepResultStatus.UNKNOWN]: 0,
|
|
283
|
+
};
|
|
284
|
+
for (const testCaseStarted of this.findAllTestCaseStarted()) {
|
|
285
|
+
const mostSevereResult = this.findTestStepFinishedAndTestStepBy(testCaseStarted)
|
|
286
|
+
.map(([testStepFinished]) => testStepFinished.testStepResult)
|
|
287
|
+
.sort(helpers_1.comparatorByStatus)
|
|
288
|
+
.at(-1);
|
|
289
|
+
if (mostSevereResult) {
|
|
290
|
+
result[mostSevereResult.status]++;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return result;
|
|
294
|
+
}
|
|
295
|
+
countTestCasesStarted() {
|
|
296
|
+
return this.findAllTestCaseStarted().length;
|
|
297
|
+
}
|
|
298
|
+
findAllPickles() {
|
|
299
|
+
const pickles = [...this.pickleById.values()];
|
|
300
|
+
return pickles.sort(helpers_1.comparatorById);
|
|
301
|
+
}
|
|
302
|
+
findAllPickleSteps() {
|
|
303
|
+
const pickleSteps = [...this.pickleStepById.values()];
|
|
304
|
+
return pickleSteps.sort(helpers_1.comparatorById);
|
|
305
|
+
}
|
|
306
|
+
findAllTestCaseStarted() {
|
|
307
|
+
return this.testCaseStarted.filter((testCaseStarted) => {
|
|
308
|
+
const testCaseFinished = this.testCaseFinishedByTestCaseStartedId.get(testCaseStarted.id);
|
|
309
|
+
// only include if not yet finished OR won't be retried
|
|
310
|
+
return !(testCaseFinished === null || testCaseFinished === void 0 ? void 0 : testCaseFinished.willBeRetried);
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
findAllTestCaseStartedGroupedByFeature() {
|
|
314
|
+
const results = new Map();
|
|
315
|
+
this.findAllTestCaseStarted()
|
|
316
|
+
.map(testCaseStarted => [this.findLineageBy(testCaseStarted), testCaseStarted])
|
|
317
|
+
.sort(([a], [b]) => (0, helpers_1.comparatorBy)(a.gherkinDocument, b.gherkinDocument, "uri"))
|
|
318
|
+
.forEach(([{ feature }, testCaseStarted]) => {
|
|
319
|
+
var _a;
|
|
320
|
+
results.set(feature, [...(_a = results.get(feature)) !== null && _a !== void 0 ? _a : [], testCaseStarted]);
|
|
321
|
+
});
|
|
322
|
+
return results;
|
|
323
|
+
}
|
|
324
|
+
findAllTestSteps() {
|
|
325
|
+
const testSteps = [...this.testStepById.values()];
|
|
326
|
+
return testSteps.sort(helpers_1.comparatorById);
|
|
327
|
+
}
|
|
328
|
+
findFeatureBy(testCaseStarted) {
|
|
329
|
+
var _a;
|
|
330
|
+
return (_a = this.findLineageBy(testCaseStarted)) === null || _a === void 0 ? void 0 : _a.feature;
|
|
331
|
+
}
|
|
332
|
+
findMostSevereTestStepResultBy(testCaseStarted) {
|
|
333
|
+
return this.findTestStepFinishedAndTestStepBy(testCaseStarted)
|
|
334
|
+
.map(([testStepFinished]) => testStepFinished.testStepResult)
|
|
335
|
+
.sort(helpers_1.comparatorByStatus)
|
|
336
|
+
.at(-1);
|
|
337
|
+
}
|
|
338
|
+
findNameOf(pickle, namingStrategy) {
|
|
339
|
+
const lineage = this.findLineageBy(pickle);
|
|
340
|
+
return lineage ? namingStrategy.reduce(lineage, pickle) : pickle.name;
|
|
341
|
+
}
|
|
342
|
+
findPickleBy(testCaseStarted) {
|
|
343
|
+
const testCase = this.findTestCaseBy(testCaseStarted);
|
|
344
|
+
assert_1.default.ok(testCase, 'Expected to find TestCase from TestCaseStarted');
|
|
345
|
+
return this.pickleById.get(testCase.pickleId);
|
|
346
|
+
}
|
|
347
|
+
findPickleStepBy(testStep) {
|
|
348
|
+
assert_1.default.ok(testStep.pickleStepId, 'Expected TestStep to have a pickleStepId');
|
|
349
|
+
return this.pickleStepById.get(testStep.pickleStepId);
|
|
350
|
+
}
|
|
351
|
+
findStepBy(pickleStep) {
|
|
352
|
+
const [astNodeId] = pickleStep.astNodeIds;
|
|
353
|
+
assert_1.default.ok('Expected PickleStep to have an astNodeId');
|
|
354
|
+
return this.stepById.get(astNodeId);
|
|
355
|
+
}
|
|
356
|
+
findTestCaseBy(testCaseStarted) {
|
|
357
|
+
return this.testCaseById.get(testCaseStarted.testCaseId);
|
|
358
|
+
}
|
|
359
|
+
findTestCaseDurationBy(testCaseStarted) {
|
|
360
|
+
const testCaseFinished = this.findTestCaseFinishedBy(testCaseStarted);
|
|
361
|
+
if (!testCaseFinished) {
|
|
362
|
+
return undefined;
|
|
363
|
+
}
|
|
364
|
+
return messages_1.TimeConversion.millisecondsToDuration(messages_1.TimeConversion.timestampToMillisecondsSinceEpoch(testCaseFinished.timestamp) -
|
|
365
|
+
messages_1.TimeConversion.timestampToMillisecondsSinceEpoch(testCaseStarted.timestamp));
|
|
366
|
+
}
|
|
367
|
+
findTestCaseFinishedBy(testCaseStarted) {
|
|
368
|
+
return this.testCaseFinishedByTestCaseStartedId.get(testCaseStarted.id);
|
|
369
|
+
}
|
|
370
|
+
findTestRunDuration() {
|
|
371
|
+
if (!this.testRunStarted || !this.testRunFinished) {
|
|
372
|
+
return undefined;
|
|
373
|
+
}
|
|
374
|
+
return messages_1.TimeConversion.millisecondsToDuration(messages_1.TimeConversion.timestampToMillisecondsSinceEpoch(this.testRunFinished.timestamp) -
|
|
375
|
+
messages_1.TimeConversion.timestampToMillisecondsSinceEpoch(this.testRunStarted.timestamp));
|
|
376
|
+
}
|
|
377
|
+
findTestRunFinished() {
|
|
378
|
+
return this.testRunFinished;
|
|
379
|
+
}
|
|
380
|
+
findTestRunStarted() {
|
|
381
|
+
return this.testRunStarted;
|
|
382
|
+
}
|
|
383
|
+
findTestStepBy(testStepFinished) {
|
|
384
|
+
return this.testStepById.get(testStepFinished.testStepId);
|
|
385
|
+
}
|
|
386
|
+
findTestStepsFinishedBy(testCaseStarted) {
|
|
387
|
+
// multimaps `get` implements `getOrDefault([])` behaviour internally
|
|
388
|
+
return [...this.testStepFinishedByTestCaseStartedId.get(testCaseStarted.id)];
|
|
389
|
+
}
|
|
390
|
+
findTestStepFinishedAndTestStepBy(testCaseStarted) {
|
|
391
|
+
return this.testStepFinishedByTestCaseStartedId
|
|
392
|
+
.get(testCaseStarted.id)
|
|
393
|
+
.map((testStepFinished) => {
|
|
394
|
+
const testStep = this.findTestStepBy(testStepFinished);
|
|
395
|
+
assert_1.default.ok(testStep, 'Expected to find TestStep by TestStepFinished');
|
|
396
|
+
return [testStepFinished, testStep];
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
findLineageBy(element) {
|
|
400
|
+
const pickle = "testCaseId" in element ? this.findPickleBy(element) : element;
|
|
401
|
+
const deepestAstNodeId = pickle.astNodeIds.at(-1);
|
|
402
|
+
assert_1.default.ok(deepestAstNodeId, 'Expected Pickle to have at least one astNodeId');
|
|
403
|
+
return this.lineageById.get(deepestAstNodeId);
|
|
404
|
+
}
|
|
179
405
|
}
|
|
180
406
|
exports.default = Query;
|
|
181
407
|
//# sourceMappingURL=Query.js.map
|
package/dist/src/Query.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Query.js","sourceRoot":"","sources":["../../src/Query.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA8C;AAC9C,iDAA2D;AAC3D,kDAAkD;AAElD,MAAqB,KAAK;IAA1B;QACmB,6BAAwB,GAAG,IAAI,yBAAa,EAAmC,CAAA;QAC/E,kCAA6B,GAAG,IAAI,yBAAa,EAG/D,CAAA;QACc,iBAAY,GAAG,IAAI,GAAG,EAA6B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CAAC,GAAG,KAAK,GAAG,CAAC,CAAA;QAC3C,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAlND,wBAkNC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport { getWorstTestStepResult } from '@cucumber/messages'\nimport { ArrayMultimap } from '@teppeis/multimaps'\n\nexport default class Query {\n private readonly testStepResultByPickleId = new ArrayMultimap<string, messages.TestStepResult>()\n private readonly testStepResultsByPickleStepId = new ArrayMultimap<\n string,\n messages.TestStepResult\n >()\n private readonly testStepById = new Map<string, messages.TestStep>()\n private readonly testCaseByPickleId = new Map<string, messages.TestCase>()\n private readonly testCaseByTestCaseId = new Map<string, messages.TestCase>()\n private readonly pickleIdByTestStepId = new Map<string, string>()\n private readonly pickleStepIdByTestStepId = new Map<string, string>()\n private readonly testStepResultsbyTestStepId = new ArrayMultimap<\n string,\n messages.TestStepResult\n >()\n private readonly testStepIdsByPickleStepId = new ArrayMultimap<string, string>()\n private readonly hooksById = new Map<string, messages.Hook>()\n\n private readonly attachmentsByTestStepId = new ArrayMultimap<string, messages.Attachment>()\n\n private readonly stepMatchArgumentsListsByPickleStepId = new Map<\n string,\n readonly messages.StepMatchArgumentsList[]\n >()\n\n public update(envelope: messages.Envelope) {\n if (envelope.testCase) {\n this.testCaseByTestCaseId.set(envelope.testCase.id, envelope.testCase)\n this.testCaseByPickleId.set(envelope.testCase.pickleId, envelope.testCase)\n for (const testStep of envelope.testCase.testSteps) {\n this.testStepById.set(testStep.id, testStep)\n this.pickleIdByTestStepId.set(testStep.id, envelope.testCase.pickleId)\n this.pickleStepIdByTestStepId.set(testStep.id, testStep.pickleStepId)\n this.testStepIdsByPickleStepId.put(testStep.pickleStepId, testStep.id)\n this.stepMatchArgumentsListsByPickleStepId.set(\n testStep.pickleStepId,\n testStep.stepMatchArgumentsLists\n )\n }\n }\n\n /*\n when a test case attempt starts besides the first one, clear all existing results\n and attachments for that test case, so we always report on the latest attempt\n TODO keep track of results and attachments from all attempts, expand API accordingly\n */\n if (envelope.testCaseStarted && envelope.testCaseStarted.attempt > 0) {\n const testCase = this.testCaseByTestCaseId.get(envelope.testCaseStarted.testCaseId)\n this.testStepResultByPickleId.delete(testCase.pickleId)\n for (const testStep of testCase.testSteps) {\n this.testStepResultsByPickleStepId.delete(testStep.pickleStepId)\n this.testStepResultsbyTestStepId.delete(testStep.id)\n this.attachmentsByTestStepId.delete(testStep.id)\n }\n }\n\n if (envelope.testStepFinished) {\n const pickleId = this.pickleIdByTestStepId.get(envelope.testStepFinished.testStepId)\n this.testStepResultByPickleId.put(pickleId, envelope.testStepFinished.testStepResult)\n\n const testStep = this.testStepById.get(envelope.testStepFinished.testStepId)\n this.testStepResultsByPickleStepId.put(\n testStep.pickleStepId,\n envelope.testStepFinished.testStepResult\n )\n this.testStepResultsbyTestStepId.put(testStep.id, envelope.testStepFinished.testStepResult)\n }\n\n if (envelope.hook) {\n this.hooksById.set(envelope.hook.id, envelope.hook)\n }\n\n if (envelope.attachment) {\n this.attachmentsByTestStepId.put(envelope.attachment.testStepId, envelope.attachment)\n }\n }\n\n /**\n * Gets all the results for multiple pickle steps\n * @param pickleStepIds\n */\n public getPickleStepTestStepResults(\n pickleStepIds: readonly string[]\n ): readonly messages.TestStepResult[] {\n if (pickleStepIds.length === 0) {\n return [\n {\n status: messages.TestStepResultStatus.UNKNOWN,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n },\n ]\n }\n return pickleStepIds.reduce((testStepResults: messages.TestStepResult[], pickleId) => {\n return testStepResults.concat(this.testStepResultsByPickleStepId.get(pickleId))\n }, [])\n }\n\n /**\n * Gets all the results for multiple pickles\n * @param pickleIds\n */\n public getPickleTestStepResults(\n pickleIds: readonly string[]\n ): readonly messages.TestStepResult[] {\n if (pickleIds.length === 0) {\n return [\n {\n status: messages.TestStepResultStatus.UNKNOWN,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n },\n ]\n }\n return pickleIds.reduce((testStepResults: messages.TestStepResult[], pickleId) => {\n return testStepResults.concat(this.testStepResultByPickleId.get(pickleId))\n }, [])\n }\n\n /**\n * Gets all the attachments for multiple pickle steps\n * @param pickleStepIds\n */\n public getPickleStepAttachments(\n pickleStepIds: readonly string[]\n ): readonly messages.Attachment[] {\n return this.getTestStepsAttachments(\n pickleStepIds.reduce((testStepIds: string[], pickleStepId: string) => {\n return testStepIds.concat(this.testStepIdsByPickleStepId.get(pickleStepId))\n }, [])\n )\n }\n\n public getTestStepsAttachments(testStepIds: readonly string[]): readonly messages.Attachment[] {\n return testStepIds.reduce((attachments: messages.Attachment[], testStepId) => {\n return attachments.concat(this.attachmentsByTestStepId.get(testStepId))\n }, [])\n }\n\n /**\n * Get StepMatchArguments for a pickle step\n * @param pickleStepId\n */\n public getStepMatchArgumentsLists(\n pickleStepId: string\n ): readonly messages.StepMatchArgumentsList[] | undefined {\n return this.stepMatchArgumentsListsByPickleStepId.get(pickleStepId)\n }\n\n public getHook(hookId: string): messages.Hook {\n return this.hooksById.get(hookId)\n }\n\n public getBeforeHookSteps(pickleId: string): readonly messages.TestStep[] {\n const hookSteps: messages.TestStep[] = []\n\n this.identifyHookSteps(\n pickleId,\n (hook) => hookSteps.push(hook),\n () => null\n )\n return hookSteps\n }\n\n public getAfterHookSteps(pickleId: string): readonly messages.TestStep[] {\n const hookSteps: messages.TestStep[] = []\n\n this.identifyHookSteps(\n pickleId,\n () => null,\n (hook) => hookSteps.push(hook)\n )\n return hookSteps\n }\n\n private identifyHookSteps(\n pickleId: string,\n onBeforeHookFound: (hook: messages.TestStep) => void,\n onAfterHookFound: (hook: messages.TestStep) => void\n ): void {\n const testCase = this.testCaseByPickleId.get(pickleId)\n\n if (!testCase) {\n return\n }\n\n let pickleStepFound = false\n\n for (const step of testCase.testSteps) {\n if (step.hookId) {\n pickleStepFound ? onAfterHookFound(step) : onBeforeHookFound(step)\n } else {\n pickleStepFound = true\n }\n }\n }\n\n public getTestStepResults(testStepId: string): messages.TestStepResult[] {\n return this.testStepResultsbyTestStepId.get(testStepId)\n }\n\n public getStatusCounts(\n pickleIds: readonly string[]\n ): Partial<Record<messages.TestStepResultStatus, number>> {\n const result: Partial<Record<messages.TestStepResultStatus, number>> = {}\n for (const pickleId of pickleIds) {\n const testStepResult = getWorstTestStepResult(this.getPickleTestStepResults([pickleId]))\n const count = result[testStepResult.status] || 0\n result[testStepResult.status] = count + 1\n }\n return result\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Query.js","sourceRoot":"","sources":["../../src/Query.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA8C;AAC9C,iDAoB2B;AAC3B,kDAAgD;AAEhD,oDAA4B;AAC5B,uCAA4E;AAE5E,MAAqB,KAAK;IAA1B;QACmB,6BAAwB,GAAG,IAAI,yBAAa,EAAmC,CAAA;QAC/E,kCAA6B,GAAG,IAAI,yBAAa,EAG/D,CAAA;QACc,uBAAkB,GAAG,IAAI,GAAG,EAA6B,CAAA;QACzD,yBAAoB,GAAG,IAAI,GAAG,EAAkB,CAAA;QAChD,6BAAwB,GAAG,IAAI,GAAG,EAAkB,CAAA;QACpD,gCAA2B,GAAG,IAAI,yBAAa,EAG7D,CAAA;QACc,8BAAyB,GAAG,IAAI,yBAAa,EAAkB,CAAA;QAC/D,cAAS,GAAG,IAAI,GAAG,EAAyB,CAAA;QAC5C,4BAAuB,GAAG,IAAI,yBAAa,EAA+B,CAAA;QAC1E,0CAAqC,GAAG,IAAI,GAAG,EAG7D,CAAA;QAIc,oBAAe,GAA2B,EAAE,CAAA;QAC5C,gBAAW,GAAyB,IAAI,GAAG,EAAE,CAAA;QAC7C,aAAQ,GAAsB,IAAI,GAAG,EAAE,CAAA;QACvC,eAAU,GAAwB,IAAI,GAAG,EAAE,CAAA;QAC3C,mBAAc,GAA4B,IAAI,GAAG,EAAE,CAAA;QACnD,iBAAY,GAA0B,IAAI,GAAG,EAAE,CAAA;QAC/C,iBAAY,GAA0B,IAAI,GAAG,EAAE,CAAA;QAC/C,wCAAmC,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AAC,CAAC,CAAA;QACjD,gBAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,gDAAgD,CAAC,CAAA;QAC7E,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;IAC/C,CAAC;CACF;AA7eD,wBA6eC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport {\n Duration,\n Feature,\n getWorstTestStepResult,\n GherkinDocument,\n Pickle,\n PickleStep,\n Rule,\n Scenario,\n Step,\n TestCase,\n TestCaseFinished,\n TestCaseStarted,\n TestRunFinished,\n TestRunStarted,\n TestStep,\n TestStepFinished,\n TestStepResult,\n TestStepResultStatus,\n TimeConversion\n} from '@cucumber/messages'\nimport {ArrayMultimap} from '@teppeis/multimaps'\nimport {Lineage, NamingStrategy} from \"./Lineage\";\nimport assert from 'assert';\nimport { comparatorBy, comparatorById, comparatorByStatus } from './helpers'\n\nexport default class Query {\n private readonly testStepResultByPickleId = new ArrayMultimap<string, messages.TestStepResult>()\n private readonly testStepResultsByPickleStepId = new ArrayMultimap<\n string,\n messages.TestStepResult\n >()\n private readonly testCaseByPickleId = new Map<string, messages.TestCase>()\n private readonly pickleIdByTestStepId = new Map<string, string>()\n private readonly pickleStepIdByTestStepId = new Map<string, string>()\n private readonly testStepResultsbyTestStepId = new ArrayMultimap<\n string,\n messages.TestStepResult\n >()\n private readonly testStepIdsByPickleStepId = new ArrayMultimap<string, string>()\n private readonly hooksById = new Map<string, messages.Hook>()\n private readonly attachmentsByTestStepId = new ArrayMultimap<string, messages.Attachment>()\n private readonly stepMatchArgumentsListsByPickleStepId = new Map<\n string,\n readonly messages.StepMatchArgumentsList[]\n >()\n\n private testRunStarted: TestRunStarted\n private testRunFinished: TestRunFinished\n private readonly testCaseStarted: Array<TestCaseStarted> = []\n private readonly lineageById: Map<string, Lineage> = new Map()\n private readonly stepById: Map<string, Step> = new Map()\n private readonly pickleById: Map<string, Pickle> = new Map()\n private readonly pickleStepById: Map<string, PickleStep> = new Map()\n private readonly testCaseById: Map<string, TestCase> = new Map()\n private readonly testStepById: Map<string, TestStep> = new Map()\n private readonly testCaseFinishedByTestCaseStartedId: Map<string, TestCaseFinished> = new Map()\n private readonly testStepFinishedByTestCaseStartedId: ArrayMultimap<string, TestStepFinished> =\n new ArrayMultimap()\n\n public update(envelope: messages.Envelope) {\n if (envelope.gherkinDocument) {\n this.updateGherkinDocument(envelope.gherkinDocument)\n }\n if (envelope.pickle) {\n this.updatePickle(envelope.pickle)\n }\n if (envelope.hook) {\n this.hooksById.set(envelope.hook.id, envelope.hook)\n }\n if (envelope.testRunStarted) {\n this.testRunStarted = envelope.testRunStarted\n }\n if (envelope.testCase) {\n this.updateTestCase(envelope.testCase)\n }\n if (envelope.testCaseStarted) {\n this.updateTestCaseStarted(envelope.testCaseStarted)\n }\n if (envelope.attachment) {\n this.attachmentsByTestStepId.put(envelope.attachment.testStepId, envelope.attachment)\n }\n if (envelope.testStepFinished) {\n this.updateTestStepFinished(envelope.testStepFinished)\n }\n if (envelope.testCaseFinished) {\n this.updateTestCaseFinished(envelope.testCaseFinished)\n }\n if (envelope.testRunFinished) {\n this.testRunFinished = envelope.testRunFinished\n }\n }\n\n private updateGherkinDocument(gherkinDocument: GherkinDocument) {\n if (gherkinDocument.feature) {\n this.updateFeature(gherkinDocument.feature, {\n gherkinDocument,\n })\n }\n }\n\n private updateFeature(feature: Feature, lineage: Lineage) {\n feature.children.forEach((featureChild) => {\n if (featureChild.background) {\n this.updateSteps(featureChild.background.steps)\n }\n if (featureChild.scenario) {\n this.updateScenario(featureChild.scenario, {\n ...lineage,\n feature,\n })\n }\n if (featureChild.rule) {\n this.updateRule(featureChild.rule, {\n ...lineage,\n feature,\n })\n }\n })\n }\n\n private updateRule(rule: Rule, lineage: Lineage) {\n rule.children.forEach((ruleChild) => {\n if (ruleChild.background) {\n this.updateSteps(ruleChild.background.steps)\n }\n if (ruleChild.scenario) {\n this.updateScenario(ruleChild.scenario, {\n ...lineage,\n rule,\n })\n }\n })\n }\n\n private updateScenario(scenario: Scenario, lineage: Lineage) {\n this.lineageById.set(scenario.id, {\n ...lineage,\n scenario,\n })\n scenario.examples.forEach((examples, examplesIndex) => {\n this.lineageById.set(examples.id, {\n ...lineage,\n scenario,\n examples,\n examplesIndex,\n })\n examples.tableBody.forEach((example, exampleIndex) => {\n this.lineageById.set(example.id, {\n ...lineage,\n scenario,\n examples,\n examplesIndex,\n example,\n exampleIndex,\n })\n })\n })\n this.updateSteps(scenario.steps)\n }\n\n private updateSteps(steps: ReadonlyArray<Step>) {\n steps.forEach((step) => this.stepById.set(step.id, step))\n }\n\n private updatePickle(pickle: Pickle) {\n this.pickleById.set(pickle.id, pickle)\n pickle.steps.forEach((pickleStep) => this.pickleStepById.set(pickleStep.id, pickleStep))\n }\n\n private updateTestCase(testCase: TestCase) {\n this.testCaseById.set(testCase.id, testCase)\n\n this.testCaseByPickleId.set(testCase.pickleId, testCase)\n testCase.testSteps.forEach((testStep) => {\n this.testStepById.set(testStep.id, testStep)\n this.pickleIdByTestStepId.set(testStep.id, testCase.pickleId)\n this.pickleStepIdByTestStepId.set(testStep.id, testStep.pickleStepId)\n this.testStepIdsByPickleStepId.put(testStep.pickleStepId, testStep.id)\n this.stepMatchArgumentsListsByPickleStepId.set(\n testStep.pickleStepId,\n testStep.stepMatchArgumentsLists\n )\n })\n }\n\n private updateTestCaseStarted(testCaseStarted: TestCaseStarted) {\n this.testCaseStarted.push(testCaseStarted)\n\n /*\n when a test case attempt starts besides the first one, clear all existing results\n and attachments for that test case, so we always report on the latest attempt\n (applies to legacy pickle-oriented query methods only)\n */\n const testCase = this.testCaseById.get(testCaseStarted.testCaseId)\n this.testStepResultByPickleId.delete(testCase.pickleId)\n for (const testStep of testCase.testSteps) {\n this.testStepResultsByPickleStepId.delete(testStep.pickleStepId)\n this.testStepResultsbyTestStepId.delete(testStep.id)\n this.attachmentsByTestStepId.delete(testStep.id)\n }\n }\n\n private updateTestStepFinished(testStepFinished: TestStepFinished) {\n this.testStepFinishedByTestCaseStartedId.put(\n testStepFinished.testCaseStartedId,\n testStepFinished\n )\n\n const pickleId = this.pickleIdByTestStepId.get(testStepFinished.testStepId)\n this.testStepResultByPickleId.put(pickleId, testStepFinished.testStepResult)\n const testStep = this.testStepById.get(testStepFinished.testStepId)\n this.testStepResultsByPickleStepId.put(\n testStep.pickleStepId,\n testStepFinished.testStepResult\n )\n this.testStepResultsbyTestStepId.put(testStep.id, testStepFinished.testStepResult)\n }\n\n private updateTestCaseFinished(testCaseFinished: TestCaseFinished) {\n this.testCaseFinishedByTestCaseStartedId.set(\n testCaseFinished.testCaseStartedId,\n testCaseFinished\n )\n }\n\n /**\n * Gets all the results for multiple pickle steps\n * @param pickleStepIds\n */\n public getPickleStepTestStepResults(\n pickleStepIds: readonly string[]\n ): readonly messages.TestStepResult[] {\n if (pickleStepIds.length === 0) {\n return [\n {\n status: messages.TestStepResultStatus.UNKNOWN,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n },\n ]\n }\n return pickleStepIds.reduce((testStepResults: messages.TestStepResult[], pickleId) => {\n return testStepResults.concat(this.testStepResultsByPickleStepId.get(pickleId))\n }, [])\n }\n\n /**\n * Gets all the results for multiple pickles\n * @param pickleIds\n */\n public getPickleTestStepResults(\n pickleIds: readonly string[]\n ): readonly messages.TestStepResult[] {\n if (pickleIds.length === 0) {\n return [\n {\n status: messages.TestStepResultStatus.UNKNOWN,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n },\n ]\n }\n return pickleIds.reduce((testStepResults: messages.TestStepResult[], pickleId) => {\n return testStepResults.concat(this.testStepResultByPickleId.get(pickleId))\n }, [])\n }\n\n /**\n * Gets all the attachments for multiple pickle steps\n * @param pickleStepIds\n */\n public getPickleStepAttachments(\n pickleStepIds: readonly string[]\n ): readonly messages.Attachment[] {\n return this.getTestStepsAttachments(\n pickleStepIds.reduce((testStepIds: string[], pickleStepId: string) => {\n return testStepIds.concat(this.testStepIdsByPickleStepId.get(pickleStepId))\n }, [])\n )\n }\n\n public getTestStepsAttachments(testStepIds: readonly string[]): readonly messages.Attachment[] {\n return testStepIds.reduce((attachments: messages.Attachment[], testStepId) => {\n return attachments.concat(this.attachmentsByTestStepId.get(testStepId))\n }, [])\n }\n\n /**\n * Get StepMatchArguments for a pickle step\n * @param pickleStepId\n */\n public getStepMatchArgumentsLists(\n pickleStepId: string\n ): readonly messages.StepMatchArgumentsList[] | undefined {\n return this.stepMatchArgumentsListsByPickleStepId.get(pickleStepId)\n }\n\n public getHook(hookId: string): messages.Hook {\n return this.hooksById.get(hookId)\n }\n\n public getBeforeHookSteps(pickleId: string): readonly messages.TestStep[] {\n const hookSteps: messages.TestStep[] = []\n\n this.identifyHookSteps(\n pickleId,\n (hook) => hookSteps.push(hook),\n () => null\n )\n return hookSteps\n }\n\n public getAfterHookSteps(pickleId: string): readonly messages.TestStep[] {\n const hookSteps: messages.TestStep[] = []\n\n this.identifyHookSteps(\n pickleId,\n () => null,\n (hook) => hookSteps.push(hook)\n )\n return hookSteps\n }\n\n private identifyHookSteps(\n pickleId: string,\n onBeforeHookFound: (hook: messages.TestStep) => void,\n onAfterHookFound: (hook: messages.TestStep) => void\n ): void {\n const testCase = this.testCaseByPickleId.get(pickleId)\n\n if (!testCase) {\n return\n }\n\n let pickleStepFound = false\n\n for (const step of testCase.testSteps) {\n if (step.hookId) {\n pickleStepFound ? onAfterHookFound(step) : onBeforeHookFound(step)\n } else {\n pickleStepFound = true\n }\n }\n }\n\n public getTestStepResults(testStepId: string): messages.TestStepResult[] {\n return this.testStepResultsbyTestStepId.get(testStepId)\n }\n\n public getStatusCounts(\n pickleIds: readonly string[]\n ): Partial<Record<messages.TestStepResultStatus, number>> {\n const result: Partial<Record<messages.TestStepResultStatus, number>> = {}\n for (const pickleId of pickleIds) {\n const testStepResult = getWorstTestStepResult(this.getPickleTestStepResults([pickleId]))\n const count = result[testStepResult.status] || 0\n result[testStepResult.status] = count + 1\n }\n return result\n }\n\n /* new common interface with Java starts here */\n\n public countMostSevereTestStepResultStatus(): Record<TestStepResultStatus, number> {\n const result: Record<TestStepResultStatus, number> = {\n [TestStepResultStatus.AMBIGUOUS]: 0,\n [TestStepResultStatus.FAILED]: 0,\n [TestStepResultStatus.PASSED]: 0,\n [TestStepResultStatus.PENDING]: 0,\n [TestStepResultStatus.SKIPPED]: 0,\n [TestStepResultStatus.UNDEFINED]: 0,\n [TestStepResultStatus.UNKNOWN]: 0,\n }\n for (const testCaseStarted of this.findAllTestCaseStarted()) {\n const mostSevereResult = this.findTestStepFinishedAndTestStepBy(testCaseStarted)\n .map(([testStepFinished]) => testStepFinished.testStepResult)\n .sort(comparatorByStatus)\n .at(-1)\n if (mostSevereResult) {\n result[mostSevereResult.status]++\n }\n }\n return result\n }\n\n public countTestCasesStarted(): number {\n return this.findAllTestCaseStarted().length\n }\n\n public findAllPickles(): ReadonlyArray<Pickle> {\n const pickles = [...this.pickleById.values()]\n return pickles.sort(comparatorById)\n }\n\n public findAllPickleSteps(): ReadonlyArray<PickleStep> {\n const pickleSteps = [...this.pickleStepById.values()]\n return pickleSteps.sort(comparatorById)\n }\n\n public findAllTestCaseStarted(): ReadonlyArray<TestCaseStarted> {\n return this.testCaseStarted.filter((testCaseStarted) => {\n const testCaseFinished = this.testCaseFinishedByTestCaseStartedId.get(testCaseStarted.id)\n // only include if not yet finished OR won't be retried\n return !testCaseFinished?.willBeRetried\n })\n }\n\n public findAllTestCaseStartedGroupedByFeature(): Map<Feature | undefined, ReadonlyArray<TestCaseStarted>> {\n const results = new Map();\n this.findAllTestCaseStarted()\n .map(testCaseStarted => ([this.findLineageBy(testCaseStarted), testCaseStarted] as const))\n .sort(([a], [b]) => comparatorBy(a.gherkinDocument, b.gherkinDocument, \"uri\"))\n .forEach(([{feature}, testCaseStarted]) => {\n results.set(feature, [...results.get(feature) ?? [], testCaseStarted])\n })\n return results\n }\n\n public findAllTestSteps(): ReadonlyArray<TestStep> {\n const testSteps = [...this.testStepById.values()]\n return testSteps.sort(comparatorById)\n }\n\n public findFeatureBy(testCaseStarted: TestCaseStarted): Feature | undefined {\n return this.findLineageBy(testCaseStarted)?.feature\n }\n\n public findMostSevereTestStepResultBy(testCaseStarted: TestCaseStarted): TestStepResult | undefined {\n return this.findTestStepFinishedAndTestStepBy(testCaseStarted)\n .map(([testStepFinished]) => testStepFinished.testStepResult)\n .sort(comparatorByStatus)\n .at(-1)\n }\n\n public findNameOf(pickle: Pickle, namingStrategy: NamingStrategy): string {\n const lineage = this.findLineageBy(pickle)\n return lineage ? namingStrategy.reduce(lineage, pickle) : pickle.name\n }\n\n public findPickleBy(testCaseStarted: TestCaseStarted): Pickle | undefined {\n const testCase = this.findTestCaseBy(testCaseStarted)\n assert.ok(testCase, 'Expected to find TestCase from TestCaseStarted')\n return this.pickleById.get(testCase.pickleId)\n }\n\n public findPickleStepBy(testStep: TestStep): PickleStep | undefined {\n assert.ok(testStep.pickleStepId, 'Expected TestStep to have a pickleStepId')\n return this.pickleStepById.get(testStep.pickleStepId)\n }\n\n public findStepBy(pickleStep: PickleStep): Step | undefined {\n const [astNodeId] = pickleStep.astNodeIds\n assert.ok('Expected PickleStep to have an astNodeId')\n return this.stepById.get(astNodeId)\n }\n\n public findTestCaseBy(testCaseStarted: TestCaseStarted): TestCase | undefined {\n return this.testCaseById.get(testCaseStarted.testCaseId)\n }\n\n public findTestCaseDurationBy(testCaseStarted: TestCaseStarted): Duration | undefined {\n const testCaseFinished = this.findTestCaseFinishedBy(testCaseStarted)\n if (!testCaseFinished) {\n return undefined\n }\n return TimeConversion.millisecondsToDuration(\n TimeConversion.timestampToMillisecondsSinceEpoch(testCaseFinished.timestamp) -\n TimeConversion.timestampToMillisecondsSinceEpoch(testCaseStarted.timestamp)\n )\n }\n\n public findTestCaseFinishedBy(testCaseStarted: TestCaseStarted): TestCaseFinished | undefined {\n return this.testCaseFinishedByTestCaseStartedId.get(testCaseStarted.id)\n }\n\n public findTestRunDuration(): Duration | undefined {\n if (!this.testRunStarted || !this.testRunFinished) {\n return undefined\n }\n return TimeConversion.millisecondsToDuration(\n TimeConversion.timestampToMillisecondsSinceEpoch(this.testRunFinished.timestamp) -\n TimeConversion.timestampToMillisecondsSinceEpoch(this.testRunStarted.timestamp)\n )\n }\n\n public findTestRunFinished(): TestRunFinished | undefined {\n return this.testRunFinished\n }\n\n public findTestRunStarted(): TestRunStarted | undefined {\n return this.testRunStarted\n }\n\n public findTestStepBy(testStepFinished: TestStepFinished): TestStep | undefined {\n return this.testStepById.get(testStepFinished.testStepId)\n }\n\n public findTestStepsFinishedBy(testCaseStarted: TestCaseStarted): ReadonlyArray<TestStepFinished> {\n // multimaps `get` implements `getOrDefault([])` behaviour internally\n return [...this.testStepFinishedByTestCaseStartedId.get(testCaseStarted.id)]\n }\n\n public findTestStepFinishedAndTestStepBy(\n testCaseStarted: TestCaseStarted\n ): ReadonlyArray<[TestStepFinished, TestStep]> {\n return this.testStepFinishedByTestCaseStartedId\n .get(testCaseStarted.id)\n .map((testStepFinished) => {\n const testStep = this.findTestStepBy(testStepFinished)\n assert.ok(testStep, 'Expected to find TestStep by TestStepFinished')\n return [testStepFinished, testStep]\n })\n }\n\n private findLineageBy(element: Pickle | TestCaseStarted) {\n const pickle = \"testCaseId\" in element ? this.findPickleBy(element) : element\n const deepestAstNodeId = pickle.astNodeIds.at(-1)\n assert.ok(deepestAstNodeId, 'Expected Pickle to have at least one astNodeId')\n return this.lineageById.get(deepestAstNodeId)\n }\n}\n"]}
|