testit-adapter-cucumber 1.1.7 → 2.0.0
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/README.md +20 -31
- package/dist/formatter.d.ts +12 -24
- package/dist/formatter.js +54 -144
- package/dist/formatter.js.map +1 -1
- package/dist/mappers.d.ts +9 -13
- package/dist/mappers.js +33 -66
- package/dist/mappers.js.map +1 -1
- package/dist/storage.d.ts +9 -11
- package/dist/storage.js +32 -43
- package/dist/storage.js.map +1 -1
- package/dist/types/formatter.type.d.ts +11 -0
- package/dist/types/{storage.js → formatter.type.js} +1 -1
- package/dist/types/formatter.type.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +20 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/{storage.d.ts → storage.type.d.ts} +7 -8
- package/dist/types/{formatter.js → storage.type.js} +1 -1
- package/dist/types/storage.type.js.map +1 -0
- package/dist/types/{tags.d.ts → tags.type.d.ts} +3 -3
- package/dist/types/{tags.js → tags.type.js} +10 -10
- package/dist/types/tags.type.js.map +1 -0
- package/dist/utils.d.ts +7 -8
- package/dist/utils.js +63 -70
- package/dist/utils.js.map +1 -1
- package/package.json +6 -3
- package/.eslintignore +0 -2
- package/.eslintrc.json +0 -27
- package/.prettierrc +0 -9
- package/dist/types/formatter.d.ts +0 -25
- package/dist/types/formatter.js.map +0 -1
- package/dist/types/storage.js.map +0 -1
- package/dist/types/tags.js.map +0 -1
- package/dist/types/world.d.ts +0 -7
- package/dist/types/world.js +0 -3
- package/dist/types/world.js.map +0 -1
- package/src/formatter.ts +0 -285
- package/src/mappers.ts +0 -181
- package/src/storage.ts +0 -212
- package/src/types/formatter.ts +0 -37
- package/src/types/storage.ts +0 -27
- package/src/types/tags.ts +0 -39
- package/src/types/world.ts +0 -8
- package/src/utils.ts +0 -162
- package/tsconfig.json +0 -101
package/README.md
CHANGED
|
@@ -10,13 +10,6 @@ npm install testit-adapter-cucumber
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
### API client
|
|
14
|
-
|
|
15
|
-
To use adapter you need to install `testit-api-client`:
|
|
16
|
-
```
|
|
17
|
-
npm install testit-api-client
|
|
18
|
-
```
|
|
19
|
-
|
|
20
13
|
### Configuration
|
|
21
14
|
|
|
22
15
|
| Description | Property | Environment variable | CLI argument |
|
|
@@ -27,21 +20,17 @@ npm install testit-api-client
|
|
|
27
20
|
| ID of configuration in TMS instance [How to getting configuration ID?](https://github.com/testit-tms/.github/tree/main/configuration#configurationid) | configurationId | TMS_CONFIGURATION_ID | tmsConfigurationId |
|
|
28
21
|
| ID of the created test run in TMS instance | testRunId | TMS_TEST_RUN_ID | tmsTestRunId |
|
|
29
22
|
|
|
30
|
-
Create `
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
testRunId: 'TEST_RUN_ID',
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
};
|
|
23
|
+
Create `tms.config.json` file in the root directory of the project:
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"url": "Url",
|
|
27
|
+
"privateToken": "Private_token",
|
|
28
|
+
"projectId": "Project_id",
|
|
29
|
+
"configurationId": "Configuration_id",
|
|
30
|
+
"testRunName": "Test_run_name",
|
|
31
|
+
"adapterMode": 2,
|
|
32
|
+
"automaticCreationTestCases": false
|
|
33
|
+
}
|
|
45
34
|
```
|
|
46
35
|
|
|
47
36
|
And fill object with your configuration. Formatter sends results to Test IT.
|
|
@@ -53,7 +42,7 @@ Add to `cucumber.js` file
|
|
|
53
42
|
```js
|
|
54
43
|
module.exports = {
|
|
55
44
|
default:
|
|
56
|
-
'-f
|
|
45
|
+
'-f testit-adapter-cucumber',
|
|
57
46
|
};
|
|
58
47
|
```
|
|
59
48
|
|
|
@@ -92,9 +81,9 @@ Cucumber tags can be used to specify information about autotest.
|
|
|
92
81
|
- `@Title` - Title that is displayed on autotest page
|
|
93
82
|
- `@DisplayName` - Name that is displayed in autotests table
|
|
94
83
|
- `@Description` - Autotest description
|
|
95
|
-
- `@
|
|
96
|
-
- `@
|
|
97
|
-
- `@
|
|
84
|
+
- `@Links` - can be specified either in JSON (`@Link={"url":"http://google.com","hasInfo":true,"description":"GoogleDescription","title":"Google","type":"Defect"}`) or in text (`@Link=http://google.com`)
|
|
85
|
+
- `@Labels` - Label that is going to be linked to autotest
|
|
86
|
+
- `@WorkItemIds` - Work item's ID to which autotest is going to be linked
|
|
98
87
|
- `@NameSpace` - directory in the TMS system
|
|
99
88
|
- `@ClassName` - subdirectory in the TMS system
|
|
100
89
|
|
|
@@ -106,16 +95,16 @@ Feature: Tags
|
|
|
106
95
|
@DisplayName=GoogiliGoogle
|
|
107
96
|
@Description=Cannot_Write_With_Spaces
|
|
108
97
|
@ExternalId=344
|
|
109
|
-
@
|
|
110
|
-
@
|
|
111
|
-
@
|
|
112
|
-
@
|
|
98
|
+
@Links=http://google.com
|
|
99
|
+
@Links=http://vk.com
|
|
100
|
+
@Labels=Maths
|
|
101
|
+
@Labels=School
|
|
113
102
|
Scenario: Scenario with links
|
|
114
103
|
When 2+2
|
|
115
104
|
Then Result is 4
|
|
116
105
|
@Title=LINKS
|
|
117
106
|
@ExternalId=343
|
|
118
|
-
@
|
|
107
|
+
@Links={"url":"http://google.com","hasInfo":true,"description":"GoogleDescription","title":"Google","type":"Defect"}
|
|
119
108
|
Scenario: Scenario with link obj
|
|
120
109
|
When 2+2
|
|
121
110
|
Then Result is 4
|
package/dist/formatter.d.ts
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
currentTestCaseId: string | undefined;
|
|
11
|
-
resolvedAutotests: Array<string | undefined> | undefined;
|
|
12
|
-
constructor(options: IFormatterOptions, config: Partial<ClientConfigWithFile>);
|
|
13
|
-
private testRunId;
|
|
14
|
-
private testRunStarted;
|
|
1
|
+
import { Link } from "testit-js-commons";
|
|
2
|
+
import { Formatter, IFormatterOptions } from "@cucumber/cucumber";
|
|
3
|
+
import { GherkinDocument, Pickle, TestCase, TestStepFinished, TestRunFinished, TestCaseStarted, TestCaseFinished, TestStepStarted } from "@cucumber/messages";
|
|
4
|
+
import { IFormatter } from "./types";
|
|
5
|
+
export default class TestItFormatter extends Formatter implements IFormatter {
|
|
6
|
+
private readonly client;
|
|
7
|
+
private readonly strategy;
|
|
8
|
+
private readonly storage;
|
|
9
|
+
private currentTestCaseId;
|
|
15
10
|
private attachmentsQueue;
|
|
16
|
-
|
|
11
|
+
constructor(options: IFormatterOptions);
|
|
17
12
|
onGherkinDocument(document: GherkinDocument): void;
|
|
18
13
|
onPickle(pickle: Pickle): void;
|
|
19
14
|
onTestCase(testCase: TestCase): void;
|
|
@@ -21,15 +16,8 @@ export declare class TestItFormatter extends Formatter implements IFormatter {
|
|
|
21
16
|
testStepStarted(testStepStarted: TestStepStarted): void;
|
|
22
17
|
onTestStepFinished(testStepFinished: TestStepFinished): void;
|
|
23
18
|
testCaseFinished(testCaseFinished: TestCaseFinished): void;
|
|
24
|
-
onTestRunFinished(_testRunFinished: TestRunFinished): void
|
|
25
|
-
loadAutotest(autotestPost: AutotestPostWithWorkItemId): Promise<void>;
|
|
26
|
-
loadPassedAutotest(autotestPost: AutotestPostWithWorkItemId): Promise<void>;
|
|
27
|
-
createTestRun(): void;
|
|
28
|
-
createNewAutotest(autotestPost: AutotestPostWithWorkItemId): Promise<void>;
|
|
29
|
-
updateAutotest(autotestPost: AutotestPostWithWorkItemId): Promise<void>;
|
|
30
|
-
linkWorkItem(externalId: string, workItemId: string): Promise<void>;
|
|
19
|
+
onTestRunFinished(_testRunFinished: TestRunFinished): Promise<void>;
|
|
31
20
|
addMessage(message: string): void;
|
|
32
|
-
addLinks(links:
|
|
21
|
+
addLinks(links: Link[]): void;
|
|
33
22
|
addAttachments(attachments: string[]): void;
|
|
34
|
-
private logError;
|
|
35
23
|
}
|
package/dist/formatter.js
CHANGED
|
@@ -1,31 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
12
|
+
const testit_js_commons_1 = require("testit-js-commons");
|
|
4
13
|
const cucumber_1 = require("@cucumber/cucumber");
|
|
5
|
-
const testit_api_client_1 = require("testit-api-client");
|
|
6
14
|
const storage_1 = require("./storage");
|
|
7
15
|
const utils_1 = require("./utils");
|
|
8
16
|
class TestItFormatter extends cucumber_1.Formatter {
|
|
9
|
-
constructor(options
|
|
17
|
+
constructor(options) {
|
|
10
18
|
super(options);
|
|
11
|
-
this.storage = new storage_1.Storage();
|
|
12
19
|
this.attachmentsQueue = [];
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
const config = new testit_js_commons_1.ConfigComposer().compose(options.parsedArgvOptions);
|
|
21
|
+
this.client = new testit_js_commons_1.Client(config);
|
|
22
|
+
this.storage = new storage_1.Storage();
|
|
23
|
+
this.strategy = testit_js_commons_1.StrategyFactory.create(this.client, config);
|
|
24
|
+
options.eventBroadcaster.on("envelope", (envelope) => __awaiter(this, void 0, void 0, function* () {
|
|
18
25
|
if (envelope.gherkinDocument) {
|
|
19
26
|
return this.onGherkinDocument(envelope.gherkinDocument);
|
|
20
27
|
}
|
|
21
28
|
if (envelope.pickle) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
const testsInRun = yield this.strategy.testsInRun;
|
|
30
|
+
const resolvedAutotests = testsInRun === null || testsInRun === void 0 ? void 0 : testsInRun.map((test) => { var _a; return (_a = test.autoTest) === null || _a === void 0 ? void 0 : _a.externalId; }).filter((id) => id !== undefined);
|
|
31
|
+
if (resolvedAutotests !== undefined) {
|
|
32
|
+
const tags = (0, utils_1.parseTags)(envelope.pickle.tags);
|
|
33
|
+
for (const externalId of resolvedAutotests) {
|
|
34
|
+
if (externalId === tags.externalId) {
|
|
35
|
+
return this.onPickle(envelope.pickle);
|
|
29
36
|
}
|
|
30
37
|
}
|
|
31
38
|
envelope.pickle = undefined;
|
|
@@ -35,9 +42,6 @@ class TestItFormatter extends cucumber_1.Formatter {
|
|
|
35
42
|
}
|
|
36
43
|
}
|
|
37
44
|
if (envelope.testCase) {
|
|
38
|
-
if (this.testRunId === undefined && this.storage.isResolvedTestCase(envelope.testCase)) {
|
|
39
|
-
this.createTestRun();
|
|
40
|
-
}
|
|
41
45
|
return this.onTestCase(envelope.testCase);
|
|
42
46
|
}
|
|
43
47
|
if (envelope.testCaseStarted) {
|
|
@@ -55,21 +59,10 @@ class TestItFormatter extends cucumber_1.Formatter {
|
|
|
55
59
|
if (envelope.testRunFinished) {
|
|
56
60
|
return this.onTestRunFinished(envelope.testRunFinished);
|
|
57
61
|
}
|
|
58
|
-
});
|
|
59
|
-
options.supportCodeLibrary.World.prototype.addMessage =
|
|
60
|
-
|
|
61
|
-
options.supportCodeLibrary.World.prototype.
|
|
62
|
-
this.addLinks.bind(this);
|
|
63
|
-
options.supportCodeLibrary.World.prototype.addAttachments =
|
|
64
|
-
this.addAttachments.bind(this);
|
|
65
|
-
}
|
|
66
|
-
onMeta(_meta) {
|
|
67
|
-
const { testRunId, configurationId } = this.client.getConfig();
|
|
68
|
-
if (testRunId !== undefined) {
|
|
69
|
-
this.testRunId = Promise.resolve(testRunId);
|
|
70
|
-
const responce = this.client.getTestRun(testRunId);
|
|
71
|
-
this.resolvedAutotests = (0, utils_1.parsedAutotests)(responce.testResults, configurationId);
|
|
72
|
-
}
|
|
62
|
+
}));
|
|
63
|
+
options.supportCodeLibrary.World.prototype.addMessage = this.addMessage.bind(this);
|
|
64
|
+
options.supportCodeLibrary.World.prototype.addLinks = this.addLinks.bind(this);
|
|
65
|
+
options.supportCodeLibrary.World.prototype.addAttachments = this.addAttachments.bind(this);
|
|
73
66
|
}
|
|
74
67
|
onGherkinDocument(document) {
|
|
75
68
|
this.storage.saveGherkinDocument(document);
|
|
@@ -95,131 +88,48 @@ class TestItFormatter extends cucumber_1.Formatter {
|
|
|
95
88
|
this.storage.saveTestCaseFinished(testCaseFinished);
|
|
96
89
|
}
|
|
97
90
|
onTestRunFinished(_testRunFinished) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
return this.loadPassedAutotest(autotestPost);
|
|
114
|
-
}
|
|
115
|
-
}));
|
|
116
|
-
await Promise.all(results.map((result) => {
|
|
117
|
-
return this.client.loadTestRunResults(id, [result]);
|
|
118
|
-
}));
|
|
119
|
-
})
|
|
120
|
-
.catch((err) => {
|
|
121
|
-
var _a;
|
|
122
|
-
console.error(err);
|
|
123
|
-
(_a = this.testRunId) === null || _a === void 0 ? void 0 : _a.then((id) => this.client.completeTestRun(id));
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
async loadAutotest(autotestPost) {
|
|
128
|
-
var _a;
|
|
129
|
-
try {
|
|
130
|
-
await this.createNewAutotest(autotestPost);
|
|
131
|
-
}
|
|
132
|
-
catch (err) {
|
|
133
|
-
const axiosError = err;
|
|
134
|
-
if (((_a = axiosError.response) === null || _a === void 0 ? void 0 : _a.status) === 409) {
|
|
135
|
-
const [autotest] = await this.client.getAutotest({
|
|
136
|
-
projectId: this.client.getConfig().projectId,
|
|
137
|
-
externalId: autotestPost.externalId,
|
|
138
|
-
});
|
|
139
|
-
await this.updateAutotest(Object.assign(Object.assign({}, autotest), { links: autotestPost.links }));
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
this.logError(axiosError);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
async loadPassedAutotest(autotestPost) {
|
|
147
|
-
var _a;
|
|
148
|
-
try {
|
|
149
|
-
await this.createNewAutotest(autotestPost);
|
|
150
|
-
}
|
|
151
|
-
catch (err) {
|
|
152
|
-
const axiosError = err;
|
|
153
|
-
if (((_a = axiosError.response) === null || _a === void 0 ? void 0 : _a.status) === 409) {
|
|
154
|
-
await this.updateAutotest(autotestPost);
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
this.logError(axiosError);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
if (autotestPost.workItemId !== undefined) {
|
|
161
|
-
this.linkWorkItem(autotestPost.externalId, autotestPost.workItemId);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
createTestRun() {
|
|
165
|
-
const { projectId } = this.client.getConfig();
|
|
166
|
-
this.testRunId = this.client
|
|
167
|
-
.createTestRun({
|
|
168
|
-
projectId,
|
|
169
|
-
})
|
|
170
|
-
.then((testRun) => testRun.id);
|
|
171
|
-
}
|
|
172
|
-
async createNewAutotest(autotestPost) {
|
|
173
|
-
autotestPost.shouldCreateWorkItem = this.client.getConfig().automaticCreationTestCases;
|
|
174
|
-
await this.client.createAutotest(autotestPost);
|
|
175
|
-
}
|
|
176
|
-
async updateAutotest(autotestPost) {
|
|
177
|
-
await this.client.updateAutotest(autotestPost).catch(this.logError);
|
|
178
|
-
}
|
|
179
|
-
async linkWorkItem(externalId, workItemId) {
|
|
180
|
-
const [autotest] = await this.client
|
|
181
|
-
.getAutotest({
|
|
182
|
-
projectId: this.client.getConfig().projectId,
|
|
183
|
-
externalId: externalId,
|
|
184
|
-
})
|
|
185
|
-
.catch(() => []);
|
|
186
|
-
if ((autotest === null || autotest === void 0 ? void 0 : autotest.id) !== undefined) {
|
|
187
|
-
await this.client.linkToWorkItem(autotest.id, {
|
|
188
|
-
id: workItemId,
|
|
189
|
-
});
|
|
190
|
-
}
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
yield this.strategy.testRunId;
|
|
93
|
+
yield Promise.all(this.attachmentsQueue);
|
|
94
|
+
const results = this.storage.getTestRunResults();
|
|
95
|
+
const autotests = this.storage.getAutotests();
|
|
96
|
+
yield Promise.all(autotests.map((autotestPost) => {
|
|
97
|
+
const result = results.find((result) => result.autoTestExternalId === autotestPost.externalId);
|
|
98
|
+
if (result !== undefined) {
|
|
99
|
+
return this.strategy.loadAutotest(autotestPost, result.outcome === "Passed");
|
|
100
|
+
}
|
|
101
|
+
}));
|
|
102
|
+
yield this.strategy.loadTestRun(results);
|
|
103
|
+
yield this.strategy.teardown();
|
|
104
|
+
});
|
|
191
105
|
}
|
|
192
106
|
addMessage(message) {
|
|
193
107
|
if (this.currentTestCaseId === undefined) {
|
|
194
|
-
throw new Error(
|
|
108
|
+
throw new Error("CurrentTestCaseId is not set");
|
|
195
109
|
}
|
|
196
110
|
this.storage.addMessage(this.currentTestCaseId, message);
|
|
197
111
|
}
|
|
198
112
|
addLinks(links) {
|
|
199
113
|
if (this.currentTestCaseId === undefined) {
|
|
200
|
-
throw new Error(
|
|
114
|
+
throw new Error("CurrentTestCaseId is not set");
|
|
201
115
|
}
|
|
202
116
|
this.storage.addLinks(this.currentTestCaseId, links);
|
|
203
117
|
}
|
|
204
118
|
addAttachments(attachments) {
|
|
205
119
|
if (this.currentTestCaseId === undefined) {
|
|
206
|
-
throw new Error(
|
|
120
|
+
throw new Error("CurrentTestCaseId is not a set");
|
|
207
121
|
}
|
|
208
122
|
const currentTestCaseId = this.currentTestCaseId;
|
|
209
|
-
this.
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
logError(err) {
|
|
220
|
-
var _a, _b;
|
|
221
|
-
console.error((_a = err.response) === null || _a === void 0 ? void 0 : _a.status, err.config.method, err.config.url, (_b = err.response) === null || _b === void 0 ? void 0 : _b.data);
|
|
123
|
+
const promise = this.client.attachments
|
|
124
|
+
.uploadAttachments(attachments)
|
|
125
|
+
.then((ids) => {
|
|
126
|
+
this.storage.addAttachments(currentTestCaseId, ids);
|
|
127
|
+
})
|
|
128
|
+
.catch((err) => {
|
|
129
|
+
console.log("Error load attachments: \n", attachments, "\n", err);
|
|
130
|
+
});
|
|
131
|
+
this.attachmentsQueue.push(promise);
|
|
222
132
|
}
|
|
223
133
|
}
|
|
224
|
-
exports.
|
|
134
|
+
exports.default = TestItFormatter;
|
|
225
135
|
//# sourceMappingURL=formatter.js.map
|
package/dist/formatter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,yDAAqH;AACrH,iDAAkE;AAalE,uCAAoC;AACpC,mCAAoC;AAEpC,MAAqB,eAAgB,SAAQ,oBAAS;IAQpD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHT,qBAAgB,GAAoB,E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,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACb,OAAO,CAAC,GAAG,CAAC,4BAA4B,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;QAEL,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;CACF;AAzJD,kCAyJC"}
|
package/dist/mappers.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { Background, DataTable, Examples, GherkinDocument, Rule, Scenario, Step
|
|
2
|
-
import { AutotestPost,
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function mapRule(rule: Rule, projectId: string, setup: AutotestStep[]): AutotestPostWithWorkItemId[];
|
|
11
|
-
export declare function mapScenario(scenario: Scenario, projectId: string, setup: AutotestStep[]): AutotestPostWithWorkItemId;
|
|
12
|
-
export declare function mapExamples(examples: Examples): AutotestStep;
|
|
13
|
-
export declare function mapStep(step: Step): AutotestStep;
|
|
1
|
+
import { Background, DataTable, Examples, GherkinDocument, Rule, Scenario, Step as CucumberStep } from "@cucumber/messages";
|
|
2
|
+
import { AutotestPost, ShortStep } from "testit-js-commons";
|
|
3
|
+
export declare function mapDate(date: number): Date;
|
|
4
|
+
export declare function mapDocument(document: GherkinDocument): AutotestPost[];
|
|
5
|
+
export declare function mapBackground(background: Background): ShortStep;
|
|
6
|
+
export declare function mapRule(rule: Rule, setup: ShortStep[]): AutotestPost[];
|
|
7
|
+
export declare function mapScenario(scenario: Scenario, setup: ShortStep[]): AutotestPost;
|
|
8
|
+
export declare function mapExamples(examples: Examples): ShortStep;
|
|
9
|
+
export declare function mapStep(step: CucumberStep): ShortStep;
|
|
14
10
|
export declare function mapDataTable(dataTable: DataTable | undefined): string | undefined;
|
package/dist/mappers.js
CHANGED
|
@@ -1,47 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapDataTable = exports.mapStep = exports.mapExamples = exports.mapScenario = exports.mapRule = exports.mapBackground = exports.mapDocument = exports.mapDate =
|
|
4
|
-
const messages_1 = require("@cucumber/messages");
|
|
3
|
+
exports.mapDataTable = exports.mapStep = exports.mapExamples = exports.mapScenario = exports.mapRule = exports.mapBackground = exports.mapDocument = exports.mapDate = void 0;
|
|
5
4
|
const utils_1 = require("./utils");
|
|
6
|
-
|
|
7
|
-
switch (status) {
|
|
8
|
-
case messages_1.TestStepResultStatus.PASSED:
|
|
9
|
-
return 'Passed';
|
|
10
|
-
case messages_1.TestStepResultStatus.FAILED:
|
|
11
|
-
return 'Failed';
|
|
12
|
-
case messages_1.TestStepResultStatus.PENDING:
|
|
13
|
-
return 'Pending';
|
|
14
|
-
case messages_1.TestStepResultStatus.SKIPPED:
|
|
15
|
-
return 'Skipped';
|
|
16
|
-
case messages_1.TestStepResultStatus.UNKNOWN:
|
|
17
|
-
case messages_1.TestStepResultStatus.UNDEFINED:
|
|
18
|
-
case messages_1.TestStepResultStatus.AMBIGUOUS:
|
|
19
|
-
return 'Blocked';
|
|
20
|
-
default:
|
|
21
|
-
throw new Error('Unknown status');
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.mapStatus = mapStatus;
|
|
5
|
+
const testit_js_commons_1 = require("testit-js-commons");
|
|
25
6
|
function mapDate(date) {
|
|
26
|
-
return new Date(date * 1000)
|
|
7
|
+
return new Date(date * 1000);
|
|
27
8
|
}
|
|
28
9
|
exports.mapDate = mapDate;
|
|
29
|
-
function mapDocument(document
|
|
10
|
+
function mapDocument(document) {
|
|
30
11
|
if (document.feature === undefined) {
|
|
31
12
|
return [];
|
|
32
13
|
}
|
|
33
14
|
const setup = document.feature.children
|
|
34
|
-
.
|
|
35
|
-
|
|
36
|
-
.map((
|
|
15
|
+
.map((child) => child.background)
|
|
16
|
+
.filter((background) => background !== undefined)
|
|
17
|
+
.map((background) => mapBackground(background));
|
|
37
18
|
const scenarioAutotests = document.feature.children
|
|
38
|
-
.
|
|
39
|
-
|
|
40
|
-
.map((
|
|
19
|
+
.map((child) => child.scenario)
|
|
20
|
+
.filter((scenario) => scenario !== undefined)
|
|
21
|
+
.map((scenario) => mapScenario(scenario, setup));
|
|
41
22
|
const ruleAutotests = document.feature.children
|
|
42
|
-
.
|
|
43
|
-
|
|
44
|
-
.flatMap((
|
|
23
|
+
.map((child) => child.rule)
|
|
24
|
+
.filter((rule) => rule !== undefined)
|
|
25
|
+
.flatMap((rule) => mapRule(rule, setup));
|
|
45
26
|
return scenarioAutotests.concat(...ruleAutotests);
|
|
46
27
|
}
|
|
47
28
|
exports.mapDocument = mapDocument;
|
|
@@ -53,52 +34,40 @@ function mapBackground(background) {
|
|
|
53
34
|
};
|
|
54
35
|
}
|
|
55
36
|
exports.mapBackground = mapBackground;
|
|
56
|
-
function mapRule(rule,
|
|
37
|
+
function mapRule(rule, setup) {
|
|
57
38
|
const ruleSetup = setup.concat(rule.children
|
|
58
|
-
.
|
|
59
|
-
|
|
60
|
-
.map((
|
|
61
|
-
return
|
|
62
|
-
.
|
|
63
|
-
|
|
64
|
-
.map((
|
|
39
|
+
.map((child) => child.background)
|
|
40
|
+
.filter((background) => background !== undefined)
|
|
41
|
+
.map((background) => mapBackground(background)));
|
|
42
|
+
return rule.children
|
|
43
|
+
.map((child) => child.scenario)
|
|
44
|
+
.filter((scenario) => scenario !== undefined)
|
|
45
|
+
.map((scenario) => mapScenario(scenario, ruleSetup));
|
|
65
46
|
}
|
|
66
47
|
exports.mapRule = mapRule;
|
|
67
|
-
function mapScenario(scenario,
|
|
68
|
-
var _a, _b;
|
|
48
|
+
function mapScenario(scenario, setup) {
|
|
49
|
+
var _a, _b, _c, _d, _e;
|
|
69
50
|
const tags = (0, utils_1.parseTags)(scenario.tags);
|
|
70
|
-
if (tags.externalId === undefined) {
|
|
71
|
-
return {
|
|
72
|
-
externalId: '',
|
|
73
|
-
name: scenario.name,
|
|
74
|
-
projectId
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
51
|
const exampleSteps = scenario.examples.map(mapExamples);
|
|
78
52
|
return {
|
|
79
53
|
setup: exampleSteps.concat(setup),
|
|
80
|
-
externalId: tags.externalId,
|
|
54
|
+
externalId: (_a = tags.externalId) !== null && _a !== void 0 ? _a : testit_js_commons_1.Utils.getHash((_b = tags.name) !== null && _b !== void 0 ? _b : scenario.name),
|
|
81
55
|
links: tags.links,
|
|
82
|
-
name: (
|
|
56
|
+
name: (_c = tags.name) !== null && _c !== void 0 ? _c : scenario.name,
|
|
83
57
|
title: tags.title,
|
|
84
|
-
description: (
|
|
85
|
-
projectId,
|
|
58
|
+
description: (_d = tags.description) !== null && _d !== void 0 ? _d : scenario.description,
|
|
86
59
|
steps: scenario.steps.map(mapStep),
|
|
87
|
-
|
|
60
|
+
workItemIds: tags.workItemIds,
|
|
88
61
|
namespace: tags.nameSpace,
|
|
89
62
|
classname: tags.className,
|
|
90
|
-
|
|
91
|
-
// labels:
|
|
92
|
-
// tags.labels.length > 0
|
|
93
|
-
// ? tags.labels.map((label) => ({ name: label }))
|
|
94
|
-
// : undefined,
|
|
63
|
+
labels: (_e = tags.labels) === null || _e === void 0 ? void 0 : _e.map((label) => ({ name: label })),
|
|
95
64
|
};
|
|
96
65
|
}
|
|
97
66
|
exports.mapScenario = mapScenario;
|
|
98
67
|
//TODO: Implement using "parameters" fields
|
|
99
68
|
function mapExamples(examples) {
|
|
100
69
|
var _a, _b, _c, _d;
|
|
101
|
-
let table
|
|
70
|
+
let table;
|
|
102
71
|
const body = examples.tableBody.map((row) => row.cells.map((cell) => cell.value));
|
|
103
72
|
if (examples.tableHeader !== undefined) {
|
|
104
73
|
const header = (_a = examples.tableHeader) === null || _a === void 0 ? void 0 : _a.cells.map((cell) => cell.value);
|
|
@@ -112,12 +81,12 @@ function mapExamples(examples) {
|
|
|
112
81
|
}
|
|
113
82
|
const description = [examples.description];
|
|
114
83
|
const tags = (0, utils_1.parseTags)(examples.tags);
|
|
115
|
-
if (table
|
|
84
|
+
if (Array.isArray(table)) {
|
|
116
85
|
description.push(JSON.stringify(table));
|
|
117
86
|
}
|
|
118
87
|
return {
|
|
119
|
-
title: (_c = (_b = tags.title) !== null && _b !== void 0 ? _b : tags.name) !== null && _c !== void 0 ? _c : (examples.name !==
|
|
120
|
-
description: (_d = tags.description) !== null && _d !== void 0 ? _d : description.join(
|
|
88
|
+
title: (_c = (_b = tags.title) !== null && _b !== void 0 ? _b : tags.name) !== null && _c !== void 0 ? _c : (examples.name !== "" ? examples.name : "Parameters"),
|
|
89
|
+
description: (_d = tags.description) !== null && _d !== void 0 ? _d : description.join("\n\n"),
|
|
121
90
|
};
|
|
122
91
|
}
|
|
123
92
|
exports.mapExamples = mapExamples;
|
|
@@ -134,9 +103,7 @@ function mapDataTable(dataTable) {
|
|
|
134
103
|
return undefined;
|
|
135
104
|
}
|
|
136
105
|
const keys = dataTable.rows[0].cells.map((cell) => cell.value);
|
|
137
|
-
const rows = dataTable.rows
|
|
138
|
-
.slice(1)
|
|
139
|
-
.map((row) => row.cells.map((cell) => cell.value));
|
|
106
|
+
const rows = dataTable.rows.slice(1).map((row) => row.cells.map((cell) => cell.value));
|
|
140
107
|
const objects = rows.map((value) => keys.reduce((acc, key, i) => {
|
|
141
108
|
acc[key] = value[i];
|
|
142
109
|
return acc;
|