@testomatio/reporter 2.0.1-beta.3 → 2.0.1-beta.5-timestamp

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 (148) hide show
  1. package/lib/adapter/codecept.js +335 -293
  2. package/lib/adapter/cucumber/current.js +203 -195
  3. package/lib/adapter/cucumber/legacy.js +155 -130
  4. package/lib/adapter/cucumber.js +16 -5
  5. package/lib/adapter/cypress-plugin/index.js +105 -91
  6. package/lib/adapter/jasmine.js +53 -54
  7. package/lib/adapter/jest.js +99 -97
  8. package/lib/adapter/mocha.js +141 -112
  9. package/lib/adapter/playwright.js +231 -199
  10. package/lib/adapter/vitest.js +149 -150
  11. package/lib/adapter/webdriver.js +121 -144
  12. package/lib/bin/cli.js +211 -229
  13. package/lib/bin/reportXml.js +52 -51
  14. package/lib/bin/startTest.js +95 -83
  15. package/lib/bin/uploadArtifacts.js +61 -56
  16. package/lib/client.js +465 -424
  17. package/lib/config.js +23 -18
  18. package/lib/constants.js +44 -50
  19. package/lib/data-storage.js +188 -216
  20. package/lib/junit-adapter/adapter.js +20 -17
  21. package/lib/junit-adapter/csharp.js +14 -28
  22. package/lib/junit-adapter/index.js +25 -27
  23. package/lib/junit-adapter/java.js +53 -41
  24. package/lib/junit-adapter/javascript.js +27 -30
  25. package/lib/junit-adapter/python.js +37 -38
  26. package/lib/junit-adapter/ruby.js +8 -11
  27. package/lib/output.js +52 -44
  28. package/lib/pipe/bitbucket.js +230 -223
  29. package/lib/pipe/csv.js +126 -113
  30. package/lib/pipe/debug.js +99 -118
  31. package/lib/pipe/github.js +213 -218
  32. package/lib/pipe/gitlab.js +206 -183
  33. package/lib/pipe/html.js +321 -258
  34. package/lib/pipe/index.js +66 -94
  35. package/lib/pipe/testomatio.js +474 -429
  36. package/lib/reporter-functions.js +26 -28
  37. package/lib/reporter.js +29 -34
  38. package/lib/services/artifacts.js +51 -55
  39. package/lib/services/index.js +12 -14
  40. package/lib/services/key-values.js +53 -56
  41. package/lib/services/logger.js +245 -226
  42. package/lib/template/testomatio.hbs +1366 -1026
  43. package/lib/uploader.js +364 -295
  44. package/lib/utils/pipe_utils.js +85 -89
  45. package/lib/utils/utils.js +307 -398
  46. package/lib/xmlReader.js +532 -525
  47. package/package.json +21 -64
  48. package/lib/adapter/codecept.d.ts +0 -2
  49. package/lib/adapter/cucumber/current.d.ts +0 -14
  50. package/lib/adapter/cucumber/legacy.d.ts +0 -0
  51. package/lib/adapter/cucumber.d.ts +0 -2
  52. package/lib/adapter/cypress-plugin/index.d.ts +0 -2
  53. package/lib/adapter/jasmine.d.ts +0 -11
  54. package/lib/adapter/jest.d.ts +0 -13
  55. package/lib/adapter/mocha.d.ts +0 -2
  56. package/lib/adapter/nightwatch.d.ts +0 -4
  57. package/lib/adapter/nightwatch.js +0 -80
  58. package/lib/adapter/playwright.d.ts +0 -14
  59. package/lib/adapter/vitest.d.ts +0 -35
  60. package/lib/adapter/webdriver.d.ts +0 -24
  61. package/lib/bin/cli.d.ts +0 -2
  62. package/lib/bin/reportXml.d.ts +0 -2
  63. package/lib/bin/startTest.d.ts +0 -2
  64. package/lib/bin/uploadArtifacts.d.ts +0 -2
  65. package/lib/client.d.ts +0 -76
  66. package/lib/config.d.ts +0 -1
  67. package/lib/constants.d.ts +0 -25
  68. package/lib/data-storage.d.ts +0 -34
  69. package/lib/junit-adapter/adapter.d.ts +0 -9
  70. package/lib/junit-adapter/csharp.d.ts +0 -5
  71. package/lib/junit-adapter/index.d.ts +0 -3
  72. package/lib/junit-adapter/java.d.ts +0 -5
  73. package/lib/junit-adapter/javascript.d.ts +0 -4
  74. package/lib/junit-adapter/python.d.ts +0 -5
  75. package/lib/junit-adapter/ruby.d.ts +0 -4
  76. package/lib/output.d.ts +0 -11
  77. package/lib/package.json +0 -3
  78. package/lib/pipe/bitbucket.d.ts +0 -25
  79. package/lib/pipe/csv.d.ts +0 -47
  80. package/lib/pipe/debug.d.ts +0 -29
  81. package/lib/pipe/github.d.ts +0 -30
  82. package/lib/pipe/gitlab.d.ts +0 -25
  83. package/lib/pipe/html.d.ts +0 -35
  84. package/lib/pipe/index.d.ts +0 -1
  85. package/lib/pipe/testomatio.d.ts +0 -71
  86. package/lib/replay.d.ts +0 -31
  87. package/lib/replay.js +0 -237
  88. package/lib/reporter-functions.d.ts +0 -34
  89. package/lib/reporter.d.ts +0 -232
  90. package/lib/services/artifacts.d.ts +0 -33
  91. package/lib/services/index.d.ts +0 -9
  92. package/lib/services/key-values.d.ts +0 -27
  93. package/lib/services/logger.d.ts +0 -64
  94. package/lib/uploader.d.ts +0 -60
  95. package/lib/utils/pipe_utils.d.ts +0 -41
  96. package/lib/utils/utils.d.ts +0 -54
  97. package/lib/xmlReader.d.ts +0 -92
  98. package/src/adapter/codecept.js +0 -373
  99. package/src/adapter/cucumber/current.js +0 -228
  100. package/src/adapter/cucumber/legacy.js +0 -158
  101. package/src/adapter/cucumber.js +0 -4
  102. package/src/adapter/cypress-plugin/index.js +0 -110
  103. package/src/adapter/jasmine.js +0 -60
  104. package/src/adapter/jest.js +0 -107
  105. package/src/adapter/mocha.cjs +0 -2
  106. package/src/adapter/mocha.js +0 -156
  107. package/src/adapter/nightwatch.js +0 -88
  108. package/src/adapter/playwright.js +0 -254
  109. package/src/adapter/vitest.js +0 -183
  110. package/src/adapter/webdriver.js +0 -142
  111. package/src/bin/cli.js +0 -348
  112. package/src/bin/reportXml.js +0 -77
  113. package/src/bin/startTest.js +0 -124
  114. package/src/bin/uploadArtifacts.js +0 -91
  115. package/src/client.js +0 -508
  116. package/src/config.js +0 -30
  117. package/src/constants.js +0 -53
  118. package/src/data-storage.js +0 -204
  119. package/src/junit-adapter/adapter.js +0 -23
  120. package/src/junit-adapter/csharp.js +0 -28
  121. package/src/junit-adapter/index.js +0 -28
  122. package/src/junit-adapter/java.js +0 -58
  123. package/src/junit-adapter/javascript.js +0 -31
  124. package/src/junit-adapter/python.js +0 -42
  125. package/src/junit-adapter/ruby.js +0 -10
  126. package/src/output.js +0 -57
  127. package/src/pipe/bitbucket.js +0 -252
  128. package/src/pipe/csv.js +0 -140
  129. package/src/pipe/debug.js +0 -119
  130. package/src/pipe/github.js +0 -232
  131. package/src/pipe/gitlab.js +0 -247
  132. package/src/pipe/html.js +0 -373
  133. package/src/pipe/index.js +0 -71
  134. package/src/pipe/testomatio.js +0 -504
  135. package/src/replay.js +0 -245
  136. package/src/reporter-functions.js +0 -55
  137. package/src/reporter.cjs_decprecated +0 -21
  138. package/src/reporter.js +0 -33
  139. package/src/services/artifacts.js +0 -59
  140. package/src/services/index.js +0 -13
  141. package/src/services/key-values.js +0 -59
  142. package/src/services/logger.js +0 -315
  143. package/src/template/emptyData.svg +0 -23
  144. package/src/template/testomatio.hbs +0 -1081
  145. package/src/uploader.js +0 -376
  146. package/src/utils/pipe_utils.js +0 -119
  147. package/src/utils/utils.js +0 -416
  148. package/src/xmlReader.js +0 -614
package/src/uploader.js DELETED
@@ -1,376 +0,0 @@
1
- import createDebugMessages from 'debug';
2
- import { S3 } from '@aws-sdk/client-s3';
3
- import { Upload } from '@aws-sdk/lib-storage';
4
- import fs from 'fs';
5
- import os from 'os';
6
- import path from 'path';
7
- import promiseRetry from 'promise-retry';
8
- import pc from 'picocolors';
9
- import { APP_PREFIX } from './constants.js';
10
- import { filesize as prettyBytes } from 'filesize';
11
-
12
- const debug = createDebugMessages('@testomatio/reporter:file-uploader');
13
-
14
- export class S3Uploader {
15
- constructor() {
16
- this.isEnabled = undefined;
17
- this.storeEnabled = true;
18
- this.config = undefined;
19
-
20
- /**
21
- * @type {{path: string, size: number}[]}
22
- */
23
- this.skippedUploads = [];
24
- this.failedUploads = [];
25
- /**
26
- * @type {{path: string, size: number, link: string}[]}
27
- */
28
- this.successfulUploads = [];
29
-
30
- this.configKeys = [
31
- 'S3_ENDPOINT',
32
- 'S3_REGION',
33
- 'S3_BUCKET',
34
- 'S3_ACCESS_KEY_ID',
35
- 'S3_SECRET_ACCESS_KEY',
36
- 'S3_SESSION_TOKEN',
37
- 'S3_FORCE_PATH_STYLE',
38
- 'TESTOMATIO_DISABLE_ARTIFACTS',
39
- 'TESTOMATIO_PRIVATE_ARTIFACTS',
40
- 'TESTOMATIO_ARTIFACT_MAX_SIZE_MB',
41
- ];
42
- }
43
-
44
- resetConfig() {
45
- this.config = undefined;
46
- this.isEnabled = undefined;
47
- }
48
-
49
- /**
50
- *
51
- * @returns {Record<string, string>}
52
- */
53
- getConfig() {
54
- if (this.config) return this.config;
55
- this.config = this.configKeys.reduce((acc, key) => {
56
- acc[key] = process.env[key];
57
- return acc;
58
- }, {});
59
- return this.config;
60
- }
61
-
62
- getMaskedConfig() {
63
- return Object.fromEntries(
64
- Object.entries(this.getConfig()).map(([key, value]) => [
65
- key,
66
- key === 'S3_SECRET_ACCESS_KEY' || key === 'S3_ACCESS_KEY_ID' ? '***' : value,
67
- ]),
68
- );
69
- }
70
-
71
- checkEnabled() {
72
- if (this.isEnabled !== undefined) return this.isEnabled;
73
-
74
- const { S3_BUCKET, TESTOMATIO_DISABLE_ARTIFACTS } = this.getConfig();
75
- if (!S3_BUCKET) debug(`Artifacts uploading is disabled because S3_BUCKET is not set`);
76
- this.isEnabled = !!(S3_BUCKET && !TESTOMATIO_DISABLE_ARTIFACTS);
77
-
78
- if (this.isEnabled) debug('S3 uploader is enabled');
79
- debug(this.getMaskedConfig());
80
-
81
- return this.isEnabled;
82
- }
83
-
84
- enableLogStorage() {
85
- this.storeEnabled = true;
86
- }
87
-
88
- disableLogStorage() {
89
- this.storeEnabled = false;
90
- }
91
-
92
- /**
93
- *
94
- * @param {*} Body
95
- * @param {*} Key
96
- * @param {{path: string, size?: number}} file
97
- * @returns
98
- */
99
- async #uploadToS3(Body, Key, file) {
100
- const { S3_BUCKET, TESTOMATIO_PRIVATE_ARTIFACTS } = this.getConfig();
101
- const ACL = TESTOMATIO_PRIVATE_ARTIFACTS ? 'private' : 'public-read';
102
-
103
- if (!S3_BUCKET || !Body) {
104
- console.log(
105
- APP_PREFIX,
106
- pc.bold(pc.red(`Failed uploading '${Key}'. Please check S3 credentials`)),
107
- this.getMaskedConfig(),
108
- );
109
- return;
110
- }
111
-
112
- debug('Uploading to S3:', Key);
113
-
114
- const s3Config = this.#getS3Config();
115
- const s3 = new S3(s3Config);
116
- const params = {
117
- Bucket: S3_BUCKET,
118
- Key,
119
- Body,
120
- };
121
- // disable ACL for I AM roles
122
- if (!s3Config.credentials.sessionToken) {
123
- params.ACL = ACL;
124
- }
125
-
126
- try {
127
- const upload = new Upload({ client: s3, params });
128
-
129
- const link = await this.getS3LocationLink(upload);
130
- this.successfulUploads.push({ path: file.path, size: file.size, link });
131
- debug(`📤 Uploaded artifact. File: ${file.path}, size: ${prettyBytes(file.size || 0)}, link: ${link}`);
132
- return link;
133
- } catch (e) {
134
- this.failedUploads.push({ path: file.path, size: file.size });
135
- debug('S3 uploading error:', e);
136
- console.log(APP_PREFIX, 'Upload failed:', e.message, '\nConfig:\n', this.getMaskedConfig());
137
- }
138
- }
139
-
140
- /**
141
- * Returns an array of uploaded files
142
- *
143
- * @returns {{rid: string, file: string, uploaded: boolean}[]}
144
- */
145
- readUploadedFiles(runId) {
146
- const tempFilePath = this.#getFilePathWithUploadsList(runId);
147
-
148
- debug('Reading file', tempFilePath);
149
-
150
- if (!fs.existsSync(tempFilePath)) {
151
- debug('File not found:', tempFilePath);
152
- return [];
153
- }
154
-
155
- const stats = fs.statSync(tempFilePath);
156
- debug('Artifacts file stats:', +stats.mtime);
157
- debug('Current time:', +new Date());
158
- const diff = +new Date() - +stats.mtime;
159
- debug('Diff:', diff);
160
- const diffHours = diff / 1000 / 60 / 60;
161
- debug('Diff hours:', diffHours);
162
- if (diffHours > 3) {
163
- console.log(APP_PREFIX, "Artifacts file is too old, can't process artifacts. Please re-run the tests.");
164
- return [];
165
- }
166
-
167
- const data = fs.readFileSync(tempFilePath, 'utf8');
168
- debug('Artifacts file contents:', data);
169
- const lines = data.split('\n').filter(Boolean);
170
- return lines.map(line => JSON.parse(line));
171
- }
172
-
173
- #getFilePathWithUploadsList(runId) {
174
- const tempFilePath = path.join(os.tmpdir(), `testomatio.run.${runId}.json`);
175
- if (!fs.existsSync(tempFilePath)) {
176
- debug('Creating artifacts file:', tempFilePath);
177
- fs.writeFileSync(tempFilePath, '');
178
- }
179
- return tempFilePath;
180
- }
181
-
182
- storeUploadedFile(filePath, runId, rid, uploaded = false) {
183
- if (!this.storeEnabled) return;
184
-
185
- if (!filePath || !runId || !rid) return;
186
-
187
- const tempFilePath = this.#getFilePathWithUploadsList(runId);
188
-
189
- if (typeof filePath === 'object') {
190
- filePath = filePath.path;
191
- }
192
-
193
- if (typeof filePath === 'string' && !path.isAbsolute(filePath)) {
194
- filePath = path.join(process.cwd(), filePath);
195
- }
196
-
197
- const data = { rid, file: filePath, uploaded };
198
- const jsonLine = `${JSON.stringify(data)}\n`;
199
- fs.appendFileSync(tempFilePath, jsonLine);
200
- }
201
-
202
- /**
203
- * @param {*} filePath
204
- * @param {*} pathInS3 contains runId, rid and filename
205
- * @returns
206
- */
207
- async uploadFileByPath(filePath, pathInS3) {
208
- /* WDIO: some artifacts uploading started before createRun function completion
209
- probably, the reason is that run is NOT created in adapter (but via cli) */
210
- this.isEnabled = this.isEnabled ?? this.checkEnabled();
211
-
212
- const [runId, rid] = pathInS3;
213
-
214
- if (!filePath) return;
215
-
216
- let fileSize = null;
217
- let fileSizeInMb = null;
218
-
219
- try {
220
- // file may not exist
221
- fileSize = fs.statSync(filePath).size || 0;
222
- fileSizeInMb = Number((fileSize / (1024 * 1024)).toFixed(2));
223
- } catch (e) {
224
- debug(`File ${filePath} does not exist`);
225
- }
226
-
227
- if (!this.isEnabled) {
228
- this.storeUploadedFile(filePath, runId, rid, false);
229
- this.skippedUploads.push({ path: filePath, size: fileSize });
230
- return;
231
- }
232
-
233
- const { S3_BUCKET, TESTOMATIO_ARTIFACT_MAX_SIZE_MB } = this.getConfig();
234
-
235
- debug('Started upload', filePath, 'to', S3_BUCKET);
236
-
237
- const isFileExist = await this.checkArtifactExistsInFileSystem(filePath, 20, 500);
238
-
239
- if (!isFileExist) {
240
- console.error(pc.yellow(`Artifacts file ${filePath} does not exist. Skipping...`));
241
- return;
242
- }
243
-
244
- // skipping artifact only if: 1. storing to file is enabled, 2. max size is set and 3. file size exceeds the limit
245
- if (
246
- this.storeEnabled &&
247
- TESTOMATIO_ARTIFACT_MAX_SIZE_MB &&
248
- fileSizeInMb > parseFloat(TESTOMATIO_ARTIFACT_MAX_SIZE_MB)
249
- ) {
250
- const skippedArtifact = { path: filePath, size: fileSize };
251
- this.storeUploadedFile(filePath, runId, rid, false);
252
- this.skippedUploads.push(skippedArtifact);
253
- debug(pc.yellow(`Artifacts file ${JSON.stringify(skippedArtifact)} exceeds the maximum allowed size. Skipping.`));
254
- return;
255
- }
256
- debug('File:', filePath, 'exists, size:', prettyBytes(fileSize));
257
-
258
- const fileStream = fs.createReadStream(filePath);
259
- const Key = pathInS3.filter(p => !!p).join('/');
260
-
261
- const link = await this.#uploadToS3(fileStream, Key, { path: filePath, size: fileSize });
262
-
263
- this.storeUploadedFile(filePath, runId, rid, !!link);
264
-
265
- return link;
266
- }
267
-
268
- /**
269
- * @param {Buffer} buffer
270
- * @param {string[]} pathInS3
271
- * @returns
272
- */
273
- async uploadFileAsBuffer(buffer, pathInS3) {
274
- /* WDIO: some artifacts uploading started before createRun function completion
275
- probably, the reason is that run is NOT created in adapter (but via cli) */
276
-
277
- this.isEnabled = this.isEnabled ?? this.checkEnabled();
278
- if (!this.isEnabled) return;
279
-
280
- let Key = pathInS3.filter(p => !!p).join('/');
281
- const ext = this.#getFileExtBase64(buffer.toString('base64'));
282
-
283
- if (ext) {
284
- Key = `${Key}.${ext}`;
285
- }
286
-
287
- return this.#uploadToS3(buffer, Key, { path: Key });
288
- }
289
-
290
- async checkArtifactExistsInFileSystem(filePath, attempts = 5, intervalMs = 500) {
291
- return promiseRetry(
292
- async (retry, number) => {
293
- try {
294
- fs.accessSync(filePath);
295
- return true;
296
- } catch (err) {
297
- if (number === attempts) {
298
- return false;
299
- }
300
- debug(`File not found, retrying (attempt ${number}/${attempts})`);
301
- await new Promise(resolve => {
302
- setTimeout(resolve, intervalMs);
303
- });
304
- retry(err);
305
- }
306
- },
307
- {
308
- retries: attempts,
309
- minTimeout: intervalMs,
310
- maxTimeout: intervalMs,
311
- },
312
- );
313
- }
314
-
315
- async getS3LocationLink(out) {
316
- const response = await out.done();
317
-
318
- let s3Location = response?.Location?.trim();
319
-
320
- if (!s3Location) {
321
- s3Location = out?.singleUploadResult?.Location;
322
- debug('Uploaded singleUploadResult.Location', s3Location);
323
-
324
- if (!s3Location) {
325
- throw new Error("Problems getting the S3 artifact's link. Please check S3 permissions!");
326
- }
327
- }
328
-
329
- // Normalize the URL
330
- if (!s3Location.startsWith('http')) {
331
- s3Location = `https://${s3Location}`;
332
- }
333
-
334
- return s3Location;
335
- }
336
-
337
- #getFileExtBase64(str) {
338
- const type = str.charAt(0);
339
-
340
- return (
341
- {
342
- '/': 'jpg',
343
- i: 'png',
344
- R: 'gif',
345
- U: 'webp',
346
- }[type] || ''
347
- );
348
- }
349
-
350
- #getS3Config() {
351
- const { S3_REGION, S3_SESSION_TOKEN, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_FORCE_PATH_STYLE, S3_ENDPOINT } =
352
- this.getConfig();
353
-
354
- const cfg = {
355
- region: S3_REGION,
356
- credentials: {
357
- accessKeyId: S3_ACCESS_KEY_ID,
358
- secretAccessKey: S3_SECRET_ACCESS_KEY,
359
- },
360
- };
361
-
362
- if (S3_FORCE_PATH_STYLE) {
363
- cfg.forcePathStyle = !['false', '0'].includes(String(S3_FORCE_PATH_STYLE || '').toLowerCase());
364
- }
365
-
366
- if (S3_SESSION_TOKEN) {
367
- cfg.credentials.sessionToken = S3_SESSION_TOKEN;
368
- }
369
-
370
- if (S3_ENDPOINT) {
371
- cfg.endpoint = S3_ENDPOINT;
372
- }
373
-
374
- return cfg;
375
- }
376
- }
@@ -1,119 +0,0 @@
1
- import { APP_PREFIX } from '../constants.js';
2
-
3
- /**
4
- * Set S3 credentials from the provided artifacts object.
5
- * @param {Object} artifacts - The artifacts object containing S3 credentials.
6
- */
7
- function setS3Credentials(artifacts) {
8
- if (!Object.keys(artifacts).length) return;
9
-
10
- console.log(APP_PREFIX, 'S3 credentials obtained from Testomat.io...');
11
-
12
- if (artifacts.ACCESS_KEY_ID) process.env.S3_ACCESS_KEY_ID = artifacts.ACCESS_KEY_ID;
13
- if (artifacts.SECRET_ACCESS_KEY) process.env.S3_SECRET_ACCESS_KEY = artifacts.SECRET_ACCESS_KEY;
14
- if (artifacts.REGION) process.env.S3_REGION = artifacts.REGION;
15
- if (artifacts.BUCKET) process.env.S3_BUCKET = artifacts.BUCKET;
16
- if (artifacts.SESSION_TOKEN) process.env.S3_SESSION_TOKEN = artifacts.SESSION_TOKEN;
17
- if (artifacts.presign) process.env.TESTOMATIO_PRIVATE_ARTIFACTS = '1';
18
- // endpoint is not received from the server; and shuld be empty if IAM used (credentails obtained from the testomat)
19
- process.env.S3_ENDPOINT = artifacts.ENDPOINT || '';
20
- }
21
-
22
- /**
23
- * Generates mode request parameters based on the input params.
24
- * @param {{type: string, id?: string, apiKey: string}} params - The input parameters for the request.
25
- * @returns {Object|null} - An object containing the generated request parameters, or null if the type is invalid.
26
- */
27
- function generateFilterRequestParams(params) {
28
- const { type, id, apiKey } = params;
29
-
30
- if (!type) {
31
- return;
32
- }
33
-
34
- if (!id) {
35
- console.error(APP_PREFIX, `Please make sure your settings "${type.toUpperCase()}"= "${id}" is correct!`);
36
- return;
37
- }
38
-
39
- return {
40
- params: {
41
- type,
42
- id: encodeURIComponent(id),
43
- api_key: apiKey,
44
- },
45
- responseType: 'json',
46
- };
47
- }
48
-
49
- /**
50
- * Parse filter parameters from a string in the format "type=id".
51
- * @param {string} opts - The input string containing the filter parameters.
52
- * @returns {Object} An object containing the parsed filter parameters.
53
- * The object has properties "type" and "id".
54
- */
55
- function parseFilterParams(opts) {
56
- const [type, id] = opts.split('=');
57
- const validType = updateFilterType(type);
58
-
59
- return {
60
- type: validType,
61
- id,
62
- };
63
- }
64
-
65
- /**
66
- * Update and validate the filter type.
67
- * @param {string} type - The original filter type.
68
- * @returns {string|undefined} The updated and validated filter type.
69
- * Returns undefined if the type is not valid.
70
- */
71
- function updateFilterType(type) {
72
- const typeLowerCase = type.toLowerCase();
73
-
74
- const filterTypes = ['tag-name', 'plan-id', 'label', 'jira-ticket'];
75
-
76
- const filterApi = [
77
- 'tag',
78
- 'plan',
79
- 'label',
80
- 'jira',
81
- // "ims-issue", //TODO: WIP
82
- ];
83
-
84
- if (!filterTypes.includes(typeLowerCase)) {
85
- console.log(APP_PREFIX, `❗❗❗ Invalid "filter=${type}" start settings! Available option list: ${filterTypes}`);
86
- return;
87
- }
88
-
89
- const index = filterTypes.indexOf(typeLowerCase);
90
-
91
- return index !== -1 ? filterApi[index] : undefined;
92
- }
93
-
94
- /**
95
- * Return an emoji based on the provided status.
96
- * @param {string} status - The status value ('passed', 'failed', or 'skipped').
97
- * @returns {string} - An emoji corresponding to the provided status.
98
- */
99
- function statusEmoji(status) {
100
- if (status === 'passed') return '🟢';
101
- if (status === 'failed') return '🔴';
102
- if (status === 'skipped') return '🟡';
103
- return '';
104
- }
105
-
106
- /**
107
- * Generate a full name string based on the provided test object.
108
- * @param {object} t - The test object.
109
- * @returns {string} - A formatted full name string for the test object.
110
- */
111
- function fullName(t) {
112
- let line = '';
113
- if (t.suite_title) line = `${t.suite_title}: `;
114
- line += `**${t.title}**`;
115
- if (t.example) line += ` \`[${Object.values(t.example)}]\``;
116
- return line;
117
- }
118
-
119
- export { updateFilterType, parseFilterParams, generateFilterRequestParams, setS3Credentials, statusEmoji, fullName };