@azure/playwright 1.1.3-alpha.20260310.1 → 1.1.3
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/dist/browser/common/constants.d.ts +3 -0
- package/dist/browser/common/constants.d.ts.map +1 -1
- package/dist/browser/common/constants.js +3 -0
- package/dist/browser/common/constants.js.map +1 -1
- package/dist/browser/common/types.d.ts +8 -0
- package/dist/browser/common/types.d.ts.map +1 -1
- package/dist/browser/common/types.js.map +1 -1
- package/dist/browser/core/playwrightService.d.ts.map +1 -1
- package/dist/browser/core/playwrightService.js +6 -0
- package/dist/browser/core/playwrightService.js.map +1 -1
- package/dist/browser/utils/utils.d.ts.map +1 -1
- package/dist/browser/utils/utils.js +2 -3
- package/dist/browser/utils/utils.js.map +1 -1
- package/dist/commonjs/common/constants.d.ts +3 -0
- package/dist/commonjs/common/constants.d.ts.map +1 -1
- package/dist/commonjs/common/constants.js +97 -126
- package/dist/commonjs/common/constants.js.map +1 -7
- package/dist/commonjs/common/customerConfig.js +14 -31
- package/dist/commonjs/common/customerConfig.js.map +1 -7
- package/dist/commonjs/common/entraIdAccessToken.js +83 -106
- package/dist/commonjs/common/entraIdAccessToken.js.map +1 -7
- package/dist/commonjs/common/environmentVariables.js +24 -43
- package/dist/commonjs/common/environmentVariables.js.map +1 -7
- package/dist/commonjs/common/executor.js +67 -88
- package/dist/commonjs/common/executor.js.map +1 -7
- package/dist/commonjs/common/httpService.js +35 -54
- package/dist/commonjs/common/httpService.js.map +1 -7
- package/dist/commonjs/common/logger.js +8 -28
- package/dist/commonjs/common/logger.js.map +1 -7
- package/dist/commonjs/common/messages.js +169 -189
- package/dist/commonjs/common/messages.js.map +1 -7
- package/dist/commonjs/common/playwrightServiceConfig.js +98 -113
- package/dist/commonjs/common/playwrightServiceConfig.js.map +1 -7
- package/dist/commonjs/common/state.js +10 -30
- package/dist/commonjs/common/state.js.map +1 -7
- package/dist/commonjs/common/types.d.ts +8 -0
- package/dist/commonjs/common/types.d.ts.map +1 -1
- package/dist/commonjs/common/types.js +5 -15
- package/dist/commonjs/common/types.js.map +1 -7
- package/dist/commonjs/core/global/playwright-service-global-setup.js +26 -52
- package/dist/commonjs/core/global/playwright-service-global-setup.js.map +1 -7
- package/dist/commonjs/core/global/playwright-service-global-teardown.js +20 -49
- package/dist/commonjs/core/global/playwright-service-global-teardown.js.map +1 -7
- package/dist/commonjs/core/initializePlaywrightServiceTestRun.js +27 -39
- package/dist/commonjs/core/initializePlaywrightServiceTestRun.js.map +1 -7
- package/dist/commonjs/core/playwrightService.d.ts.map +1 -1
- package/dist/commonjs/core/playwrightService.js +211 -166
- package/dist/commonjs/core/playwrightService.js.map +1 -7
- package/dist/commonjs/core/playwrightServiceEntra.js +48 -67
- package/dist/commonjs/core/playwrightServiceEntra.js.map +1 -7
- package/dist/commonjs/core/playwrightServiceUtils.d.ts.map +1 -1
- package/dist/commonjs/core/playwrightServiceUtils.js +11 -44
- package/dist/commonjs/core/playwrightServiceUtils.js.map +1 -7
- package/dist/commonjs/index.js +18 -36
- package/dist/commonjs/index.js.map +1 -7
- package/dist/commonjs/reporter/index.js +15 -34
- package/dist/commonjs/reporter/index.js.map +1 -7
- package/dist/commonjs/reporter/playwrightReporter.js +216 -222
- package/dist/commonjs/reporter/playwrightReporter.js.map +1 -7
- package/dist/commonjs/utils/PlaywrightServiceClient.js +91 -140
- package/dist/commonjs/utils/PlaywrightServiceClient.js.map +1 -7
- package/dist/commonjs/utils/cIInfoProvider.js +74 -81
- package/dist/commonjs/utils/cIInfoProvider.js.map +1 -7
- package/dist/commonjs/utils/getPackageVersion.d.ts.map +1 -1
- package/dist/commonjs/utils/getPackageVersion.js +19 -50
- package/dist/commonjs/utils/getPackageVersion.js.map +1 -7
- package/dist/commonjs/utils/getPlaywrightVersion.js +21 -42
- package/dist/commonjs/utils/getPlaywrightVersion.js.map +1 -7
- package/dist/commonjs/utils/packageManager.js +40 -59
- package/dist/commonjs/utils/packageManager.js.map +1 -7
- package/dist/commonjs/utils/parseJwt.js +17 -37
- package/dist/commonjs/utils/parseJwt.js.map +1 -7
- package/dist/commonjs/utils/playwrightReporterStorageManager.js +342 -381
- package/dist/commonjs/utils/playwrightReporterStorageManager.js.map +1 -7
- package/dist/commonjs/utils/utils.d.ts.map +1 -1
- package/dist/commonjs/utils/utils.js +368 -417
- package/dist/commonjs/utils/utils.js.map +1 -7
- package/dist/esm/common/constants.d.ts +3 -0
- package/dist/esm/common/constants.d.ts.map +1 -1
- package/dist/esm/common/constants.js +4 -0
- package/dist/esm/common/constants.js.map +2 -2
- package/dist/esm/common/types.d.ts +8 -0
- package/dist/esm/common/types.d.ts.map +1 -1
- package/dist/esm/core/playwrightService.d.ts.map +1 -1
- package/dist/esm/core/playwrightService.js +6 -0
- package/dist/esm/core/playwrightService.js.map +2 -2
- package/dist/esm/utils/utils.d.ts.map +1 -1
- package/dist/esm/utils/utils.js +4 -3
- package/dist/esm/utils/utils.js.map +2 -2
- package/dist/react-native/common/constants.d.ts +3 -0
- package/dist/react-native/common/constants.d.ts.map +1 -1
- package/dist/react-native/common/constants.js +3 -0
- package/dist/react-native/common/constants.js.map +1 -1
- package/dist/react-native/common/types.d.ts +8 -0
- package/dist/react-native/common/types.d.ts.map +1 -1
- package/dist/react-native/common/types.js.map +1 -1
- package/dist/react-native/core/playwrightService.d.ts.map +1 -1
- package/dist/react-native/core/playwrightService.js +6 -0
- package/dist/react-native/core/playwrightService.js.map +1 -1
- package/dist/react-native/utils/utils.d.ts.map +1 -1
- package/dist/react-native/utils/utils.js +2 -3
- package/dist/react-native/utils/utils.js.map +1 -1
- package/package.json +6 -6
|
@@ -1,142 +1,115 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var playwrightReporterStorageManager_exports = {};
|
|
19
|
-
__export(playwrightReporterStorageManager_exports, {
|
|
20
|
-
PlaywrightReporterStorageManager: () => PlaywrightReporterStorageManager
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(playwrightReporterStorageManager_exports);
|
|
23
|
-
var import_storage_blob = require("@azure/storage-blob");
|
|
24
|
-
var import_logger = require("../common/logger.js");
|
|
25
|
-
var import_fs = require("fs");
|
|
26
|
-
var import_path = require("path");
|
|
27
|
-
var import_constants = require("../common/constants.js");
|
|
28
|
-
var import_messages = require("../common/messages.js");
|
|
29
|
-
var import_utils = require("./utils.js");
|
|
30
|
-
var import_playwrightServiceConfig = require("../common/playwrightServiceConfig.js");
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.PlaywrightReporterStorageManager = void 0;
|
|
6
|
+
const storage_blob_1 = require("@azure/storage-blob");
|
|
7
|
+
const logger_js_1 = require("../common/logger.js");
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const constants_js_1 = require("../common/constants.js");
|
|
11
|
+
const messages_js_1 = require("../common/messages.js");
|
|
12
|
+
const utils_js_1 = require("./utils.js");
|
|
13
|
+
const playwrightServiceConfig_js_1 = require("../common/playwrightServiceConfig.js");
|
|
31
14
|
class PlaywrightReporterStorageManager {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
15
|
+
// Uploads the HTML report folder to Azure Storage
|
|
16
|
+
async uploadHtmlReportFolder(credential, runId, outputFolder, workspaceDetails) {
|
|
17
|
+
logger_js_1.coreLogger.info(`Starting HTML report upload for runId: ${runId}, outputFolder: ${outputFolder}`);
|
|
18
|
+
const storageAccountName = (0, utils_js_1.getStorageAccountNameFromUri)(workspaceDetails?.storageUri || "") || "unknown";
|
|
19
|
+
try {
|
|
20
|
+
if (!workspaceDetails.storageUri) {
|
|
21
|
+
logger_js_1.coreLogger.error("Storage URI not found in workspace details");
|
|
22
|
+
return {
|
|
23
|
+
success: false,
|
|
24
|
+
errorMessage: messages_js_1.ServiceErrorMessageConstants.STORAGE_URI_NOT_FOUND.message,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const blobServiceClient = new storage_blob_1.BlobServiceClient(workspaceDetails?.storageUri, credential);
|
|
28
|
+
logger_js_1.coreLogger.info("blobServiceClient created successfully.");
|
|
29
|
+
const serviceUrlInfo = (0, utils_js_1.populateValuesFromServiceUrl)();
|
|
30
|
+
if (!serviceUrlInfo?.accountId) {
|
|
31
|
+
logger_js_1.coreLogger.error("Unable to extract workspace ID from service URL");
|
|
32
|
+
return {
|
|
33
|
+
success: false,
|
|
34
|
+
errorMessage: messages_js_1.ServiceErrorMessageConstants.UNABLE_TO_EXTRACT_WORKSPACE_ID.message,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const containerName = serviceUrlInfo.accountId.toLowerCase().replace(/[^a-z0-9-]/g, "-");
|
|
38
|
+
const containerClient = blobServiceClient.getContainerClient(containerName);
|
|
39
|
+
const containerExists = await containerClient.exists();
|
|
40
|
+
if (!containerExists) {
|
|
41
|
+
logger_js_1.coreLogger.info(`Container ${containerName} does not exist. Creating new container.`);
|
|
42
|
+
await containerClient.create();
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
logger_js_1.coreLogger.info(`Container ${containerName} already exists.`);
|
|
46
|
+
}
|
|
47
|
+
const folderName = runId;
|
|
48
|
+
console.log(messages_js_1.ServiceErrorMessageConstants.UPLOADING_ARTIFACTS.formatWithDetails(storageAccountName, containerName, folderName));
|
|
49
|
+
await this.modifyTraceIndexHtml(outputFolder);
|
|
50
|
+
const uploadResults = await this.uploadFolderInParallel(containerClient, outputFolder, outputFolder, folderName);
|
|
51
|
+
if (uploadResults.totalFiles === 0) {
|
|
52
|
+
return { success: false, errorMessage: "No files found to upload" };
|
|
53
|
+
}
|
|
54
|
+
const failedFiles = uploadResults.totalFiles - uploadResults.uploadedFiles.length;
|
|
55
|
+
if (failedFiles > 0) {
|
|
56
|
+
if (uploadResults.failedFileDetails) {
|
|
57
|
+
const hasAuthorizationError = uploadResults.failedFileDetails.some((fileDetail) => fileDetail.error.includes("not authorized to perform this operation") ||
|
|
58
|
+
fileDetail.error.includes("AuthorizationFailure"));
|
|
59
|
+
if (hasAuthorizationError) {
|
|
60
|
+
return {
|
|
61
|
+
success: false,
|
|
62
|
+
errorMessage: messages_js_1.ServiceErrorMessageConstants.STORAGE_AUTHORIZATION_FAILED.formatWithStorageAccount(storageAccountName),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Get list of failed file names by comparing total files with uploaded files
|
|
67
|
+
const uploadedSet = new Set(uploadResults.uploadedFiles);
|
|
68
|
+
const allFiles = (0, utils_js_1.collectAllFiles)(outputFolder, outputFolder, folderName);
|
|
69
|
+
const failedFileNames = allFiles
|
|
70
|
+
.filter((file) => !uploadedSet.has(file.relativePath))
|
|
71
|
+
.map((file) => file.relativePath);
|
|
72
|
+
return {
|
|
73
|
+
success: false,
|
|
74
|
+
partialSuccess: true,
|
|
75
|
+
failedFileCount: failedFiles,
|
|
76
|
+
totalFiles: uploadResults.totalFiles,
|
|
77
|
+
failedFiles: failedFileNames,
|
|
78
|
+
failedFileDetails: uploadResults.failedFileDetails,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return { success: true };
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
85
|
+
const hasStorageAccountDeletedError = errorMessage.includes("ENOTFOUND") ||
|
|
86
|
+
errorMessage.includes("getaddrinfo") ||
|
|
87
|
+
errorMessage.includes("not found") ||
|
|
88
|
+
errorMessage.includes("404");
|
|
89
|
+
if (hasStorageAccountDeletedError) {
|
|
90
|
+
return {
|
|
91
|
+
success: false,
|
|
92
|
+
errorMessage: messages_js_1.ServiceErrorMessageConstants.STORAGE_ACCOUNT_DELETED.formatWithStorageAccount(storageAccountName),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
logger_js_1.coreLogger.error(`Failed to upload HTML report: ${error}`);
|
|
96
|
+
return { success: false, errorMessage };
|
|
97
97
|
}
|
|
98
|
-
const uploadedSet = new Set(uploadResults.uploadedFiles);
|
|
99
|
-
const allFiles = (0, import_utils.collectAllFiles)(outputFolder, outputFolder, folderName);
|
|
100
|
-
const failedFileNames = allFiles.filter((file) => !uploadedSet.has(file.relativePath)).map((file) => file.relativePath);
|
|
101
|
-
return {
|
|
102
|
-
success: false,
|
|
103
|
-
partialSuccess: true,
|
|
104
|
-
failedFileCount: failedFiles,
|
|
105
|
-
totalFiles: uploadResults.totalFiles,
|
|
106
|
-
failedFiles: failedFileNames,
|
|
107
|
-
failedFileDetails: uploadResults.failedFileDetails
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
return { success: true };
|
|
111
|
-
} catch (error) {
|
|
112
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
113
|
-
const hasStorageAccountDeletedError = errorMessage.includes("ENOTFOUND") || errorMessage.includes("getaddrinfo") || errorMessage.includes("not found") || errorMessage.includes("404");
|
|
114
|
-
if (hasStorageAccountDeletedError) {
|
|
115
|
-
return {
|
|
116
|
-
success: false,
|
|
117
|
-
errorMessage: import_messages.ServiceErrorMessageConstants.STORAGE_ACCOUNT_DELETED.formatWithStorageAccount(
|
|
118
|
-
storageAccountName
|
|
119
|
-
)
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
import_logger.coreLogger.error(`Failed to upload HTML report: ${error}`);
|
|
123
|
-
return { success: false, errorMessage };
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
async modifyTraceIndexHtml(outputFolder) {
|
|
127
|
-
import_logger.coreLogger.info(`Starting trace modification for folder: ${outputFolder}`);
|
|
128
|
-
const indexPath = (0, import_path.join)(outputFolder, "trace/index.html");
|
|
129
|
-
const localIndexPath = (0, import_path.join)(outputFolder, "trace/index.local.html");
|
|
130
|
-
if (!(0, import_fs.existsSync)(indexPath)) {
|
|
131
|
-
import_logger.coreLogger.error(`trace/index.html not found at path: ${indexPath}`);
|
|
132
|
-
return;
|
|
133
98
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
99
|
+
async modifyTraceIndexHtml(outputFolder) {
|
|
100
|
+
logger_js_1.coreLogger.info(`Starting trace modification for folder: ${outputFolder}`);
|
|
101
|
+
const indexPath = (0, path_1.join)(outputFolder, "trace/index.html");
|
|
102
|
+
const localIndexPath = (0, path_1.join)(outputFolder, "trace/index.local.html");
|
|
103
|
+
if (!(0, fs_1.existsSync)(indexPath)) {
|
|
104
|
+
logger_js_1.coreLogger.error(`trace/index.html not found at path: ${indexPath}`);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
logger_js_1.coreLogger.info(`Found trace/index.html at: ${indexPath}`);
|
|
108
|
+
try {
|
|
109
|
+
const originalHtml = (0, fs_1.readFileSync)(indexPath, "utf-8");
|
|
110
|
+
(0, fs_1.writeFileSync)(localIndexPath, originalHtml, "utf-8");
|
|
111
|
+
logger_js_1.coreLogger.info(`Backed up original trace viewer to: ${localIndexPath}`);
|
|
112
|
+
const redirectTraceviewerScript = `<!DOCTYPE html>
|
|
140
113
|
<html>
|
|
141
114
|
<head>
|
|
142
115
|
<meta charset="utf-8">
|
|
@@ -234,262 +207,250 @@ class PlaywrightReporterStorageManager {
|
|
|
234
207
|
</body>
|
|
235
208
|
</html>
|
|
236
209
|
`;
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
// Uploads the entire Playwright HTML report folder after tests complete.
|
|
247
|
-
async uploadPlaywrightHtmlReportAfterTests(outputFolderName, workspaceMetadata) {
|
|
248
|
-
try {
|
|
249
|
-
import_logger.coreLogger.info(
|
|
250
|
-
`Starting post-test HTML report upload, folder name: ${outputFolderName || "default (playwright-report)"}`
|
|
251
|
-
);
|
|
252
|
-
const cred = import_playwrightServiceConfig.PlaywrightServiceConfig.instance.credential;
|
|
253
|
-
if (!cred) {
|
|
254
|
-
import_logger.coreLogger.error("No credential found for authentication");
|
|
255
|
-
return {
|
|
256
|
-
success: false,
|
|
257
|
-
errorMessage: import_messages.ServiceErrorMessageConstants.NO_CRED_ENTRA_AUTH_ERROR.message
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
import_logger.coreLogger.info("Credential found for authentication");
|
|
261
|
-
const folderName = outputFolderName || "playwright-report";
|
|
262
|
-
const outputFolderPath = (0, import_path.join)(process.cwd(), folderName);
|
|
263
|
-
if (!(0, import_fs.existsSync)(outputFolderPath)) {
|
|
264
|
-
import_logger.coreLogger.error(`HTML report folder not found: ${outputFolderPath}`);
|
|
265
|
-
return {
|
|
266
|
-
success: false,
|
|
267
|
-
errorMessage: import_messages.ServiceErrorMessageConstants.PLAYWRIGHT_TEST_REPORT_NOT_FOUND.formatWithFolder(
|
|
268
|
-
folderName
|
|
269
|
-
)
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
import_logger.coreLogger.info(`HTML report folder found: ${outputFolderPath}`);
|
|
273
|
-
const testRunId = import_playwrightServiceConfig.PlaywrightServiceConfig.instance.runId;
|
|
274
|
-
import_logger.coreLogger.info(`Starting upload for test run ID: ${testRunId}`);
|
|
275
|
-
const result = await this.uploadHtmlReportFolder(
|
|
276
|
-
cred,
|
|
277
|
-
testRunId,
|
|
278
|
-
outputFolderPath,
|
|
279
|
-
workspaceMetadata
|
|
280
|
-
);
|
|
281
|
-
import_logger.coreLogger.info(`Completed upload for test run ID: ${testRunId}`);
|
|
282
|
-
return result;
|
|
283
|
-
} catch (error) {
|
|
284
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
285
|
-
import_logger.coreLogger.error(`Upload failed: ${errorMessage}`);
|
|
286
|
-
return { success: false, errorMessage };
|
|
210
|
+
(0, fs_1.writeFileSync)(indexPath, redirectTraceviewerScript, "utf-8");
|
|
211
|
+
logger_js_1.coreLogger.info("Successfully updated TraceViewer index file");
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
logger_js_1.coreLogger.error(`Error modifying trace/index.html: ${error instanceof Error ? error.message : String(error)}`);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
287
217
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
218
|
+
// Uploads the entire Playwright HTML report folder after tests complete.
|
|
219
|
+
async uploadPlaywrightHtmlReportAfterTests(outputFolderName, workspaceMetadata) {
|
|
220
|
+
try {
|
|
221
|
+
logger_js_1.coreLogger.info(`Starting post-test HTML report upload, folder name: ${outputFolderName || "default (playwright-report)"}`);
|
|
222
|
+
const cred = playwrightServiceConfig_js_1.PlaywrightServiceConfig.instance.credential;
|
|
223
|
+
if (!cred) {
|
|
224
|
+
logger_js_1.coreLogger.error("No credential found for authentication");
|
|
225
|
+
return {
|
|
226
|
+
success: false,
|
|
227
|
+
errorMessage: messages_js_1.ServiceErrorMessageConstants.NO_CRED_ENTRA_AUTH_ERROR.message,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
logger_js_1.coreLogger.info("Credential found for authentication");
|
|
231
|
+
const folderName = outputFolderName || "playwright-report";
|
|
232
|
+
const outputFolderPath = (0, path_1.join)(process.cwd(), folderName);
|
|
233
|
+
if (!(0, fs_1.existsSync)(outputFolderPath)) {
|
|
234
|
+
logger_js_1.coreLogger.error(`HTML report folder not found: ${outputFolderPath}`);
|
|
235
|
+
return {
|
|
236
|
+
success: false,
|
|
237
|
+
errorMessage: messages_js_1.ServiceErrorMessageConstants.PLAYWRIGHT_TEST_REPORT_NOT_FOUND.formatWithFolder(folderName),
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
logger_js_1.coreLogger.info(`HTML report folder found: ${outputFolderPath}`);
|
|
241
|
+
const testRunId = playwrightServiceConfig_js_1.PlaywrightServiceConfig.instance.runId;
|
|
242
|
+
logger_js_1.coreLogger.info(`Starting upload for test run ID: ${testRunId}`);
|
|
243
|
+
const result = await this.uploadHtmlReportFolder(cred, testRunId, outputFolderPath, workspaceMetadata);
|
|
244
|
+
logger_js_1.coreLogger.info(`Completed upload for test run ID: ${testRunId}`);
|
|
245
|
+
return result;
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
249
|
+
logger_js_1.coreLogger.error(`Upload failed: ${errorMessage}`);
|
|
250
|
+
return { success: false, errorMessage };
|
|
251
|
+
}
|
|
296
252
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
253
|
+
// Parallel Upload Engine - Core upload orchestration with performance optimization
|
|
254
|
+
async uploadFolderInParallel(containerClient, folderPath, basePath, runIdFolderPrefix) {
|
|
255
|
+
// Sort by size descending - upload large files first for better parallelization
|
|
256
|
+
const filesToUpload = (0, utils_js_1.collectAllFiles)(folderPath, basePath, runIdFolderPrefix).sort((a, b) => b.size - a.size);
|
|
257
|
+
if (filesToUpload.length === 0) {
|
|
258
|
+
return { uploadedFiles: [], failedFiles: [], totalFiles: 0, totalSize: 0, uploadTime: 0 };
|
|
259
|
+
}
|
|
260
|
+
const totalSize = filesToUpload.reduce((sum, file) => sum + file.size, 0);
|
|
261
|
+
const concurrency = (0, utils_js_1.calculateOptimalConcurrency)(filesToUpload);
|
|
262
|
+
logger_js_1.coreLogger.info(`Calculated optimal concurrency: ${concurrency} for ${filesToUpload.length} files (total size: ${(totalSize / 1024 / 1024).toFixed(2)} MB)`);
|
|
263
|
+
const uploadStartTime = Date.now();
|
|
264
|
+
logger_js_1.coreLogger.info(`Starting parallel upload with ${concurrency} concurrent operations`);
|
|
265
|
+
const results = await this.uploadWithConcurrencyControl(containerClient, filesToUpload, concurrency);
|
|
266
|
+
const uploadEndTime = Date.now();
|
|
267
|
+
const uploadTime = uploadEndTime - uploadStartTime;
|
|
268
|
+
logger_js_1.coreLogger.info(`Upload completed in ${uploadTime}ms (${(uploadTime / 1000).toFixed(2)}s)`);
|
|
269
|
+
const failed = results.filter((r) => r.status === "rejected").length;
|
|
270
|
+
const successful = results.filter((r) => r.status === "fulfilled").length;
|
|
271
|
+
logger_js_1.coreLogger.info(`Upload results: ${successful} successful, ${failed} failed out of ${results.length} total files`);
|
|
272
|
+
if (failed > 0) {
|
|
273
|
+
const errors = results
|
|
274
|
+
.filter((r) => r.status === "rejected")
|
|
275
|
+
.map((r) => r.reason.message)
|
|
276
|
+
.slice(0, 5); // Show first 5 errors
|
|
277
|
+
errors.forEach((error, index) => {
|
|
278
|
+
logger_js_1.coreLogger.error(` ${index + 1}. ${error}`);
|
|
279
|
+
});
|
|
280
|
+
// Get failed file names and their error messages
|
|
281
|
+
const uploadedSet = new Set(results
|
|
282
|
+
.filter((r) => r.status === "fulfilled")
|
|
283
|
+
.map((r) => r.value));
|
|
284
|
+
const failedFileNames = filesToUpload
|
|
285
|
+
.filter((file) => !uploadedSet.has(file.relativePath))
|
|
286
|
+
.map((file) => file.relativePath);
|
|
287
|
+
// Create detailed error mapping
|
|
288
|
+
const failedFileDetails = [];
|
|
289
|
+
results.forEach((result, index) => {
|
|
290
|
+
if (result.status === "rejected") {
|
|
291
|
+
const fileName = filesToUpload[index]?.relativePath || `File at index ${index}`;
|
|
292
|
+
const errorMessage = result.reason instanceof Error ? result.reason.message : String(result.reason);
|
|
293
|
+
failedFileDetails.push({ fileName, error: errorMessage });
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
// Log error but don't throw to prevent breaking HTML reporter
|
|
297
|
+
logger_js_1.coreLogger.error(`Upload failed: ${failed} files could not be uploaded. Sample errors: ${errors.join(", ")}`);
|
|
298
|
+
return {
|
|
299
|
+
uploadedFiles: results
|
|
300
|
+
.filter((r) => r.status === "fulfilled")
|
|
301
|
+
.map((r) => r.value),
|
|
302
|
+
failedFiles: failedFileNames,
|
|
303
|
+
failedFileDetails,
|
|
304
|
+
totalFiles: filesToUpload.length,
|
|
305
|
+
totalSize,
|
|
306
|
+
uploadTime,
|
|
307
|
+
};
|
|
332
308
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
uploadTime
|
|
344
|
-
};
|
|
309
|
+
const uploadedFiles = results
|
|
310
|
+
.filter((r) => r.status === "fulfilled")
|
|
311
|
+
.map((r) => r.value);
|
|
312
|
+
return {
|
|
313
|
+
uploadedFiles,
|
|
314
|
+
failedFiles: [],
|
|
315
|
+
totalFiles: filesToUpload.length,
|
|
316
|
+
totalSize,
|
|
317
|
+
uploadTime,
|
|
318
|
+
};
|
|
345
319
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
await this.uploadSingleFileOptimized(containerClient, fileInfo);
|
|
360
|
-
return fileInfo.relativePath;
|
|
361
|
-
} catch (error) {
|
|
362
|
-
import_logger.coreLogger.error(
|
|
363
|
-
`Failed to upload file: ${fileInfo.relativePath} - ${error instanceof Error ? error.message : "Unknown error"}`
|
|
364
|
-
);
|
|
365
|
-
throw error;
|
|
366
|
-
}
|
|
367
|
-
});
|
|
368
|
-
return this.executeWithOptimizedBatching(uploadTasks, concurrency);
|
|
369
|
-
}
|
|
370
|
-
// Optimized Batch Execution Engine - High-performance task processing system
|
|
371
|
-
async executeWithOptimizedBatching(tasks, concurrency) {
|
|
372
|
-
const results = new Array(tasks.length);
|
|
373
|
-
let completedTasks = 0;
|
|
374
|
-
const batchSize = Math.min(import_constants.UploadConstants.BATCH_SIZE, concurrency * 2);
|
|
375
|
-
const batches = [];
|
|
376
|
-
for (let i = 0; i < tasks.length; i += batchSize) {
|
|
377
|
-
batches.push(tasks.slice(i, i + batchSize));
|
|
320
|
+
// Concurrency Control System - Manages parallel execution with controlled resource usage
|
|
321
|
+
async uploadWithConcurrencyControl(containerClient, files, concurrency) {
|
|
322
|
+
const uploadTasks = files.map((fileInfo) => async () => {
|
|
323
|
+
try {
|
|
324
|
+
await this.uploadSingleFileOptimized(containerClient, fileInfo);
|
|
325
|
+
return fileInfo.relativePath;
|
|
326
|
+
}
|
|
327
|
+
catch (error) {
|
|
328
|
+
logger_js_1.coreLogger.error(`Failed to upload file: ${fileInfo.relativePath} - ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
329
|
+
throw error;
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
return this.executeWithOptimizedBatching(uploadTasks, concurrency);
|
|
378
333
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
const result = await task();
|
|
390
|
-
results[globalIndex] = { status: "fulfilled", value: result };
|
|
391
|
-
return result;
|
|
392
|
-
} catch (error) {
|
|
393
|
-
results[globalIndex] = { status: "rejected", reason: error };
|
|
394
|
-
import_logger.coreLogger.error(
|
|
395
|
-
`Task failed at index ${globalIndex}: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
396
|
-
);
|
|
397
|
-
return;
|
|
334
|
+
// Optimized Batch Execution Engine - High-performance task processing system
|
|
335
|
+
async executeWithOptimizedBatching(tasks, concurrency) {
|
|
336
|
+
const results = new Array(tasks.length);
|
|
337
|
+
let completedTasks = 0;
|
|
338
|
+
// Splits tasks into optimal batches to balance memory usage vs. throughput
|
|
339
|
+
const batchSize = Math.min(constants_js_1.UploadConstants.BATCH_SIZE, concurrency * 2);
|
|
340
|
+
const batches = [];
|
|
341
|
+
// Each batch will be processed with full concurrency before moving to next batch
|
|
342
|
+
for (let i = 0; i < tasks.length; i += batchSize) {
|
|
343
|
+
batches.push(tasks.slice(i, i + batchSize));
|
|
398
344
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
345
|
+
// Process each batch sequentially to maintain memory efficiency
|
|
346
|
+
logger_js_1.coreLogger.info(`Processing ${batches.length} batches with ${batchSize} tasks per batch`);
|
|
347
|
+
for (let batchIndex = 0; batchIndex < batches.length; batchIndex++) {
|
|
348
|
+
const batch = batches[batchIndex];
|
|
349
|
+
const batchStartIndex = batchIndex * batchSize;
|
|
350
|
+
logger_js_1.coreLogger.info(`Starting batch ${batchIndex + 1}/${batches.length} with ${batch.length} tasks`);
|
|
351
|
+
// Transform each task into a promise that captures results at correct index
|
|
352
|
+
const batchPromises = batch.map(async (task, taskIndex) => {
|
|
353
|
+
const globalIndex = batchStartIndex + taskIndex;
|
|
354
|
+
try {
|
|
355
|
+
const result = await task();
|
|
356
|
+
results[globalIndex] = { status: "fulfilled", value: result };
|
|
357
|
+
return result;
|
|
358
|
+
}
|
|
359
|
+
catch (error) {
|
|
360
|
+
results[globalIndex] = { status: "rejected", reason: error };
|
|
361
|
+
logger_js_1.coreLogger.error(`Task failed at index ${globalIndex}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
const executing = [];
|
|
366
|
+
for (const promise of batchPromises) {
|
|
367
|
+
if (executing.length >= concurrency) {
|
|
368
|
+
await Promise.race(executing);
|
|
369
|
+
}
|
|
370
|
+
const wrappedPromise = promise
|
|
371
|
+
.then((result) => {
|
|
372
|
+
completedTasks++;
|
|
373
|
+
return result;
|
|
374
|
+
})
|
|
375
|
+
.catch(() => {
|
|
376
|
+
completedTasks++;
|
|
377
|
+
})
|
|
378
|
+
.finally(() => {
|
|
379
|
+
// Cleanup: remove completed promise from executing array
|
|
380
|
+
const index = executing.indexOf(wrappedPromise);
|
|
381
|
+
if (index > -1)
|
|
382
|
+
executing.splice(index, 1);
|
|
383
|
+
});
|
|
384
|
+
executing.push(wrappedPromise);
|
|
385
|
+
}
|
|
386
|
+
// Wait for all promises in current batch to complete before moving to next batch
|
|
387
|
+
await Promise.allSettled(executing);
|
|
388
|
+
logger_js_1.coreLogger.info(`Completed batch ${batchIndex + 1}/${batches.length}`);
|
|
404
389
|
}
|
|
405
|
-
|
|
406
|
-
completedTasks++;
|
|
407
|
-
return result;
|
|
408
|
-
}).catch(() => {
|
|
409
|
-
completedTasks++;
|
|
410
|
-
}).finally(() => {
|
|
411
|
-
const index = executing.indexOf(wrappedPromise);
|
|
412
|
-
if (index > -1) executing.splice(index, 1);
|
|
413
|
-
});
|
|
414
|
-
executing.push(wrappedPromise);
|
|
415
|
-
}
|
|
416
|
-
await Promise.allSettled(executing);
|
|
417
|
-
import_logger.coreLogger.info(`Completed batch ${batchIndex + 1}/${batches.length}`);
|
|
390
|
+
return results;
|
|
418
391
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
throw new Error(
|
|
447
|
-
`Upload failed for ${fileInfo.relativePath} after ${maxRetries} attempts: ${errorMessage}`
|
|
448
|
-
);
|
|
392
|
+
// Individual File Upload with Retry Logic
|
|
393
|
+
async uploadSingleFileOptimized(containerClient, fileInfo) {
|
|
394
|
+
logger_js_1.coreLogger.info(`Uploading file: ${fileInfo.relativePath} (${(fileInfo.size / 1024).toFixed(2)} KB, ${fileInfo.contentType})`);
|
|
395
|
+
const blockBlobClient = containerClient.getBlockBlobClient(fileInfo.relativePath);
|
|
396
|
+
const maxRetries = constants_js_1.UploadConstants.MAX_RETRY_ATTEMPTS;
|
|
397
|
+
const baseDelay = constants_js_1.UploadConstants.RETRY_BASE_DELAY;
|
|
398
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
399
|
+
try {
|
|
400
|
+
await this.performOptimizedUpload(blockBlobClient, fileInfo);
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
catch (error) {
|
|
404
|
+
const isLastAttempt = attempt === maxRetries;
|
|
405
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
406
|
+
logger_js_1.coreLogger.info(`Upload attempt ${attempt} failed for ${fileInfo.relativePath}: ${errorMessage}`);
|
|
407
|
+
if (isLastAttempt) {
|
|
408
|
+
logger_js_1.coreLogger.error(`All retry attempts exhausted for ${fileInfo.relativePath}: ${errorMessage}`);
|
|
409
|
+
if (error instanceof Error) {
|
|
410
|
+
throw error;
|
|
411
|
+
}
|
|
412
|
+
throw new Error(`Upload failed for ${fileInfo.relativePath} after ${maxRetries} attempts: ${errorMessage}`);
|
|
413
|
+
}
|
|
414
|
+
// Exponential backoff with jitter (Azure SDK pattern)
|
|
415
|
+
const delay = baseDelay * Math.pow(2, attempt - 1) + Math.random() * 500;
|
|
416
|
+
logger_js_1.coreLogger.info(`Retrying upload for ${fileInfo.relativePath} in ${delay.toFixed(0)}ms (attempt ${attempt + 1}/${maxRetries})`);
|
|
417
|
+
await new Promise((_resolve) => setTimeout(_resolve, delay));
|
|
418
|
+
}
|
|
449
419
|
}
|
|
450
|
-
const delay = baseDelay * Math.pow(2, attempt - 1) + Math.random() * 500;
|
|
451
|
-
import_logger.coreLogger.info(
|
|
452
|
-
`Retrying upload for ${fileInfo.relativePath} in ${delay.toFixed(0)}ms (attempt ${attempt + 1}/${maxRetries})`
|
|
453
|
-
);
|
|
454
|
-
await new Promise((_resolve) => setTimeout(_resolve, delay));
|
|
455
|
-
}
|
|
456
420
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
421
|
+
// Multi-Strategy Upload Engine - Optimized upload based on file characteristics
|
|
422
|
+
async performOptimizedUpload(blockBlobClient, fileInfo) {
|
|
423
|
+
if (fileInfo.size <= constants_js_1.UploadConstants.SMALL_FILE_THRESHOLD) {
|
|
424
|
+
// DIRECT UPLOAD: Optimal for small files (≤1MB)
|
|
425
|
+
const fileContent = (0, fs_1.readFileSync)(fileInfo.fullPath);
|
|
426
|
+
await blockBlobClient.upload(fileContent, fileContent.length, {
|
|
427
|
+
blobHTTPHeaders: {
|
|
428
|
+
blobContentType: fileInfo.contentType,
|
|
429
|
+
},
|
|
430
|
+
});
|
|
465
431
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
}
|
|
432
|
+
else if (fileInfo.size <= constants_js_1.UploadConstants.LARGE_FILE_THRESHOLD) {
|
|
433
|
+
// BLOCK UPLOAD: Optimal for medium files (1MB - 100MB)
|
|
434
|
+
const fileContent = (0, fs_1.readFileSync)(fileInfo.fullPath);
|
|
435
|
+
await blockBlobClient.uploadData(fileContent, {
|
|
436
|
+
blobHTTPHeaders: {
|
|
437
|
+
blobContentType: fileInfo.contentType,
|
|
438
|
+
},
|
|
439
|
+
blockSize: constants_js_1.UploadConstants.OPTIMIZED_BLOCK_SIZE,
|
|
440
|
+
concurrency: constants_js_1.UploadConstants.PER_FILE_CONCURRENCY,
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
// STREAMING UPLOAD: Optimal for large files (>100MB)
|
|
445
|
+
const stream = (0, fs_1.createReadStream)(fileInfo.fullPath);
|
|
446
|
+
await blockBlobClient.uploadStream(stream, constants_js_1.UploadConstants.STREAM_BUFFER_SIZE, constants_js_1.UploadConstants.LARGE_FILE_CONCURRENCY, {
|
|
447
|
+
blobHTTPHeaders: {
|
|
448
|
+
blobContentType: fileInfo.contentType,
|
|
449
|
+
},
|
|
450
|
+
});
|
|
486
451
|
}
|
|
487
|
-
|
|
452
|
+
logger_js_1.coreLogger.info(`Successfully uploaded: ${fileInfo.relativePath}`);
|
|
488
453
|
}
|
|
489
|
-
import_logger.coreLogger.info(`Successfully uploaded: ${fileInfo.relativePath}`);
|
|
490
|
-
}
|
|
491
454
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
PlaywrightReporterStorageManager
|
|
495
|
-
});
|
|
455
|
+
exports.PlaywrightReporterStorageManager = PlaywrightReporterStorageManager;
|
|
456
|
+
//# sourceMappingURL=playwrightReporterStorageManager.js.map
|