testit-adapter-cucumber 1.1.7 → 2.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.
Files changed (45) hide show
  1. package/README.md +24 -35
  2. package/dist/formatter.d.ts +12 -24
  3. package/dist/formatter.js +54 -144
  4. package/dist/formatter.js.map +1 -1
  5. package/dist/mappers.d.ts +9 -13
  6. package/dist/mappers.js +33 -66
  7. package/dist/mappers.js.map +1 -1
  8. package/dist/storage.d.ts +9 -11
  9. package/dist/storage.js +32 -43
  10. package/dist/storage.js.map +1 -1
  11. package/dist/types/formatter.type.d.ts +11 -0
  12. package/dist/types/{storage.js → formatter.type.js} +1 -1
  13. package/dist/types/formatter.type.js.map +1 -0
  14. package/dist/types/index.d.ts +3 -0
  15. package/dist/types/index.js +20 -0
  16. package/dist/types/index.js.map +1 -0
  17. package/dist/types/{storage.d.ts → storage.type.d.ts} +7 -8
  18. package/dist/types/{formatter.js → storage.type.js} +1 -1
  19. package/dist/types/storage.type.js.map +1 -0
  20. package/dist/types/{tags.d.ts → tags.type.d.ts} +3 -3
  21. package/dist/types/{tags.js → tags.type.js} +10 -10
  22. package/dist/types/tags.type.js.map +1 -0
  23. package/dist/utils.d.ts +7 -8
  24. package/dist/utils.js +63 -70
  25. package/dist/utils.js.map +1 -1
  26. package/package.json +6 -3
  27. package/.eslintignore +0 -2
  28. package/.eslintrc.json +0 -27
  29. package/.prettierrc +0 -9
  30. package/dist/types/formatter.d.ts +0 -25
  31. package/dist/types/formatter.js.map +0 -1
  32. package/dist/types/storage.js.map +0 -1
  33. package/dist/types/tags.js.map +0 -1
  34. package/dist/types/world.d.ts +0 -7
  35. package/dist/types/world.js +0 -3
  36. package/dist/types/world.js.map +0 -1
  37. package/src/formatter.ts +0 -285
  38. package/src/mappers.ts +0 -181
  39. package/src/storage.ts +0 -212
  40. package/src/types/formatter.ts +0 -37
  41. package/src/types/storage.ts +0 -27
  42. package/src/types/tags.ts +0 -39
  43. package/src/types/world.ts +0 -8
  44. package/src/utils.ts +0 -162
  45. 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 `testitFormatter.js` file in the root directory of the project:
31
- ```js
32
- const { TestItFormatter } = require('testit-adapter-cucumber');
33
-
34
- module.exports = class CustomFormatter extends TestItFormatter {
35
- constructor(options) {
36
- super(options, {
37
- url: 'URL',
38
- privateToken: 'USER_PRIVATE_TOKEN',
39
- projectId: 'PROJECT_ID',
40
- configurationId: 'CONFIGURATION_ID',
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 ./testitFormatter.js',
45
+ '-f testit-adapter-cucumber',
57
46
  };
58
47
  ```
59
48
 
@@ -88,13 +77,13 @@ Cucumber tags can be used to specify information about autotest.
88
77
 
89
78
  > Only those specified above the `Scenario` are taken into account
90
79
 
91
- - `@ExternalId` - Unique identifier of autotest (Required)
92
- - `@Title` - Title that is displayed on autotest page
93
- - `@DisplayName` - Name that is displayed in autotests table
94
- - `@Description` - Autotest description
95
- - `@Link` - 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`)
96
- - `@Label` - Label that is going to be linked to autotest
97
- - `@WorkItemId` - Work item's ID to which autotest is going to be linked
80
+ - `@ExternalId` - unique internal autotest ID (used in Test IT)
81
+ - `@Title` - autotest name specified in the autotest card. If not specified, the name from the displayName method is used
82
+ - `@DisplayName` - internal autotest name (used in Test IT)
83
+ - `@Description` - autotest description specified in the autotest card
84
+ - `@Links` - links listed in the autotest card (`@Link={"url":"http://google.com","hasInfo":true,"description":"GoogleDescription","title":"Google","type":"Defect"}`) or in text (`@Link=http://google.com`)
85
+ - `@Labels` - tags listed in the autotest card
86
+ - `@WorkItemIds` - a method that links autotests with manual tests. Receives the array of manual tests' IDs
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
- @Link=http://google.com
110
- @Link=http://vk.com
111
- @Label=Maths
112
- @Label=School
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
- @Link={"url":"http://google.com","hasInfo":true,"description":"GoogleDescription","title":"Google","type":"Defect"}
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
@@ -1,19 +1,14 @@
1
- import { Formatter, IFormatterOptions } from '@cucumber/cucumber';
2
- import { GherkinDocument, Pickle, TestCase, TestStepFinished, TestRunFinished, TestCaseStarted, TestCaseFinished, TestStepStarted, Meta } from '@cucumber/messages';
3
- import { ClientConfigWithFile, IClient, LinkPost } from 'testit-api-client';
4
- import { IStorage } from './types/storage';
5
- import { IFormatter } from './types/formatter';
6
- import { AutotestPostWithWorkItemId } from './mappers';
7
- export declare class TestItFormatter extends Formatter implements IFormatter {
8
- client: IClient;
9
- storage: IStorage;
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
- onMeta(_meta: Meta): void;
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: LinkPost[]): void;
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
- exports.TestItFormatter = void 0;
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, config) {
17
+ constructor(options) {
10
18
  super(options);
11
- this.storage = new storage_1.Storage();
12
19
  this.attachmentsQueue = [];
13
- this.client = new testit_api_client_1.Client(config);
14
- options.eventBroadcaster.on('envelope', (envelope) => {
15
- if (envelope.meta) {
16
- return this.onMeta(envelope.meta);
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
- if (this.resolvedAutotests !== undefined) {
23
- if (this.resolvedAutotests.length > 0) {
24
- const tags = (0, utils_1.parseTags)(envelope.pickle.tags);
25
- for (const externalId of this.resolvedAutotests) {
26
- if (externalId === tags.externalId) {
27
- return this.onPickle(envelope.pickle);
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
- this.addMessage.bind(this);
61
- options.supportCodeLibrary.World.prototype.addLinks =
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
- const { configurationId } = this.client.getConfig();
99
- const results = this.storage.getTestRunResults(configurationId);
100
- if (this.testRunId !== undefined && results.length > 0) {
101
- Promise.all([
102
- this.testRunId,
103
- Promise.all(this.attachmentsQueue),
104
- ])
105
- .then(async ([id]) => {
106
- const autotests = this.storage.getAutotests(this.client.getConfig().projectId);
107
- await Promise.all(autotests.map((autotestPost) => {
108
- const result = results.find((result) => result.autotestExternalId === autotestPost.externalId);
109
- if (result !== undefined) {
110
- if (result.outcome !== 'Passed') {
111
- return this.loadAutotest(autotestPost);
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('CurrentTestCaseId is not set');
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('CurrentTestCaseId is not set');
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('CurrentTestCaseId is not set');
120
+ throw new Error("CurrentTestCaseId is not a set");
207
121
  }
208
122
  const currentTestCaseId = this.currentTestCaseId;
209
- this.attachmentsQueue.push(...attachments.map(async (attachment) => {
210
- const { id } = await this.client.loadAttachment(attachment);
211
- if (id === undefined) {
212
- // NOTE: Why?
213
- console.warn('Attachment id is not returned');
214
- return;
215
- }
216
- this.storage.addAttachment(currentTestCaseId, id);
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.TestItFormatter = TestItFormatter;
134
+ exports.default = TestItFormatter;
225
135
  //# sourceMappingURL=formatter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatter.js","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":";;;AAAA,iDAAkE;AAclE,yDAK2B;AAE3B,uCAAoC;AAIpC,mCAAqD;AAErD,MAAa,eAAgB,SAAQ,oBAAS;IAM5C,YACE,OAA0B,EAC1B,MAAqC;Q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AAI,IAAI,CAAC,iBAAiB,KAAK,SAAS,EAAE;YACxC,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;SACnD;QAED,MAAM,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC;QAEjD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW;aACpC,iBAAiB,CAAC,WAAW,CAAC;aAC9B,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YACZ,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;QACtD,CAAC,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, TestStepResultStatus } from '@cucumber/messages';
2
- import { AutotestPost, AutotestStep, OutcomeType } from 'testit-api-client';
3
- export interface AutotestPostWithWorkItemId extends AutotestPost {
4
- workItemId?: string;
5
- }
6
- export declare function mapStatus(status: TestStepResultStatus): OutcomeType;
7
- export declare function mapDate(date: number): string;
8
- export declare function mapDocument(document: GherkinDocument, projectId: string): AutotestPostWithWorkItemId[];
9
- export declare function mapBackground(background: Background): AutotestStep;
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 = exports.mapStatus = void 0;
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
- function mapStatus(status) {
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).toISOString();
7
+ return new Date(date * 1000);
27
8
  }
28
9
  exports.mapDate = mapDate;
29
- function mapDocument(document, projectId) {
10
+ function mapDocument(document) {
30
11
  if (document.feature === undefined) {
31
12
  return [];
32
13
  }
33
14
  const setup = document.feature.children
34
- .filter((child) => child.background !== undefined)
35
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
36
- .map((child) => mapBackground(child.background));
15
+ .map((child) => child.background)
16
+ .filter((background) => background !== undefined)
17
+ .map((background) => mapBackground(background));
37
18
  const scenarioAutotests = document.feature.children
38
- .filter((child) => child.scenario !== undefined)
39
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
40
- .map((child) => mapScenario(child.scenario, projectId, setup));
19
+ .map((child) => child.scenario)
20
+ .filter((scenario) => scenario !== undefined)
21
+ .map((scenario) => mapScenario(scenario, setup));
41
22
  const ruleAutotests = document.feature.children
42
- .filter((child) => child.rule !== undefined)
43
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
44
- .flatMap((child) => mapRule(child.rule, projectId, setup));
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, projectId, setup) {
37
+ function mapRule(rule, setup) {
57
38
  const ruleSetup = setup.concat(rule.children
58
- .filter((child) => child.background !== undefined)
59
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
60
- .map((child) => mapBackground(child.background)));
61
- return (rule.children
62
- .filter((child) => child.scenario !== undefined)
63
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
64
- .map((child) => mapScenario(child.scenario, projectId, ruleSetup)));
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, projectId, setup) {
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: (_a = tags.name) !== null && _a !== void 0 ? _a : scenario.name,
56
+ name: (_c = tags.name) !== null && _c !== void 0 ? _c : scenario.name,
83
57
  title: tags.title,
84
- description: (_b = tags.description) !== null && _b !== void 0 ? _b : scenario.description,
85
- projectId,
58
+ description: (_d = tags.description) !== null && _d !== void 0 ? _d : scenario.description,
86
59
  steps: scenario.steps.map(mapStep),
87
- workItemId: tags.workItemId,
60
+ workItemIds: tags.workItemIds,
88
61
  namespace: tags.nameSpace,
89
62
  classname: tags.className,
90
- // Disable for now (BUG??)
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.length > 0) {
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 !== '' ? examples.name : 'Parameters'),
120
- description: (_d = tags.description) !== null && _d !== void 0 ? _d : description.join('\n\n'),
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;