testit-adapter-cucumber 1.1.0 → 1.1.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.
@@ -0,0 +1,8 @@
1
+ {
2
+ "ExpandedNodes": [
3
+ "",
4
+ "\\src"
5
+ ],
6
+ "SelectedNode": "\\src\\formatter.ts",
7
+ "PreviewInSolutionExplorer": false
8
+ }
Binary file
package/README.md CHANGED
@@ -8,7 +8,6 @@
8
8
  | Test IT | Adapter |
9
9
  |---------|---------|
10
10
  | 3.5 | 1.0 |
11
- |---------|---------|
12
11
  | 4.0 | 1.1 |
13
12
 
14
13
  ### Installation
@@ -1,18 +1,14 @@
1
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';
2
+ import { Meta, GherkinDocument, Pickle, TestCase, TestStepFinished, TestCaseStarted, TestCaseFinished, TestStepStarted } from '@cucumber/messages';
3
+ import { AdapterProperties, Link } from 'testit-js-commons';
5
4
  import { IFormatter } from './types/formatter';
6
- import { AutotestPostWithWorkItemId } from './mappers';
7
5
  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;
6
+ private storage;
7
+ private adapterManager;
8
+ private resolvedAutotests;
14
9
  private testRunStarted;
15
- private attachmentsQueue;
10
+ currentTestCaseId: string | undefined;
11
+ constructor(options: IFormatterOptions, properties: Partial<AdapterProperties>);
16
12
  onMeta(_meta: Meta): void;
17
13
  onGherkinDocument(document: GherkinDocument): void;
18
14
  onPickle(pickle: Pickle): void;
@@ -21,15 +17,8 @@ export declare class TestItFormatter extends Formatter implements IFormatter {
21
17
  testStepStarted(testStepStarted: TestStepStarted): void;
22
18
  onTestStepFinished(testStepFinished: TestStepFinished): void;
23
19
  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>;
31
20
  addMessage(message: string): void;
32
- addLinks(links: LinkPost[]): void;
33
- addAttachments(attachments: string[]): void;
34
- private logError;
21
+ addLinks(links: Link[]): void;
22
+ addAttachments(data: string[] | string, isText?: boolean, name?: string): Promise<void>;
23
+ loadAttachment(attachmentPath: string): Promise<void>;
35
24
  }
package/dist/formatter.js CHANGED
@@ -2,15 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TestItFormatter = void 0;
4
4
  const cucumber_1 = require("@cucumber/cucumber");
5
- const testit_api_client_1 = require("testit-api-client");
6
- const storage_1 = require("./storage");
7
- const utils_1 = require("./utils");
5
+ const fs_1 = require("fs");
6
+ const uuid_1 = require("uuid");
7
+ const path_1 = require("path");
8
+ const testit_js_commons_1 = require("testit-js-commons");
9
+ const tags_parser_1 = require("./tags-parser");
10
+ const scenario_storage_1 = require("./scenario-storage");
8
11
  class TestItFormatter extends cucumber_1.Formatter {
9
- constructor(options, config) {
12
+ constructor(options, properties) {
10
13
  super(options);
11
- this.storage = new storage_1.Storage();
12
- this.attachmentsQueue = [];
13
- this.client = new testit_api_client_1.Client(config);
14
+ this.storage = new scenario_storage_1.Storage();
15
+ this.adapterManager = testit_js_commons_1.Adapter.getAdapterManager(properties);
16
+ this.resolvedAutotests = this.adapterManager.getAutotestsForLaunch();
14
17
  options.eventBroadcaster.on('envelope', (envelope) => {
15
18
  if (envelope.meta) {
16
19
  return this.onMeta(envelope.meta);
@@ -19,25 +22,24 @@ class TestItFormatter extends cucumber_1.Formatter {
19
22
  return this.onGherkinDocument(envelope.gherkinDocument);
20
23
  }
21
24
  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);
25
+ this.resolvedAutotests.then(resolvedAutotests => {
26
+ if (resolvedAutotests !== undefined) {
27
+ if (resolvedAutotests.length > 0) {
28
+ const tags = (0, tags_parser_1.parseTags)(envelope.pickle.tags);
29
+ for (const externalId of resolvedAutotests) {
30
+ if (externalId === tags.externalId) {
31
+ return this.onPickle(envelope.pickle);
32
+ }
28
33
  }
29
34
  }
35
+ envelope.pickle = undefined;
30
36
  }
31
- envelope.pickle = undefined;
32
- }
33
- else {
34
- return this.onPickle(envelope.pickle);
35
- }
37
+ else {
38
+ return this.onPickle(envelope.pickle);
39
+ }
40
+ });
36
41
  }
37
42
  if (envelope.testCase) {
38
- if (this.testRunId === undefined && this.storage.isResolvedTestCase(envelope.testCase)) {
39
- this.createTestRun();
40
- }
41
43
  return this.onTestCase(envelope.testCase);
42
44
  }
43
45
  if (envelope.testCaseStarted) {
@@ -52,9 +54,6 @@ class TestItFormatter extends cucumber_1.Formatter {
52
54
  if (envelope.testCaseFinished) {
53
55
  return this.testCaseFinished(envelope.testCaseFinished);
54
56
  }
55
- if (envelope.testRunFinished) {
56
- return this.onTestRunFinished(envelope.testRunFinished);
57
- }
58
57
  });
59
58
  options.supportCodeLibrary.World.prototype.addMessage =
60
59
  this.addMessage.bind(this);
@@ -64,12 +63,7 @@ class TestItFormatter extends cucumber_1.Formatter {
64
63
  this.addAttachments.bind(this);
65
64
  }
66
65
  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
- }
66
+ this.testRunStarted = this.adapterManager.startLaunch();
73
67
  }
74
68
  onGherkinDocument(document) {
75
69
  this.storage.saveGherkinDocument(document);
@@ -91,102 +85,18 @@ class TestItFormatter extends cucumber_1.Formatter {
91
85
  this.storage.saveTestStepFinished(testStepFinished);
92
86
  }
93
87
  testCaseFinished(testCaseFinished) {
94
- this.currentTestCaseId = undefined;
95
88
  this.storage.saveTestCaseFinished(testCaseFinished);
96
- }
97
- 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
- }
89
+ if (this.testRunStarted === undefined) {
90
+ throw new Error('Test run is not started');
144
91
  }
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);
92
+ const testCaseId = this.currentTestCaseId;
93
+ this.testRunStarted
94
+ .then(() => {
95
+ if (testCaseId !== undefined) {
96
+ this.adapterManager.writeTest(this.storage.getTestResult(testCaseId));
158
97
  }
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
- await this.client.createAutotest(autotestPost);
174
- }
175
- async updateAutotest(autotestPost) {
176
- await this.client.updateAutotest(autotestPost).catch(this.logError);
177
- }
178
- async linkWorkItem(externalId, workItemId) {
179
- const [autotest] = await this.client
180
- .getAutotest({
181
- projectId: this.client.getConfig().projectId,
182
- externalId: externalId,
183
- })
184
- .catch(() => []);
185
- if ((autotest === null || autotest === void 0 ? void 0 : autotest.id) !== undefined) {
186
- await this.client.linkToWorkItem(autotest.id, {
187
- id: workItemId,
188
- });
189
- }
98
+ });
99
+ this.currentTestCaseId = undefined;
190
100
  }
191
101
  addMessage(message) {
192
102
  if (this.currentTestCaseId === undefined) {
@@ -200,24 +110,40 @@ class TestItFormatter extends cucumber_1.Formatter {
200
110
  }
201
111
  this.storage.addLinks(this.currentTestCaseId, links);
202
112
  }
203
- addAttachments(attachments) {
113
+ async addAttachments(data, isText = false, name) {
114
+ if (isText) {
115
+ if (name == undefined) {
116
+ name = (0, uuid_1.v4)() + '-attachment.txt';
117
+ }
118
+ const attachmentPath = (0, path_1.join)(__dirname, name);
119
+ (0, fs_1.writeFileSync)(attachmentPath, data.toString(), {
120
+ flag: 'w',
121
+ });
122
+ this.loadAttachment(attachmentPath);
123
+ (0, fs_1.unlinkSync)(attachmentPath);
124
+ }
125
+ else if (typeof data == 'string') {
126
+ this.loadAttachment(data);
127
+ }
128
+ else {
129
+ for (const attachmentPath of data) {
130
+ this.loadAttachment(attachmentPath);
131
+ }
132
+ }
133
+ }
134
+ async loadAttachment(attachmentPath) {
204
135
  if (this.currentTestCaseId === undefined) {
205
136
  throw new Error('CurrentTestCaseId is not set');
206
137
  }
207
138
  const currentTestCaseId = this.currentTestCaseId;
208
- this.attachmentsQueue.push(...attachments.map(async (attachment) => {
209
- const { id } = await this.client.loadAttachment(attachment);
210
- if (id === undefined) {
211
- // NOTE: Why?
212
- console.warn('Attachment id is not returned');
213
- return;
214
- }
139
+ const id = await this.adapterManager.loadAttachment(attachmentPath);
140
+ if (id === undefined) {
141
+ // NOTE: Why?
142
+ console.warn('Attachment id is not returned');
143
+ }
144
+ else {
215
145
  this.storage.addAttachment(currentTestCaseId, id);
216
- }));
217
- }
218
- logError(err) {
219
- var _a, _b;
220
- 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);
146
+ }
221
147
  }
222
148
  }
223
149
  exports.TestItFormatter = TestItFormatter;
@@ -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,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AAC,cAAsB;QACvC,IAAI,IAAI,CAAC,iBAAiB,KAAK,SAAS,EAAE;YACtC,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QAED,MAAM,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC;QAEjD,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;QAEpE,IAAI,EAAE,KAAK,SAAS,EAAE;YAClB,aAAa;YACb,OAAO,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;SACjD;aACI;YACD,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;SACrD;IACL,CAAC;CACJ;AAtKD,0CAsKC"}
@@ -0,0 +1,4 @@
1
+ import { TestStepResultStatus } from '@cucumber/messages';
2
+ import { OutcomeType } from 'testit-js-commons';
3
+ export declare function mapStatus(status: TestStepResultStatus): OutcomeType;
4
+ export declare function mapDate(date: number): string;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapDate = exports.mapStatus = void 0;
4
+ const messages_1 = require("@cucumber/messages");
5
+ function mapStatus(status) {
6
+ switch (status) {
7
+ case messages_1.TestStepResultStatus.PASSED:
8
+ return 'Passed';
9
+ case messages_1.TestStepResultStatus.FAILED:
10
+ return 'Failed';
11
+ case messages_1.TestStepResultStatus.PENDING:
12
+ return 'Pending';
13
+ case messages_1.TestStepResultStatus.SKIPPED:
14
+ return 'Skipped';
15
+ case messages_1.TestStepResultStatus.UNKNOWN:
16
+ case messages_1.TestStepResultStatus.UNDEFINED:
17
+ case messages_1.TestStepResultStatus.AMBIGUOUS:
18
+ return 'Blocked';
19
+ default:
20
+ throw new Error('Unknown status');
21
+ }
22
+ }
23
+ exports.mapStatus = mapStatus;
24
+ function mapDate(date) {
25
+ return new Date(date * 1000).toISOString();
26
+ }
27
+ exports.mapDate = mapDate;
28
+ //# sourceMappingURL=scenario-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scenario-parser.js","sourceRoot":"","sources":["../src/scenario-parser.ts"],"names":[],"mappings":";;;AAAA,iDAE4B;AAG5B,SAAgB,SAAS,CAAC,MAA4B;IAClD,QAAQ,MAAM,EAAE;QACZ,KAAK,+BAAoB,CAAC,MAAM;YAC5B,OAAO,QAAQ,CAAC;QACpB,KAAK,+BAAoB,CAAC,MAAM;YAC5B,OAAO,QAAQ,CAAC;QACpB,KAAK,+BAAoB,CAAC,OAAO;YAC7B,OAAO,SAAS,CAAC;QACrB,KAAK,+BAAoB,CAAC,OAAO;YAC7B,OAAO,SAAS,CAAC;QACrB,KAAK,+BAAoB,CAAC,OAAO,CAAC;QAClC,KAAK,+BAAoB,CAAC,SAAS,CAAC;QACpC,KAAK,+BAAoB,CAAC,SAAS;YAC/B,OAAO,SAAS,CAAC;QACrB;YACI,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;KACzC;AACL,CAAC;AAjBD,8BAiBC;AAED,SAAgB,OAAO,CAAC,IAAY;IAChC,OAAO,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;AAC/C,CAAC;AAFD,0BAEC"}
@@ -1,7 +1,6 @@
1
- import { AttachmentPut, AttachmentPutModelAutotestStepResults, AutotestResultsForTestRun, LinkPost } from 'testit-api-client';
2
1
  import { GherkinDocument, Pickle, PickleStep, TestCase, TestCaseFinished, TestCaseStarted, TestStepFinished, TestStepStarted } from '@cucumber/messages';
2
+ import { TestResult, Attachment, TestResultStep, Link } from 'testit-js-commons';
3
3
  import { IStorage } from './types/storage';
4
- import { AutotestPostWithWorkItemId } from './mappers';
5
4
  export declare class Storage implements IStorage {
6
5
  private gherkinDocuments;
7
6
  private pickles;
@@ -11,22 +10,21 @@ export declare class Storage implements IStorage {
11
10
  private testStepsStarted;
12
11
  private testStepsFinished;
13
12
  private messages;
14
- private links;
13
+ private resultLinks;
15
14
  private attachments;
15
+ isResolvedTestCase(testCase: TestCase): boolean;
16
16
  saveGherkinDocument(document: GherkinDocument): void;
17
- getAutotests(projectId: string): AutotestPostWithWorkItemId[];
18
17
  savePickle(pickle: Pickle): void;
19
- isResolvedTestCase(testCase: TestCase): boolean;
20
18
  saveTestCase(testCase: TestCase): void;
21
19
  saveTestCaseStarted(testCaseStarted: TestCaseStarted): void;
22
20
  saveTestCaseFinished(testCaseFinished: TestCaseFinished): void;
23
21
  saveTestStepStarted(testStepStarted: TestStepStarted): void;
24
22
  saveTestStepFinished(testStepFinished: TestStepFinished): void;
25
- getTestRunResults(configurationId: string): AutotestResultsForTestRun[];
26
- getStepResult(pickleStep: PickleStep, testCase: TestCase): AttachmentPutModelAutotestStepResults;
23
+ getTestResult(testId: string): TestResult;
24
+ getStepResult(pickleStep: PickleStep, testCase: TestCase): TestResultStep;
27
25
  getStepMessage(pickleStep: PickleStep, testCase: TestCase): string | undefined;
28
- getAttachments(testCaseId: string): AttachmentPut[] | undefined;
26
+ getAttachments(testCaseId: string): Attachment[] | undefined;
29
27
  addMessage(testCaseId: string, message: string): void;
30
- addLinks(testCaseId: string, links: LinkPost[]): void;
28
+ addLinks(testCaseId: string, links: Link[]): void;
31
29
  addAttachment(testCaseId: string, attachmentId: string): void;
32
30
  }
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Storage = void 0;
4
+ const testit_js_commons_1 = require("testit-js-commons");
5
+ const scenario_parser_1 = require("./scenario-parser");
6
+ const tags_parser_1 = require("./tags-parser");
7
+ class Storage {
8
+ constructor() {
9
+ this.gherkinDocuments = [];
10
+ this.pickles = [];
11
+ this.testCases = [];
12
+ this.testCasesStarted = [];
13
+ this.testCasesFinished = [];
14
+ this.testStepsStarted = [];
15
+ this.testStepsFinished = [];
16
+ this.messages = {};
17
+ this.resultLinks = {};
18
+ this.attachments = {};
19
+ }
20
+ isResolvedTestCase(testCase) {
21
+ for (const pickle of this.pickles) {
22
+ const tags = (0, tags_parser_1.parseTags)(pickle.tags);
23
+ if (tags.externalId !== undefined && testCase.pickleId === pickle.id) {
24
+ return true;
25
+ }
26
+ }
27
+ return false;
28
+ }
29
+ saveGherkinDocument(document) {
30
+ this.gherkinDocuments.push(document);
31
+ }
32
+ savePickle(pickle) {
33
+ this.pickles.push(pickle);
34
+ }
35
+ saveTestCase(testCase) {
36
+ this.testCases.push(testCase);
37
+ }
38
+ saveTestCaseStarted(testCaseStarted) {
39
+ this.testCasesStarted.push(testCaseStarted);
40
+ }
41
+ saveTestCaseFinished(testCaseFinished) {
42
+ this.testCasesFinished.push(testCaseFinished);
43
+ }
44
+ saveTestStepStarted(testStepStarted) {
45
+ this.testStepsStarted.push(testStepStarted);
46
+ }
47
+ saveTestStepFinished(testStepFinished) {
48
+ this.testStepsFinished.push(testStepFinished);
49
+ }
50
+ getTestResult(testId) {
51
+ var _a, _b, _c, _d;
52
+ const testCase = this.testCases.find((testCase) => testCase.id === testId);
53
+ if (testCase === undefined) {
54
+ throw new Error('TestCase not found');
55
+ }
56
+ ;
57
+ const pickle = this.pickles.find((pickle) => pickle.id === testCase.pickleId);
58
+ if (pickle === undefined) {
59
+ throw new Error('Pickle not found');
60
+ }
61
+ const tags = (0, tags_parser_1.parseTags)(pickle.tags);
62
+ if (tags.externalId === undefined) {
63
+ throw new Error('External ID is not provided');
64
+ }
65
+ const testCaseStarted = this.testCasesStarted.find((testCase) => testCase.id === testCase.id);
66
+ if (testCaseStarted === undefined) {
67
+ throw new Error('TestCaseStarted not found');
68
+ }
69
+ ;
70
+ const testCaseFinished = this.testCasesFinished.find((testCase) => testCase.testCaseStartedId === testCaseStarted.id);
71
+ if (testCaseFinished === undefined) {
72
+ throw new Error('TestCaseFinished not found');
73
+ }
74
+ ;
75
+ const steps = pickle.steps
76
+ .map((step) => this.getStepResult(step, testCase))
77
+ .filter((item, i, arr) => {
78
+ var _a;
79
+ const prevOutcome = (_a = arr[i - 1]) === null || _a === void 0 ? void 0 : _a.outcome;
80
+ if (item.outcome === 'Skipped' &&
81
+ prevOutcome !== undefined &&
82
+ ['Failed', 'Skipped'].includes(prevOutcome)) {
83
+ return false;
84
+ }
85
+ return true;
86
+ });
87
+ const messages = [];
88
+ for (const step of pickle.steps) {
89
+ const message = this.getStepMessage(step, testCase);
90
+ if (message !== undefined) {
91
+ messages.push(message);
92
+ }
93
+ }
94
+ const resultLinks = (_a = this.resultLinks[testCase.id]) !== null && _a !== void 0 ? _a : [];
95
+ return {
96
+ externalId: tags.externalId,
97
+ displayName: (_b = tags.name) !== null && _b !== void 0 ? _b : pickle.name,
98
+ links: tags.links,
99
+ resultLinks: resultLinks,
100
+ stepResults: steps,
101
+ outcome: (0, testit_js_commons_1.calculateResultOutcome)(steps.map((step) => step.outcome)),
102
+ startedOn: (0, scenario_parser_1.mapDate)(testCaseStarted.timestamp.seconds),
103
+ completedOn: (0, scenario_parser_1.mapDate)(testCaseFinished.timestamp.seconds),
104
+ duration: testCaseFinished.timestamp.seconds -
105
+ testCaseStarted.timestamp.seconds,
106
+ message: (_d = (_c = this.messages[testCase.id]) === null || _c === void 0 ? void 0 : _c.join('\n\n')) !== null && _d !== void 0 ? _d : undefined,
107
+ traces: messages.join('\n\n'),
108
+ attachments: this.getAttachments(testCase.id),
109
+ };
110
+ }
111
+ getStepResult(pickleStep, testCase) {
112
+ const testStep = testCase.testSteps.find((step) => step.pickleStepId === pickleStep.id);
113
+ if (testStep === undefined) {
114
+ throw new Error('TestCase step not found');
115
+ }
116
+ const testStepStarted = this.testStepsStarted.find((step) => step.testStepId === testStep.id);
117
+ if (testStepStarted === undefined) {
118
+ throw new Error('TestStepStarted not found');
119
+ }
120
+ const testStepFinished = this.testStepsFinished.find((step) => step.testStepId === testStepStarted.testStepId);
121
+ if (testStepFinished === undefined) {
122
+ throw new Error('TestStepFinished not found');
123
+ }
124
+ return {
125
+ title: pickleStep.text,
126
+ startedOn: (0, scenario_parser_1.mapDate)(testStepStarted.timestamp.seconds),
127
+ duration: testStepFinished.testStepResult.duration.seconds,
128
+ completedOn: (0, scenario_parser_1.mapDate)(testStepFinished.timestamp.seconds),
129
+ outcome: (0, scenario_parser_1.mapStatus)(testStepFinished.testStepResult.status),
130
+ };
131
+ }
132
+ getStepMessage(pickleStep, testCase) {
133
+ const testStep = testCase.testSteps.find((step) => step.pickleStepId === pickleStep.id);
134
+ if (testStep === undefined) {
135
+ throw new Error('TestCase step not found');
136
+ }
137
+ const testStepStarted = this.testStepsStarted.find((step) => step.testStepId === testStep.id);
138
+ if (testStepStarted === undefined) {
139
+ throw new Error('TestStepStarted not found');
140
+ }
141
+ const testStepFinished = this.testStepsFinished.find((step) => step.testStepId === testStepStarted.testStepId);
142
+ if (testStepFinished === undefined) {
143
+ throw new Error('TestStepFinished not found');
144
+ }
145
+ return testStepFinished.testStepResult.message;
146
+ }
147
+ getAttachments(testCaseId) {
148
+ if (this.attachments[testCaseId] === undefined) {
149
+ return undefined;
150
+ }
151
+ return this.attachments[testCaseId];
152
+ }
153
+ addMessage(testCaseId, message) {
154
+ if (this.messages[testCaseId] === undefined) {
155
+ this.messages[testCaseId] = [message];
156
+ }
157
+ else {
158
+ this.messages[testCaseId].push(message);
159
+ }
160
+ }
161
+ addLinks(testCaseId, links) {
162
+ if (this.resultLinks[testCaseId] === undefined) {
163
+ this.resultLinks[testCaseId] = links;
164
+ }
165
+ else {
166
+ this.resultLinks[testCaseId].push(...links);
167
+ }
168
+ }
169
+ addAttachment(testCaseId, attachmentId) {
170
+ const attachment = {
171
+ 'id': attachmentId
172
+ };
173
+ if (this.attachments[testCaseId] === undefined) {
174
+ this.attachments[testCaseId] = [attachment];
175
+ }
176
+ else {
177
+ this.attachments[testCaseId].concat(attachment);
178
+ }
179
+ }
180
+ }
181
+ exports.Storage = Storage;
182
+ //# sourceMappingURL=scenario-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scenario-storage.js","sourceRoot":"","sources":["../src/scenario-storage.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