@testrevolution/bugbug-cli 8.11.1 → 8.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@testrevolution/bugbug-cli",
3
3
  "description": "BugBug CLI",
4
- "version": "8.11.1",
4
+ "version": "8.12.0",
5
5
  "keywords": [
6
6
  "automation",
7
7
  "cli",
@@ -181,6 +181,7 @@ describe('commands module', () => {
181
181
  withDetails: false,
182
182
  reporter: 'inline',
183
183
  outputPath: 'test-report.xml',
184
+ triggeredBy: 'cli',
184
185
  });
185
186
  });
186
187
 
@@ -200,6 +201,7 @@ describe('commands module', () => {
200
201
  withDetails: false,
201
202
  reporter: 'inline',
202
203
  outputPath: 'test-report.xml',
204
+ triggeredBy: 'cli',
203
205
  });
204
206
  });
205
207
 
@@ -219,6 +221,7 @@ describe('commands module', () => {
219
221
  withDetails: false,
220
222
  reporter: 'inline',
221
223
  outputPath: 'test-report.xml',
224
+ triggeredBy: 'cli',
222
225
  });
223
226
  });
224
227
 
@@ -238,6 +241,7 @@ describe('commands module', () => {
238
241
  withDetails: false,
239
242
  reporter: 'inline',
240
243
  outputPath: 'test-report.xml',
244
+ triggeredBy: 'cli',
241
245
  });
242
246
  });
243
247
 
@@ -257,6 +261,7 @@ describe('commands module', () => {
257
261
  withDetails: false,
258
262
  reporter: 'inline',
259
263
  outputPath: 'test-report.xml',
264
+ triggeredBy: 'cli',
260
265
  });
261
266
  });
262
267
 
@@ -278,6 +283,7 @@ describe('commands module', () => {
278
283
  withDetails: false,
279
284
  reporter: 'inline',
280
285
  outputPath: 'test-report.xml',
286
+ triggeredBy: 'cli',
281
287
  });
282
288
  });
283
289
 
@@ -298,6 +304,7 @@ describe('commands module', () => {
298
304
  withDetails: false,
299
305
  reporter: 'inline',
300
306
  outputPath: 'test-report.xml',
307
+ triggeredBy: 'cli',
301
308
  });
302
309
  });
303
310
 
@@ -318,6 +325,7 @@ describe('commands module', () => {
318
325
  withDetails: false,
319
326
  reporter: 'inline',
320
327
  outputPath: 'test-report.xml',
328
+ triggeredBy: 'cli',
321
329
  });
322
330
  });
323
331
 
@@ -338,6 +346,7 @@ describe('commands module', () => {
338
346
  withDetails: false,
339
347
  reporter: 'inline',
340
348
  outputPath: 'test-report.xml',
349
+ triggeredBy: 'cli',
341
350
  });
342
351
  });
343
352
 
@@ -358,6 +367,7 @@ describe('commands module', () => {
358
367
  withDetails: false,
359
368
  reporter: 'inline',
360
369
  outputPath: 'test-report.xml',
370
+ triggeredBy: 'cli',
361
371
  });
362
372
  });
363
373
 
@@ -377,6 +387,7 @@ describe('commands module', () => {
377
387
  withDetails: true,
378
388
  reporter: 'inline',
379
389
  outputPath: 'test-report.xml',
390
+ triggeredBy: 'cli',
380
391
  });
381
392
  });
382
393
 
@@ -396,6 +407,7 @@ describe('commands module', () => {
396
407
  withDetails: false,
397
408
  reporter: 'inline',
398
409
  outputPath: 'test-report.xml',
410
+ triggeredBy: 'cli',
399
411
  });
400
412
  });
401
413
 
@@ -416,6 +428,7 @@ describe('commands module', () => {
416
428
  withDetails: false,
417
429
  reporter: 'inline',
418
430
  outputPath: 'test-report.xml',
431
+ triggeredBy: 'cli',
419
432
  });
420
433
  });
421
434
 
@@ -436,6 +449,7 @@ describe('commands module', () => {
436
449
  withDetails: false,
437
450
  reporter: 'inline',
438
451
  outputPath: 'test-report.xml',
452
+ triggeredBy: 'cli',
439
453
  });
440
454
  });
441
455
 
@@ -455,6 +469,7 @@ describe('commands module', () => {
455
469
  withDetails: false,
456
470
  reporter: 'inline',
457
471
  outputPath: 'test-report.xml',
472
+ triggeredBy: 'cli',
458
473
  });
459
474
  });
460
475
 
@@ -474,6 +489,7 @@ describe('commands module', () => {
474
489
  withDetails: false,
475
490
  reporter: 'inline',
476
491
  outputPath: 'test-report.xml',
492
+ triggeredBy: 'cli',
477
493
  });
478
494
  });
479
495
 
@@ -493,6 +509,7 @@ describe('commands module', () => {
493
509
  withDetails: false,
494
510
  reporter: 'inline',
495
511
  outputPath: 'test-report.xml',
512
+ triggeredBy: 'cli',
496
513
  });
497
514
  });
498
515
 
@@ -512,6 +529,7 @@ describe('commands module', () => {
512
529
  withDetails: false,
513
530
  reporter: 'inline',
514
531
  outputPath: 'test-report.xml',
532
+ triggeredBy: 'cli',
515
533
  });
516
534
  });
517
535
 
@@ -530,7 +548,7 @@ describe('commands module', () => {
530
548
  expect(axios).toHaveBeenCalledWith({
531
549
  method: 'GET',
532
550
  url: `https://bugbug.io/test-api/v1/testruns/${id}/`,
533
- data: {},
551
+ data: { triggeredBy: 'cli' },
534
552
  params: {},
535
553
  headers: { Authorization: `Token ${configValue.token}`, 'User-Agent': settings.USER_AGENT },
536
554
  });
@@ -557,8 +575,9 @@ describe('commands module', () => {
557
575
  expect(axios).toHaveBeenCalledWith({
558
576
  method: 'GET',
559
577
  url: `https://bugbug.io/test-api/v1/testruns/${id}/`,
560
- data: {},
578
+ data: { triggeredBy: 'cli' },
561
579
  params: {},
580
+
562
581
  headers: { Authorization: `Token ${configValue.token}`, 'User-Agent': settings.USER_AGENT },
563
582
  });
564
583
  });
@@ -585,8 +604,9 @@ describe('commands module', () => {
585
604
  expect(axios).toHaveBeenCalledWith({
586
605
  method: 'GET',
587
606
  url: `https://bugbug.io/test-api/v1/testruns/${id}/`,
588
- data: {},
607
+ data: { triggeredBy: 'cli' },
589
608
  params: {},
609
+
590
610
  headers: { Authorization: `Token ${configValue.token}`, 'User-Agent': settings.USER_AGENT },
591
611
  });
592
612
  });
@@ -606,8 +626,9 @@ describe('commands module', () => {
606
626
  expect(axios).toHaveBeenCalledWith({
607
627
  method: 'GET',
608
628
  url: `https://bugbug.io/test-api/v1/testruns/${id}/status/`,
609
- data: {},
629
+ data: { triggeredBy: 'cli' },
610
630
  params: {},
631
+
611
632
  headers: { Authorization: `Token ${configValue.token}`, 'User-Agent': settings.USER_AGENT },
612
633
  });
613
634
  });
@@ -630,6 +651,7 @@ describe('commands module', () => {
630
651
  suite_id: id,
631
652
  profile_name: undefined,
632
653
  variables: [],
654
+ triggeredBy: 'cli',
633
655
  },
634
656
  params: {},
635
657
  headers: { Authorization: `Token ${configValue.token}`, 'User-Agent': settings.USER_AGENT },
@@ -656,6 +678,8 @@ describe('commands module', () => {
656
678
  suite_id: id,
657
679
  profile_name: profileName,
658
680
  variables: [],
681
+ triggeredBy: 'cli',
682
+
659
683
  },
660
684
  params: {},
661
685
  headers: { Authorization: `Token ${configValue.token}`, 'User-Agent': settings.USER_AGENT },
@@ -709,7 +733,10 @@ describe('commands module', () => {
709
733
  method: 'POST',
710
734
  url: 'https://bugbug.io/test-api/v1/testruns/',
711
735
  data: {
712
- test_id: id, profile_name: undefined, variables: [],
736
+ test_id: id,
737
+ profile_name: undefined,
738
+ variables: [],
739
+ triggeredBy: 'cli',
713
740
  },
714
741
  params: {},
715
742
  headers: { Authorization: `Token ${configValue.token}`, 'User-Agent': settings.USER_AGENT },
@@ -734,7 +761,7 @@ describe('commands module', () => {
734
761
  method: 'POST',
735
762
  url: 'https://bugbug.io/test-api/v1/testruns/',
736
763
  data: {
737
- test_id: id, profile_name: profileName, variables: [],
764
+ test_id: id, profile_name: profileName, variables: [], triggeredBy: 'cli',
738
765
  },
739
766
  params: {},
740
767
  headers: { Authorization: `Token ${configValue.token}`, 'User-Agent': settings.USER_AGENT },
@@ -760,23 +787,26 @@ describe('commands module', () => {
760
787
  method: 'POST',
761
788
  url: 'https://bugbug.io/test-api/v1/testruns/',
762
789
  data: {
763
- test_id: id, profile_name: undefined, variables: [],
790
+ test_id: id, profile_name: undefined, variables: [], triggeredBy: 'cli',
791
+
764
792
  },
765
- params: {},
793
+ params: { },
766
794
  headers: { Authorization: `Token ${configValue.token}`, 'User-Agent': settings.USER_AGENT },
767
795
  });
768
796
  expect(axios).toHaveBeenNthCalledWith(2, {
769
797
  method: 'GET',
770
798
  url: `https://bugbug.io/test-api/v1/testruns/${apiMocks.runTestSuccess.data.id}/status/`,
771
- data: {},
799
+ data: { triggeredBy: 'cli' },
772
800
  params: {},
801
+
773
802
  headers: { Authorization: `Token ${configValue.token}`, 'User-Agent': settings.USER_AGENT },
774
803
  });
775
804
  expect(axios).toHaveBeenNthCalledWith(3, {
776
805
  method: 'GET',
777
806
  url: `https://bugbug.io/test-api/v1/testruns/${apiMocks.runTestSuccess.data.id}/`,
778
- data: {},
807
+ data: { triggeredBy: 'cli' },
779
808
  params: {},
809
+
780
810
  headers: { Authorization: `Token ${configValue.token}`, 'User-Agent': settings.USER_AGENT },
781
811
  });
782
812
  });
@@ -796,8 +826,9 @@ describe('commands module', () => {
796
826
  expect(axios).toHaveBeenCalledWith({
797
827
  method: 'GET',
798
828
  url: 'https://bugbug.io/test-api/v1/profiles/',
799
- data: {},
829
+ data: { triggeredBy: 'cli' },
800
830
  params: {},
831
+
801
832
  headers: { Authorization: `Token ${configValue.token}`, 'User-Agent': settings.USER_AGENT },
802
833
  });
803
834
  });
@@ -817,8 +848,9 @@ describe('commands module', () => {
817
848
  expect(axios).toHaveBeenCalledWith({
818
849
  method: 'GET',
819
850
  url: 'https://bugbug.io/test-api/v1/tests/',
820
- data: {},
851
+ data: { triggeredBy: 'cli' },
821
852
  params: {},
853
+
822
854
  headers: { Authorization: `Token ${configValue.token}`, 'User-Agent': settings.USER_AGENT },
823
855
  });
824
856
  });
@@ -838,8 +870,9 @@ describe('commands module', () => {
838
870
  expect(axios).toHaveBeenCalledWith({
839
871
  method: 'GET',
840
872
  url: 'https://bugbug.io/test-api/v1/suites/',
841
- data: {},
873
+ data: { triggeredBy: 'cli' },
842
874
  params: {},
875
+
843
876
  headers: { Authorization: `Token ${configValue.token}`, 'User-Agent': settings.USER_AGENT },
844
877
  });
845
878
  });
@@ -28,7 +28,7 @@ const getList = async (type, query, extraParams) => {
28
28
  const route = settings.API_ROUTING[`${type}List`];
29
29
  try {
30
30
  const params = query ? { query } : {};
31
- const result = await apiCall(route.path, route.method, {}, params);
31
+ const result = await apiCall(route.path, route.method, {}, params, extraParams.triggeredBy);
32
32
  if (result) {
33
33
  printList(spinner, result.data);
34
34
  return getExitCode(true);
@@ -49,7 +49,7 @@ const getResult = async (type, id, extraParams) => {
49
49
  const route = settings.API_ROUTING[`${type}Result`];
50
50
  const path = format(route.path, id);
51
51
  try {
52
- const result = await apiCall(path, route.method, {}, {});
52
+ const result = await apiCall(path, route.method, {}, {}, extraParams.triggeredBy);
53
53
  if (result) {
54
54
  switch (reporter) {
55
55
  case settings.REPORTER_TYPE.junit: {
@@ -86,9 +86,9 @@ const checkStatus = async (type, id, extraParams) => {
86
86
  try {
87
87
  let response;
88
88
  if (nowait) {
89
- response = await apiCall(path, route.method, {}, {});
89
+ response = await apiCall(path, route.method, {}, {}, extraParams.triggeredBy);
90
90
  } else {
91
- response = await apiCallPoll(path, route.method, {}, spinner, 0);
91
+ response = await apiCallPoll(path, route.method, {}, spinner, 0, extraParams.triggeredBy);
92
92
  }
93
93
  if (
94
94
  reporter !== settings.REPORTER_TYPE.inline
@@ -113,7 +113,7 @@ const run = async (type, data, extraParams) => {
113
113
  const route = settings.API_ROUTING[`${type}Run`];
114
114
  const spinner = getSpinner(noprogress);
115
115
  try {
116
- const response = await apiCall(route.path, route.method, data, {});
116
+ const response = await apiCall(route.path, route.method, data, {}, extraParams.triggeredBy);
117
117
  const { data: responseData } = response;
118
118
  if (responseData) {
119
119
  spinner.info(`Queued (${type}RunId: ${responseData.id})`);
@@ -158,6 +158,7 @@ const parseArgs = async (args) => {
158
158
  const extraParams = {
159
159
  nowait: args.wait === false || args.nowait || false,
160
160
  noprogress: args.progress === false || args.noprogress || false,
161
+ triggeredBy: args['triggered-by'] || 'cli',
161
162
  withDetails: args['with-details'] || false,
162
163
  reporter: args.reporter || settings.REPORTER_TYPE.inline,
163
164
  outputPath: args['output-path'] || 'test-report.xml',
@@ -175,7 +176,7 @@ const validateArgs = async (args) => {
175
176
  return false;
176
177
  }
177
178
 
178
- const knownKeys = ['_', 'wait', 'nowait', 'noprogress', 'progress', 'with-details', 'debug', 'profile', 'variable', 'result-timeout', 'reporter', 'output-path'];
179
+ const knownKeys = ['_', 'wait', 'nowait', 'noprogress', 'progress', 'with-details', 'debug', 'profile', 'variable', 'result-timeout', 'reporter', 'output-path', 'triggered-by'];
179
180
  const unknownKeys = await getUnknownOptions(args, knownKeys);
180
181
  if (unknownKeys.length > 0) {
181
182
  console.error(`Unknown options: ${unknownKeys.join(', ')}`);
package/src/utils/api.js CHANGED
@@ -79,7 +79,7 @@ const mountAxiosInterceptors = (printRawResponse) => {
79
79
  // eslint-disable-next-line no-promise-executor-return
80
80
  const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
81
81
 
82
- const apiCall = async (path, method, data, params) => {
82
+ const apiCall = async (path, method, data, params, triggeredBy) => {
83
83
  const url = `${settings.API_URL}${path}`;
84
84
  const token = await config.getConfigValue('token');
85
85
 
@@ -90,7 +90,7 @@ const apiCall = async (path, method, data, params) => {
90
90
  result = await axios({
91
91
  method,
92
92
  url,
93
- data,
93
+ data: { ...data, triggeredBy },
94
94
  params,
95
95
  headers: {
96
96
  Authorization: `Token ${token}`,
@@ -111,8 +111,8 @@ const apiCall = async (path, method, data, params) => {
111
111
  return result;
112
112
  };
113
113
 
114
- const apiCallPoll = async (path, method, data, spinner, retryCounter) => {
115
- const response = await apiCall(path, method, data, {});
114
+ const apiCallPoll = async (path, method, data, spinner, retryCounter, triggeredBy) => {
115
+ const response = await apiCall(path, method, data, {}, triggeredBy);
116
116
  const modifiedDiff = Date.now() - Date.parse(response.data.modified);
117
117
  const isTimeout = modifiedDiff > settings.API_POLLING_MODIFIED_INTERVAL;
118
118
  if (retryCounter >= settings.API_POLLING_MAX_RETRY_TIMES && isTimeout) {
@@ -120,7 +120,7 @@ const apiCallPoll = async (path, method, data, spinner, retryCounter) => {
120
120
  }
121
121
  if (settings.RETRY_STATUS.includes(response.data.status)) {
122
122
  await wait(settings.API_POLLING_INTERVAL);
123
- return apiCallPoll(path, method, data, spinner, retryCounter + 1);
123
+ return apiCallPoll(path, method, data, spinner, retryCounter + 1, triggeredBy);
124
124
  }
125
125
  return response;
126
126
  };