@mablhq/mabl-cli 2.55.0 → 2.57.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.
@@ -167,21 +167,6 @@ object-assign
167
167
  * MIT Licensed
168
168
  */
169
169
 
170
- /*! *****************************************************************************
171
- Copyright (c) Microsoft Corporation.
172
-
173
- Permission to use, copy, modify, and/or distribute this software for any
174
- purpose with or without fee is hereby granted.
175
-
176
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
177
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
178
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
179
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
180
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
181
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
182
- PERFORMANCE OF THIS SOFTWARE.
183
- ***************************************************************************** */
184
-
185
170
  /*! axe v4.8.3
186
171
  * Copyright (c) 2015 - 2023 Deque Systems, Inc.
187
172
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mablhq/mabl-cli",
3
- "version": "2.55.0",
3
+ "version": "2.57.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "The official mabl command line interface tool",
6
6
  "main": "index.js",
@@ -23,6 +23,7 @@
23
23
  "@aws-crypto/crc32c": "5.1.0",
24
24
  "@google-cloud/storage": "7.9.0",
25
25
  "@mablhq/newman-reporter-mabl-console": "0.4.2",
26
+ "@mablhq/playwright-reporter": "0.4.0",
26
27
  "@plist/common": "1.1.0",
27
28
  "@plist/parse": "1.1.0",
28
29
  "@types/adm-zip": "0.5.5",
@@ -76,8 +77,8 @@
76
77
  "open": "6.4.0",
77
78
  "ora": "4.0.4",
78
79
  "pixelmatch": "5.3.0",
79
- "playwright": "1.50.1",
80
- "playwright-core": "1.50.1",
80
+ "playwright": "1.51.0",
81
+ "playwright-core": "1.51.0",
81
82
  "pluralize": "8.0.0",
82
83
  "pngjs": "6.0.0",
83
84
  "portfinder": "1.0.28",
@@ -2,9 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseOutReportOptions = exports.handleReportingForTestsRun = void 0;
4
4
  const constants_1 = require("../commands/constants");
5
+ const TestResult_1 = require("../core/execution/TestResult");
5
6
  const loggingProvider_1 = require("../providers/logging/loggingProvider");
6
7
  const mochAwesomeReporter_1 = require("./mochAwesome/mochAwesomeReporter");
7
- async function handleReportingForTestsRun(reporter, testResults, reportOptions) {
8
+ const playwright_reporter_1 = require("@mablhq/playwright-reporter");
9
+ async function handleReportingForTestsRun(reporter, testResults, apiClient, workspaceId, reportOptions, browser) {
8
10
  let options;
9
11
  try {
10
12
  options = reportOptions ? parseOutReportOptions(reportOptions) : {};
@@ -14,9 +16,18 @@ async function handleReportingForTestsRun(reporter, testResults, reportOptions)
14
16
  }
15
17
  try {
16
18
  switch (reporter) {
17
- case constants_1.ReporterOptions.Mochawesome:
19
+ case constants_1.Reporter.Mochawesome:
18
20
  await (0, mochAwesomeReporter_1.generateMochAwesomeReportFromTestResults)(testResults, options);
19
21
  break;
22
+ case constants_1.Reporter.Mabl:
23
+ if (!workspaceId) {
24
+ throw new Error('Workspace ID is required for Mabl reporting');
25
+ }
26
+ if (!browser) {
27
+ throw new Error('Browser is required for Mabl reporting');
28
+ }
29
+ await generateMablReportFromTestResults(workspaceId, testResults, options, apiClient, browser);
30
+ break;
20
31
  default:
21
32
  throw new Error(`Unsupported reporter options supplied: ${reporter}`);
22
33
  }
@@ -26,6 +37,55 @@ async function handleReportingForTestsRun(reporter, testResults, reportOptions)
26
37
  }
27
38
  }
28
39
  exports.handleReportingForTestsRun = handleReportingForTestsRun;
40
+ async function generateMablReportFromTestResults(workspaceId, testResults, _options, apiClient, browser) {
41
+ const reporterApiClient = new playwright_reporter_1.MablApiClient({
42
+ httpClient: apiClient.httpClient,
43
+ apiUrl: apiClient.baseApiUrl,
44
+ log: (message) => {
45
+ loggingProvider_1.logger.info(message);
46
+ return;
47
+ },
48
+ logError: (message) => {
49
+ loggingProvider_1.logger.error(message);
50
+ return;
51
+ },
52
+ });
53
+ const uploadClient = new playwright_reporter_1.UploadClient({
54
+ uploadServiceUrl: new URL(apiClient.baseApiUrl),
55
+ httpClient: apiClient.httpClient,
56
+ });
57
+ const mablReporter = new playwright_reporter_1.MablReporter({
58
+ apiClient: reporterApiClient,
59
+ uploadClient,
60
+ log: (message) => {
61
+ loggingProvider_1.logger.debug(message);
62
+ },
63
+ logError: (message) => {
64
+ loggingProvider_1.logger.error(message);
65
+ },
66
+ workspaceId,
67
+ context: 'mabl_local',
68
+ });
69
+ for (const result of testResults.testResults.filter((result) => shouldReportTestResult(result.status))) {
70
+ const outcome = testResultStatusToReporterOutcome(result.status);
71
+ const status = outcome === 'passed' ? 'passed' : 'failed';
72
+ try {
73
+ await mablReporter.createTestResult({
74
+ workspace_id: workspaceId,
75
+ started_time: result.startTime,
76
+ completed_time: result.endTime,
77
+ test_id: result.testId,
78
+ test_type: 'browser',
79
+ outcome,
80
+ status: testResultStatusToReporterStatus(result.status),
81
+ browser,
82
+ }, undefined, [], status);
83
+ }
84
+ catch (error) {
85
+ loggingProvider_1.logger.error(`Unable to create Mabl test result due to error: ${error}`);
86
+ }
87
+ }
88
+ }
29
89
  function parseOutReportOptions(suppliedOptions) {
30
90
  const reporterOptions = {};
31
91
  const pairs = suppliedOptions.split(',');
@@ -44,3 +104,18 @@ function parseOutReportOptions(suppliedOptions) {
44
104
  return reporterOptions;
45
105
  }
46
106
  exports.parseOutReportOptions = parseOutReportOptions;
107
+ function testResultStatusToReporterOutcome(status) {
108
+ if (status === TestResult_1.TestResultStatus.passed) {
109
+ return 'passed';
110
+ }
111
+ return 'failed';
112
+ }
113
+ function shouldReportTestResult(status) {
114
+ return (status === TestResult_1.TestResultStatus.failed || status === TestResult_1.TestResultStatus.passed);
115
+ }
116
+ function testResultStatusToReporterStatus(status) {
117
+ if (status === TestResult_1.TestResultStatus.passed) {
118
+ return 'completed';
119
+ }
120
+ return 'failed';
121
+ }