@azure/playwright 1.0.1-alpha.20251225.1 → 1.0.1-alpha.20251231.2

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 (137) hide show
  1. package/dist/browser/common/constants.d.ts +1 -0
  2. package/dist/browser/common/constants.d.ts.map +1 -1
  3. package/dist/browser/common/constants.js +1 -0
  4. package/dist/browser/common/constants.js.map +1 -1
  5. package/dist/browser/common/messages.d.ts +60 -9
  6. package/dist/browser/common/messages.d.ts.map +1 -1
  7. package/dist/browser/common/messages.js +74 -23
  8. package/dist/browser/common/messages.js.map +1 -1
  9. package/dist/browser/common/types.d.ts +12 -0
  10. package/dist/browser/common/types.d.ts.map +1 -1
  11. package/dist/browser/common/types.js.map +1 -1
  12. package/dist/browser/core/initializePlaywrightServiceTestRun.d.ts.map +1 -1
  13. package/dist/browser/core/initializePlaywrightServiceTestRun.js +4 -5
  14. package/dist/browser/core/initializePlaywrightServiceTestRun.js.map +1 -1
  15. package/dist/browser/reporter/playwrightReporter.d.ts +2 -1
  16. package/dist/browser/reporter/playwrightReporter.d.ts.map +1 -1
  17. package/dist/browser/reporter/playwrightReporter.js +99 -34
  18. package/dist/browser/reporter/playwrightReporter.js.map +1 -1
  19. package/dist/browser/utils/PlaywrightServiceClient.d.ts +9 -0
  20. package/dist/browser/utils/PlaywrightServiceClient.d.ts.map +1 -0
  21. package/dist/browser/utils/PlaywrightServiceClient.js +67 -0
  22. package/dist/browser/utils/PlaywrightServiceClient.js.map +1 -0
  23. package/dist/browser/utils/playwrightReporterStorageManager.d.ts +4 -5
  24. package/dist/browser/utils/playwrightReporterStorageManager.d.ts.map +1 -1
  25. package/dist/browser/utils/playwrightReporterStorageManager.js +155 -97
  26. package/dist/browser/utils/playwrightReporterStorageManager.js.map +1 -1
  27. package/dist/browser/utils/utils.d.ts +1 -0
  28. package/dist/browser/utils/utils.d.ts.map +1 -1
  29. package/dist/browser/utils/utils.js +19 -0
  30. package/dist/browser/utils/utils.js.map +1 -1
  31. package/dist/commonjs/common/constants.d.ts +1 -0
  32. package/dist/commonjs/common/constants.d.ts.map +1 -1
  33. package/dist/commonjs/common/constants.js +1 -0
  34. package/dist/commonjs/common/constants.js.map +1 -1
  35. package/dist/commonjs/common/messages.d.ts +60 -9
  36. package/dist/commonjs/common/messages.d.ts.map +1 -1
  37. package/dist/commonjs/common/messages.js +74 -23
  38. package/dist/commonjs/common/messages.js.map +1 -1
  39. package/dist/commonjs/common/types.d.ts +12 -0
  40. package/dist/commonjs/common/types.d.ts.map +1 -1
  41. package/dist/commonjs/common/types.js.map +1 -1
  42. package/dist/commonjs/core/initializePlaywrightServiceTestRun.d.ts.map +1 -1
  43. package/dist/commonjs/core/initializePlaywrightServiceTestRun.js +4 -5
  44. package/dist/commonjs/core/initializePlaywrightServiceTestRun.js.map +1 -1
  45. package/dist/commonjs/reporter/playwrightReporter.d.ts +2 -1
  46. package/dist/commonjs/reporter/playwrightReporter.d.ts.map +1 -1
  47. package/dist/commonjs/reporter/playwrightReporter.js +97 -32
  48. package/dist/commonjs/reporter/playwrightReporter.js.map +1 -1
  49. package/dist/commonjs/utils/PlaywrightServiceClient.d.ts +9 -0
  50. package/dist/commonjs/utils/PlaywrightServiceClient.d.ts.map +1 -0
  51. package/dist/commonjs/utils/PlaywrightServiceClient.js +71 -0
  52. package/dist/commonjs/utils/PlaywrightServiceClient.js.map +1 -0
  53. package/dist/commonjs/utils/playwrightReporterStorageManager.d.ts +4 -5
  54. package/dist/commonjs/utils/playwrightReporterStorageManager.d.ts.map +1 -1
  55. package/dist/commonjs/utils/playwrightReporterStorageManager.js +153 -95
  56. package/dist/commonjs/utils/playwrightReporterStorageManager.js.map +1 -1
  57. package/dist/commonjs/utils/utils.d.ts +1 -0
  58. package/dist/commonjs/utils/utils.d.ts.map +1 -1
  59. package/dist/commonjs/utils/utils.js +21 -1
  60. package/dist/commonjs/utils/utils.js.map +1 -1
  61. package/dist/esm/common/constants.d.ts +1 -0
  62. package/dist/esm/common/constants.d.ts.map +1 -1
  63. package/dist/esm/common/constants.js +1 -0
  64. package/dist/esm/common/constants.js.map +1 -1
  65. package/dist/esm/common/messages.d.ts +60 -9
  66. package/dist/esm/common/messages.d.ts.map +1 -1
  67. package/dist/esm/common/messages.js +74 -23
  68. package/dist/esm/common/messages.js.map +1 -1
  69. package/dist/esm/common/types.d.ts +12 -0
  70. package/dist/esm/common/types.d.ts.map +1 -1
  71. package/dist/esm/common/types.js.map +1 -1
  72. package/dist/esm/core/initializePlaywrightServiceTestRun.d.ts.map +1 -1
  73. package/dist/esm/core/initializePlaywrightServiceTestRun.js +4 -5
  74. package/dist/esm/core/initializePlaywrightServiceTestRun.js.map +1 -1
  75. package/dist/esm/reporter/playwrightReporter.d.ts +2 -1
  76. package/dist/esm/reporter/playwrightReporter.d.ts.map +1 -1
  77. package/dist/esm/reporter/playwrightReporter.js +99 -34
  78. package/dist/esm/reporter/playwrightReporter.js.map +1 -1
  79. package/dist/esm/utils/PlaywrightServiceClient.d.ts +9 -0
  80. package/dist/esm/utils/PlaywrightServiceClient.d.ts.map +1 -0
  81. package/dist/esm/utils/PlaywrightServiceClient.js +67 -0
  82. package/dist/esm/utils/PlaywrightServiceClient.js.map +1 -0
  83. package/dist/esm/utils/playwrightReporterStorageManager.d.ts +4 -5
  84. package/dist/esm/utils/playwrightReporterStorageManager.d.ts.map +1 -1
  85. package/dist/esm/utils/playwrightReporterStorageManager.js +155 -97
  86. package/dist/esm/utils/playwrightReporterStorageManager.js.map +1 -1
  87. package/dist/esm/utils/utils.d.ts +1 -0
  88. package/dist/esm/utils/utils.d.ts.map +1 -1
  89. package/dist/esm/utils/utils.js +19 -0
  90. package/dist/esm/utils/utils.js.map +1 -1
  91. package/dist/react-native/common/constants.d.ts +1 -0
  92. package/dist/react-native/common/constants.d.ts.map +1 -1
  93. package/dist/react-native/common/constants.js +1 -0
  94. package/dist/react-native/common/constants.js.map +1 -1
  95. package/dist/react-native/common/messages.d.ts +60 -9
  96. package/dist/react-native/common/messages.d.ts.map +1 -1
  97. package/dist/react-native/common/messages.js +74 -23
  98. package/dist/react-native/common/messages.js.map +1 -1
  99. package/dist/react-native/common/types.d.ts +12 -0
  100. package/dist/react-native/common/types.d.ts.map +1 -1
  101. package/dist/react-native/common/types.js.map +1 -1
  102. package/dist/react-native/core/initializePlaywrightServiceTestRun.d.ts.map +1 -1
  103. package/dist/react-native/core/initializePlaywrightServiceTestRun.js +4 -5
  104. package/dist/react-native/core/initializePlaywrightServiceTestRun.js.map +1 -1
  105. package/dist/react-native/reporter/playwrightReporter.d.ts +2 -1
  106. package/dist/react-native/reporter/playwrightReporter.d.ts.map +1 -1
  107. package/dist/react-native/reporter/playwrightReporter.js +99 -34
  108. package/dist/react-native/reporter/playwrightReporter.js.map +1 -1
  109. package/dist/react-native/utils/PlaywrightServiceClient.d.ts +9 -0
  110. package/dist/react-native/utils/PlaywrightServiceClient.d.ts.map +1 -0
  111. package/dist/react-native/utils/PlaywrightServiceClient.js +67 -0
  112. package/dist/react-native/utils/PlaywrightServiceClient.js.map +1 -0
  113. package/dist/react-native/utils/playwrightReporterStorageManager.d.ts +4 -5
  114. package/dist/react-native/utils/playwrightReporterStorageManager.d.ts.map +1 -1
  115. package/dist/react-native/utils/playwrightReporterStorageManager.js +155 -97
  116. package/dist/react-native/utils/playwrightReporterStorageManager.js.map +1 -1
  117. package/dist/react-native/utils/utils.d.ts +1 -0
  118. package/dist/react-native/utils/utils.d.ts.map +1 -1
  119. package/dist/react-native/utils/utils.js +19 -0
  120. package/dist/react-native/utils/utils.js.map +1 -1
  121. package/package.json +1 -1
  122. package/dist/browser/utils/playwrightServiceApicall.d.ts +0 -16
  123. package/dist/browser/utils/playwrightServiceApicall.d.ts.map +0 -1
  124. package/dist/browser/utils/playwrightServiceApicall.js +0 -57
  125. package/dist/browser/utils/playwrightServiceApicall.js.map +0 -1
  126. package/dist/commonjs/utils/playwrightServiceApicall.d.ts +0 -16
  127. package/dist/commonjs/utils/playwrightServiceApicall.d.ts.map +0 -1
  128. package/dist/commonjs/utils/playwrightServiceApicall.js +0 -61
  129. package/dist/commonjs/utils/playwrightServiceApicall.js.map +0 -1
  130. package/dist/esm/utils/playwrightServiceApicall.d.ts +0 -16
  131. package/dist/esm/utils/playwrightServiceApicall.d.ts.map +0 -1
  132. package/dist/esm/utils/playwrightServiceApicall.js +0 -57
  133. package/dist/esm/utils/playwrightServiceApicall.js.map +0 -1
  134. package/dist/react-native/utils/playwrightServiceApicall.d.ts +0 -16
  135. package/dist/react-native/utils/playwrightServiceApicall.d.ts.map +0 -1
  136. package/dist/react-native/utils/playwrightServiceApicall.js +0 -57
  137. package/dist/react-native/utils/playwrightServiceApicall.js.map +0 -1
@@ -6,13 +6,14 @@ const logger_js_1 = require("../common/logger.js");
6
6
  const playwrightServiceConfig_js_1 = require("../common/playwrightServiceConfig.js");
7
7
  const constants_js_1 = require("../common/constants.js");
8
8
  const messages_js_1 = require("../common/messages.js");
9
- const playwrightServiceApicall_js_1 = require("../utils/playwrightServiceApicall.js");
9
+ const PlaywrightServiceClient_js_1 = require("../utils/PlaywrightServiceClient.js");
10
10
  /**
11
11
  * Azure Playwright Reporter - Uploads generated Playwright test report folder to Azure Storage.
12
12
  */
13
13
  class PlaywrightReporter {
14
14
  config;
15
15
  workspaceMetadata = null;
16
+ isReportingEnabled = false;
16
17
  /**
17
18
  * Called when test run begins. Stores configuration for later use and validates serviceAuthType and
18
19
  * retrieves workspace metadata.
@@ -20,34 +21,87 @@ class PlaywrightReporter {
20
21
  */
21
22
  async onBegin(config) {
22
23
  logger_js_1.coreLogger.info(`Reporter configuration: ${JSON.stringify(config.reporter, null, 2)}`);
23
- // Validate that HTML reporter is configured
24
- this.validateHtmlReporterConfiguration(config);
25
- // Validate that reporter is used only with ENTRA_ID authentication
24
+ this.config = config;
25
+ // Check if using service config
26
+ const usingServiceConfig = process.env[constants_js_1.InternalEnvironmentVariables.USING_SERVICE_CONFIG] === "true";
27
+ logger_js_1.coreLogger.info(`Using service config: ${usingServiceConfig}`);
28
+ if (!usingServiceConfig) {
29
+ console.error(messages_js_1.ServiceErrorMessageConstants.REPORTER_REQUIRES_SERVICE_CONFIG.message);
30
+ this.isReportingEnabled = false;
31
+ return;
32
+ }
33
+ // Check if test run creation was successful
34
+ const testRunCreationSuccess = process.env[constants_js_1.InternalEnvironmentVariables.TEST_RUN_CREATION_SUCCESS] === "true";
35
+ if (!testRunCreationSuccess) {
36
+ console.error(messages_js_1.ServiceErrorMessageConstants.REPORTING_STATUS_FAILED.message);
37
+ console.error(messages_js_1.ServiceErrorMessageConstants.REPORTING_TEST_RUN_FAILED.message);
38
+ this.isReportingEnabled = false;
39
+ return;
40
+ }
41
+ // Check authentication
26
42
  const playwrightServiceConfig = playwrightServiceConfig_js_1.PlaywrightServiceConfig.instance;
27
43
  logger_js_1.coreLogger.info(`Current authentication type: ${playwrightServiceConfig.serviceAuthType}`);
28
44
  const isUsingAccessToken = playwrightServiceConfig.serviceAuthType === constants_js_1.ServiceAuth.ACCESS_TOKEN;
29
45
  if (isUsingAccessToken) {
30
- (0, utils_js_1.exitWithFailureMessage)(messages_js_1.ServiceErrorMessageConstants.REPORTER_REQUIRES_ENTRA_AUTH);
46
+ console.error(messages_js_1.ServiceErrorMessageConstants.REPORTER_REQUIRES_ENTRA_AUTH.message);
47
+ this.isReportingEnabled = false;
48
+ return;
31
49
  }
32
50
  logger_js_1.coreLogger.info("Authentication validation passed - using ENTRA_ID");
33
- this.config = config;
34
51
  // Get workspace metadata for later use
35
52
  try {
36
- const playwrightServiceApiClient = new playwrightServiceApicall_js_1.PlaywrightServiceApiCall();
53
+ const playwrightServiceApiClient = new PlaywrightServiceClient_js_1.PlaywrightServiceClient();
37
54
  this.workspaceMetadata = await playwrightServiceApiClient.getWorkspaceMetadata();
38
- process.stdout.write("Initializing reporting for this test run.\n");
55
+ if (!this.workspaceMetadata?.storageUri) {
56
+ console.error(messages_js_1.ServiceErrorMessageConstants.WORKSPACE_REPORTING_DISABLED.message);
57
+ this.isReportingEnabled = false;
58
+ return;
59
+ }
60
+ this.isReportingEnabled = true;
61
+ this.validateHtmlReporterConfiguration(config);
62
+ if (this.isReportingEnabled) {
63
+ console.log(messages_js_1.ServiceErrorMessageConstants.REPORTING_ENABLED.message);
64
+ }
39
65
  }
40
66
  catch (error) {
41
- logger_js_1.coreLogger.error(`Failed to get workspace metadata: ${error instanceof Error ? error.message : String(error)}\n`);
42
- process.stderr.write("Failed to initialize reporting for this test run.\n");
67
+ const errorMessage = error instanceof Error ? error.message : String(error);
68
+ console.error(`${messages_js_1.ServiceErrorMessageConstants.WORKSPACE_METADATA_FETCH_FAILED.message}Error: ${errorMessage} `);
69
+ this.isReportingEnabled = false;
43
70
  }
44
71
  }
45
72
  /**
46
- * Called when test run ends. Uploads Playwright test report to Azure Storage.
73
+ * Called when test run ends. Uploads Playwright test report to Azure Storage if reporting is enabled.
47
74
  */
48
75
  async onEnd() {
49
- process.stdout.write(`Uploading Playwright Test report in Azure storage account.\n`);
50
- await this.uploadHtmlReport();
76
+ if (this.isReportingEnabled) {
77
+ console.log(messages_js_1.ServiceErrorMessageConstants.COLLECTING_ARTIFACTS.message);
78
+ const uploadResult = await this.uploadHtmlReport();
79
+ if (uploadResult.success) {
80
+ if (uploadResult.partialSuccess &&
81
+ uploadResult.failedFileDetails &&
82
+ uploadResult.failedFileDetails.length > 0) {
83
+ console.log("Warning: Failed to upload the following files:");
84
+ uploadResult.failedFileDetails.forEach((fileDetail) => {
85
+ console.log(` - ${fileDetail.fileName}, ERROR: ${fileDetail.error}`);
86
+ });
87
+ console.log(messages_js_1.ServiceErrorMessageConstants.REPORTING_STATUS_PARTIAL.message);
88
+ }
89
+ else {
90
+ console.log(messages_js_1.ServiceErrorMessageConstants.REPORTING_STATUS_SUCCESS.message);
91
+ }
92
+ // Display portal URL for both full and partial success
93
+ if (this.workspaceMetadata) {
94
+ const portalUrl = (0, utils_js_1.getPortalTestRunUrl)(this.workspaceMetadata);
95
+ console.log(messages_js_1.ServiceErrorMessageConstants.TEST_REPORT_VIEW_URL.formatWithUrl(portalUrl));
96
+ }
97
+ }
98
+ else {
99
+ console.error(messages_js_1.ServiceErrorMessageConstants.REPORTING_STATUS_FAILED.message);
100
+ if (uploadResult.errorMessage) {
101
+ console.error(`Error: ${uploadResult.errorMessage}`);
102
+ }
103
+ }
104
+ }
51
105
  }
52
106
  async uploadHtmlReport() {
53
107
  try {
@@ -55,36 +109,47 @@ class PlaywrightReporter {
55
109
  logger_js_1.coreLogger.info(`Resolved Playwright test report output folder: ${outputFolder}`);
56
110
  const storageManager = new playwrightReporterStorageManager_js_1.PlaywrightReporterStorageManager();
57
111
  logger_js_1.coreLogger.info("Starting Playwright test report upload process");
58
- await storageManager.uploadPlaywrightHtmlReportAfterTests(outputFolder, this.workspaceMetadata);
59
- logger_js_1.coreLogger.info(`✅ Playwright Test report uploaded successfully to Azure Storage.`);
60
- // Display portal URL for test report
61
- if (this.workspaceMetadata) {
62
- const portalUrl = (0, utils_js_1.getPortalTestRunUrl)(this.workspaceMetadata);
63
- process.stdout.write(`You can view test report at: ${portalUrl}\n`);
112
+ const uploadResult = await storageManager.uploadPlaywrightHtmlReportAfterTests(outputFolder, this.workspaceMetadata);
113
+ if (uploadResult.success) {
114
+ logger_js_1.coreLogger.info(`Playwright Test report uploaded successfully to Azure Storage.`);
64
115
  }
116
+ return uploadResult;
65
117
  }
66
118
  catch (error) {
67
119
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
68
- process.stderr.write(`❌ Failed to upload Playwright test report: ${errorMessage}\n`);
120
+ logger_js_1.coreLogger.error(`Upload failed: ${errorMessage}`);
121
+ return { success: false, errorMessage };
69
122
  }
70
123
  }
71
124
  validateHtmlReporterConfiguration(config) {
72
125
  if (!config.reporter || !Array.isArray(config.reporter)) {
73
- throw new Error(messages_js_1.ServiceErrorMessageConstants.HTML_REPORTER_REQUIRED.message);
126
+ console.error(messages_js_1.ServiceErrorMessageConstants.HTML_REPORTER_REQUIRED.message);
127
+ this.isReportingEnabled = false;
128
+ return;
74
129
  }
75
- const hasHtmlReporter = config.reporter.some((reporter) => {
76
- if (typeof reporter === "string") {
77
- return reporter === "html";
78
- }
79
- if (Array.isArray(reporter) && reporter.length > 0) {
80
- return reporter[0] === "html";
81
- }
82
- return false;
130
+ const htmlReporterIndex = config.reporter.findIndex((reporter) => {
131
+ const reporterName = typeof reporter === "string" ? reporter : reporter?.[0];
132
+ return reporterName === "html";
133
+ });
134
+ const azureReporterIndex = config.reporter.findIndex((reporter) => {
135
+ const reporterName = typeof reporter === "string" ? reporter : reporter?.[0];
136
+ return (typeof reporterName === "string" &&
137
+ reporterName.includes("playwright") &&
138
+ reporterName.includes("reporter"));
83
139
  });
84
- if (!hasHtmlReporter) {
85
- (0, utils_js_1.exitWithFailureMessage)(messages_js_1.ServiceErrorMessageConstants.HTML_REPORTER_REQUIRED);
140
+ // Validate HTML reporter exists
141
+ if (htmlReporterIndex === -1) {
142
+ console.error(messages_js_1.ServiceErrorMessageConstants.HTML_REPORTER_REQUIRED.message);
143
+ this.isReportingEnabled = false;
144
+ return;
145
+ }
146
+ // Validate HTML reporter comes before Azure reporter (if Azure reporter exists)
147
+ if (azureReporterIndex !== -1 && htmlReporterIndex > azureReporterIndex) {
148
+ console.error(messages_js_1.ServiceErrorMessageConstants.HTML_REPORTER_REQUIRED.message);
149
+ this.isReportingEnabled = false;
150
+ return;
86
151
  }
87
- logger_js_1.coreLogger.info("HTML reporter validation passed - HTML reporter is configured");
152
+ logger_js_1.coreLogger.info("HTML reporter validation passed - HTML reporter is configured and properly ordered");
88
153
  }
89
154
  }
90
155
  exports.default = PlaywrightReporter;
@@ -1 +1 @@
1
- {"version":3,"file":"playwrightReporter.js","sourceRoot":"","sources":["../../../src/reporter/playwrightReporter.ts"],"names":[],"mappings":";;AAGA,sGAAgG;AAChG,gDAI2B;AAC3B,mDAAiD;AACjD,qFAA+E;AAC/E,yDAAqD;AACrD,uDAAqE;AACrE,sFAAgF;AAGhF;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,IAAI,KAAK,CAAC,0CAA4B,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;QAC/E,CAAC;QAED,MAAM,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;YACxD,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;gBACjC,OAAO,QAAQ,KAAK,MAAM,CAAC;YAC7B,CAAC;YACD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACnD,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC;YAChC,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,IAAA,iCAAsB,EAAC,0CAA4B,CAAC,sBAAsB,CAAC,CAAC;QAC9E,CAAC;QAED,sBAAU,CAAC,IAAI,CAAC,+DAA+D,CAAC,CAAC;IACnF,CAAC;CACF;AA3FD,qCA2FC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { FullConfig, Reporter } from \"@playwright/test/reporter\";\nimport { PlaywrightReporterStorageManager } from \"../utils/playwrightReporterStorageManager.js\";\nimport {\n getHtmlReporterOutputFolder,\n getPortalTestRunUrl,\n exitWithFailureMessage,\n} from \"../utils/utils.js\";\nimport { coreLogger } from \"../common/logger.js\";\nimport { PlaywrightServiceConfig } from \"../common/playwrightServiceConfig.js\";\nimport { ServiceAuth } from \"../common/constants.js\";\nimport { ServiceErrorMessageConstants } from \"../common/messages.js\";\nimport { PlaywrightServiceApiCall } from \"../utils/playwrightServiceApicall.js\";\nimport type { WorkspaceMetaData } from \"../common/types.js\";\n\n/**\n * Azure Playwright Reporter - Uploads generated Playwright test report folder to Azure Storage.\n */\n\nexport default class PlaywrightReporter implements Reporter {\n private config: FullConfig | undefined;\n private workspaceMetadata: WorkspaceMetaData | null = null;\n\n /**\n * Called when test run begins. Stores configuration for later use and validates serviceAuthType and\n * retrieves workspace metadata.\n * @param config - Playwright test configuration\n */\n\n async onBegin(config: FullConfig): Promise<void> {\n coreLogger.info(`Reporter configuration: ${JSON.stringify(config.reporter, null, 2)}`);\n\n // Validate that HTML reporter is configured\n this.validateHtmlReporterConfiguration(config);\n\n // Validate that reporter is used only with ENTRA_ID authentication\n const playwrightServiceConfig = PlaywrightServiceConfig.instance;\n coreLogger.info(`Current authentication type: ${playwrightServiceConfig.serviceAuthType}`);\n const isUsingAccessToken = playwrightServiceConfig.serviceAuthType === ServiceAuth.ACCESS_TOKEN;\n if (isUsingAccessToken) {\n exitWithFailureMessage(ServiceErrorMessageConstants.REPORTER_REQUIRES_ENTRA_AUTH);\n }\n coreLogger.info(\"Authentication validation passed - using ENTRA_ID\");\n this.config = config;\n // Get workspace metadata for later use\n try {\n const playwrightServiceApiClient = new PlaywrightServiceApiCall();\n this.workspaceMetadata = await playwrightServiceApiClient.getWorkspaceMetadata();\n process.stdout.write(\"Initializing reporting for this test run.\\n\");\n } catch (error) {\n coreLogger.error(\n `Failed to get workspace metadata: ${error instanceof Error ? error.message : String(error)}\\n`,\n );\n process.stderr.write(\"Failed to initialize reporting for this test run.\\n\");\n }\n }\n\n /**\n * Called when test run ends. Uploads Playwright test report to Azure Storage.\n */\n\n async onEnd(): Promise<void> {\n process.stdout.write(`Uploading Playwright Test report in Azure storage account.\\n`);\n await this.uploadHtmlReport();\n }\n\n private async uploadHtmlReport(): Promise<void> {\n try {\n const outputFolder = getHtmlReporterOutputFolder(this.config);\n coreLogger.info(`Resolved Playwright test report output folder: ${outputFolder}`);\n const storageManager = new PlaywrightReporterStorageManager();\n coreLogger.info(\"Starting Playwright test report upload process\");\n await storageManager.uploadPlaywrightHtmlReportAfterTests(\n outputFolder,\n this.workspaceMetadata,\n );\n coreLogger.info(`✅ Playwright Test report uploaded successfully to Azure Storage.`);\n\n // Display portal URL for test report\n if (this.workspaceMetadata) {\n const portalUrl = getPortalTestRunUrl(this.workspaceMetadata);\n process.stdout.write(`You can view test report at: ${portalUrl}\\n`);\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : \"Unknown error\";\n process.stderr.write(`❌ Failed to upload Playwright test report: ${errorMessage}\\n`);\n }\n }\n\n private validateHtmlReporterConfiguration(config: FullConfig): void {\n if (!config.reporter || !Array.isArray(config.reporter)) {\n throw new Error(ServiceErrorMessageConstants.HTML_REPORTER_REQUIRED.message);\n }\n\n const hasHtmlReporter = config.reporter.some((reporter) => {\n if (typeof reporter === \"string\") {\n return reporter === \"html\";\n }\n if (Array.isArray(reporter) && reporter.length > 0) {\n return reporter[0] === \"html\";\n }\n return false;\n });\n\n if (!hasHtmlReporter) {\n exitWithFailureMessage(ServiceErrorMessageConstants.HTML_REPORTER_REQUIRED);\n }\n\n coreLogger.info(\"HTML reporter validation passed - HTML reporter is configured\");\n }\n}\n"]}
1
+ {"version":3,"file":"playwrightReporter.js","sourceRoot":"","sources":["../../../src/reporter/playwrightReporter.ts"],"names":[],"mappings":";;AAGA,sGAAgG;AAChG,gDAAqF;AACrF,mDAAiD;AACjD,qFAA+E;AAC/E,yDAAmF;AACnF,uDAAqE;AACrE,oFAA8E;AAG9E;;GAEG;AAEH,MAAqB,kBAAkB;IAC7B,MAAM,CAAyB;IAC/B,iBAAiB,GAA6B,IAAI,CAAC;IACnD,kBAAkB,GAAG,KAAK,CAAC;IAEnC;;;;OAIG;IAEH,KAAK,CAAC,OAAO,CAAC,MAAkB;QAC9B,sBAAU,CAAC,IAAI,CAAC,2BAA2B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QAEvF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,gCAAgC;QAChC,MAAM,kBAAkB,GACtB,OAAO,CAAC,GAAG,CAAC,2CAA4B,CAAC,oBAAoB,CAAC,KAAK,MAAM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C,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;YAC7E,OAAO,CACL,OAAO,YAAY,KAAK,QAAQ;gBAChC,YAAY,CAAC,QAAQ,CAAC,YAAY,CAAC;gBACnC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,CAClC,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,gCAAgC;QAChC,IAAI,iBAAiB,KAAK,CAAC,CAAC,EAAE,CAAC;YAC7B,OAAO,CAAC,KAAK,CAAC,0CAA4B,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;YAC3E,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;YAChC,OAAO;QACT,CAAC;QAED,gFAAgF;QAChF,IAAI,kBAAkB,KAAK,CAAC,CAAC,IAAI,iBAAiB,GAAG,kBAAkB,EAAE,CAAC;YACxE,OAAO,CAAC,KAAK,CAAC,0CAA4B,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;YAC3E,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;YAChC,OAAO;QACT,CAAC;QAED,sBAAU,CAAC,IAAI,CACb,oFAAoF,CACrF,CAAC;IACJ,CAAC;CACF;AA3KD,qCA2KC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { FullConfig, Reporter } from \"@playwright/test/reporter\";\nimport { PlaywrightReporterStorageManager } from \"../utils/playwrightReporterStorageManager.js\";\nimport { getHtmlReporterOutputFolder, getPortalTestRunUrl } from \"../utils/utils.js\";\nimport { coreLogger } from \"../common/logger.js\";\nimport { PlaywrightServiceConfig } from \"../common/playwrightServiceConfig.js\";\nimport { ServiceAuth, InternalEnvironmentVariables } from \"../common/constants.js\";\nimport { ServiceErrorMessageConstants } from \"../common/messages.js\";\nimport { PlaywrightServiceClient } from \"../utils/PlaywrightServiceClient.js\";\nimport type { WorkspaceMetaData, UploadResult } from \"../common/types.js\";\n\n/**\n * Azure Playwright Reporter - Uploads generated Playwright test report folder to Azure Storage.\n */\n\nexport default class PlaywrightReporter implements Reporter {\n private config: FullConfig | undefined;\n private workspaceMetadata: WorkspaceMetaData | null = null;\n private isReportingEnabled = false;\n\n /**\n * Called when test run begins. Stores configuration for later use and validates serviceAuthType and\n * retrieves workspace metadata.\n * @param config - Playwright test configuration\n */\n\n async onBegin(config: FullConfig): Promise<void> {\n coreLogger.info(`Reporter configuration: ${JSON.stringify(config.reporter, null, 2)}`);\n\n this.config = config;\n\n // Check if using service config\n const usingServiceConfig =\n process.env[InternalEnvironmentVariables.USING_SERVICE_CONFIG] === \"true\";\n coreLogger.info(`Using service config: ${usingServiceConfig}`);\n if (!usingServiceConfig) {\n console.error(ServiceErrorMessageConstants.REPORTER_REQUIRES_SERVICE_CONFIG.message);\n this.isReportingEnabled = false;\n return;\n }\n\n // Check if test run creation was successful\n const testRunCreationSuccess =\n process.env[InternalEnvironmentVariables.TEST_RUN_CREATION_SUCCESS] === \"true\";\n if (!testRunCreationSuccess) {\n console.error(ServiceErrorMessageConstants.REPORTING_STATUS_FAILED.message);\n console.error(ServiceErrorMessageConstants.REPORTING_TEST_RUN_FAILED.message);\n this.isReportingEnabled = false;\n return;\n }\n\n // Check authentication\n const playwrightServiceConfig = PlaywrightServiceConfig.instance;\n coreLogger.info(`Current authentication type: ${playwrightServiceConfig.serviceAuthType}`);\n const isUsingAccessToken = playwrightServiceConfig.serviceAuthType === ServiceAuth.ACCESS_TOKEN;\n if (isUsingAccessToken) {\n console.error(ServiceErrorMessageConstants.REPORTER_REQUIRES_ENTRA_AUTH.message);\n this.isReportingEnabled = false;\n return;\n }\n coreLogger.info(\"Authentication validation passed - using ENTRA_ID\");\n\n // Get workspace metadata for later use\n try {\n const playwrightServiceApiClient = new PlaywrightServiceClient();\n this.workspaceMetadata = await playwrightServiceApiClient.getWorkspaceMetadata();\n\n if (!this.workspaceMetadata?.storageUri) {\n console.error(ServiceErrorMessageConstants.WORKSPACE_REPORTING_DISABLED.message);\n this.isReportingEnabled = false;\n return;\n }\n\n this.isReportingEnabled = true;\n\n this.validateHtmlReporterConfiguration(config);\n if (this.isReportingEnabled) {\n console.log(ServiceErrorMessageConstants.REPORTING_ENABLED.message);\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n console.error(\n `${ServiceErrorMessageConstants.WORKSPACE_METADATA_FETCH_FAILED.message}Error: ${errorMessage} `,\n );\n this.isReportingEnabled = false;\n }\n }\n\n /**\n * Called when test run ends. Uploads Playwright test report to Azure Storage if reporting is enabled.\n */\n\n async onEnd(): Promise<void> {\n if (this.isReportingEnabled) {\n console.log(ServiceErrorMessageConstants.COLLECTING_ARTIFACTS.message);\n const uploadResult = await this.uploadHtmlReport();\n\n if (uploadResult.success) {\n if (\n uploadResult.partialSuccess &&\n uploadResult.failedFileDetails &&\n uploadResult.failedFileDetails.length > 0\n ) {\n console.log(\"Warning: Failed to upload the following files:\");\n uploadResult.failedFileDetails.forEach((fileDetail) => {\n console.log(` - ${fileDetail.fileName}, ERROR: ${fileDetail.error}`);\n });\n console.log(ServiceErrorMessageConstants.REPORTING_STATUS_PARTIAL.message);\n } else {\n console.log(ServiceErrorMessageConstants.REPORTING_STATUS_SUCCESS.message);\n }\n // Display portal URL for both full and partial success\n if (this.workspaceMetadata) {\n const portalUrl = getPortalTestRunUrl(this.workspaceMetadata);\n console.log(ServiceErrorMessageConstants.TEST_REPORT_VIEW_URL.formatWithUrl(portalUrl));\n }\n } else {\n console.error(ServiceErrorMessageConstants.REPORTING_STATUS_FAILED.message);\n if (uploadResult.errorMessage) {\n console.error(`Error: ${uploadResult.errorMessage}`);\n }\n }\n }\n }\n\n private async uploadHtmlReport(): Promise<UploadResult> {\n try {\n const outputFolder = getHtmlReporterOutputFolder(this.config);\n coreLogger.info(`Resolved Playwright test report output folder: ${outputFolder}`);\n const storageManager = new PlaywrightReporterStorageManager();\n coreLogger.info(\"Starting Playwright test report upload process\");\n const uploadResult = await storageManager.uploadPlaywrightHtmlReportAfterTests(\n outputFolder,\n this.workspaceMetadata,\n );\n\n if (uploadResult.success) {\n coreLogger.info(`Playwright Test report uploaded successfully to Azure Storage.`);\n }\n return uploadResult;\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : \"Unknown error\";\n coreLogger.error(`Upload failed: ${errorMessage}`);\n return { success: false, errorMessage };\n }\n }\n\n private validateHtmlReporterConfiguration(config: FullConfig): void {\n if (!config.reporter || !Array.isArray(config.reporter)) {\n console.error(ServiceErrorMessageConstants.HTML_REPORTER_REQUIRED.message);\n this.isReportingEnabled = false;\n return;\n }\n\n const htmlReporterIndex = config.reporter.findIndex((reporter) => {\n const reporterName = typeof reporter === \"string\" ? reporter : reporter?.[0];\n return reporterName === \"html\";\n });\n\n const azureReporterIndex = config.reporter.findIndex((reporter) => {\n const reporterName = typeof reporter === \"string\" ? reporter : reporter?.[0];\n return (\n typeof reporterName === \"string\" &&\n reporterName.includes(\"playwright\") &&\n reporterName.includes(\"reporter\")\n );\n });\n\n // Validate HTML reporter exists\n if (htmlReporterIndex === -1) {\n console.error(ServiceErrorMessageConstants.HTML_REPORTER_REQUIRED.message);\n this.isReportingEnabled = false;\n return;\n }\n\n // Validate HTML reporter comes before Azure reporter (if Azure reporter exists)\n if (azureReporterIndex !== -1 && htmlReporterIndex > azureReporterIndex) {\n console.error(ServiceErrorMessageConstants.HTML_REPORTER_REQUIRED.message);\n this.isReportingEnabled = false;\n return;\n }\n\n coreLogger.info(\n \"HTML reporter validation passed - HTML reporter is configured and properly ordered\",\n );\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { HttpService } from "../common/httpService.js";
2
+ import { TestRunCreatePayload, WorkspaceMetaData } from "../common/types.js";
3
+ export declare class PlaywrightServiceClient {
4
+ private httpService;
5
+ constructor(httpService?: HttpService);
6
+ createOrUpdateTestRun(payload: TestRunCreatePayload): Promise<void>;
7
+ getWorkspaceMetadata(): Promise<WorkspaceMetaData>;
8
+ }
9
+ //# sourceMappingURL=PlaywrightServiceClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlaywrightServiceClient.d.ts","sourceRoot":"","sources":["../../../src/utils/PlaywrightServiceClient.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAG7E,qBAAa,uBAAuB;IAClC,OAAO,CAAC,WAAW,CAAc;gBAErB,WAAW,CAAC,EAAE,WAAW;IAI/B,qBAAqB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IA8CnE,oBAAoB,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAsCzD"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PlaywrightServiceClient = void 0;
4
+ // Copyright (c) Microsoft Corporation.
5
+ // Licensed under the MIT License.
6
+ const utils_js_1 = require("./utils.js");
7
+ const messages_js_1 = require("../common/messages.js");
8
+ const httpService_js_1 = require("../common/httpService.js");
9
+ const constants_js_1 = require("../common/constants.js");
10
+ class PlaywrightServiceClient {
11
+ httpService;
12
+ constructor(httpService) {
13
+ this.httpService = httpService ?? new httpService_js_1.HttpService();
14
+ }
15
+ async createOrUpdateTestRun(payload) {
16
+ try {
17
+ const baseUrl = (0, utils_js_1.getTestRunApiUrl)();
18
+ const token = (0, utils_js_1.getAccessToken)();
19
+ if (!token) {
20
+ throw new Error("PLAYWRIGHT_SERVICE_ACCESS_TOKEN environment variable is not set.");
21
+ }
22
+ const url = new URL(baseUrl);
23
+ url.searchParams.set("api-version", constants_js_1.Constants.LatestAPIVersion);
24
+ const method = "PATCH";
25
+ const data = JSON.stringify(payload);
26
+ const contentType = "application/merge-patch+json";
27
+ const correlationId = crypto.randomUUID();
28
+ const response = await this.httpService.callAPI(method, url.toString(), data, token, contentType, correlationId);
29
+ if (response.status !== 200) {
30
+ const errorMessage = (0, utils_js_1.extractErrorMessage)(response?.bodyAsText ?? "");
31
+ process.env[constants_js_1.InternalEnvironmentVariables.TEST_RUN_CREATION_SUCCESS] = "false";
32
+ console.error(messages_js_1.ServiceErrorMessageConstants.TEST_RUN_CREATION_FAILED.formatWithErrorDetails(errorMessage || "Unknown error"));
33
+ return;
34
+ }
35
+ console.log("Test run created successfully.");
36
+ process.env[constants_js_1.InternalEnvironmentVariables.TEST_RUN_CREATION_SUCCESS] = "true";
37
+ }
38
+ catch (error) {
39
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred during test run creation";
40
+ process.env[constants_js_1.InternalEnvironmentVariables.TEST_RUN_CREATION_SUCCESS] = "false";
41
+ console.error(messages_js_1.ServiceErrorMessageConstants.TEST_RUN_CREATION_FAILED.formatWithErrorDetails(errorMessage));
42
+ }
43
+ }
44
+ async getWorkspaceMetadata() {
45
+ try {
46
+ const baseUrl = (0, utils_js_1.getWorkspaceMetaDataApiUrl)();
47
+ const token = (0, utils_js_1.getAccessToken)();
48
+ if (!token) {
49
+ throw new Error("PLAYWRIGHT_SERVICE_ACCESS_TOKEN environment variable is not set.");
50
+ }
51
+ const url = new URL(baseUrl);
52
+ url.searchParams.set("api-version", constants_js_1.Constants.LatestAPIVersion);
53
+ const method = "GET";
54
+ const correlationId = crypto.randomUUID();
55
+ const response = await this.httpService.callAPI(method, url.toString(), null, token, "", correlationId);
56
+ if (response.status !== 200) {
57
+ const errorMessage = (0, utils_js_1.extractErrorMessage)(response?.bodyAsText ?? "");
58
+ throw new Error(messages_js_1.ServiceErrorMessageConstants.FAILED_TO_GET_WORKSPACE_METADATA.formatWithError(errorMessage || `HTTP ${response.status}: Failed to retrieve workspace details`));
59
+ }
60
+ return response.bodyAsText ? JSON.parse(response.bodyAsText) : {};
61
+ }
62
+ catch (error) {
63
+ if (error instanceof Error) {
64
+ throw error;
65
+ }
66
+ throw new Error(messages_js_1.ServiceErrorMessageConstants.FAILED_TO_GET_WORKSPACE_METADATA.message);
67
+ }
68
+ }
69
+ }
70
+ exports.PlaywrightServiceClient = PlaywrightServiceClient;
71
+ //# sourceMappingURL=PlaywrightServiceClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlaywrightServiceClient.js","sourceRoot":"","sources":["../../../src/utils/PlaywrightServiceClient.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AACvC,kCAAkC;AAClC,yCAKoB;AACpB,uDAAqE;AACrE,6DAAuD;AAEvD,yDAAiF;AAEjF,MAAa,uBAAuB;IAC1B,WAAW,CAAc;IAEjC,YAAY,WAAyB;QACnC,IAAI,CAAC,WAAW,GAAG,WAAW,IAAI,IAAI,4BAAW,EAAE,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,OAA6B;QACvD,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,IAAA,2BAAgB,GAAE,CAAC;YACnC,MAAM,KAAK,GAAG,IAAA,yBAAc,GAAE,CAAC;YAC/B,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;YACtF,CAAC;YACD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;YAC7B,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,EAAE,wBAAS,CAAC,gBAAgB,CAAC,CAAC;YAChE,MAAM,MAAM,GAAG,OAAO,CAAC;YACvB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YACrC,MAAM,WAAW,GAAG,8BAA8B,CAAC;YACnD,MAAM,aAAa,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;YAE1C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAC7C,MAAM,EACN,GAAG,CAAC,QAAQ,EAAE,EACd,IAAI,EACJ,KAAK,EACL,WAAW,EACX,aAAa,CACd,CAAC;YAEF,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBAC5B,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AAC,UAAU,EAAE,CAAC;YAE1C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAC7C,MAAM,EACN,GAAG,CAAC,QAAQ,EAAE,EACd,IAAI,EACJ,KAAK,EACL,EAAE,EACF,aAAa,CACd,CAAC;YAEF,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBAC5B,MAAM,YAAY,GAAG,IAAA,8BAAmB,EAAC,QAAQ,EAAE,UAAU,IAAI,EAAE,CAAC,CAAC;gBACrE,MAAM,IAAI,KAAK,CACb,0CAA4B,CAAC,gCAAgC,CAAC,eAAe,CAC3E,YAAY,IAAI,QAAQ,QAAQ,CAAC,MAAM,wCAAwC,CAChF,CACF,CAAC;YACJ,CAAC;YAED,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACpE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;gBAC3B,MAAM,KAAK,CAAC;YACd,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,0CAA4B,CAAC,gCAAgC,CAAC,OAAO,CAAC,CAAC;QACzF,CAAC;IACH,CAAC;CACF;AA3FD,0DA2FC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport {\n getTestRunApiUrl,\n getAccessToken,\n extractErrorMessage,\n getWorkspaceMetaDataApiUrl,\n} from \"./utils.js\";\nimport { ServiceErrorMessageConstants } from \"../common/messages.js\";\nimport { HttpService } from \"../common/httpService.js\";\nimport { TestRunCreatePayload, WorkspaceMetaData } from \"../common/types.js\";\nimport { Constants, InternalEnvironmentVariables } from \"../common/constants.js\";\n\nexport class PlaywrightServiceClient {\n private httpService: HttpService;\n\n constructor(httpService?: HttpService) {\n this.httpService = httpService ?? new HttpService();\n }\n\n async createOrUpdateTestRun(payload: TestRunCreatePayload): Promise<void> {\n try {\n const baseUrl = getTestRunApiUrl();\n const token = getAccessToken();\n if (!token) {\n throw new Error(\"PLAYWRIGHT_SERVICE_ACCESS_TOKEN environment variable is not set.\");\n }\n const url = new URL(baseUrl);\n url.searchParams.set(\"api-version\", Constants.LatestAPIVersion);\n const method = \"PATCH\";\n const data = JSON.stringify(payload);\n const contentType = \"application/merge-patch+json\";\n const correlationId = crypto.randomUUID();\n\n const response = await this.httpService.callAPI(\n method,\n url.toString(),\n data,\n token,\n contentType,\n correlationId,\n );\n\n if (response.status !== 200) {\n const errorMessage = extractErrorMessage(response?.bodyAsText ?? \"\");\n process.env[InternalEnvironmentVariables.TEST_RUN_CREATION_SUCCESS] = \"false\";\n console.error(\n ServiceErrorMessageConstants.TEST_RUN_CREATION_FAILED.formatWithErrorDetails(\n errorMessage || \"Unknown error\",\n ),\n );\n return;\n }\n\n console.log(\"Test run created successfully.\");\n process.env[InternalEnvironmentVariables.TEST_RUN_CREATION_SUCCESS] = \"true\";\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error occurred during test run creation\";\n process.env[InternalEnvironmentVariables.TEST_RUN_CREATION_SUCCESS] = \"false\";\n console.error(\n ServiceErrorMessageConstants.TEST_RUN_CREATION_FAILED.formatWithErrorDetails(errorMessage),\n );\n }\n }\n\n async getWorkspaceMetadata(): Promise<WorkspaceMetaData> {\n try {\n const baseUrl = getWorkspaceMetaDataApiUrl();\n const token = getAccessToken();\n if (!token) {\n throw new Error(\"PLAYWRIGHT_SERVICE_ACCESS_TOKEN environment variable is not set.\");\n }\n const url = new URL(baseUrl);\n url.searchParams.set(\"api-version\", Constants.LatestAPIVersion);\n const method = \"GET\";\n const correlationId = crypto.randomUUID();\n\n const response = await this.httpService.callAPI(\n method,\n url.toString(),\n null,\n token,\n \"\",\n correlationId,\n );\n\n if (response.status !== 200) {\n const errorMessage = extractErrorMessage(response?.bodyAsText ?? \"\");\n throw new Error(\n ServiceErrorMessageConstants.FAILED_TO_GET_WORKSPACE_METADATA.formatWithError(\n errorMessage || `HTTP ${response.status}: Failed to retrieve workspace details`,\n ),\n );\n }\n\n return response.bodyAsText ? JSON.parse(response.bodyAsText) : {};\n } catch (error) {\n if (error instanceof Error) {\n throw error;\n }\n throw new Error(ServiceErrorMessageConstants.FAILED_TO_GET_WORKSPACE_METADATA.message);\n }\n }\n}\n"]}
@@ -1,10 +1,9 @@
1
1
  import type { TokenCredential } from "@azure/core-auth";
2
- import type { WorkspaceMetaData } from "../common/types.js";
2
+ import type { WorkspaceMetaData, UploadResult } from "../common/types.js";
3
3
  export declare class PlaywrightReporterStorageManager {
4
- uploadHtmlReportFolder(credential: TokenCredential, runId: string, outputFolder: string, workspaceDetails: WorkspaceMetaData): Promise<void>;
5
- private uploadSasWorkerFile;
6
- private modifyIndexHtml;
7
- uploadPlaywrightHtmlReportAfterTests(outputFolderName?: string, workspaceMetadata?: WorkspaceMetaData | null): Promise<void>;
4
+ uploadHtmlReportFolder(credential: TokenCredential, runId: string, outputFolder: string, workspaceDetails: WorkspaceMetaData): Promise<UploadResult>;
5
+ private modifyTraceIndexHtml;
6
+ uploadPlaywrightHtmlReportAfterTests(outputFolderName?: string, workspaceMetadata?: WorkspaceMetaData | null): Promise<UploadResult>;
8
7
  private uploadFolderInParallel;
9
8
  private uploadWithConcurrencyControl;
10
9
  private executeWithOptimizedBatching;
@@ -1 +1 @@
1
- {"version":3,"file":"playwrightReporterStorageManager.d.ts","sourceRoot":"","sources":["../../../src/utils/playwrightReporterStorageManager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAYxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,qBAAa,gCAAgC;IACrC,sBAAsB,CAC1B,UAAU,EAAE,eAAe,EAC3B,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,iBAAiB,GAClC,OAAO,CAAC,IAAI,CAAC;YA6CF,mBAAmB;YA+BnB,eAAe;IA2DvB,oCAAoC,CACxC,gBAAgB,CAAC,EAAE,MAAM,EACzB,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,IAAI,GAC3C,OAAO,CAAC,IAAI,CAAC;YA8BF,sBAAsB;YAyEtB,4BAA4B;YAqB5B,4BAA4B;YAuE5B,yBAAyB;YA4CzB,sBAAsB;CAsCrC"}
1
+ {"version":3,"file":"playwrightReporterStorageManager.d.ts","sourceRoot":"","sources":["../../../src/utils/playwrightReporterStorageManager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAaxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE1E,qBAAa,gCAAgC;IAErC,sBAAsB,CAC1B,UAAU,EAAE,eAAe,EAC3B,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,iBAAiB,GAClC,OAAO,CAAC,YAAY,CAAC;YAwGV,oBAAoB;IAmD5B,oCAAoC,CACxC,gBAAgB,CAAC,EAAE,MAAM,EACzB,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,IAAI,GAC3C,OAAO,CAAC,YAAY,CAAC;YAiDV,sBAAsB;YA4GtB,4BAA4B;YAwB5B,4BAA4B;YA4E5B,yBAAyB;YA8CzB,sBAAsB;CAsCrC"}