@testomatio/reporter 1.2.1-beta → 1.2.1-beta.codecept-id

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 (47) hide show
  1. package/README.md +61 -54
  2. package/lib/adapter/codecept.js +136 -57
  3. package/lib/adapter/cucumber/current.js +103 -60
  4. package/lib/adapter/cucumber/legacy.js +27 -12
  5. package/lib/adapter/cucumber.js +2 -2
  6. package/lib/adapter/cypress-plugin/index.js +52 -25
  7. package/lib/adapter/jasmine.js +1 -1
  8. package/lib/adapter/jest.js +49 -11
  9. package/lib/adapter/mocha.js +103 -51
  10. package/lib/adapter/playwright.js +100 -31
  11. package/lib/adapter/webdriver.js +1 -1
  12. package/lib/bin/reportXml.js +14 -13
  13. package/lib/bin/startTest.js +27 -6
  14. package/lib/client.js +193 -69
  15. package/lib/config.js +34 -0
  16. package/lib/constants.js +19 -7
  17. package/lib/data-storage.js +203 -0
  18. package/lib/fileUploader.js +128 -53
  19. package/lib/junit-adapter/adapter.js +0 -2
  20. package/lib/junit-adapter/csharp.js +3 -4
  21. package/lib/junit-adapter/index.js +3 -3
  22. package/lib/junit-adapter/java.js +35 -17
  23. package/lib/junit-adapter/javascript.js +1 -2
  24. package/lib/junit-adapter/python.js +12 -14
  25. package/lib/junit-adapter/ruby.js +1 -2
  26. package/lib/pipe/csv.js +5 -3
  27. package/lib/pipe/github.js +27 -39
  28. package/lib/pipe/gitlab.js +20 -24
  29. package/lib/pipe/html.js +317 -0
  30. package/lib/pipe/index.js +3 -1
  31. package/lib/pipe/testomatio.js +182 -55
  32. package/lib/reporter-functions.js +46 -0
  33. package/lib/reporter.js +11 -9
  34. package/lib/services/artifacts.js +57 -0
  35. package/lib/services/index.js +13 -0
  36. package/lib/services/key-values.js +58 -0
  37. package/lib/services/logger.js +311 -0
  38. package/lib/template/template-draft.hbs +249 -0
  39. package/lib/template/testomatio.hbs +388 -0
  40. package/lib/utils/pipe_utils.js +128 -0
  41. package/lib/{util.js → utils/utils.js} +145 -12
  42. package/lib/xmlReader.js +211 -122
  43. package/package.json +18 -8
  44. package/lib/_ArtifactStorageOld.js +0 -142
  45. package/lib/artifactStorage.js +0 -25
  46. package/lib/dataStorage.js +0 -180
  47. package/lib/logger.js +0 -278
@@ -0,0 +1,388 @@
1
+ <html lang='en'>
2
+ <head>
3
+ <meta charset='UTF-8' />
4
+ <meta
5
+ name='viewport'
6
+ content='width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0'
7
+ />
8
+ <meta http-equiv='X-UA-Compatible' content='ie=edge' />
9
+ <link
10
+ href='https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css'
11
+ rel='stylesheet'
12
+ integrity='sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC'
13
+ crossorigin='anonymous'
14
+ />
15
+ <link
16
+ rel='stylesheet'
17
+ href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css'
18
+ integrity='sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=='
19
+ crossorigin='anonymous'
20
+ referrerpolicy='no-referrer'
21
+ />
22
+ {{#if runId}}
23
+ <title>Report #{{runId}} - Testomat.io</title>
24
+ {{else}}
25
+ <title>Report Testomat.io</title>
26
+ {{/if}}
27
+ <style>
28
+ body { padding: 0; margin: 0; } header, div, p, form, input, a, span, button { box-sizing: border-box; } img {
29
+ width: 100%; display: block; max-width: 100%; height: auto; } p, span{ font-weight: 400; font-size: 14px; color:
30
+ grey; margin: 0; } .report{ padding-top: 15px; } .level_1{ margin-bottom: 20px; border-bottom: 1px solid grey;
31
+ padding-bottom: 10px; } .header{ display: flex; justify-content: space-between; align-items: center; }
32
+ .header__point{ width: 8px; height: 8px; border-radius: 50%; margin-right: 15px; } .header__point_red{ background:
33
+ red; } .header__block{ display: flex; align-items: center; } .header__case{ display: flex; align-items: center;
34
+ margin-right: 15px; } .header__case p{ margin-right: 7px; } .header__case span{ color: black; } .header__block
35
+ button{ margin-left: 15px; } .header__type{ background: #0d6efd; color: #FFF; border-radius: 10px; padding: 1px
36
+ 5px; margin-right: 15px; } .header__case i{ color: grey; margin-right: 5px; } .title{ display: flex;
37
+ margin-bottom: 20px; } .title p{ color: black; font-size: 20px; margin-right: 5px; } .statright{ display: flex; }
38
+ .statdesc{ display: flex; flex-direction: column; } .statdesc__row{ padding: 15px 10px; display: flex; }
39
+ .statdesc__row_first{ width: 150px; } .statdesc__row:nth-child(odd){ background: #F4F5FF; } .statdesc__row p{
40
+ font-weight: bold; } .statdesc{ width: 100%; } .statstatus{ display: flex; align-items: center; } .statstatus p{
41
+ font-weight: bold; } .statstatus div{ font-weight: bold; } .statstatus_failed div{ width: 10px; height: 10px;
42
+ border-radius: 50%; margin-right: 5px; } .statstatus_failed p{ color: red; text-transform: uppercase; }
43
+ .statstatus_failed div{ background: red; } .statstatus_passed div{ width: 10px; height: 10px; border-radius: 50%;
44
+ margin-right: 5px; text-transform: uppercase; } .statstatus_passed div { background: green; } .statstatus_passed p
45
+ { color: green; text-transform: uppercase; } .statstatus_skipped div{ width: 10px; height: 10px; border-radius:
46
+ 50%; margin-right: 5px; text-transform: uppercase; } .statstatus_skipped div { background: yellow; }
47
+ .statstatus_skipped p { color: yellow; text-transform: uppercase; } .fa-magnifying-glass{ font-size: 24px; color:
48
+ gray; } .level_5{ margin-top: 20px; } .numTest{ font-weight: 700; font-size: 16px; color:#0d6efd; } .testitem{
49
+ border: 1px solid grey; border-radius: 10px; margin-bottom: 15px; } .testitem__top{ width: 100%; display: flex;
50
+ background: #e9ecef; padding: 3px 0; border-radius:10px; cursor: pointer; } .testitem__icon{ display: flex;
51
+ align-items: center; justify-content: center; width: 30px; margin-right: 15px; } .testitem__ico{ font-size: 18px;
52
+ } .testitem__name{ font-weight: 700; color: black; font-size: 16px; } .testitem__body{ display: flex; border-top:
53
+ 1px solid grey; } .testitem__menu{ display: flex; flex-direction: column; border-right: 1px solid grey; padding:
54
+ 15px; } .testitem__mitem{ margin-bottom: 10px; font-size: 14px; cursor: pointer; color: grey; }
55
+ .testitem__mitem_active{ color: green; } .testitem__case{ display: flex; flex-direction: column; padding: 10px; }
56
+ .testitem__title{ font-size: 18px; color: black; font-weight: 700; margin-bottom: 15px; text-decoration:
57
+ underline; } .testitem__block p{ font-size: 14px; white-space: pre-line; } .test__empty__list { margin-bottom:
58
+ 10px; color: grey; } /* Passed TAB*/ #passedTest:not(:checked) + .btn-outline-dark { background-color: #39BD2F; }
59
+ #passedTest:checked + .btn-outline-dark { background-color: #68cf61; color: white; } /* Failed TAB*/
60
+ #failedTest:not(:checked) + .btn-outline-dark { background-color: #F2230C; } #failedTest:checked +
61
+ .btn-outline-dark { background-color: #FA6E5E; color: white; } /* Skipped TAB*/ #skippedTest:not(:checked) +
62
+ .btn-outline-dark { background-color: #F2C00C; } #skippedTest:checked + .btn-outline-dark { background-color:
63
+ #dfc155; }
64
+ </style>
65
+ </head>
66
+
67
+ <body class='bg-gray-50 pt-6 px-4 lg:pt-4 lg:px-40 h-full;'>
68
+ <section class='report' id='report'>
69
+ <div class='container'>
70
+ <!-- top -->
71
+ <div class='row level_1'>
72
+ <div class='col-12'>
73
+ <div class='header'>
74
+ <div class='header__block'>
75
+ {{#if runId}}
76
+ <div class='header__case'>
77
+ <p>Run</p>
78
+ <span><strong>#</strong>{{runId}}</span>
79
+ </div>
80
+ {{/if}}
81
+ <p class='header__type'>
82
+ <i class='fa-solid fa-face-smile'></i>
83
+ automated job
84
+ </p>
85
+ </div>
86
+ <div class='header__block'>
87
+ {{#if runUrl}}
88
+ <a href='{{runUrl}}' target='_blank' class='btn btn-primary'>
89
+ Full Report
90
+ </a>
91
+ {{else}}
92
+ <button class='btn btn-primary' disabled>
93
+ Full Report
94
+ </button>
95
+ {{/if}}
96
+ </div>
97
+ </div>
98
+ </div>
99
+ </div>
100
+ <!-- top -->
101
+
102
+ <div class='row level_2'>
103
+ <div class='col-12'>
104
+ <div class='title'>
105
+ <p>Testomatio Run Information</p>
106
+ </div>
107
+ </div>
108
+ </div>
109
+
110
+ <!-- Schedule and information -->
111
+ <div class='row level_3'>
112
+ <div class='col-6'>
113
+ <div class='statleft'>
114
+ <div id='graff'></div>
115
+ </div>
116
+ </div>
117
+ <div class='col-6'>
118
+ <div class='statright'>
119
+ <div class='statdesc'>
120
+ <!-- 1 -->
121
+ <div class='statdesc__row'>
122
+ <div class='statdesc__row_first'>
123
+ <p>Status</p>
124
+ </div>
125
+ <div class='statstatus statstatus_{{status}}'>
126
+ <div></div>
127
+ <p>{{status}}</p>
128
+ </div>
129
+ </div>
130
+ <!-- 1 -->
131
+ <!-- 1 -->
132
+ <div class='statdesc__row'>
133
+ <div class='statdesc__row_first'>
134
+ <p>Execution Duration</p>
135
+ </div>
136
+ <span>{{executionTime}}</span>
137
+ </div>
138
+ <!-- 1 -->
139
+ <!-- 1 -->
140
+ <div class='statdesc__row'>
141
+ <div class='statdesc__row_first'>
142
+ <p>Tests</p>
143
+ </div>
144
+ <span>{{tests.length}}</span>
145
+ </div>
146
+ <!-- 1 -->
147
+ <!-- 1 -->
148
+ <div class='statdesc__row'>
149
+ <div class='statdesc__row_first'>
150
+ <p>Start Execution Date</p>
151
+ </div>
152
+ <span>{{executionDate}}</span>
153
+ </div>
154
+ <!-- 1 -->
155
+ </div>
156
+ </div>
157
+ </div>
158
+ </div>
159
+ <!-- Schedule and information -->
160
+ <div class='row level_4'>
161
+ <div class='col-6'>
162
+ <div class='input-group'>
163
+ <div class='input-group-prepend'>
164
+ <span class='input-group-text' id='basic-addon1'>
165
+ <i class='fa-solid fa-magnifying-glass'></i>
166
+ </span>
167
+ </div>
168
+ <input
169
+ type='text'
170
+ class='form-control inputSearch'
171
+ placeholder='Search'
172
+ aria-label='Search'
173
+ aria-describedby='basic-addon1'
174
+ />
175
+ </div>
176
+ </div>
177
+
178
+ <div class='col-6 d-flex justify-content-end'>
179
+ <div class='btn-group menuTests' role='group' aria-label='Basic radio toggle button group'>
180
+
181
+ <input
182
+ type='radio'
183
+ class='btn-check'
184
+ name='groupTest'
185
+ id='allTest'
186
+ autocomplete='off'
187
+ category='all'
188
+ checked
189
+ />
190
+ <label class='btn btn-outline-dark' for='allTest'>All
191
+ <span class='numTest' name='numTest' lcategory='all'>0</span></label>
192
+
193
+ <input
194
+ type='radio'
195
+ class='btn-check'
196
+ name='groupTest'
197
+ id='passedTest'
198
+ autocomplete='off'
199
+ category='passed'
200
+ />
201
+ <label class='btn btn-outline-dark' for='passedTest'>Passed
202
+ <span class='numTest' name='numTest' lcategory='passed'>0</span></label>
203
+
204
+ <input
205
+ type='radio'
206
+ class='btn-check'
207
+ name='groupTest'
208
+ id='failedTest'
209
+ autocomplete='off'
210
+ category='failed'
211
+ />
212
+ <label class='btn btn-outline-dark' for='failedTest'>Failed
213
+ <span class='numTest' name='numTest' lcategory='failed'>0</span></label>
214
+
215
+ <input
216
+ type='radio'
217
+ class='btn-check'
218
+ name='groupTest'
219
+ id='skippedTest'
220
+ autocomplete='off'
221
+ category='skipped'
222
+ />
223
+ <label class='btn btn-outline-dark' for='skippedTest'>Skipped
224
+ <span class='numTest' name='numTest' lcategory='skipped'>0</span></label>
225
+
226
+ </div>
227
+ </div>
228
+ </div>
229
+
230
+ <div class='row level_5'>
231
+ <div class='col-12'>
232
+ {{#if tests.length}}
233
+ <div class='testWrapp'>
234
+ {{#each tests}}
235
+
236
+ <div class='testitem d-none' name='testitem' type='dummy' category='false'>
237
+
238
+ <div class='testitem__top'>
239
+ <div class='testitem__icon'>
240
+ <i class='fa-solid fa-chevron-right testitem__ico testitem__ico_right'></i>
241
+ <i class='fa-solid fa-chevron-down d-none testitem__ico testitem__ico_down'></i>
242
+ </div>
243
+ <p class='testitem__name'>Test</p>
244
+ </div>
245
+
246
+ <div class='testitem__body d-none'>
247
+
248
+ <div class='testitem__menu'>
249
+ <span type='steps' class='testitem__mitem testitem__mitem_active'>Steps
250
+ <i class='fa-solid fa-arrow-right'></i></span>
251
+ <span type='status' class='testitem__mitem'>Status
252
+ <i class='fa-solid fa-arrow-right'></i></span>
253
+ <span type='message' class='testitem__mitem'>Message
254
+ <i class='fa-solid fa-arrow-right'></i></span>
255
+ <span type='files' class='testitem__mitem'>Files <i class='fa-solid fa-arrow-right'></i></span>
256
+ </div>
257
+
258
+ <div class='testitem__content'>
259
+
260
+ <!-- 1 -->
261
+ <div class='testitem__case' type='steps'>
262
+ <p class='testitem__title'>Steps</p>
263
+ <div class='testitem__block'>
264
+ <span>...</span>
265
+ </div>
266
+ </div>
267
+ <!-- 1 -->
268
+
269
+ <!-- 2 -->
270
+ <div class='testitem__case d-none' type='status'>
271
+ <p class='testitem__title'>Status</p>
272
+ <div class='testitem__block'>
273
+ <span>...</span>
274
+ </div>
275
+ </div>
276
+ <!-- 2 -->
277
+
278
+ <!-- 3 -->
279
+ <div class='testitem__case d-none' type='message'>
280
+ <p class='testitem__title'>Message</p>
281
+ <div class='testitem__block'>
282
+ <span>...</span>
283
+ </div>
284
+ </div>
285
+ <!-- 3 -->
286
+
287
+ <!-- 4 -->
288
+ <div class='testitem__case d-none' type='files'>
289
+ <p class='testitem__title'>Files</p>
290
+ <div class='testitem__block'>
291
+ <span>...</span>
292
+ </div>
293
+ </div>
294
+ <!-- 4 -->
295
+ </div>
296
+ </div>
297
+ </div>
298
+ {{/each}}
299
+ </div>
300
+ {{else}}
301
+ <div class='row'>
302
+ <div class='col-12 test__empty__list'>
303
+ <p>No tests found to display 😔</p>
304
+ </div>
305
+ </div>
306
+ {{/if}}
307
+ </div>
308
+ </div>
309
+
310
+ </div>
311
+ </section>
312
+
313
+ <script type='text/javascript' src='https://www.gstatic.com/charts/loader.js'></script>
314
+ <script type='text/javascript'>
315
+ // Load google charts google.charts.load('current', {'packages':['corechart']});
316
+ google.charts.setOnLoadCallback(drawChart); // Draw the chart and set the chart values function drawChart() { let
317
+ data = {}; const passedTests =
318
+ {{getTestsByStatus tests 'PASSED'}}; const failedTests =
319
+ {{getTestsByStatus tests 'FAILED'}}; const skippedTests =
320
+ {{getTestsByStatus tests 'SKIPPED'}}; if (passedTests === 0 && failedTests === 0 && skippedTests === 0) { data =
321
+ google.visualization.arrayToDataTable([ ['Task', 'Tests'], ['No Tests', 1] ]) } else { data =
322
+ google.visualization.arrayToDataTable([ ['Task', 'Tests'], ['No Tests', 0], ['Passed', passedTests], ['Failed',
323
+ failedTests], ['Skipped', skippedTests], ]); } // Optional: add a title and set the width and height of the chart
324
+ const options = { 'title':'', 'width':550, 'height':300, 'colors': ['#939992', '#39BD2F', '#F2230C', '#F2C00C'] };
325
+ // Display the chart inside the <div> element with id="piechart" const chart = new
326
+ google.visualization.PieChart(document.getElementById('graff')); chart.draw(data, options); } // processing and
327
+ adding test data to the template function addOneTest(category,testData = {}){ const { suite_title, title, steps,
328
+ message, files } = testData; // radio btn test's count function incrementCount(element) { let count =
329
+ parseInt(element.textContent); count++; element.textContent = count; } function addCountToRadio(page,category){
330
+ const menuTests = page.querySelector('.menuTests'); const all =
331
+ menuTests.querySelector('span[name="numTest"][lcategory="all"]'); incrementCount(all); const elemCat =
332
+ menuTests.querySelector('span[name="numTest"][lcategory="' + category + '"]'); if (elemCat) {
333
+ incrementCount(elemCat); } } // collapse - expand block function collapse_expand(top){ const block =
334
+ top.closest('.testitem'); const icon = top.querySelector('.testitem__icon'); const testitem__ico_right =
335
+ icon.querySelector('.testitem__ico_right'); const testitem__ico_down = icon.querySelector('.testitem__ico_down');
336
+ const body = block.querySelector('.testitem__body'); if(body.classList.contains('d-none')){
337
+ body.classList.remove('d-none'); testitem__ico_right.classList.add('d-none');
338
+ testitem__ico_down.classList.remove('d-none'); } else{ body.classList.add('d-none');
339
+ testitem__ico_down.classList.add('d-none'); testitem__ico_right.classList.remove('d-none'); } } function
340
+ menu(clone){ function removeAddActive(elem){ const menu = elem.closest('.testitem__menu'); const item =
341
+ menu.querySelectorAll('.testitem__mitem'); for(let i=0; i<item.length; i++){
342
+ item[i].classList.remove('testitem__mitem_active'); } elem.classList.add('testitem__mitem_active'); } function
343
+ show_content(elem){ removeAddActive(elem); const body = elem.closest('.testitem__body'); const content =
344
+ body.querySelector('.testitem__content'); const blocks = content.querySelectorAll('.testitem__case'); for(let i=0;
345
+ i<blocks.length; i++){ blocks[i].classList.add('d-none'); } const type = elem.getAttribute('type'); const
346
+ show_elem = content.querySelector('div[type="'+type+'"]'); show_elem.classList.remove('d-none'); } const menu =
347
+ clone.querySelector('.testitem__menu'); const item = menu.querySelectorAll('.testitem__mitem'); for(let i=0;
348
+ i<item.length; i++){ item[i].addEventListener('click',function(){ show_content(item[i]) }) } } const page =
349
+ document.querySelector('.report'); const wrapp = page.querySelector('.testWrapp'); const dummy =
350
+ wrapp.querySelector('div[name="testitem"][type="dummy"]'); const clone = dummy.cloneNode(true);
351
+ clone.setAttribute('type','clone'); clone.setAttribute('category',category); clone.classList.remove('d-none');
352
+ wrapp.append(clone); const testitem__name = clone.querySelector('.testitem__name'); const fullTestName =
353
+ suite_title ? suite_title + " - " + title : title; testitem__name.textContent = fullTestName; const body =
354
+ clone.querySelector('.testitem__body'); let content = body.querySelector('.testitem__content'); let content_error
355
+ = content.querySelector('div[type="steps"]').querySelector('span'); content_error.innerHTML = steps; let
356
+ content_status = content.querySelector('div[type="status"]').querySelector('span'); content_status.innerHTML =
357
+ category; let content_message = content.querySelector('div[type="message"]').querySelector('span');
358
+ content_message.innerHTML = message; let content_files =
359
+ content.querySelector('div[type="files"]').querySelector('span'); if (files.includes("This test has no files")) {
360
+ content_files.innerHTML = files; } if (!files.includes("This test has no files")) { const filesList =
361
+ document.createElement('ul'); content_files.innerHTML = ""; if (Array.isArray(files) && files.length > 0) {
362
+ files.forEach((file) => { const listItem = document.createElement('li'); const fileLink =
363
+ document.createElement('a'); fileLink.href = file.path; fileLink.target = '_blank'; fileLink.textContent =
364
+ file.path; listItem.appendChild(fileLink); filesList.appendChild(listItem); });
365
+ content_files.appendChild(filesList); } } const testitem__top = clone.querySelector('.testitem__top');
366
+ testitem__top.addEventListener("click", function(){ collapse_expand(testitem__top); }); menu(clone);
367
+ addCountToRadio(page,category); } function radioMenuStart(){ function showBlockForCat(input){ const page =
368
+ input.closest('.report'); const wrapp = page.querySelector('.testWrapp'); const clone =
369
+ wrapp.querySelectorAll('div[name="testitem"][type="clone"]'); for(let i=0; i<clone.length; i++){
370
+ clone[i].classList.add('d-none'); } const category = input.getAttribute('category'); if(category == 'all'){
371
+ for(let i=0; i<clone.length; i++){ clone[i].classList.remove('d-none'); } } else{ for(let i=0; i<clone.length;
372
+ i++){ if(clone[i].getAttribute('category') == category){ clone[i].classList.remove('d-none'); } } } } const page =
373
+ document.querySelector('.report'); const menuTests = page.querySelector('.menuTests'); const items =
374
+ menuTests.querySelectorAll('input[name="groupTest"]'); for(let i=0; i<items.length; i++){
375
+ items[i].addEventListener('change',function(){ showBlockForCat(items[i]) }) } } radioMenuStart(); function
376
+ search(){ function searchBlock(input){ const value = input.value; const page = input.closest('.report'); const
377
+ wrapp = page.querySelector('.testWrapp'); const clone =
378
+ wrapp.querySelectorAll('div[name="testitem"][type="clone"]'); for(let i=0; i<clone.length; i++){
379
+ clone[i].classList.add('d-none'); } for(let i=0; i<clone.length; i++){ let testitem__name =
380
+ clone[i].querySelector('.testitem__name'); let nameInBlock = testitem__name.textContent;
381
+ if(nameInBlock.includes(value)){ clone[i].classList.remove('d-none'); } } } const page =
382
+ document.querySelector('.report'); const inputSearch = page.querySelector('.inputSearch');
383
+ inputSearch.addEventListener('input',function(){ searchBlock(inputSearch) }) } search(); const executedTests =
384
+ {{{json tests}}}; for (let i = 0; i < executedTests.length; i++) { const status = executedTests[i].status;
385
+ addOneTest(status, executedTests[i]); }
386
+ </script>
387
+ </body>
388
+ </html>
@@ -0,0 +1,128 @@
1
+ const { resetConfig } = require('../fileUploader');
2
+ const { APP_PREFIX } = require('../constants');
3
+
4
+ /**
5
+ * Set S3 credentials from the provided artifacts object.
6
+ * @param {Object} artifacts - The artifacts object containing S3 credentials.
7
+ */
8
+ function setS3Credentials(artifacts) {
9
+ if (!Object.keys(artifacts).length) return;
10
+
11
+ console.log(APP_PREFIX, 'S3 were credentials obtained from Testomat.io...');
12
+
13
+ if (artifacts.ACCESS_KEY_ID) process.env.S3_ACCESS_KEY_ID = artifacts.ACCESS_KEY_ID;
14
+ if (artifacts.SECRET_ACCESS_KEY) process.env.S3_SECRET_ACCESS_KEY = artifacts.SECRET_ACCESS_KEY;
15
+ if (artifacts.REGION) process.env.S3_REGION = artifacts.REGION;
16
+ if (artifacts.BUCKET) process.env.S3_BUCKET = artifacts.BUCKET;
17
+ if (artifacts.ENDPOINT) process.env.S3_ENDPOINT = artifacts.ENDPOINT;
18
+ if (artifacts.presign) process.env.TESTOMATIO_PRIVATE_ARTIFACTS = '1';
19
+ resetConfig();
20
+ }
21
+ /**
22
+ * Generates mode request parameters based on the input params.
23
+ * @param {Object} params - The input parameters for the request.
24
+ * @param {string} params.type - The type of the request (e.g., "tag").
25
+ * @param {string} params.id - The ID associated with the request.
26
+ * @param {string} params.apiKey - The API key for authentication.
27
+ * @returns {Object|null} - An object containing the generated request parameters, or null if the type is invalid.
28
+ */
29
+ function generateFilterRequestParams(params) {
30
+ const { type, id, apiKey } = params;
31
+
32
+ if (!type) {
33
+ return;
34
+ }
35
+
36
+ if (!id) {
37
+ console.error(APP_PREFIX, `Please make sure your settings "${type.toUpperCase()}"= "${id}" is correct!`);
38
+ return;
39
+ }
40
+
41
+ return {
42
+ params: {
43
+ type,
44
+ id: encodeURIComponent(id),
45
+ api_key: apiKey,
46
+ },
47
+ responseType: 'json',
48
+ };
49
+ }
50
+
51
+ /**
52
+ * Parse filter parameters from a string in the format "type=id".
53
+ * @param {string} opts - The input string containing the filter parameters.
54
+ * @returns {Object} An object containing the parsed filter parameters.
55
+ * The object has properties "type" and "id".
56
+ */
57
+ function parseFilterParams(opts) {
58
+ const [type, id] = opts.split('=');
59
+ const validType = updateFilterType(type);
60
+
61
+ return {
62
+ type: validType,
63
+ id,
64
+ };
65
+ }
66
+
67
+ /**
68
+ * Update and validate the filter type.
69
+ * @param {string} type - The original filter type.
70
+ * @returns {string|undefined} The updated and validated filter type.
71
+ * Returns undefined if the type is not valid.
72
+ */
73
+ function updateFilterType(type) {
74
+ const typeLowerCase = type.toLowerCase();
75
+
76
+ const filterTypes = ['tag-name', 'plan-id', 'label', 'jira-ticket'];
77
+
78
+ const filterApi = [
79
+ 'tag',
80
+ 'plan',
81
+ 'label',
82
+ 'jira',
83
+ // "ims-issue", //TODO: WIP
84
+ ];
85
+
86
+ if (!filterTypes.includes(typeLowerCase)) {
87
+ console.log(APP_PREFIX, `❗❗❗ Invalid "filter=${type}" start settings! Available option list: ${filterTypes}`);
88
+ return;
89
+ }
90
+
91
+ const index = filterTypes.indexOf(typeLowerCase);
92
+
93
+ return index !== -1 ? filterApi[index] : undefined;
94
+ }
95
+
96
+ /**
97
+ * Return an emoji based on the provided status.
98
+ * @param {string} status - The status value ('passed', 'failed', or 'skipped').
99
+ * @returns {string} - An emoji corresponding to the provided status.
100
+ */
101
+ function statusEmoji(status) {
102
+ if (status === 'passed') return '🟢';
103
+ if (status === 'failed') return '🔴';
104
+ if (status === 'skipped') return '🟡';
105
+ return '';
106
+ }
107
+
108
+ /**
109
+ * Generate a full name string based on the provided test object.
110
+ * @param {object} t - The test object.
111
+ * @returns {string} - A formatted full name string for the test object.
112
+ */
113
+ function fullName(t) {
114
+ let line = '';
115
+ if (t.suite_title) line = `${t.suite_title}: `;
116
+ line += `**${t.title}**`;
117
+ if (t.example) line += ` \`[${Object.values(t.example)}]\``;
118
+ return line;
119
+ }
120
+
121
+ module.exports = {
122
+ updateFilterType,
123
+ parseFilterParams,
124
+ generateFilterRequestParams,
125
+ setS3Credentials,
126
+ statusEmoji,
127
+ fullName,
128
+ };