@azure/microsoft-playwright-testing 1.0.0-alpha.20240913.2 → 1.0.0-alpha.20240917.1
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/CHANGELOG.md +11 -2
- package/dist/common/constants.d.ts +1 -1
- package/dist/common/constants.js +1 -1
- package/dist/common/constants.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/utils/serviceClient.d.ts.map +1 -1
- package/dist/utils/serviceClient.js +13 -8
- package/dist/utils/serviceClient.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Release History
|
|
2
2
|
|
|
3
|
-
## 1.0.0-beta.
|
|
3
|
+
## 1.0.0-beta.4 (Unreleased)
|
|
4
4
|
|
|
5
5
|
### Features Added
|
|
6
6
|
|
|
@@ -10,9 +10,18 @@
|
|
|
10
10
|
|
|
11
11
|
### Other Changes
|
|
12
12
|
|
|
13
|
+
## 1.0.0-beta.3 (2024-09-16)
|
|
14
|
+
|
|
15
|
+
This release provides better error messaging and error handling by improving logging.
|
|
16
|
+
|
|
17
|
+
### Bugs Fixed
|
|
18
|
+
|
|
19
|
+
- Optimized test result publishing by reusing the Sas uri till it's expiry.
|
|
20
|
+
- Fixed unexpected process termination by improving error handling of API used to publish test results.
|
|
21
|
+
|
|
13
22
|
## 1.0.0-beta.2 (2024-09-12)
|
|
14
23
|
|
|
15
|
-
This release updates the Microsoft Playwright Testing library documentation and improves error messages.
|
|
24
|
+
This release updates the Microsoft Playwright Testing library documentation and improves error messages.
|
|
16
25
|
|
|
17
26
|
### Bugs Fixed
|
|
18
27
|
|
|
@@ -44,7 +44,7 @@ export declare class Constants {
|
|
|
44
44
|
static readonly TEST_FRAMEWORK_RUNNERNAME = "PLAYWRIGHT";
|
|
45
45
|
static readonly TEST_TYPE = "WebTest";
|
|
46
46
|
static readonly TEST_SDK_LANGUAGE = "JAVASCRIPT";
|
|
47
|
-
static readonly REPORTER_PACKAGE_VERSION = "1.0.0-beta.
|
|
47
|
+
static readonly REPORTER_PACKAGE_VERSION = "1.0.0-beta.3";
|
|
48
48
|
static readonly DEFAULT_DASHBOARD_ENDPOINT = "https://playwright.microsoft.com";
|
|
49
49
|
static readonly DEFAULT_SERVICE_ENDPOINT = "https://{region}.reporting.api.playwright-test.io";
|
|
50
50
|
static readonly DEFAULT_REDACTED_MESSAGE = "***REDACTED***";
|
package/dist/common/constants.js
CHANGED
|
@@ -52,7 +52,7 @@ Constants.TEST_FRAMEWORK_RUNNERNAME = "PLAYWRIGHT";
|
|
|
52
52
|
Constants.TEST_TYPE = "WebTest";
|
|
53
53
|
Constants.TEST_SDK_LANGUAGE = "JAVASCRIPT";
|
|
54
54
|
// Placeholder version
|
|
55
|
-
Constants.REPORTER_PACKAGE_VERSION = "1.0.0-beta.
|
|
55
|
+
Constants.REPORTER_PACKAGE_VERSION = "1.0.0-beta.3";
|
|
56
56
|
Constants.DEFAULT_DASHBOARD_ENDPOINT = "https://playwright.microsoft.com";
|
|
57
57
|
Constants.DEFAULT_SERVICE_ENDPOINT = "https://{region}.reporting.api.playwright-test.io";
|
|
58
58
|
Constants.DEFAULT_REDACTED_MESSAGE = "***REDACTED***";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":";;;AAIa,QAAA,2BAA2B,GAAG;IACzC,+CAA+C,EAAE,EAAE;IACnD,KAAK,EAAE,8CAA8C;IACrD,mCAAmC,EAAE,CAAC;CACvC,CAAC;AAEF;;;GAGG;AACU,QAAA,SAAS,GAAG;IACvB,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;CACV,CAAC;AAEX;;;GAGG;AACU,QAAA,WAAW,GAAG;IACzB,QAAQ,EAAE,UAAU;IACpB,YAAY,EAAE,cAAc;CACpB,CAAC;AAEX;;;GAGG;AACU,QAAA,0BAA0B,GAA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,CAAC,QAAQ;KAC7B;IACD;QACE,GAAG,EAAE,yCAAyC;QAC9C,OAAO,EACL,kHAAkH;QACpH,OAAO,EACL,yFAAyF;QAC3F,IAAI,EAAE,qBAAa,CAAC,QAAQ;KAC7B;IACD;QACE,GAAG,EAAE,6BAA6B;QAClC,OAAO,EAAE,sFAAsF;QAC/F,OAAO,EAAE,0DAA0D;QACnE,IAAI,EAAE,qBAAa,CAAC,QAAQ;KAC7B;IACD;QACE,GAAG,EAAE,yBAAyB;QAC9B,OAAO,EAAE,+DAA+D;QACxE,OAAO,EAAE,sDAAsD;QAC/D,IAAI,EAAE,qBAAa,CAAC,QAAQ;KAC7B;IACD;QACE,GAAG,EAAE,0BAA0B;QAC/B,OAAO,EACL,mKAAmK;QACrK,OAAO,EAAE,2CAA2C;QACpD,IAAI,EAAE,qBAAa,CAAC,QAAQ;KAC7B;IACD;QACE,GAAG,EAAE,iCAAiC;QACtC,OAAO,EAAE,yEAAyE;QAClF,OAAO,EAAE,uEAAuE;QAChF,IAAI,EAAE,qBAAa,CAAC,QAAQ;KAC7B;CACF,CAAC;AAEW,QAAA,4BAA4B,GAAG;IAC1C,sBAAsB,EAAE,yBAAyB;IACjD,qBAAqB,EAAE,wBAAwB;IAC/C,6BAA6B,EAAE,gCAAgC;CAChE,CAAC;AAEW,QAAA,oCAAoC,GAAG,QAAQ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport { ApiErrorMessage } from \"./types\";\n\nexport const EntraIdAccessTokenConstants = {\n LIFETIME_LEFT_THRESHOLD_IN_MINUTES_FOR_ROTATION: 15,\n SCOPE: \"https://management.core.windows.net/.default\",\n ROTATION_INTERVAL_PERIOD_IN_MINUTES: 4,\n};\n\n/** @public\n *\n * OS types supported on Microsoft Playwright Testing cloud hosted browsers\n */\nexport const ServiceOS = {\n LINUX: \"linux\",\n WINDOWS: \"windows\",\n} as const;\n\n/** @public\n *\n * Authentication types supported on Microsoft Playwright Testing\n */\nexport const ServiceAuth = {\n ENTRA_ID: \"ENTRA_ID\",\n ACCESS_TOKEN: \"ACCESS_TOKEN\",\n} as const;\n\n/** @public\n *\n * Environment variables used by Microsoft Playwright Testing\n */\nexport const ServiceEnvironmentVariable = {\n PLAYWRIGHT_SERVICE_OS: \"PLAYWRIGHT_SERVICE_OS\",\n PLAYWRIGHT_SERVICE_RUN_ID: \"PLAYWRIGHT_SERVICE_RUN_ID\",\n PLAYWRIGHT_SERVICE_EXPOSE_NETWORK_ENVIRONMENT_VARIABLE: \"PLAYWRIGHT_SERVICE_EXPOSE_NETWORK\",\n PLAYWRIGHT_SERVICE_ACCESS_TOKEN: \"PLAYWRIGHT_SERVICE_ACCESS_TOKEN\",\n PLAYWRIGHT_SERVICE_URL: \"PLAYWRIGHT_SERVICE_URL\",\n PLAYWRIGHT_SERVICE_REPORTING_URL: \"PLAYWRIGHT_SERVICE_REPORTING_URL\",\n};\n\nexport const DefaultConnectOptionsConstants = {\n DEFAULT_TIMEOUT: 30000,\n DEFAULT_SLOW_MO: 0,\n DEFAULT_EXPOSE_NETWORK: \"<loopback>\",\n DEFAULT_SERVICE_OS: ServiceOS.LINUX,\n};\n\nexport const API_VERSION = \"2023-10-01-preview\";\n\n// Do not put an ending slash for the urls,\n// for example use https://www.microsoft.com/en-in and not https://www.microsoft.com/en-in/\n\nexport class Constants {\n // Config related constants\n public static readonly TEST_FRAMEWORK_NAME = \"PLAYWRIGHT\";\n public static readonly TEST_FRAMEWORK_RUNNERNAME = \"PLAYWRIGHT\";\n public static readonly TEST_TYPE = \"WebTest\";\n public static readonly TEST_SDK_LANGUAGE = \"JAVASCRIPT\";\n // Placeholder version\n public static readonly REPORTER_PACKAGE_VERSION = \"1.0.0-beta.2\";\n public static readonly DEFAULT_DASHBOARD_ENDPOINT = \"https://playwright.microsoft.com\";\n public static readonly DEFAULT_SERVICE_ENDPOINT =\n \"https://{region}.reporting.api.playwright-test.io\";\n public static readonly DEFAULT_REDACTED_MESSAGE = \"***REDACTED***\";\n public static readonly SAS_URI_SEPARATOR = \"?\";\n public static readonly DEFAULT_TEST_RUN_NAME = \"MPTReporterTests\";\n public static readonly TEST_BATCH_SIZE = 50;\n public static readonly UPLOAD_MODE = \"sdk\";\n public static readonly GIT_VERSION_COMMAND = \"git --version\";\n public static readonly GIT_REV_PARSE = \"git rev-parse --is-inside-work-tree\";\n public static readonly GIT_COMMIT_MESSAGE_COMMAND = 'git log -1 --pretty=format:\"%s\"';\n public static readonly ERROR_MESSAGES_MAX_LENGTH = 100;\n public static readonly API_VERSION = \"2024-09-01-preview\";\n public static readonly NON_RETRYABLE_STATUS_CODES = [400, 403, 404, 405, 409];\n public static readonly SupportedRegions: string[] = [\n \"eastus\",\n \"eastasia\",\n \"westeurope\",\n \"westus3\",\n \"centraluseuap\",\n \"eastus2euap\",\n ];\n // Error messages\n public static readonly CONFLICT_409_ERROR_MESSAGE =\n \"Test run with id {runId} already exists. Provide a unique run id.\";\n public static readonly FORBIDDEN_403_ERROR_MESSAGE =\n \"Reporting is not enabled for your workspace {workspaceId}. Enable the Reporting feature under Feature management settings using the Playwright portal: https://playwright.microsoft.com/workspaces/{workspaceId}/settings/general\";\n // API Endpoints\n public static readonly testRunsEndpoint: string = \"workspaces/{workspaceId}/test-runs\";\n public static readonly testRunsShardEndpoint: string =\n \"workspaces/{workspaceId}/test-runs/{testRunId}:updateShardExecutionStatus\";\n public static readonly storageUriEndpoint: string =\n \"workspaces/{workspaceId}/test-runs/{testRunId}:createArtifactsUploadBaseUri\";\n public static readonly testResultsEndpoint: string =\n \"workspaces/{workspaceId}/test-results/upload-batch\";\n public static readonly patchTestRun: string = \"patchTestRun\";\n public static readonly getTestRun: string = \"getTestRun\";\n public static readonly patchTestRunShardStart: string = \"patchTestRunShardStart\";\n public static readonly patchTestRunShardEnd: string = \"patchTestRunShardEnd\";\n public static readonly postTestResults: string = \"postTestResults\";\n public static readonly getStorageUri: string = \"getStorageUri\";\n\n public static readonly ERROR_MESSAGE: ApiErrorMessage = {\n patchTestRun: {\n 400: \"The request made to the server is invalid. Please check the request parameters and try again.\",\n 401: \"The authentication token provided is invalid. Please check the token and try again.\",\n 500: \"An unexpected error occurred on our server. Our team is working to resolve the issue. Please try again later, or contact support if the problem continues.\",\n 429: \"You have exceeded the rate limit for the API. Please wait and try again later.\",\n 504: \"The request to the service timed out. Please try again later.\",\n 503: \"The service is currently unavailable. Please check the service status and try again.\",\n },\n getTestRun: {\n 400: \"The request made to the server is invalid. Please check the request parameters and try again.\",\n 401: \"The authentication token provided is invalid. Please check the token and try again.\",\n 403: \"You do not have the required permissions to run tests. Please contact your workspace administrator.\",\n 500: \"An unexpected error occurred on our server. Our team is working to resolve the issue. Please try again later, or contact support if the problem continues.\",\n 429: \"You have exceeded the rate limit for the API. Please wait and try again later.\",\n 504: \"The request to the service timed out. Please try again later.\",\n 503: \"The service is currently unavailable. Please check the service status and try again.\",\n },\n patchTestRunShardStart: {\n 400: \"The request made to the server is invalid. Please check the request parameters and try again.\",\n 401: \"The authentication token provided is invalid. Please check the token and try again.\",\n 403: \"You do not have the required permissions to run tests. Please contact your workspace administrator.\",\n 500: \"An unexpected error occurred on our server. Our team is working to resolve the issue. Please try again later, or contact support if the problem continues.\",\n 429: \"You have exceeded the rate limit for the API. Please wait and try again later.\",\n 504: \"The request to the service timed out. Please try again later.\",\n 503: \"The service is currently unavailable. Please check the service status and try again.\",\n },\n patchTestRunShardEnd: {\n 400: \"The request made to the server is invalid. Please check the request parameters and try again.\",\n 401: \"The authentication token provided is invalid. Please check the token and try again.\",\n 403: \"You do not have the required permissions to run tests. Please contact your workspace administrator.\",\n 500: \"An unexpected error occurred on our server. Our team is working to resolve the issue. Please try again later, or contact support if the problem continues.\",\n 429: \"You have exceeded the rate limit for the API. Please wait and try again later.\",\n 504: \"The request to the service timed out. Please try again later.\",\n 503: \"The service is currently unavailable. Please check the service status and try again.\",\n },\n postTestResults: {\n 400: \"The request made to the server is invalid. Please check the request parameters and try again.\",\n 401: \"The authentication token provided is invalid. Please check the token and try again.\",\n 403: \"You do not have the required permissions to run tests. Please contact your workspace administrator.\",\n 500: \"An unexpected error occurred on our server. Our team is working to resolve the issue. Please try again later, or contact support if the problem continues.\",\n 429: \"You have exceeded the rate limit for the API. Please wait and try again later.\",\n 504: \"The request to the service timed out. Please try again later.\",\n 503: \"The service is currently unavailable. Please check the service status and try again.\",\n },\n getStorageUri: {\n 400: \"The request made to the server is invalid. Please check the request parameters and try again.\",\n 401: \"The authentication token provided is invalid. Please check the token and try again.\",\n 403: \"You do not have the required permissions to run tests. Please contact your workspace administrator.\",\n 500: \"An unexpected error occurred on our server. Our team is working to resolve the issue. Please try again later, or contact support if the problem continues.\",\n 429: \"You have exceeded the rate limit for the API. Please wait and try again later.\",\n 504: \"The request to the service timed out. Please try again later.\",\n 503: \"The service is currently unavailable. Please check the service status and try again.\",\n },\n };\n}\n\nexport const TestErrorType = {\n Scalable: \"Scalable\",\n Reporting: \"Reporting\",\n};\n\nexport const TestResultErrorConstants = [\n {\n key: \"Unauthorized_Scalable\",\n message: \"The authentication token provided is invalid. Please check the token and try again.\",\n pattern: /(?=.*browserType\\.connect)(?=.*401 Unauthorized)/i,\n type: TestErrorType.Scalable,\n },\n {\n key: \"NoPermissionOnWorkspace_Scalable\",\n message: `You do not have the required permissions to run tests. This could be because:\n\n a. You do not have the required roles on the workspace. Only Owner and Contributor roles can run tests. Contact the service administrator.\n b. The workspace you are trying to run the tests on is in a different Azure tenant than what you are signed into. Check the tenant id from Azure portal (https://aka.ms/mpt/find-tenant-id) and login using the command 'az login --tenant <TENANT_ID>'.\n `,\n pattern:\n /(?=.*browserType\\.connect)(?=.*403 Forbidden)(?=[\\s\\S]*CheckAccess API call with non successful response)/i,\n type: TestErrorType.Scalable,\n },\n {\n key: \"InvalidWorkspace_Scalable\",\n message: \"The specified workspace does not exist. Please verify your workspace settings.\",\n pattern:\n /(?=.*browserType\\.connect)(?=.*403 Forbidden)(?=[\\s\\S]*InvalidAccountOrSubscriptionState)/i,\n type: TestErrorType.Scalable,\n },\n {\n key: \"InvalidAccessToken_Scalable\",\n message:\n \"The provided access token does not match the specified workspace URL. Please verify that both values are correct.\",\n pattern: /(?=.*browserType\\.connect)(?=.*403 Forbidden)(?=[\\s\\S]*InvalidAccessToken)/i,\n type: TestErrorType.Scalable,\n },\n {\n key: \"AccessTokenOrUserOrWorkspaceNotFound_Scalable\",\n message:\n \"The data for the user, workspace or access token was not found. Please check the request or create new token and try again.\",\n pattern: /(?=.*browserType\\.connect)(?=.*404 Not Found)(?=[\\s\\S]*NotFound)/i,\n type: TestErrorType.Scalable,\n },\n {\n key: \"AccessKeyBasedAuthNotSupported_Scalable\",\n message:\n \"Authentication through service access token is disabled for this workspace. Please use Entra ID to authenticate.\",\n pattern:\n /(?=.*browserType\\.connect)(?=.*403 Forbidden)(?=[\\s\\S]*AccessKeyBasedAuthNotSupported)/i,\n type: TestErrorType.Scalable,\n },\n {\n key: \"ServiceUnavailable_Scalable\",\n message: \"The service is currently unavailable. Please check the service status and try again.\",\n pattern: /(?=.*browserType\\.connect)(?=.*503 Service Unavailable)/i,\n type: TestErrorType.Scalable,\n },\n {\n key: \"GatewayTimeout_Scalable\",\n message: \"The request to the service timed out. Please try again later.\",\n pattern: /(?=.*browserType\\.connect)(?=.*504 Gateway Timeout)/i,\n type: TestErrorType.Scalable,\n },\n {\n key: \"QuotaLimitError_Scalable\",\n message:\n \"It is possible that the maximum number of concurrent sessions allowed for your workspace has been exceeded. Check the quota at https://aka.ms/mpt/resource-quota.\",\n pattern: /browserType.connect: Timeout .* exceeded/i,\n type: TestErrorType.Scalable,\n },\n {\n key: \"BrowserConnectionError_Scalable\",\n message: \"The service is currently unavailable. Please try again after some time.\",\n pattern: /browserType.connect: Target page, context or browser has been closed/i,\n type: TestErrorType.Scalable,\n },\n];\n\nexport const InternalEnvironmentVariables = {\n MPT_PLAYWRIGHT_VERSION: \"_MPT_PLAYWRIGHT_VERSION\",\n MPT_SETUP_FATAL_ERROR: \"_MPT_SETUP_FATAL_ERROR\",\n MPT_CLOUD_HOSTED_BROWSER_USED: \"_MPT_CLOUD_HOSTED_BROWSER_USED\",\n};\n\nexport const MINIMUM_SUPPORTED_PLAYWRIGHT_VERSION = \"1.47.0\";\n"]}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":";;;AAIa,QAAA,2BAA2B,GAAG;IACzC,+CAA+C,EAAE,EAAE;IACnD,KAAK,EAAE,8CAA8C;IACrD,mCAAmC,EAAE,CAAC;CACvC,CAAC;AAEF;;;GAGG;AACU,QAAA,SAAS,GAAG;IACvB,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;CACV,CAAC;AAEX;;;GAGG;AACU,QAAA,WAAW,GAAG;IACzB,QAAQ,EAAE,UAAU;IACpB,YAAY,EAAE,cAAc;CACpB,CAAC;AAEX;;;GAGG;AACU,QAAA,0BAA0B,GAAG;IACxC,qBAAqB,EAAE,uBAAuB;IAC9C,yBAAyB,EAAE,2BAA2B;IACtD,sDAAsD,EAAE,mCAAmC;IAC3F,+BAA+B,EAAE,iCAAiC;IAClE,sBAAsB,EAAE,wBAAwB;IAChD,gCAAgC,EAAE,kCAAkC;CACrE,CAAC;AAEW,QAAA,8BAA8B,GAAG;IAC5C,eAAe,EAAE,KAAK;IACtB,eAAe,EAAE,CAAC;IAClB,sBAAsB,EAAE,YAAY;IACpC,kBAAkB,EAAE,iBAAS,CAAC,KAAK;CACpC,CAAC;AAEW,QAAA,WAAW,GAAG,oBAAoB,CAAC;AAEhD,2CAA2C;AAC3C,2FAA2F;AAE3F,MAAa,SAAS;;AAAtB,8BAyGC;AAxGC,2BAA2B;AACJ,6BAAmB,GAAG,YAAY,CAAC;AACnC,mCAAyB,GAAG,YAAY,CAAC;AACzC,mBAAS,GAAG,SAAS,CAAC;AACtB,2BAAiB,GAAG,YAAY,CAAC;AACxD,sBAAsB;AACC,kCAAwB,GAAG,cAAc,CAAC;AAC1C,oCAA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C,QAAQ;KAC7B;CACF,CAAC;AAEW,QAAA,4BAA4B,GAAG;IAC1C,sBAAsB,EAAE,yBAAyB;IACjD,qBAAqB,EAAE,wBAAwB;IAC/C,6BAA6B,EAAE,gCAAgC;CAChE,CAAC;AAEW,QAAA,oCAAoC,GAAG,QAAQ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport { ApiErrorMessage } from \"./types\";\n\nexport const EntraIdAccessTokenConstants = {\n LIFETIME_LEFT_THRESHOLD_IN_MINUTES_FOR_ROTATION: 15,\n SCOPE: \"https://management.core.windows.net/.default\",\n ROTATION_INTERVAL_PERIOD_IN_MINUTES: 4,\n};\n\n/** @public\n *\n * OS types supported on Microsoft Playwright Testing cloud hosted browsers\n */\nexport const ServiceOS = {\n LINUX: \"linux\",\n WINDOWS: \"windows\",\n} as const;\n\n/** @public\n *\n * Authentication types supported on Microsoft Playwright Testing\n */\nexport const ServiceAuth = {\n ENTRA_ID: \"ENTRA_ID\",\n ACCESS_TOKEN: \"ACCESS_TOKEN\",\n} as const;\n\n/** @public\n *\n * Environment variables used by Microsoft Playwright Testing\n */\nexport const ServiceEnvironmentVariable = {\n PLAYWRIGHT_SERVICE_OS: \"PLAYWRIGHT_SERVICE_OS\",\n PLAYWRIGHT_SERVICE_RUN_ID: \"PLAYWRIGHT_SERVICE_RUN_ID\",\n PLAYWRIGHT_SERVICE_EXPOSE_NETWORK_ENVIRONMENT_VARIABLE: \"PLAYWRIGHT_SERVICE_EXPOSE_NETWORK\",\n PLAYWRIGHT_SERVICE_ACCESS_TOKEN: \"PLAYWRIGHT_SERVICE_ACCESS_TOKEN\",\n PLAYWRIGHT_SERVICE_URL: \"PLAYWRIGHT_SERVICE_URL\",\n PLAYWRIGHT_SERVICE_REPORTING_URL: \"PLAYWRIGHT_SERVICE_REPORTING_URL\",\n};\n\nexport const DefaultConnectOptionsConstants = {\n DEFAULT_TIMEOUT: 30000,\n DEFAULT_SLOW_MO: 0,\n DEFAULT_EXPOSE_NETWORK: \"<loopback>\",\n DEFAULT_SERVICE_OS: ServiceOS.LINUX,\n};\n\nexport const API_VERSION = \"2023-10-01-preview\";\n\n// Do not put an ending slash for the urls,\n// for example use https://www.microsoft.com/en-in and not https://www.microsoft.com/en-in/\n\nexport class Constants {\n // Config related constants\n public static readonly TEST_FRAMEWORK_NAME = \"PLAYWRIGHT\";\n public static readonly TEST_FRAMEWORK_RUNNERNAME = \"PLAYWRIGHT\";\n public static readonly TEST_TYPE = \"WebTest\";\n public static readonly TEST_SDK_LANGUAGE = \"JAVASCRIPT\";\n // Placeholder version\n public static readonly REPORTER_PACKAGE_VERSION = \"1.0.0-beta.3\";\n public static readonly DEFAULT_DASHBOARD_ENDPOINT = \"https://playwright.microsoft.com\";\n public static readonly DEFAULT_SERVICE_ENDPOINT =\n \"https://{region}.reporting.api.playwright-test.io\";\n public static readonly DEFAULT_REDACTED_MESSAGE = \"***REDACTED***\";\n public static readonly SAS_URI_SEPARATOR = \"?\";\n public static readonly DEFAULT_TEST_RUN_NAME = \"MPTReporterTests\";\n public static readonly TEST_BATCH_SIZE = 50;\n public static readonly UPLOAD_MODE = \"sdk\";\n public static readonly GIT_VERSION_COMMAND = \"git --version\";\n public static readonly GIT_REV_PARSE = \"git rev-parse --is-inside-work-tree\";\n public static readonly GIT_COMMIT_MESSAGE_COMMAND = 'git log -1 --pretty=format:\"%s\"';\n public static readonly ERROR_MESSAGES_MAX_LENGTH = 100;\n public static readonly API_VERSION = \"2024-09-01-preview\";\n public static readonly NON_RETRYABLE_STATUS_CODES = [400, 403, 404, 405, 409];\n public static readonly SupportedRegions: string[] = [\n \"eastus\",\n \"eastasia\",\n \"westeurope\",\n \"westus3\",\n \"centraluseuap\",\n \"eastus2euap\",\n ];\n // Error messages\n public static readonly CONFLICT_409_ERROR_MESSAGE =\n \"Test run with id {runId} already exists. Provide a unique run id.\";\n public static readonly FORBIDDEN_403_ERROR_MESSAGE =\n \"Reporting is not enabled for your workspace {workspaceId}. Enable the Reporting feature under Feature management settings using the Playwright portal: https://playwright.microsoft.com/workspaces/{workspaceId}/settings/general\";\n // API Endpoints\n public static readonly testRunsEndpoint: string = \"workspaces/{workspaceId}/test-runs\";\n public static readonly testRunsShardEndpoint: string =\n \"workspaces/{workspaceId}/test-runs/{testRunId}:updateShardExecutionStatus\";\n public static readonly storageUriEndpoint: string =\n \"workspaces/{workspaceId}/test-runs/{testRunId}:createArtifactsUploadBaseUri\";\n public static readonly testResultsEndpoint: string =\n \"workspaces/{workspaceId}/test-results/upload-batch\";\n public static readonly patchTestRun: string = \"patchTestRun\";\n public static readonly getTestRun: string = \"getTestRun\";\n public static readonly patchTestRunShardStart: string = \"patchTestRunShardStart\";\n public static readonly patchTestRunShardEnd: string = \"patchTestRunShardEnd\";\n public static readonly postTestResults: string = \"postTestResults\";\n public static readonly getStorageUri: string = \"getStorageUri\";\n\n public static readonly ERROR_MESSAGE: ApiErrorMessage = {\n patchTestRun: {\n 400: \"The request made to the server is invalid. Please check the request parameters and try again.\",\n 401: \"The authentication token provided is invalid. Please check the token and try again.\",\n 500: \"An unexpected error occurred on our server. Our team is working to resolve the issue. Please try again later, or contact support if the problem continues.\",\n 429: \"You have exceeded the rate limit for the API. Please wait and try again later.\",\n 504: \"The request to the service timed out. Please try again later.\",\n 503: \"The service is currently unavailable. Please check the service status and try again.\",\n },\n getTestRun: {\n 400: \"The request made to the server is invalid. Please check the request parameters and try again.\",\n 401: \"The authentication token provided is invalid. Please check the token and try again.\",\n 403: \"You do not have the required permissions to run tests. Please contact your workspace administrator.\",\n 500: \"An unexpected error occurred on our server. Our team is working to resolve the issue. Please try again later, or contact support if the problem continues.\",\n 429: \"You have exceeded the rate limit for the API. Please wait and try again later.\",\n 504: \"The request to the service timed out. Please try again later.\",\n 503: \"The service is currently unavailable. Please check the service status and try again.\",\n },\n patchTestRunShardStart: {\n 400: \"The request made to the server is invalid. Please check the request parameters and try again.\",\n 401: \"The authentication token provided is invalid. Please check the token and try again.\",\n 403: \"You do not have the required permissions to run tests. Please contact your workspace administrator.\",\n 500: \"An unexpected error occurred on our server. Our team is working to resolve the issue. Please try again later, or contact support if the problem continues.\",\n 429: \"You have exceeded the rate limit for the API. Please wait and try again later.\",\n 504: \"The request to the service timed out. Please try again later.\",\n 503: \"The service is currently unavailable. Please check the service status and try again.\",\n },\n patchTestRunShardEnd: {\n 400: \"The request made to the server is invalid. Please check the request parameters and try again.\",\n 401: \"The authentication token provided is invalid. Please check the token and try again.\",\n 403: \"You do not have the required permissions to run tests. Please contact your workspace administrator.\",\n 500: \"An unexpected error occurred on our server. Our team is working to resolve the issue. Please try again later, or contact support if the problem continues.\",\n 429: \"You have exceeded the rate limit for the API. Please wait and try again later.\",\n 504: \"The request to the service timed out. Please try again later.\",\n 503: \"The service is currently unavailable. Please check the service status and try again.\",\n },\n postTestResults: {\n 400: \"The request made to the server is invalid. Please check the request parameters and try again.\",\n 401: \"The authentication token provided is invalid. Please check the token and try again.\",\n 403: \"You do not have the required permissions to run tests. Please contact your workspace administrator.\",\n 500: \"An unexpected error occurred on our server. Our team is working to resolve the issue. Please try again later, or contact support if the problem continues.\",\n 429: \"You have exceeded the rate limit for the API. Please wait and try again later.\",\n 504: \"The request to the service timed out. Please try again later.\",\n 503: \"The service is currently unavailable. Please check the service status and try again.\",\n },\n getStorageUri: {\n 400: \"The request made to the server is invalid. Please check the request parameters and try again.\",\n 401: \"The authentication token provided is invalid. Please check the token and try again.\",\n 403: \"You do not have the required permissions to run tests. Please contact your workspace administrator.\",\n 500: \"An unexpected error occurred on our server. Our team is working to resolve the issue. Please try again later, or contact support if the problem continues.\",\n 429: \"You have exceeded the rate limit for the API. Please wait and try again later.\",\n 504: \"The request to the service timed out. Please try again later.\",\n 503: \"The service is currently unavailable. Please check the service status and try again.\",\n },\n };\n}\n\nexport const TestErrorType = {\n Scalable: \"Scalable\",\n Reporting: \"Reporting\",\n};\n\nexport const TestResultErrorConstants = [\n {\n key: \"Unauthorized_Scalable\",\n message: \"The authentication token provided is invalid. Please check the token and try again.\",\n pattern: /(?=.*browserType\\.connect)(?=.*401 Unauthorized)/i,\n type: TestErrorType.Scalable,\n },\n {\n key: \"NoPermissionOnWorkspace_Scalable\",\n message: `You do not have the required permissions to run tests. This could be because:\n\n a. You do not have the required roles on the workspace. Only Owner and Contributor roles can run tests. Contact the service administrator.\n b. The workspace you are trying to run the tests on is in a different Azure tenant than what you are signed into. Check the tenant id from Azure portal (https://aka.ms/mpt/find-tenant-id) and login using the command 'az login --tenant <TENANT_ID>'.\n `,\n pattern:\n /(?=.*browserType\\.connect)(?=.*403 Forbidden)(?=[\\s\\S]*CheckAccess API call with non successful response)/i,\n type: TestErrorType.Scalable,\n },\n {\n key: \"InvalidWorkspace_Scalable\",\n message: \"The specified workspace does not exist. Please verify your workspace settings.\",\n pattern:\n /(?=.*browserType\\.connect)(?=.*403 Forbidden)(?=[\\s\\S]*InvalidAccountOrSubscriptionState)/i,\n type: TestErrorType.Scalable,\n },\n {\n key: \"InvalidAccessToken_Scalable\",\n message:\n \"The provided access token does not match the specified workspace URL. Please verify that both values are correct.\",\n pattern: /(?=.*browserType\\.connect)(?=.*403 Forbidden)(?=[\\s\\S]*InvalidAccessToken)/i,\n type: TestErrorType.Scalable,\n },\n {\n key: \"AccessTokenOrUserOrWorkspaceNotFound_Scalable\",\n message:\n \"The data for the user, workspace or access token was not found. Please check the request or create new token and try again.\",\n pattern: /(?=.*browserType\\.connect)(?=.*404 Not Found)(?=[\\s\\S]*NotFound)/i,\n type: TestErrorType.Scalable,\n },\n {\n key: \"AccessKeyBasedAuthNotSupported_Scalable\",\n message:\n \"Authentication through service access token is disabled for this workspace. Please use Entra ID to authenticate.\",\n pattern:\n /(?=.*browserType\\.connect)(?=.*403 Forbidden)(?=[\\s\\S]*AccessKeyBasedAuthNotSupported)/i,\n type: TestErrorType.Scalable,\n },\n {\n key: \"ServiceUnavailable_Scalable\",\n message: \"The service is currently unavailable. Please check the service status and try again.\",\n pattern: /(?=.*browserType\\.connect)(?=.*503 Service Unavailable)/i,\n type: TestErrorType.Scalable,\n },\n {\n key: \"GatewayTimeout_Scalable\",\n message: \"The request to the service timed out. Please try again later.\",\n pattern: /(?=.*browserType\\.connect)(?=.*504 Gateway Timeout)/i,\n type: TestErrorType.Scalable,\n },\n {\n key: \"QuotaLimitError_Scalable\",\n message:\n \"It is possible that the maximum number of concurrent sessions allowed for your workspace has been exceeded. Check the quota at https://aka.ms/mpt/resource-quota.\",\n pattern: /browserType.connect: Timeout .* exceeded/i,\n type: TestErrorType.Scalable,\n },\n {\n key: \"BrowserConnectionError_Scalable\",\n message: \"The service is currently unavailable. Please try again after some time.\",\n pattern: /browserType.connect: Target page, context or browser has been closed/i,\n type: TestErrorType.Scalable,\n },\n];\n\nexport const InternalEnvironmentVariables = {\n MPT_PLAYWRIGHT_VERSION: \"_MPT_PLAYWRIGHT_VERSION\",\n MPT_SETUP_FATAL_ERROR: \"_MPT_SETUP_FATAL_ERROR\",\n MPT_CLOUD_HOSTED_BROWSER_USED: \"_MPT_CLOUD_HOSTED_BROWSER_USED\",\n};\n\nexport const MINIMUM_SUPPORTED_PLAYWRIGHT_VERSION = \"1.47.0\";\n"]}
|
package/dist/tsdoc-metadata.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceClient.d.ts","sourceRoot":"","sources":["../../src/utils/serviceClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAEtE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM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EAAE,MAAM,EAAE,EACvB,kBAAkB,EAAE,cAAc,EAClC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC;IA2Bb,eAAe,CAAC,WAAW,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBzD,gBAAgB,IAAI,OAAO,CAAC,UAAU,CAAC;IAiB7C,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,mBAAmB;CAS5B"}
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5
5
|
exports.ServiceClient = void 0;
|
|
6
6
|
const constants_1 = require("../common/constants");
|
|
7
7
|
const httpService_1 = require("../common/httpService");
|
|
8
|
+
const logger_1 = require("../common/logger");
|
|
8
9
|
class ServiceClient {
|
|
9
10
|
constructor(
|
|
10
11
|
/* eslint-disable @azure/azure-sdk/ts-use-interface-parameters */
|
|
@@ -61,15 +62,19 @@ class ServiceClient {
|
|
|
61
62
|
}
|
|
62
63
|
// eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters
|
|
63
64
|
async postTestResults(testResults) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
try {
|
|
66
|
+
const payload = {
|
|
67
|
+
value: testResults,
|
|
68
|
+
};
|
|
69
|
+
const response = await this.httpService.callAPI("POST", `${this.getServiceEndpoint()}/${constants_1.Constants.testResultsEndpoint.replace("{workspaceId}", this.envVariables.accountId)}?api-version=${constants_1.Constants.API_VERSION}`, JSON.stringify(payload), this.envVariables.accessToken, "application/json", this.envVariables.correlationId);
|
|
70
|
+
if (response.status === 200) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this.handleErrorResponse(response, constants_1.Constants.postTestResults);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
logger_1.reporterLogger.error(`Error occurred while posting test results: ${error}`);
|
|
70
77
|
}
|
|
71
|
-
this.handleErrorResponse(response, constants_1.Constants.postTestResults);
|
|
72
|
-
throw new Error(`Received status ${response.status} from service from POST TestResults call.`);
|
|
73
78
|
}
|
|
74
79
|
async createStorageUri() {
|
|
75
80
|
const response = await this.httpService.callAPI("POST", `${this.getServiceEndpoint()}/${constants_1.Constants.storageUriEndpoint.replace("{workspaceId}", this.envVariables.accountId).replace("{testRunId}", this.envVariables.runId)}?api-version=${constants_1.Constants.API_VERSION}`, null, this.envVariables.accessToken, "application/json", this.envVariables.correlationId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceClient.js","sourceRoot":"","sources":["../../src/utils/serviceClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAGlC,mDAAgD;AAEhD,uDAAoD;AASpD,MAAa,aAAa;IAOxB;IACE,iEAAiE;IACjE,YAAkC,EAClC,aAA4B;IAC5B,gEAAgE;IAChE,mBAAmD,EACnD,2BAAqD,EACrD,0BAAiD;QAEjD,IAAI,CAAC,WAAW,GAAG,IAAI,yBAAW,EAAE,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,uBAAuB,GAAG,mBAAmB,CAAC;QACnD,IAAI,CAAC,2BAA2B,GAAG,2BAA2B,CAAC;QAC/D,IAAI,CAAC,0BAA0B,GAAG,0BAA0B,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,MAAc;QAC/B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;QAClE,MAAM,QAAQ,GAAqB,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAC/D,OAAO,EACP,GAAG,IAAI,CAAC,kBAAkB,EAAE,IAAI,qBAAS,CAAC,gBAAgB,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,YAAY,CAAC,SAAU,CAAC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B,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;YACvD,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,YAAY,IAAI,CAAC,CAAC;IAC5C,CAAC;CACF;AAhKD,sCAgKC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { FullResult } from \"@playwright/test/reporter\";\nimport { Constants } from \"../common/constants\";\nimport { EnvironmentVariables } from \"../common/environmentVariables\";\nimport { HttpService } from \"../common/httpService\";\nimport { Shard, UploadMetadata } from \"../model/shard\";\nimport { StorageUri } from \"../model/storageUri\";\nimport { TestResult } from \"../model/testResult\";\nimport { TestRun } from \"../model/testRun\";\nimport { CIInfo } from \"./cIInfoProvider\";\nimport ReporterUtils from \"./reporterUtils\";\nimport { PipelineResponse } from \"@azure/core-rest-pipeline\";\n\nexport class ServiceClient {\n private httpService: HttpService;\n private readonly envVariables: EnvironmentVariables;\n private readonly reporterUtils: ReporterUtils;\n private readonly addInformationalMessage: (errorMessage: string) => void;\n private isInformationMessagePresent: (key: string) => boolean;\n private addKeyToInformationMessage: (key: string) => void;\n constructor(\n /* eslint-disable @azure/azure-sdk/ts-use-interface-parameters */\n envVariables: EnvironmentVariables,\n reporterUtils: ReporterUtils,\n /* eslint-enable @azure/azure-sdk/ts-use-interface-parameters */\n addErrorInformation: (errorMessage: string) => void,\n isInformationMessagePresent: (key: string) => boolean,\n addKeyToInformationMessage: (key: string) => void,\n ) {\n this.httpService = new HttpService();\n this.envVariables = envVariables;\n this.reporterUtils = reporterUtils;\n this.addInformationalMessage = addErrorInformation;\n this.isInformationMessagePresent = isInformationMessagePresent;\n this.addKeyToInformationMessage = addKeyToInformationMessage;\n }\n\n async patchTestRun(ciInfo: CIInfo): Promise<TestRun> {\n const testRun = await this.reporterUtils.getTestRunObject(ciInfo);\n const response: PipelineResponse = await this.httpService.callAPI(\n \"PATCH\",\n `${this.getServiceEndpoint()}/${Constants.testRunsEndpoint.replace(\"{workspaceId}\", this.envVariables.accountId!)}/${this.envVariables.runId}?api-version=${Constants.API_VERSION}`,\n JSON.stringify(testRun),\n this.envVariables.accessToken,\n \"application/merge-patch+json\",\n this.envVariables.correlationId!,\n );\n if (response.status === 200) {\n return JSON.parse(response.bodyAsText!) as TestRun;\n } else if (response.status === 409) {\n const errorMessage = Constants.CONFLICT_409_ERROR_MESSAGE.replace(\n \"{runId}\",\n this.envVariables.runId,\n );\n this.addInformationalMessage(errorMessage);\n process.stdout.write(`\\n${errorMessage}`);\n } else if (response.status === 403) {\n const errorMessage = Constants.FORBIDDEN_403_ERROR_MESSAGE.replace(\n new RegExp(\"{workspaceId}\", \"g\"),\n this.envVariables.accountId!,\n );\n this.addInformationalMessage(errorMessage);\n process.stdout.write(`\\n${errorMessage}`);\n } else {\n this.handleErrorResponse(response, Constants.patchTestRun);\n }\n throw new Error(`Received status ${response.status} from service from PATCH TestRun call.`);\n }\n\n async postTestRunShardStart(): Promise<Shard> {\n const postTestRunShardObject = this.reporterUtils.getTestRunShardStartObject();\n const response: PipelineResponse = await this.httpService.callAPI(\n \"POST\",\n `${this.getServiceEndpoint()}/${Constants.testRunsShardEndpoint.replace(\"{workspaceId}\", this.envVariables.accountId!).replace(\"{testRunId}\", this.envVariables.runId)}/?api-version=${Constants.API_VERSION}`,\n JSON.stringify(postTestRunShardObject),\n this.envVariables.accessToken,\n \"application/json\",\n this.envVariables.correlationId!,\n );\n if (response.status === 200) {\n return JSON.parse(response.bodyAsText!) as Shard;\n }\n this.handleErrorResponse(response, Constants.patchTestRunShardStart);\n\n throw new Error(\n `Received status ${response.status} from service from PATCH TestRun Shard Start call.`,\n );\n }\n\n async postTestRunShardEnd(\n result: FullResult,\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n shard: Shard,\n errorMessages: string[],\n attachmentMetadata: UploadMetadata,\n workers: number,\n ): Promise<TestRun> {\n const postTestRunShardObject = this.reporterUtils.getTestRunShardEndObject(\n result,\n shard,\n errorMessages,\n attachmentMetadata,\n workers,\n );\n const response: PipelineResponse = await this.httpService.callAPI(\n \"POST\",\n `${this.getServiceEndpoint()}/${Constants.testRunsShardEndpoint.replace(\"{workspaceId}\", this.envVariables.accountId!).replace(\"{testRunId}\", this.envVariables.runId)}/?api-version=${Constants.API_VERSION}`,\n JSON.stringify(postTestRunShardObject),\n this.envVariables.accessToken,\n \"application/json\",\n this.envVariables.correlationId!,\n );\n if (response.status === 200) {\n return JSON.parse(response.bodyAsText!) as TestRun;\n }\n this.handleErrorResponse(response, Constants.patchTestRunShardEnd);\n\n throw new Error(\n `Received status ${response.status} from service from PATCH TestRun Shard End call.`,\n );\n }\n\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n async postTestResults(testResults: TestResult[]): Promise<void> {\n const payload: any = {\n value: testResults,\n };\n const response: PipelineResponse = await this.httpService.callAPI(\n \"POST\",\n `${this.getServiceEndpoint()}/${Constants.testResultsEndpoint.replace(\"{workspaceId}\", this.envVariables.accountId!)}?api-version=${Constants.API_VERSION}`,\n JSON.stringify(payload),\n this.envVariables.accessToken,\n \"application/json\",\n this.envVariables.correlationId!,\n );\n if (response.status === 200) {\n return;\n }\n this.handleErrorResponse(response, Constants.postTestResults);\n\n throw new Error(`Received status ${response.status} from service from POST TestResults call.`);\n }\n\n async createStorageUri(): Promise<StorageUri> {\n const response: PipelineResponse = await this.httpService.callAPI(\n \"POST\",\n `${this.getServiceEndpoint()}/${Constants.storageUriEndpoint.replace(\"{workspaceId}\", this.envVariables.accountId!).replace(\"{testRunId}\", this.envVariables.runId)}?api-version=${Constants.API_VERSION}`,\n null,\n this.envVariables.accessToken,\n \"application/json\",\n this.envVariables.correlationId!,\n );\n if (response.status === 200) {\n return JSON.parse(response.bodyAsText!) as StorageUri;\n }\n this.handleErrorResponse(response, Constants.getStorageUri);\n\n throw new Error(`Received status ${response.status} from service from GET StorageUri call.`);\n }\n\n private getServiceEndpoint(): string {\n return process.env[\"PLAYWRIGHT_SERVICE_REPORTING_URL\"]!;\n }\n\n private handleErrorResponse(response: PipelineResponse, action: string): void {\n const statusCode = response.status;\n const errorMessage = Constants.ERROR_MESSAGE[action]?.[statusCode] ?? \"Unknown error occured.\";\n if (!this.isInformationMessagePresent(statusCode.toString())) {\n this.addKeyToInformationMessage(statusCode.toString());\n this.addInformationalMessage(errorMessage);\n }\n process.stdout.write(`${errorMessage}\\n`);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"serviceClient.js","sourceRoot":"","sources":["../../src/utils/serviceClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAGlC,mDAAgD;AAEhD,uDAAoD;AAQpD,6CAAkD;AAElD,MAAa,aAAa;IAOxB;IACE,iEAAiE;IACjE,YAAkC,EAClC,aAA4B;IAC5B,gEAAgE;IAChE,mBAAmD,EACnD,2BAAqD,EACrD,0BAAiD;QAEjD,IAAI,CAAC,WAAW,GAAG,IAAI,yBAAW,EAAE,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,uBAAuB,GAAG,mBAAmB,CAAC;QACnD,IAAI,CAAC,2BAA2B,GAAG,2BAA2B,CAAC;QAC/D,IAAI,CAAC,0BAA0B,GAAG,0BAA0B,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,MAAc;QAC/B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;QAClE,MAAM,QAAQ,GAAqB,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAC/D,OAAO,EACP,GAAG,IAAI,CAAC,kBAAkB,EAAE,IAAI,qBAAS,CAAC,gBAAgB,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,YAAY,CAAC,SAAU,CAAC,IAAI,IAAI,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CAAC,EAAE,CAAC;YAC7D,IAAI,CAAC,0BAA0B,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;YACvD,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,YAAY,IAAI,CAAC,CAAC;IAC5C,CAAC;CACF;AAlKD,sCAkKC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { FullResult } from \"@playwright/test/reporter\";\nimport { Constants } from \"../common/constants\";\nimport { EnvironmentVariables } from \"../common/environmentVariables\";\nimport { HttpService } from \"../common/httpService\";\nimport { Shard, UploadMetadata } from \"../model/shard\";\nimport { StorageUri } from \"../model/storageUri\";\nimport { TestResult } from \"../model/testResult\";\nimport { TestRun } from \"../model/testRun\";\nimport { CIInfo } from \"./cIInfoProvider\";\nimport ReporterUtils from \"./reporterUtils\";\nimport { PipelineResponse } from \"@azure/core-rest-pipeline\";\nimport { reporterLogger } from \"../common/logger\";\n\nexport class ServiceClient {\n private httpService: HttpService;\n private readonly envVariables: EnvironmentVariables;\n private readonly reporterUtils: ReporterUtils;\n private readonly addInformationalMessage: (errorMessage: string) => void;\n private isInformationMessagePresent: (key: string) => boolean;\n private addKeyToInformationMessage: (key: string) => void;\n constructor(\n /* eslint-disable @azure/azure-sdk/ts-use-interface-parameters */\n envVariables: EnvironmentVariables,\n reporterUtils: ReporterUtils,\n /* eslint-enable @azure/azure-sdk/ts-use-interface-parameters */\n addErrorInformation: (errorMessage: string) => void,\n isInformationMessagePresent: (key: string) => boolean,\n addKeyToInformationMessage: (key: string) => void,\n ) {\n this.httpService = new HttpService();\n this.envVariables = envVariables;\n this.reporterUtils = reporterUtils;\n this.addInformationalMessage = addErrorInformation;\n this.isInformationMessagePresent = isInformationMessagePresent;\n this.addKeyToInformationMessage = addKeyToInformationMessage;\n }\n\n async patchTestRun(ciInfo: CIInfo): Promise<TestRun> {\n const testRun = await this.reporterUtils.getTestRunObject(ciInfo);\n const response: PipelineResponse = await this.httpService.callAPI(\n \"PATCH\",\n `${this.getServiceEndpoint()}/${Constants.testRunsEndpoint.replace(\"{workspaceId}\", this.envVariables.accountId!)}/${this.envVariables.runId}?api-version=${Constants.API_VERSION}`,\n JSON.stringify(testRun),\n this.envVariables.accessToken,\n \"application/merge-patch+json\",\n this.envVariables.correlationId!,\n );\n if (response.status === 200) {\n return JSON.parse(response.bodyAsText!) as TestRun;\n } else if (response.status === 409) {\n const errorMessage = Constants.CONFLICT_409_ERROR_MESSAGE.replace(\n \"{runId}\",\n this.envVariables.runId,\n );\n this.addInformationalMessage(errorMessage);\n process.stdout.write(`\\n${errorMessage}`);\n } else if (response.status === 403) {\n const errorMessage = Constants.FORBIDDEN_403_ERROR_MESSAGE.replace(\n new RegExp(\"{workspaceId}\", \"g\"),\n this.envVariables.accountId!,\n );\n this.addInformationalMessage(errorMessage);\n process.stdout.write(`\\n${errorMessage}`);\n } else {\n this.handleErrorResponse(response, Constants.patchTestRun);\n }\n throw new Error(`Received status ${response.status} from service from PATCH TestRun call.`);\n }\n\n async postTestRunShardStart(): Promise<Shard> {\n const postTestRunShardObject = this.reporterUtils.getTestRunShardStartObject();\n const response: PipelineResponse = await this.httpService.callAPI(\n \"POST\",\n `${this.getServiceEndpoint()}/${Constants.testRunsShardEndpoint.replace(\"{workspaceId}\", this.envVariables.accountId!).replace(\"{testRunId}\", this.envVariables.runId)}/?api-version=${Constants.API_VERSION}`,\n JSON.stringify(postTestRunShardObject),\n this.envVariables.accessToken,\n \"application/json\",\n this.envVariables.correlationId!,\n );\n if (response.status === 200) {\n return JSON.parse(response.bodyAsText!) as Shard;\n }\n this.handleErrorResponse(response, Constants.patchTestRunShardStart);\n\n throw new Error(\n `Received status ${response.status} from service from PATCH TestRun Shard Start call.`,\n );\n }\n\n async postTestRunShardEnd(\n result: FullResult,\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n shard: Shard,\n errorMessages: string[],\n attachmentMetadata: UploadMetadata,\n workers: number,\n ): Promise<TestRun> {\n const postTestRunShardObject = this.reporterUtils.getTestRunShardEndObject(\n result,\n shard,\n errorMessages,\n attachmentMetadata,\n workers,\n );\n const response: PipelineResponse = await this.httpService.callAPI(\n \"POST\",\n `${this.getServiceEndpoint()}/${Constants.testRunsShardEndpoint.replace(\"{workspaceId}\", this.envVariables.accountId!).replace(\"{testRunId}\", this.envVariables.runId)}/?api-version=${Constants.API_VERSION}`,\n JSON.stringify(postTestRunShardObject),\n this.envVariables.accessToken,\n \"application/json\",\n this.envVariables.correlationId!,\n );\n if (response.status === 200) {\n return JSON.parse(response.bodyAsText!) as TestRun;\n }\n this.handleErrorResponse(response, Constants.patchTestRunShardEnd);\n\n throw new Error(\n `Received status ${response.status} from service from PATCH TestRun Shard End call.`,\n );\n }\n\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n async postTestResults(testResults: TestResult[]): Promise<void> {\n try {\n const payload: any = {\n value: testResults,\n };\n const response: PipelineResponse = await this.httpService.callAPI(\n \"POST\",\n `${this.getServiceEndpoint()}/${Constants.testResultsEndpoint.replace(\"{workspaceId}\", this.envVariables.accountId!)}?api-version=${Constants.API_VERSION}`,\n JSON.stringify(payload),\n this.envVariables.accessToken,\n \"application/json\",\n this.envVariables.correlationId!,\n );\n if (response.status === 200) {\n return;\n }\n this.handleErrorResponse(response, Constants.postTestResults);\n } catch (error) {\n reporterLogger.error(`Error occurred while posting test results: ${error}`);\n }\n }\n\n async createStorageUri(): Promise<StorageUri> {\n const response: PipelineResponse = await this.httpService.callAPI(\n \"POST\",\n `${this.getServiceEndpoint()}/${Constants.storageUriEndpoint.replace(\"{workspaceId}\", this.envVariables.accountId!).replace(\"{testRunId}\", this.envVariables.runId)}?api-version=${Constants.API_VERSION}`,\n null,\n this.envVariables.accessToken,\n \"application/json\",\n this.envVariables.correlationId!,\n );\n if (response.status === 200) {\n return JSON.parse(response.bodyAsText!) as StorageUri;\n }\n this.handleErrorResponse(response, Constants.getStorageUri);\n\n throw new Error(`Received status ${response.status} from service from GET StorageUri call.`);\n }\n\n private getServiceEndpoint(): string {\n return process.env[\"PLAYWRIGHT_SERVICE_REPORTING_URL\"]!;\n }\n\n private handleErrorResponse(response: PipelineResponse, action: string): void {\n const statusCode = response.status;\n const errorMessage = Constants.ERROR_MESSAGE[action]?.[statusCode] ?? \"Unknown error occured.\";\n if (!this.isInformationMessagePresent(statusCode.toString())) {\n this.addKeyToInformationMessage(statusCode.toString());\n this.addInformationalMessage(errorMessage);\n }\n process.stdout.write(`${errorMessage}\\n`);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure/microsoft-playwright-testing",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.20240917.1",
|
|
4
4
|
"description": "Package to integrate your Playwright test suite with Microsoft Playwright Testing service",
|
|
5
5
|
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/playwrighttesting/microsoft-playwright-testing/README.md",
|
|
6
6
|
"sdk-type": "client",
|