@azure/playwright 1.0.0-beta.2 → 1.0.0-beta.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/messages.d.ts +4 -0
- package/dist/browser/common/messages.d.ts.map +1 -1
- package/dist/browser/common/messages.js +4 -0
- package/dist/browser/common/messages.js.map +1 -1
- package/dist/browser/common/playwrightServiceConfig.d.ts.map +1 -1
- package/dist/browser/common/playwrightServiceConfig.js.map +1 -1
- package/dist/browser/common/types.d.ts +0 -8
- 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 +23 -8
- package/dist/browser/core/playwrightService.js.map +1 -1
- package/dist/browser/core/playwrightServiceUtils.d.ts.map +1 -1
- package/dist/browser/core/playwrightServiceUtils.js +7 -2
- package/dist/browser/core/playwrightServiceUtils.js.map +1 -1
- package/dist/browser/utils/getPackageVersion.d.ts +2 -0
- package/dist/browser/utils/getPackageVersion.d.ts.map +1 -0
- package/dist/browser/utils/getPackageVersion.js +23 -0
- package/dist/browser/utils/getPackageVersion.js.map +1 -0
- package/dist/browser/utils/utils.d.ts +6 -1
- package/dist/browser/utils/utils.d.ts.map +1 -1
- package/dist/browser/utils/utils.js +30 -29
- package/dist/browser/utils/utils.js.map +1 -1
- package/dist/commonjs/common/messages.d.ts +4 -0
- package/dist/commonjs/common/messages.d.ts.map +1 -1
- package/dist/commonjs/common/messages.js +4 -0
- package/dist/commonjs/common/messages.js.map +1 -1
- package/dist/commonjs/common/playwrightServiceConfig.d.ts.map +1 -1
- package/dist/commonjs/common/playwrightServiceConfig.js.map +1 -1
- package/dist/commonjs/common/types.d.ts +0 -8
- package/dist/commonjs/common/types.d.ts.map +1 -1
- package/dist/commonjs/common/types.js.map +1 -1
- package/dist/commonjs/core/playwrightService.d.ts.map +1 -1
- package/dist/commonjs/core/playwrightService.js +22 -7
- package/dist/commonjs/core/playwrightService.js.map +1 -1
- package/dist/commonjs/core/playwrightServiceUtils-cjs.cjs.map +1 -0
- package/dist/commonjs/core/playwrightServiceUtils-cjs.d.cts.map +1 -0
- package/dist/commonjs/core/playwrightServiceUtils.d.ts +1 -1
- package/dist/commonjs/core/playwrightServiceUtils.js +1 -1
- package/dist/commonjs/utils/getPackageVersion-cjs.cjs.map +1 -0
- package/dist/commonjs/utils/getPackageVersion-cjs.d.cts.map +1 -0
- package/dist/commonjs/utils/getPackageVersion.d.ts +2 -0
- package/dist/commonjs/utils/getPackageVersion.js +21 -0
- package/dist/commonjs/utils/utils.d.ts +6 -1
- package/dist/commonjs/utils/utils.d.ts.map +1 -1
- package/dist/commonjs/utils/utils.js +33 -31
- package/dist/commonjs/utils/utils.js.map +1 -1
- package/dist/esm/common/messages.d.ts +4 -0
- package/dist/esm/common/messages.d.ts.map +1 -1
- package/dist/esm/common/messages.js +4 -0
- package/dist/esm/common/messages.js.map +1 -1
- package/dist/esm/common/playwrightServiceConfig.d.ts.map +1 -1
- package/dist/esm/common/playwrightServiceConfig.js.map +1 -1
- package/dist/esm/common/types.d.ts +0 -8
- package/dist/esm/common/types.d.ts.map +1 -1
- package/dist/esm/common/types.js.map +1 -1
- package/dist/esm/core/playwrightService.d.ts.map +1 -1
- package/dist/esm/core/playwrightService.js +23 -8
- package/dist/esm/core/playwrightService.js.map +1 -1
- package/dist/esm/core/playwrightServiceUtils.d.ts.map +1 -1
- package/dist/esm/core/playwrightServiceUtils.js +7 -2
- package/dist/esm/core/playwrightServiceUtils.js.map +1 -1
- package/dist/esm/utils/getPackageVersion.d.ts +2 -0
- package/dist/esm/utils/getPackageVersion.d.ts.map +1 -0
- package/dist/esm/utils/getPackageVersion.js +23 -0
- package/dist/esm/utils/getPackageVersion.js.map +1 -0
- package/dist/esm/utils/utils.d.ts +6 -1
- package/dist/esm/utils/utils.d.ts.map +1 -1
- package/dist/esm/utils/utils.js +30 -29
- package/dist/esm/utils/utils.js.map +1 -1
- package/dist/react-native/common/messages.d.ts +4 -0
- package/dist/react-native/common/messages.d.ts.map +1 -1
- package/dist/react-native/common/messages.js +4 -0
- package/dist/react-native/common/messages.js.map +1 -1
- package/dist/react-native/common/playwrightServiceConfig.d.ts.map +1 -1
- package/dist/react-native/common/playwrightServiceConfig.js.map +1 -1
- package/dist/react-native/common/types.d.ts +0 -8
- 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 +23 -8
- package/dist/react-native/core/playwrightService.js.map +1 -1
- package/dist/react-native/core/playwrightServiceUtils.d.ts.map +1 -1
- package/dist/react-native/core/playwrightServiceUtils.js +7 -2
- package/dist/react-native/core/playwrightServiceUtils.js.map +1 -1
- package/dist/react-native/utils/getPackageVersion.d.ts +2 -0
- package/dist/react-native/utils/getPackageVersion.d.ts.map +1 -0
- package/dist/react-native/utils/getPackageVersion.js +23 -0
- package/dist/react-native/utils/getPackageVersion.js.map +1 -0
- package/dist/react-native/utils/utils.d.ts +6 -1
- package/dist/react-native/utils/utils.d.ts.map +1 -1
- package/dist/react-native/utils/utils.js +30 -29
- package/dist/react-native/utils/utils.js.map +1 -1
- package/package.json +31 -31
- package/dist/commonjs/core/playwrightServiceUtils.d.ts.map +0 -1
- package/dist/commonjs/core/playwrightServiceUtils.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/common/messages.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+CA+CE,MAAM,KAAG,MAAM
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/common/messages.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+CA+CE,MAAM,KAAG,MAAM;;;;;;;;;;;;;;CAezD,CAAC"}
|
|
@@ -50,5 +50,9 @@ export const ServiceErrorMessageConstants = {
|
|
|
50
50
|
key: "InvalidRunIdFormat",
|
|
51
51
|
message: "The Run ID must be a valid GUID format. Please provide a valid GUID for the Run ID.",
|
|
52
52
|
},
|
|
53
|
+
INVALID_AUTH_TYPE_ERROR: {
|
|
54
|
+
key: "InvalidAuthTypeError",
|
|
55
|
+
message: "Invalid authentication type specified. Please use either ENTRA_ID or ACCESS_TOKEN.",
|
|
56
|
+
},
|
|
53
57
|
};
|
|
54
58
|
//# sourceMappingURL=messages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/common/messages.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,oBAAoB,EAAE;QACpB,GAAG,EAAE,mBAAmB;QACxB,OAAO,EACL,8GAA8G;KACjH;IACD,uBAAuB,EAAE;QACvB,GAAG,EAAE,uBAAuB;QAC5B,OAAO,EAAE,qCAAqC;KAC/C;IACD,gCAAgC,EAAE;QAChC,GAAG,EAAE,+BAA+B;QACpC,OAAO,EACL,0IAA0I;KAC7I;IACD,4CAA4C,EAAE;QAC5C,GAAG,EAAE,yCAAyC;QAC9C,OAAO,EACL,4IAA4I;KAC/I;IACD,wBAAwB,EAAE;QACxB,GAAG,EAAE,oBAAoB;QACzB,OAAO,EACL,mHAAmH;KACtH;IACD,aAAa,EAAE;QACb,GAAG,EAAE,aAAa;QAClB,OAAO,EACL,uHAAuH;KAC1H;IACD,qBAAqB,EAAE;QACrB,GAAG,EAAE,oBAAoB;QACzB,OAAO,EAAE,8EAA8E;KACxF;IACD,qBAAqB,EAAE;QACrB,GAAG,EAAE,oBAAoB;QACzB,OAAO,EAAE,4DAA4D;KACtE;IACD,wBAAwB,EAAE;QACxB,GAAG,EAAE,sBAAsB;QAC3B,OAAO,EACL,8IAA8I;KACjJ;IACD,yBAAyB,EAAE;QACzB,GAAG,EAAE,uBAAuB;QAC5B,OAAO,EACL,wIAAwI;QAC1I,sBAAsB,EAAE,CAAC,YAAoB,EAAU,EAAE,CACvD,mEAAmE,YAAY,iFAAiF;KACnK;IACD,iCAAiC,EAAE;QACjC,GAAG,EAAE,+BAA+B;QACpC,OAAO,EAAE,sJAAsJ;KAChK;IACD,qBAAqB,EAAE;QACrB,GAAG,EAAE,oBAAoB;QACzB,OAAO,EAAE,qFAAqF;KAC/F;CACF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport const ServiceErrorMessageConstants = {\n NO_SERVICE_URL_ERROR: {\n key: \"NoServiceUrlError\",\n message:\n \"The value for the PLAYWRIGHT_SERVICE_URL variable is not set correctly. Please verify the URL and try again.\",\n },\n INVALID_GLOBAL_FUNCTION: {\n key: \"InvalidGlobalFunction\",\n message: \"File must export a single function.\",\n },\n INVALID_PLAYWRIGHT_VERSION_ERROR: {\n key: \"InvalidPlaywrightVersionError\",\n message:\n \"The Playwright version you are using is not supported. See the list of supported versions at https://aka.ms/pww/docs/supported-versions.\",\n },\n MULTIPLE_SETUP_FILE_PLAYWRIGHT_VERSION_ERROR: {\n key: \"MultipleSetupFilePlaywrightVersionError\",\n message:\n \"The Playwright version you are using does not support multiple setup/teardown files. Please update to Playwright version 1.49.0 or higher.\",\n },\n WORKSPACE_MISMATCH_ERROR: {\n key: \"InvalidAccessToken\",\n message:\n \"The provided access token does not match the specified workspace URL. Please verify that both values are correct.\",\n },\n NO_AUTH_ERROR: {\n key: \"NoAuthError\",\n message:\n \"Could not authenticate with the service. Please refer to https://aka.ms/pww/docs/authentication for more information.\",\n },\n INVALID_MPT_PAT_ERROR: {\n key: \"InvalidMptPatError\",\n message: \"The authentication token provided is invalid. Check the token and try again.\",\n },\n EXPIRED_MPT_PAT_ERROR: {\n key: \"ExpiredMptPatError\",\n message: \"Your authentication token has expired. Create a new token.\",\n },\n NO_CRED_ENTRA_AUTH_ERROR: {\n key: \"NoCredEntraAuthError\",\n message:\n \"Azure credentials not found when using Entra ID authentication. Please refer to https://aka.ms/pww/docs/authentication for more information.\",\n },\n FAILED_TO_CREATE_TEST_RUN: {\n key: \"FailedToCreateTestRun\",\n message:\n \"Failed to create the test run in the Playwright service. Please refer to https://aka.ms/pww/docs/troubleshooting for more information.\",\n formatWithErrorDetails: (errorDetails: string): string =>\n `Failed to create the test run in the Playwright service. Error: ${errorDetails}. Please refer to https://aka.ms/pww/docs/troubleshooting for more information.`,\n },\n INVALID_PARAM_WITH_SERVICE_CONFIG: {\n key: \"InvalidParamWithServiceConfig\",\n message: `Remove serviceAuth, runId, and runName from getConnectOptions when using getServiceConfig. Configure these options through getServiceConfig instead.`,\n },\n INVALID_RUN_ID_FORMAT: {\n key: \"InvalidRunIdFormat\",\n message: \"The Run ID must be a valid GUID format. Please provide a valid GUID for the Run ID.\",\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/common/messages.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,oBAAoB,EAAE;QACpB,GAAG,EAAE,mBAAmB;QACxB,OAAO,EACL,8GAA8G;KACjH;IACD,uBAAuB,EAAE;QACvB,GAAG,EAAE,uBAAuB;QAC5B,OAAO,EAAE,qCAAqC;KAC/C;IACD,gCAAgC,EAAE;QAChC,GAAG,EAAE,+BAA+B;QACpC,OAAO,EACL,0IAA0I;KAC7I;IACD,4CAA4C,EAAE;QAC5C,GAAG,EAAE,yCAAyC;QAC9C,OAAO,EACL,4IAA4I;KAC/I;IACD,wBAAwB,EAAE;QACxB,GAAG,EAAE,oBAAoB;QACzB,OAAO,EACL,mHAAmH;KACtH;IACD,aAAa,EAAE;QACb,GAAG,EAAE,aAAa;QAClB,OAAO,EACL,uHAAuH;KAC1H;IACD,qBAAqB,EAAE;QACrB,GAAG,EAAE,oBAAoB;QACzB,OAAO,EAAE,8EAA8E;KACxF;IACD,qBAAqB,EAAE;QACrB,GAAG,EAAE,oBAAoB;QACzB,OAAO,EAAE,4DAA4D;KACtE;IACD,wBAAwB,EAAE;QACxB,GAAG,EAAE,sBAAsB;QAC3B,OAAO,EACL,8IAA8I;KACjJ;IACD,yBAAyB,EAAE;QACzB,GAAG,EAAE,uBAAuB;QAC5B,OAAO,EACL,wIAAwI;QAC1I,sBAAsB,EAAE,CAAC,YAAoB,EAAU,EAAE,CACvD,mEAAmE,YAAY,iFAAiF;KACnK;IACD,iCAAiC,EAAE;QACjC,GAAG,EAAE,+BAA+B;QACpC,OAAO,EAAE,sJAAsJ;KAChK;IACD,qBAAqB,EAAE;QACrB,GAAG,EAAE,oBAAoB;QACzB,OAAO,EAAE,qFAAqF;KAC/F;IACD,uBAAuB,EAAE;QACvB,GAAG,EAAE,sBAAsB;QAC3B,OAAO,EAAE,oFAAoF;KAC9F;CACF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport const ServiceErrorMessageConstants = {\n NO_SERVICE_URL_ERROR: {\n key: \"NoServiceUrlError\",\n message:\n \"The value for the PLAYWRIGHT_SERVICE_URL variable is not set correctly. Please verify the URL and try again.\",\n },\n INVALID_GLOBAL_FUNCTION: {\n key: \"InvalidGlobalFunction\",\n message: \"File must export a single function.\",\n },\n INVALID_PLAYWRIGHT_VERSION_ERROR: {\n key: \"InvalidPlaywrightVersionError\",\n message:\n \"The Playwright version you are using is not supported. See the list of supported versions at https://aka.ms/pww/docs/supported-versions.\",\n },\n MULTIPLE_SETUP_FILE_PLAYWRIGHT_VERSION_ERROR: {\n key: \"MultipleSetupFilePlaywrightVersionError\",\n message:\n \"The Playwright version you are using does not support multiple setup/teardown files. Please update to Playwright version 1.49.0 or higher.\",\n },\n WORKSPACE_MISMATCH_ERROR: {\n key: \"InvalidAccessToken\",\n message:\n \"The provided access token does not match the specified workspace URL. Please verify that both values are correct.\",\n },\n NO_AUTH_ERROR: {\n key: \"NoAuthError\",\n message:\n \"Could not authenticate with the service. Please refer to https://aka.ms/pww/docs/authentication for more information.\",\n },\n INVALID_MPT_PAT_ERROR: {\n key: \"InvalidMptPatError\",\n message: \"The authentication token provided is invalid. Check the token and try again.\",\n },\n EXPIRED_MPT_PAT_ERROR: {\n key: \"ExpiredMptPatError\",\n message: \"Your authentication token has expired. Create a new token.\",\n },\n NO_CRED_ENTRA_AUTH_ERROR: {\n key: \"NoCredEntraAuthError\",\n message:\n \"Azure credentials not found when using Entra ID authentication. Please refer to https://aka.ms/pww/docs/authentication for more information.\",\n },\n FAILED_TO_CREATE_TEST_RUN: {\n key: \"FailedToCreateTestRun\",\n message:\n \"Failed to create the test run in the Playwright service. Please refer to https://aka.ms/pww/docs/troubleshooting for more information.\",\n formatWithErrorDetails: (errorDetails: string): string =>\n `Failed to create the test run in the Playwright service. Error: ${errorDetails}. Please refer to https://aka.ms/pww/docs/troubleshooting for more information.`,\n },\n INVALID_PARAM_WITH_SERVICE_CONFIG: {\n key: \"InvalidParamWithServiceConfig\",\n message: `Remove serviceAuth, runId, and runName from getConnectOptions when using getServiceConfig. Configure these options through getServiceConfig instead.`,\n },\n INVALID_RUN_ID_FORMAT: {\n key: \"InvalidRunIdFormat\",\n message: \"The Run ID must be a valid GUID format. Please provide a valid GUID for the Run ID.\",\n },\n INVALID_AUTH_TYPE_ERROR: {\n key: \"InvalidAuthTypeError\",\n message: \"Invalid authentication type specified. Please use either ENTRA_ID or ACCESS_TOKEN.\",\n },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playwrightServiceConfig.d.ts","sourceRoot":"","sources":["../../../src/common/playwrightServiceConfig.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAM7E,cAAM,uBAAuB;IACpB,SAAS,EAAE,MAAM,CA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YAC5B,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;QAC5E,CAAC;QACD,IAAI,OAAO,EAAE,MAAM,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC/B,CAAC;QACD,IAAI,OAAO,EAAE,OAAO,EAAE,CAAC;YACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QACjC,CAAC;IACH,CAAC,CAAC;CACH;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n Constants,\n DefaultConnectOptionsConstants,\n InternalEnvironmentVariables,\n ServiceAuth,\n} from \"./constants.js\";\nimport type { PlaywrightServiceAdditionalOptions, OsType } from \"./types.js\";\nimport { getAndSetRunId, getRunName, ValidateRunID } from \"../utils/utils.js\";\nimport { CIInfoProvider } from \"../utils/cIInfoProvider.js\";\nimport { state } from \"./state.js\";\nimport { ServiceErrorMessageConstants } from \"./messages.js\";\n\nclass PlaywrightServiceConfig {\n public serviceOs: OsType;\n public runId: string;\n public timeout: number;\n public slowMo: number;\n public exposeNetwork: string;\n public runName: string;\n public apiVersion: string;\n private _serviceAuthType: string = ServiceAuth.ENTRA_ID;\n\n constructor() {\n this.serviceOs = (process.env[InternalEnvironmentVariables.MPT_SERVICE_OS] ||\n DefaultConnectOptionsConstants.DEFAULT_SERVICE_OS) as OsType;\n this.runName = process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_NAME] || \"\";\n this.runId = process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_ID] || \"\";\n this.timeout = DefaultConnectOptionsConstants.DEFAULT_TIMEOUT;\n this.slowMo = DefaultConnectOptionsConstants.DEFAULT_SLOW_MO;\n this.exposeNetwork = DefaultConnectOptionsConstants.DEFAULT_EXPOSE_NETWORK;\n this.apiVersion =\n process.env[InternalEnvironmentVariables.MPT_API_VERSION] || Constants.LatestAPIVersion;\n }\n\n public static get instance(): PlaywrightServiceConfig {\n if (!state.playwrightServiceConfig) {\n state.playwrightServiceConfig = new PlaywrightServiceConfig();\n }\n return state.playwrightServiceConfig;\n }\n\n public get serviceAuthType(): string {\n return this._serviceAuthType;\n }\n\n public set serviceAuthType(value: string) {\n this._serviceAuthType = value;\n }\n\n public async initialize(): Promise<void> {\n if (!this.runName) {\n const ciConfigInfo = CIInfoProvider.getCIInfo();\n this.runName = await getRunName(ciConfigInfo);\n }\n }\n\n validateOptions = (options?: PlaywrightServiceAdditionalOptions): void => {\n if (!options) return;\n\n const isUsingServiceConfig =\n process.env[InternalEnvironmentVariables.USING_SERVICE_CONFIG] === \"true\";\n if (isUsingServiceConfig) {\n if (options.serviceAuthType || options.runId || options.runName) {\n const errorMessage = ServiceErrorMessageConstants.INVALID_PARAM_WITH_SERVICE_CONFIG.message;\n throw new Error(errorMessage);\n }\n return;\n }\n };\n\n setOptions = (\n options?: PlaywrightServiceAdditionalOptions,\n isGetConnectOptions: boolean = false,\n ): void => {\n if (isGetConnectOptions) {\n this.validateOptions(options);\n }\n\n if (options?.exposeNetwork) {\n this.exposeNetwork = options.exposeNetwork;\n }\n if (options?.apiVersion) {\n if (!process.env[InternalEnvironmentVariables.MPT_API_VERSION]) {\n process.env[InternalEnvironmentVariables.MPT_API_VERSION] = options.apiVersion;\n }\n this.apiVersion = options.apiVersion;\n }\n if (!process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_ID]) {\n if (options?.runId) {\n ValidateRunID(options.runId);\n this.runId = options.runId;\n process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_ID] = this.runId;\n } else {\n this.runId = getAndSetRunId();\n }\n }\n if (!process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_NAME] && options?.runName) {\n this.runName = options.runName;\n process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_NAME] = this.runName;\n }\n if (options?.os) {\n this.serviceOs = options.os;\n process.env[InternalEnvironmentVariables.MPT_SERVICE_OS] = this.serviceOs;\n }\n if (options?.slowMo) {\n this.slowMo = options.slowMo;\n }\n if (options?.timeout) {\n this.timeout = options.timeout;\n }\n };\n}\n\nexport { PlaywrightServiceConfig };\n"]}
|
|
@@ -97,14 +97,6 @@ export type PlaywrightServiceAdditionalOptions = {
|
|
|
97
97
|
* @defaultValue `<loopback>`
|
|
98
98
|
*/
|
|
99
99
|
exposeNetwork?: string;
|
|
100
|
-
/**
|
|
101
|
-
* @public
|
|
102
|
-
*
|
|
103
|
-
* Use cloud hosted browsers.
|
|
104
|
-
*
|
|
105
|
-
* @defaultValue `false`
|
|
106
|
-
*/
|
|
107
|
-
useCloudHostedBrowsers?: boolean;
|
|
108
100
|
/**
|
|
109
101
|
* @public
|
|
110
102
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/common/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAIpD;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,qBAAqB,GAAG,eAAe,GAAG;IACpD,OAAO,EAAE,cAAc,CAAC;CACzB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,kBAAkB,CAAC;IAErC;;;;;;OAMG;IACH,EAAE,CAAC,EAAE,MAAM,CA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CACrB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/common/types.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ConnectOptions } from \"@playwright/test\";\nimport type { ServiceAuth, ServiceOS, SDKLanguage } from \"./constants.js\";\nimport type { TokenCredential } from \"@azure/identity\";\nimport { CIInfo } from \"../utils/cIInfoProvider.js\";\n\n// Public APIs\n\n/**\n * @public\n *\n * Endpoint options for the service.\n */\nexport type EndpointOptions = {\n /**\n * @public\n *\n * A browser websocket endpoint to connect to.\n */\n wsEndpoint: string;\n};\n\n/**\n * @public\n *\n * Browser connect options for the service. This includes endpoint options and connect options.\n *\n * @example\n * ```\n * import playwright, { test, expect, BrowserType } from \"@playwright/test\";\n * import { getConnectOptions, BrowserConnectOptions } from \"@azure/playwright\";\n *\n * test(\"has title\", async ({ browserName }) => {\n * const { wsEndpoint, options } : BrowserConnectOptions = await getConnectOptions();\n * const browser = await (playwright[browserName] as BrowserType).connect(wsEndpoint, options);\n * const context = await browser.newContext();\n * const page = await context.newPage();\n *\n * await page.goto(\"https://playwright.dev/\");\n * await expect(page).toHaveTitle(/Playwright/);\n *\n * await page.close();\n * await context.close();\n * await browser.close();\n * });\n * ```\n */\nexport type BrowserConnectOptions = EndpointOptions & {\n options: ConnectOptions;\n};\n\n/**\n * @public\n *\n * Additional options for the service.\n */\nexport type PlaywrightServiceAdditionalOptions = {\n /**\n * @public\n *\n * Authentication types supported by Azure Playwright.\n *\n * @defaultValue `ENTRA_ID`\n */\n serviceAuthType?: AuthenticationType;\n\n /**\n * @public\n *\n * Operating system types supported by Azure Playwright.\n *\n * @defaultValue `linux`\n */\n os?: OsType;\n\n /**\n * @public\n *\n * Run id for the test run.\n *\n * @defaultValue `current datetime as ISO string`\n */\n runId?: string;\n\n /**\n * @public\n *\n * Maximum time in milliseconds to wait for the connection to be established.\n *\n * @defaultValue `30000`\n */\n timeout?: number;\n\n /**\n * @public\n *\n * Slows down Playwright operations by the specified amount of milliseconds.\n *\n * @defaultValue `0`\n */\n slowMo?: number;\n\n /**\n * @public\n *\n * Exposes network available on the connecting client to the browser being connected to.\n *\n * @defaultValue `<loopback>`\n */\n exposeNetwork?: string;\n\n /**\n * @public\n *\n *
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/common/types.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ConnectOptions } from \"@playwright/test\";\nimport type { ServiceAuth, ServiceOS, SDKLanguage } from \"./constants.js\";\nimport type { TokenCredential } from \"@azure/identity\";\nimport { CIInfo } from \"../utils/cIInfoProvider.js\";\n\n// Public APIs\n\n/**\n * @public\n *\n * Endpoint options for the service.\n */\nexport type EndpointOptions = {\n /**\n * @public\n *\n * A browser websocket endpoint to connect to.\n */\n wsEndpoint: string;\n};\n\n/**\n * @public\n *\n * Browser connect options for the service. This includes endpoint options and connect options.\n *\n * @example\n * ```\n * import playwright, { test, expect, BrowserType } from \"@playwright/test\";\n * import { getConnectOptions, BrowserConnectOptions } from \"@azure/playwright\";\n *\n * test(\"has title\", async ({ browserName }) => {\n * const { wsEndpoint, options } : BrowserConnectOptions = await getConnectOptions();\n * const browser = await (playwright[browserName] as BrowserType).connect(wsEndpoint, options);\n * const context = await browser.newContext();\n * const page = await context.newPage();\n *\n * await page.goto(\"https://playwright.dev/\");\n * await expect(page).toHaveTitle(/Playwright/);\n *\n * await page.close();\n * await context.close();\n * await browser.close();\n * });\n * ```\n */\nexport type BrowserConnectOptions = EndpointOptions & {\n options: ConnectOptions;\n};\n\n/**\n * @public\n *\n * Additional options for the service.\n */\nexport type PlaywrightServiceAdditionalOptions = {\n /**\n * @public\n *\n * Authentication types supported by Azure Playwright.\n *\n * @defaultValue `ENTRA_ID`\n */\n serviceAuthType?: AuthenticationType;\n\n /**\n * @public\n *\n * Operating system types supported by Azure Playwright.\n *\n * @defaultValue `linux`\n */\n os?: OsType;\n\n /**\n * @public\n *\n * Run id for the test run.\n *\n * @defaultValue `current datetime as ISO string`\n */\n runId?: string;\n\n /**\n * @public\n *\n * Maximum time in milliseconds to wait for the connection to be established.\n *\n * @defaultValue `30000`\n */\n timeout?: number;\n\n /**\n * @public\n *\n * Slows down Playwright operations by the specified amount of milliseconds.\n *\n * @defaultValue `0`\n */\n slowMo?: number;\n\n /**\n * @public\n *\n * Exposes network available on the connecting client to the browser being connected to.\n *\n * @defaultValue `<loopback>`\n */\n exposeNetwork?: string;\n\n /**\n * @public\n *\n * Custom token credential for Entra ID authentication. Learn more at {@link https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/using-azure-identity.md | Using Azure Identity}.\n *\n * @defaultValue `DefaultAzureCredential`\n */\n credential?: TokenCredential;\n /**\n * @public\n *\n * Run name for the test run.\n *\n * @defaultValue `guid`\n */\n runName?: string;\n\n /**\n * @public\n *\n * API Version\n *\n * @defaultValue `2025-07-01-preview`\n */\n apiVersion?: \"2025-07-01-preview\";\n};\n\n/**\n * @public\n *\n * OS Types supported by Azure Playwright.\n */\nexport type OsType = (typeof ServiceOS)[keyof typeof ServiceOS];\n\n/**\n * @public\n *\n * Authentication types supported by Azure Playwright.\n */\nexport type AuthenticationType = (typeof ServiceAuth)[keyof typeof ServiceAuth];\n\n// Internal APIs\n\nexport type JwtPayload = {\n iss?: string;\n sub?: string;\n aud?: string[] | string;\n exp?: number;\n nbf?: number;\n iat?: number;\n jti?: string;\n};\n\nexport type AccessTokenClaims = JwtPayload & {\n pwid?: string;\n};\n\nexport type VersionInfo = {\n major: number;\n minor: number;\n patch: number;\n};\n\nexport type PackageManager = {\n runCommand: (command: string, args: string) => string;\n getVersionFromStdout: (stdout: string) => string;\n};\n\nexport type RunConfig = {\n framework?: RunFramework;\n sdkLanguage?: (typeof SDKLanguage)[keyof typeof SDKLanguage];\n maxWorkers?: number;\n};\n\nexport type RunFramework = {\n name?: string;\n version?: string;\n runnerName?: string;\n};\n\nexport type TestRunCreatePayload = {\n displayName: string;\n config?: RunConfig;\n ciConfig?: CIInfo;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playwrightService.d.ts","sourceRoot":"","sources":["../../../src/core/playwrightService.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,kCAAkC,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"playwrightService.d.ts","sourceRoot":"","sources":["../../../src/core/playwrightService.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,kCAAkC,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAgBpG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAa7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,QAAA,MAAM,gBAAgB,GACpB,QAAQ,oBAAoB,EAC5B,UAAU,kCAAkC,KAC3C,oBA6GF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,QAAA,MAAM,iBAAiB,GACrB,UAAU,kCAAkC,KAC3C,OAAO,CAAC,qBAAqB,CA0C/B,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { DefaultConnectOptionsConstants, InternalEnvironmentVariables, ServiceAu
|
|
|
4
4
|
import customerConfig from "../common/customerConfig.js";
|
|
5
5
|
import { PlaywrightServiceConfig } from "../common/playwrightServiceConfig.js";
|
|
6
6
|
import playwrightServiceEntra from "./playwrightServiceEntra.js";
|
|
7
|
-
import { fetchOrValidateAccessToken, getAccessToken, getServiceWSEndpoint, validateMptPAT,
|
|
7
|
+
import { fetchOrValidateAccessToken, getAccessToken, getServiceWSEndpoint, validateMptPAT, validatePlaywrightVersion, validateServiceUrl, exitWithFailureMessage, getPlaywrightVersion, getVersionInfo, throwErrorWithFailureMessage, getPackageVersion, warnIfAccessTokenCloseToExpiry, } from "../utils/utils.js";
|
|
8
8
|
import { ServiceErrorMessageConstants } from "../common/messages.js";
|
|
9
9
|
import { globalPaths } from "./playwrightServiceUtils.js";
|
|
10
10
|
const performOneTimeOperation = (options) => {
|
|
@@ -122,11 +122,6 @@ const getServiceConfig = (config, options) => {
|
|
|
122
122
|
globalFunctions.globalTeardown = globalPaths.teardown;
|
|
123
123
|
}
|
|
124
124
|
performOneTimeOperation(options);
|
|
125
|
-
if (options?.useCloudHostedBrowsers === false) {
|
|
126
|
-
return {
|
|
127
|
-
...globalFunctions,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
125
|
if (!process.env[InternalEnvironmentVariables.MPT_CLOUD_HOSTED_BROWSER_USED]) {
|
|
131
126
|
process.env[InternalEnvironmentVariables.MPT_CLOUD_HOSTED_BROWSER_USED] = "true";
|
|
132
127
|
console.log("\nRunning tests using Azure Playwright service.");
|
|
@@ -176,9 +171,29 @@ const getServiceConfig = (config, options) => {
|
|
|
176
171
|
* ```
|
|
177
172
|
*/
|
|
178
173
|
const getConnectOptions = async (options) => {
|
|
179
|
-
const playwrightServiceConfig =
|
|
174
|
+
const playwrightServiceConfig = PlaywrightServiceConfig.instance;
|
|
180
175
|
playwrightServiceConfig.setOptions(options, true);
|
|
181
|
-
|
|
176
|
+
performOneTimeOperation(options);
|
|
177
|
+
playwrightServiceConfig.serviceAuthType =
|
|
178
|
+
options?.serviceAuthType || DefaultConnectOptionsConstants.DEFAULT_SERVICE_AUTH_TYPE;
|
|
179
|
+
let token;
|
|
180
|
+
if (playwrightServiceConfig.serviceAuthType === ServiceAuth.ENTRA_ID) {
|
|
181
|
+
if (!options?.credential) {
|
|
182
|
+
throw new Error(ServiceErrorMessageConstants.NO_CRED_ENTRA_AUTH_ERROR.message);
|
|
183
|
+
}
|
|
184
|
+
playwrightServiceEntra.entraIdAccessToken = options.credential;
|
|
185
|
+
token = await fetchOrValidateAccessToken(options.credential);
|
|
186
|
+
}
|
|
187
|
+
else if (playwrightServiceConfig.serviceAuthType === ServiceAuth.ACCESS_TOKEN) {
|
|
188
|
+
validateMptPAT(throwErrorWithFailureMessage);
|
|
189
|
+
token = getAccessToken();
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
throw new Error(ServiceErrorMessageConstants.INVALID_AUTH_TYPE_ERROR.message);
|
|
193
|
+
}
|
|
194
|
+
if (!token) {
|
|
195
|
+
throw new Error(ServiceErrorMessageConstants.NO_AUTH_ERROR.message);
|
|
196
|
+
}
|
|
182
197
|
return {
|
|
183
198
|
wsEndpoint: getServiceWSEndpoint(playwrightServiceConfig.runId, playwrightServiceConfig.serviceOs, playwrightServiceConfig.apiVersion),
|
|
184
199
|
options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playwrightService.js","sourceRoot":"","sources":["../../../src/core/playwrightService.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,8BAA8B,EAC9B,4BAA4B,EAC5B,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,cAAc,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,sBAAsB,MAAM,6BAA6B,CAAC;AAEjE,OAAO,EACL,0BAA0B,EAC1B,cAAc,EACd,oBAAoB,EACpB,cA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BAAiB,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n DefaultConnectOptionsConstants,\n InternalEnvironmentVariables,\n ServiceAuth,\n} from \"../common/constants.js\";\nimport customerConfig from \"../common/customerConfig.js\";\nimport { PlaywrightServiceConfig } from \"../common/playwrightServiceConfig.js\";\nimport playwrightServiceEntra from \"./playwrightServiceEntra.js\";\nimport type { PlaywrightServiceAdditionalOptions, BrowserConnectOptions } from \"../common/types.js\";\nimport {\n fetchOrValidateAccessToken,\n getAccessToken,\n getServiceWSEndpoint,\n validateMptPAT,\n warnIfAccessTokenCloseToExpiry,\n validatePlaywrightVersion,\n validateServiceUrl,\n exitWithFailureMessage,\n getPackageVersion,\n getPlaywrightVersion,\n getVersionInfo,\n} from \"../utils/utils.js\";\nimport { ServiceErrorMessageConstants } from \"../common/messages.js\";\nimport type { PlaywrightTestConfig } from \"@playwright/test\";\nimport { globalPaths } from \"./playwrightServiceUtils.js\";\n\nconst performOneTimeOperation = (options?: PlaywrightServiceAdditionalOptions): void => {\n const oneTimeOperationFlag =\n process.env[InternalEnvironmentVariables.ONE_TIME_OPERATION_FLAG] === \"true\";\n if (oneTimeOperationFlag) return;\n process.env[InternalEnvironmentVariables.ONE_TIME_OPERATION_FLAG] = \"true\";\n if (options?.serviceAuthType === ServiceAuth.ACCESS_TOKEN) {\n warnIfAccessTokenCloseToExpiry();\n }\n};\n/**\n * @public\n *\n * Generate playwright configuration integrated with Azure Playwright.\n *\n * @param config - base playwright configuration\n * @param options - additional options for the service\n * @returns PlaywrightConfig\n *\n * @example\n * ```\n * import { defineConfig } from \"playwright/test\";\n * import { getServiceConfig } from \"@azure/playwright\";\n * import playwrightConfig from \"./playwright.config\";\n *\n * export default defineConfig(playwrightConfig, getServiceConfig(playwrightConfig));\n * ```\n *\n * @example\n * ```\n * import { defineConfig } from \"playwright/test\";\n * import { getServiceConfig, ServiceOS } from \"@azure/playwright\";\n * import playwrightConfig from \"./playwright.config\";\n *\n * export default defineConfig(playwrightConfig, getServiceConfig(playwrightConfig, {\n * runId: \"custom run id\",\n * os: ServiceOS.WINDOWS\n * }));\n * ```\n */\nconst getServiceConfig = (\n config: PlaywrightTestConfig,\n options?: PlaywrightServiceAdditionalOptions,\n): PlaywrightTestConfig => {\n validatePlaywrightVersion();\n validateServiceUrl();\n\n // Set environment variable to indicate user is using service config\n process.env[InternalEnvironmentVariables.USING_SERVICE_CONFIG] = \"true\";\n const playwrightVersionInfo = getVersionInfo(getPlaywrightVersion());\n const isMultipleGlobalFileSupported =\n playwrightVersionInfo.major >= 1 && playwrightVersionInfo.minor >= 49;\n if (options?.credential) {\n playwrightServiceEntra.entraIdAccessToken = options.credential;\n }\n\n // if global setup/teardown is string -\n // 1. if multiple global file is supported, convert it to array\n // 2. wrap playwright-service global setup/teardown with customer provided global setup/teardown\n\n // if global setup/teardown is array -\n // 1. if multiple global file is not supported, throw error\n // 2. append playwright-service global setup/teardown with customer provided global setup/teardown\n if (config && config.globalSetup) {\n if (typeof config.globalSetup === \"string\") {\n if (isMultipleGlobalFileSupported) {\n customerConfig.globalSetup = [config.globalSetup];\n } else {\n customerConfig.globalSetup = config.globalSetup;\n }\n } else {\n if (!isMultipleGlobalFileSupported) {\n throw new Error(\n ServiceErrorMessageConstants.MULTIPLE_SETUP_FILE_PLAYWRIGHT_VERSION_ERROR.message,\n );\n }\n customerConfig.globalSetup = config.globalSetup;\n }\n }\n\n if (config && config.globalTeardown) {\n if (typeof config.globalTeardown === \"string\") {\n if (isMultipleGlobalFileSupported) {\n customerConfig.globalTeardown = [config.globalTeardown];\n } else {\n customerConfig.globalTeardown = config.globalTeardown;\n }\n } else {\n if (!isMultipleGlobalFileSupported) {\n throw new Error(\n ServiceErrorMessageConstants.MULTIPLE_SETUP_FILE_PLAYWRIGHT_VERSION_ERROR.message,\n );\n }\n customerConfig.globalTeardown = config.globalTeardown;\n }\n }\n\n const playwrightServiceConfig = PlaywrightServiceConfig.instance;\n playwrightServiceConfig.setOptions(options);\n playwrightServiceConfig.serviceAuthType =\n options?.serviceAuthType || DefaultConnectOptionsConstants.DEFAULT_SERVICE_AUTH_TYPE;\n\n const globalFunctions: any = {};\n\n if (options?.serviceAuthType === ServiceAuth.ACCESS_TOKEN) {\n // mpt PAT requested and set by the customer, no need to setup entra lifecycle handlers\n validateMptPAT(exitWithFailureMessage);\n }\n // If multiple global file is supported, append playwright-service global setup/teardown with customer provided global setup/teardown\n if (isMultipleGlobalFileSupported) {\n globalFunctions.globalSetup = [] as string[];\n globalFunctions.globalTeardown = [] as string[];\n if (customerConfig.globalSetup) {\n globalFunctions.globalSetup.push(...(customerConfig.globalSetup as string[]));\n }\n if (customerConfig.globalTeardown) {\n globalFunctions.globalTeardown.push(...(customerConfig.globalTeardown as string[]));\n }\n globalFunctions.globalSetup.push(globalPaths.setup);\n globalFunctions.globalTeardown.push(globalPaths.teardown);\n } else {\n // If multiple global file is not supported, wrap playwright-service global setup/teardown with customer provided global setup/teardown\n globalFunctions.globalSetup = globalPaths.setup;\n globalFunctions.globalTeardown = globalPaths.teardown;\n }\n performOneTimeOperation(options);\n if (options?.useCloudHostedBrowsers === false) {\n return {\n ...globalFunctions,\n };\n }\n if (!process.env[InternalEnvironmentVariables.MPT_CLOUD_HOSTED_BROWSER_USED]) {\n process.env[InternalEnvironmentVariables.MPT_CLOUD_HOSTED_BROWSER_USED] = \"true\";\n console.log(\"\\nRunning tests using Azure Playwright service.\");\n }\n\n return {\n use: {\n connectOptions: {\n wsEndpoint: getServiceWSEndpoint(\n playwrightServiceConfig.runId,\n playwrightServiceConfig.serviceOs,\n playwrightServiceConfig.apiVersion,\n ),\n headers: {\n Authorization: `Bearer ${getAccessToken()}`,\n \"x-ms-package-version\": `@azure/playwright/${getPackageVersion()}`,\n },\n timeout: playwrightServiceConfig.timeout,\n exposeNetwork: playwrightServiceConfig.exposeNetwork,\n slowMo: playwrightServiceConfig.slowMo,\n },\n },\n ...globalFunctions,\n };\n};\n\n/**\n * @public\n *\n * Get connect options required to connect to Azure Playwright's cloud hosted browsers.\n *\n * @param options - additional options for the service\n * @returns BrowserConnectOptions\n *\n * @example\n * ```\n * import playwright, { test, expect, BrowserType } from \"@playwright/test\";\n * import { getConnectOptions } from \"@azure/playwright\";\n *\n * test('has title', async ({ browserName }) => {\n * const { wsEndpoint, options } = await getConnectOptions();\n * const browser = await (playwright[browserName] as BrowserType).connect(wsEndpoint, options);\n * const context = await browser.newContext();\n * const page = await context.newPage();\n *\n * await page.goto('https://playwright.dev/');\n * await expect(page).toHaveTitle(/Playwright/);\n *\n * await page.close();\n * await context.close();\n * await browser.close();\n * });\n * ```\n */\nconst getConnectOptions = async (\n options?: PlaywrightServiceAdditionalOptions,\n): Promise<BrowserConnectOptions> => {\n const playwrightServiceConfig = new PlaywrightServiceConfig();\n\n playwrightServiceConfig.setOptions(options, true);\n\n const token = await fetchOrValidateAccessToken(options?.credential);\n return {\n wsEndpoint: getServiceWSEndpoint(\n playwrightServiceConfig.runId,\n playwrightServiceConfig.serviceOs,\n playwrightServiceConfig.apiVersion,\n ),\n options: {\n headers: {\n Authorization: `Bearer ${token}`,\n \"x-ms-package-version\": `@azure/playwright/${getPackageVersion()}`,\n },\n timeout: playwrightServiceConfig.timeout,\n exposeNetwork: playwrightServiceConfig.exposeNetwork,\n slowMo: playwrightServiceConfig.slowMo,\n },\n };\n};\n\nexport { getServiceConfig, getConnectOptions };\n"]}
|
|
1
|
+
{"version":3,"file":"playwrightService.js","sourceRoot":"","sources":["../../../src/core/playwrightService.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,8BAA8B,EAC9B,4BAA4B,EAC5B,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,cAAc,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,sBAAsB,MAAM,6BAA6B,CAAC;AAEjE,OAAO,EACL,0BAA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,CAAC;QAChF,cAAc,CAAC,4BAA4B,CAAC,CAAC;QAC7C,KAAK,GAAG,cAAc,EAAE,CAAC;IAC3B,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAChF,CAAC;IAED,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACtE,CAAC;IAED,OAAO;QACL,UAAU,EAAE,oBAAoB,CAC9B,uBAAuB,CAAC,KAAK,EAC7B,uBAAuB,CAAC,SAAS,EACjC,uBAAuB,CAAC,UAAU,CACnC;QACD,OAAO,EAAE;YACP,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,KAAK,EAAE;gBAChC,sBAAsB,EAAE,qBAAqB,iBAAiB,EAAE,EAAE;aACnE;YACD,OAAO,EAAE,uBAAuB,CAAC,OAAO;YACxC,aAAa,EAAE,uBAAuB,CAAC,aAAa;YACpD,MAAM,EAAE,uBAAuB,CAAC,MAAM;SACvC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n DefaultConnectOptionsConstants,\n InternalEnvironmentVariables,\n ServiceAuth,\n} from \"../common/constants.js\";\nimport customerConfig from \"../common/customerConfig.js\";\nimport { PlaywrightServiceConfig } from \"../common/playwrightServiceConfig.js\";\nimport playwrightServiceEntra from \"./playwrightServiceEntra.js\";\nimport type { PlaywrightServiceAdditionalOptions, BrowserConnectOptions } from \"../common/types.js\";\nimport {\n fetchOrValidateAccessToken,\n getAccessToken,\n getServiceWSEndpoint,\n validateMptPAT,\n validatePlaywrightVersion,\n validateServiceUrl,\n exitWithFailureMessage,\n getPlaywrightVersion,\n getVersionInfo,\n throwErrorWithFailureMessage,\n getPackageVersion,\n warnIfAccessTokenCloseToExpiry,\n} from \"../utils/utils.js\";\nimport { ServiceErrorMessageConstants } from \"../common/messages.js\";\nimport type { PlaywrightTestConfig } from \"@playwright/test\";\nimport { globalPaths } from \"./playwrightServiceUtils.js\";\n\nconst performOneTimeOperation = (options?: PlaywrightServiceAdditionalOptions): void => {\n const oneTimeOperationFlag =\n process.env[InternalEnvironmentVariables.ONE_TIME_OPERATION_FLAG] === \"true\";\n if (oneTimeOperationFlag) return;\n process.env[InternalEnvironmentVariables.ONE_TIME_OPERATION_FLAG] = \"true\";\n if (options?.serviceAuthType === ServiceAuth.ACCESS_TOKEN) {\n warnIfAccessTokenCloseToExpiry();\n }\n};\n\n/**\n * @public\n *\n * Generate playwright configuration integrated with Azure Playwright.\n *\n * @param config - base playwright configuration\n * @param options - additional options for the service\n * @returns PlaywrightConfig\n *\n * @example\n * ```\n * import { defineConfig } from \"playwright/test\";\n * import { getServiceConfig } from \"@azure/playwright\";\n * import playwrightConfig from \"./playwright.config\";\n *\n * export default defineConfig(playwrightConfig, getServiceConfig(playwrightConfig));\n * ```\n *\n * @example\n * ```\n * import { defineConfig } from \"playwright/test\";\n * import { getServiceConfig, ServiceOS } from \"@azure/playwright\";\n * import playwrightConfig from \"./playwright.config\";\n *\n * export default defineConfig(playwrightConfig, getServiceConfig(playwrightConfig, {\n * runId: \"custom run id\",\n * os: ServiceOS.WINDOWS\n * }));\n * ```\n */\nconst getServiceConfig = (\n config: PlaywrightTestConfig,\n options?: PlaywrightServiceAdditionalOptions,\n): PlaywrightTestConfig => {\n validatePlaywrightVersion();\n validateServiceUrl();\n\n // Set environment variable to indicate user is using service config\n process.env[InternalEnvironmentVariables.USING_SERVICE_CONFIG] = \"true\";\n const playwrightVersionInfo = getVersionInfo(getPlaywrightVersion());\n const isMultipleGlobalFileSupported =\n playwrightVersionInfo.major >= 1 && playwrightVersionInfo.minor >= 49;\n if (options?.credential) {\n playwrightServiceEntra.entraIdAccessToken = options.credential;\n }\n\n // if global setup/teardown is string -\n // 1. if multiple global file is supported, convert it to array\n // 2. wrap playwright-service global setup/teardown with customer provided global setup/teardown\n\n // if global setup/teardown is array -\n // 1. if multiple global file is not supported, throw error\n // 2. append playwright-service global setup/teardown with customer provided global setup/teardown\n if (config && config.globalSetup) {\n if (typeof config.globalSetup === \"string\") {\n if (isMultipleGlobalFileSupported) {\n customerConfig.globalSetup = [config.globalSetup];\n } else {\n customerConfig.globalSetup = config.globalSetup;\n }\n } else {\n if (!isMultipleGlobalFileSupported) {\n throw new Error(\n ServiceErrorMessageConstants.MULTIPLE_SETUP_FILE_PLAYWRIGHT_VERSION_ERROR.message,\n );\n }\n customerConfig.globalSetup = config.globalSetup;\n }\n }\n\n if (config && config.globalTeardown) {\n if (typeof config.globalTeardown === \"string\") {\n if (isMultipleGlobalFileSupported) {\n customerConfig.globalTeardown = [config.globalTeardown];\n } else {\n customerConfig.globalTeardown = config.globalTeardown;\n }\n } else {\n if (!isMultipleGlobalFileSupported) {\n throw new Error(\n ServiceErrorMessageConstants.MULTIPLE_SETUP_FILE_PLAYWRIGHT_VERSION_ERROR.message,\n );\n }\n customerConfig.globalTeardown = config.globalTeardown;\n }\n }\n\n const playwrightServiceConfig = PlaywrightServiceConfig.instance;\n playwrightServiceConfig.setOptions(options);\n playwrightServiceConfig.serviceAuthType =\n options?.serviceAuthType || DefaultConnectOptionsConstants.DEFAULT_SERVICE_AUTH_TYPE;\n\n const globalFunctions: any = {};\n\n if (options?.serviceAuthType === ServiceAuth.ACCESS_TOKEN) {\n // mpt PAT requested and set by the customer, no need to setup entra lifecycle handlers\n validateMptPAT(exitWithFailureMessage);\n }\n // If multiple global file is supported, append playwright-service global setup/teardown with customer provided global setup/teardown\n if (isMultipleGlobalFileSupported) {\n globalFunctions.globalSetup = [] as string[];\n globalFunctions.globalTeardown = [] as string[];\n if (customerConfig.globalSetup) {\n globalFunctions.globalSetup.push(...(customerConfig.globalSetup as string[]));\n }\n if (customerConfig.globalTeardown) {\n globalFunctions.globalTeardown.push(...(customerConfig.globalTeardown as string[]));\n }\n globalFunctions.globalSetup.push(globalPaths.setup);\n globalFunctions.globalTeardown.push(globalPaths.teardown);\n } else {\n // If multiple global file is not supported, wrap playwright-service global setup/teardown with customer provided global setup/teardown\n globalFunctions.globalSetup = globalPaths.setup;\n globalFunctions.globalTeardown = globalPaths.teardown;\n }\n\n performOneTimeOperation(options);\n\n if (!process.env[InternalEnvironmentVariables.MPT_CLOUD_HOSTED_BROWSER_USED]) {\n process.env[InternalEnvironmentVariables.MPT_CLOUD_HOSTED_BROWSER_USED] = \"true\";\n console.log(\"\\nRunning tests using Azure Playwright service.\");\n }\n\n return {\n use: {\n connectOptions: {\n wsEndpoint: getServiceWSEndpoint(\n playwrightServiceConfig.runId,\n playwrightServiceConfig.serviceOs,\n playwrightServiceConfig.apiVersion,\n ),\n headers: {\n Authorization: `Bearer ${getAccessToken()}`,\n \"x-ms-package-version\": `@azure/playwright/${getPackageVersion()}`,\n },\n timeout: playwrightServiceConfig.timeout,\n exposeNetwork: playwrightServiceConfig.exposeNetwork,\n slowMo: playwrightServiceConfig.slowMo,\n },\n },\n ...globalFunctions,\n };\n};\n\n/**\n * @public\n *\n * Get connect options required to connect to Azure Playwright's cloud hosted browsers.\n *\n * @param options - additional options for the service\n * @returns BrowserConnectOptions\n *\n * @example\n * ```\n * import playwright, { test, expect, BrowserType } from \"@playwright/test\";\n * import { getConnectOptions } from \"@azure/playwright\";\n *\n * test('has title', async ({ browserName }) => {\n * const { wsEndpoint, options } = await getConnectOptions();\n * const browser = await (playwright[browserName] as BrowserType).connect(wsEndpoint, options);\n * const context = await browser.newContext();\n * const page = await context.newPage();\n *\n * await page.goto('https://playwright.dev/');\n * await expect(page).toHaveTitle(/Playwright/);\n *\n * await page.close();\n * await context.close();\n * await browser.close();\n * });\n * ```\n */\nconst getConnectOptions = async (\n options?: PlaywrightServiceAdditionalOptions,\n): Promise<BrowserConnectOptions> => {\n const playwrightServiceConfig = PlaywrightServiceConfig.instance;\n\n playwrightServiceConfig.setOptions(options, true);\n performOneTimeOperation(options);\n playwrightServiceConfig.serviceAuthType =\n options?.serviceAuthType || DefaultConnectOptionsConstants.DEFAULT_SERVICE_AUTH_TYPE;\n\n let token: string | undefined;\n if (playwrightServiceConfig.serviceAuthType === ServiceAuth.ENTRA_ID) {\n if (!options?.credential) {\n throw new Error(ServiceErrorMessageConstants.NO_CRED_ENTRA_AUTH_ERROR.message);\n }\n playwrightServiceEntra.entraIdAccessToken = options.credential;\n token = await fetchOrValidateAccessToken(options.credential);\n } else if (playwrightServiceConfig.serviceAuthType === ServiceAuth.ACCESS_TOKEN) {\n validateMptPAT(throwErrorWithFailureMessage);\n token = getAccessToken();\n } else {\n throw new Error(ServiceErrorMessageConstants.INVALID_AUTH_TYPE_ERROR.message);\n }\n\n if (!token) {\n throw new Error(ServiceErrorMessageConstants.NO_AUTH_ERROR.message);\n }\n\n return {\n wsEndpoint: getServiceWSEndpoint(\n playwrightServiceConfig.runId,\n playwrightServiceConfig.serviceOs,\n playwrightServiceConfig.apiVersion,\n ),\n options: {\n headers: {\n Authorization: `Bearer ${token}`,\n \"x-ms-package-version\": `@azure/playwright/${getPackageVersion()}`,\n },\n timeout: playwrightServiceConfig.timeout,\n exposeNetwork: playwrightServiceConfig.exposeNetwork,\n slowMo: playwrightServiceConfig.slowMo,\n },\n };\n};\n\nexport { getServiceConfig, getConnectOptions };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playwrightServiceUtils.d.ts","sourceRoot":"","sources":["../../../src/core/playwrightServiceUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"playwrightServiceUtils.d.ts","sourceRoot":"","sources":["../../../src/core/playwrightServiceUtils.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,WAAW;;;CAGvB,CAAC"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { dirname } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
7
|
+
// @ts-ignore ESM only output
|
|
8
|
+
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
4
9
|
export const globalPaths = {
|
|
5
|
-
setup: path.join(
|
|
6
|
-
teardown: path.join(
|
|
10
|
+
setup: path.join(currentDir, "./global/playwright-service-global-setup.js"),
|
|
11
|
+
teardown: path.join(currentDir, "./global/playwright-service-global-teardown.js"),
|
|
7
12
|
};
|
|
8
13
|
//# sourceMappingURL=playwrightServiceUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playwrightServiceUtils.js","sourceRoot":"","sources":["../../../src/core/playwrightServiceUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"playwrightServiceUtils.js","sourceRoot":"","sources":["../../../src/core/playwrightServiceUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,6DAA6D;AAC7D,6BAA6B;AAC7B,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE3D,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,6CAA6C,CAAC;IAC3E,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,gDAAgD,CAAC;CAClF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport path from \"node:path\";\nimport { dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore ESM only output\nconst currentDir = dirname(fileURLToPath(import.meta.url));\n\nexport const globalPaths = {\n setup: path.join(currentDir, \"./global/playwright-service-global-setup.js\"),\n teardown: path.join(currentDir, \"./global/playwright-service-global-teardown.js\"),\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPackageVersion.d.ts","sourceRoot":"","sources":["../../../src/utils/getPackageVersion.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,2BAA2B,GAAI,QAAQ,MAAM,KAAG,MAQ5D,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import path, { dirname } from "node:path";
|
|
4
|
+
import { coreLogger } from "../common/logger.js";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { createRequire } from "node:module";
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
8
|
+
// @ts-ignore ESM only output
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
11
|
+
// @ts-ignore ESM only output
|
|
12
|
+
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
export const getPackageVersionFromFolder = (folder) => {
|
|
14
|
+
try {
|
|
15
|
+
const version = require(path.join(currentDir, folder, "package.json")).version;
|
|
16
|
+
return version;
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
coreLogger.error("Error fetching package version:", error);
|
|
20
|
+
return "";
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=getPackageVersion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPackageVersion.js","sourceRoot":"","sources":["../../../src/utils/getPackageVersion.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,6DAA6D;AAC7D,6BAA6B;AAC7B,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,6DAA6D;AAC7D,6BAA6B;AAC7B,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE3D,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,MAAc,EAAU,EAAE;IACpE,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC;QAC/E,OAAO,OAAO,CAAC;IACjB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,UAAU,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;QAC3D,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport path, { dirname } from \"node:path\";\nimport { coreLogger } from \"../common/logger.js\";\nimport { fileURLToPath } from \"node:url\";\nimport { createRequire } from \"node:module\";\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore ESM only output\nconst require = createRequire(import.meta.url);\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore ESM only output\nconst currentDir = dirname(fileURLToPath(import.meta.url));\n\nexport const getPackageVersionFromFolder = (folder: string): string => {\n try {\n const version = require(path.join(currentDir, folder, \"package.json\")).version;\n return version;\n } catch (error) {\n coreLogger.error(\"Error fetching package version:\", error);\n return \"\";\n }\n};\n"]}
|
|
@@ -4,11 +4,17 @@ import { FullConfig } from "@playwright/test";
|
|
|
4
4
|
import { CIInfo } from "./cIInfoProvider.js";
|
|
5
5
|
export { getPlaywrightVersion } from "./getPlaywrightVersion.js";
|
|
6
6
|
export { parseJwt } from "./parseJwt.js";
|
|
7
|
+
export declare const getPackageVersion: () => string;
|
|
7
8
|
export declare const exitWithFailureMessage: (error: {
|
|
8
9
|
key: string;
|
|
9
10
|
message: string;
|
|
10
11
|
formatWithErrorDetails?: (errorDetails: string) => string;
|
|
11
12
|
}, errorDetails?: string) => never;
|
|
13
|
+
export declare const throwErrorWithFailureMessage: (error: {
|
|
14
|
+
key: string;
|
|
15
|
+
message: string;
|
|
16
|
+
formatWithErrorDetails?: (errorDetails: string) => string;
|
|
17
|
+
}, errorDetails?: string) => never;
|
|
12
18
|
export declare const populateValuesFromServiceUrl: () => {
|
|
13
19
|
region: string;
|
|
14
20
|
domain: string;
|
|
@@ -27,7 +33,6 @@ export declare const validateMptPAT: (validationFailureCallback: (error: {
|
|
|
27
33
|
}) => void) => void;
|
|
28
34
|
export declare const warnIfAccessTokenCloseToExpiry: () => void;
|
|
29
35
|
export declare const fetchOrValidateAccessToken: (credential?: TokenCredential) => Promise<string>;
|
|
30
|
-
export declare const getPackageVersion: () => string;
|
|
31
36
|
export declare const getVersionInfo: (version: string) => VersionInfo;
|
|
32
37
|
export declare const validatePlaywrightVersion: () => void;
|
|
33
38
|
export declare const getTestRunConfig: (config: FullConfig) => RunConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAqB,WAAW,EAAc,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAUhG,OAAO,KA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I,GAAG,SAAS,KAAG,OAM7D,CAAC;AAEF,eAAO,MAAM,cAAc,QAAO,MAIjC,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,OAAO,MAAM,EAAE,IAAI,MAAM,EAAE,YAAY,MAAM,KAAG,MAEpF,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAO,IAKrC,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,KAAG,IAM7C,CAAC;AACF,eAAO,MAAM,cAAc,GACzB,2BAA2B,CAAC,KAAK,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,KAAK,IAAI,KAC3E,IAqBF,CAAC;AAYF,eAAO,MAAM,8BAA8B,QAAO,IAUjD,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAU,aAAa,eAAe,KAAG,OAAO,CAAC,MAAM,CAW7F,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,KAAG,WAYhD,CAAC;AAEF,eAAO,MAAM,yBAAyB,QAAO,IAc5C,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,QAAQ,UAAU,KAAG,SAcrD,CAAC;AAEF,wBAAgB,gBAAgB,IAAI,MAAM,CAWzC;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAErE;AAkBD,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAyBhE;AAED,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAchE"}
|
|
@@ -4,16 +4,30 @@ import { Constants, InternalEnvironmentVariables, ServiceEnvironmentVariable, Ru
|
|
|
4
4
|
import { ServiceErrorMessageConstants } from "../common/messages.js";
|
|
5
5
|
import { coreLogger } from "../common/logger.js";
|
|
6
6
|
import process from "node:process";
|
|
7
|
-
import path from "node:path";
|
|
8
7
|
import { randomUUID } from "node:crypto";
|
|
9
8
|
import { parseJwt } from "./parseJwt.js";
|
|
10
9
|
import { getPlaywrightVersion } from "./getPlaywrightVersion.js";
|
|
11
10
|
import { createEntraIdAccessToken } from "../common/entraIdAccessToken.js";
|
|
12
11
|
import { CI_PROVIDERS } from "./cIInfoProvider.js";
|
|
13
12
|
import { exec } from "child_process";
|
|
13
|
+
import { getPackageVersionFromFolder } from "./getPackageVersion.js";
|
|
14
14
|
// Re-exporting for backward compatibility
|
|
15
15
|
export { getPlaywrightVersion } from "./getPlaywrightVersion.js";
|
|
16
16
|
export { parseJwt } from "./parseJwt.js";
|
|
17
|
+
export const getPackageVersion = () => {
|
|
18
|
+
// hacky way to get package version
|
|
19
|
+
// try from dist folder first (customer perspective)
|
|
20
|
+
const distVersion = getPackageVersionFromFolder("../../../");
|
|
21
|
+
if (distVersion) {
|
|
22
|
+
return distVersion;
|
|
23
|
+
}
|
|
24
|
+
// if not found, try from src folder (internal test suite)
|
|
25
|
+
const srcVersion = getPackageVersionFromFolder("../../");
|
|
26
|
+
if (srcVersion) {
|
|
27
|
+
return srcVersion;
|
|
28
|
+
}
|
|
29
|
+
return "unknown-version";
|
|
30
|
+
};
|
|
17
31
|
// const playwrightServiceConfig = new PlaywrightServiceConfig();
|
|
18
32
|
export const exitWithFailureMessage = (error, errorDetails) => {
|
|
19
33
|
console.log();
|
|
@@ -26,6 +40,13 @@ export const exitWithFailureMessage = (error, errorDetails) => {
|
|
|
26
40
|
// eslint-disable-next-line n/no-process-exit
|
|
27
41
|
process.exit(1);
|
|
28
42
|
};
|
|
43
|
+
export const throwErrorWithFailureMessage = (error, errorDetails) => {
|
|
44
|
+
console.log();
|
|
45
|
+
const finalMessage = error.formatWithErrorDetails && errorDetails
|
|
46
|
+
? error.formatWithErrorDetails(errorDetails)
|
|
47
|
+
: error.message;
|
|
48
|
+
throw new Error(finalMessage);
|
|
49
|
+
};
|
|
29
50
|
export const populateValuesFromServiceUrl = () => {
|
|
30
51
|
// Service URL format: wss://<region>.api.playwright.microsoft.com/accounts/<workspace-id>/browsers
|
|
31
52
|
const url = process.env["PLAYWRIGHT_SERVICE_URL"];
|
|
@@ -109,6 +130,9 @@ const warnAboutTokenExpiry = (expirationTime, currentTime) => {
|
|
|
109
130
|
};
|
|
110
131
|
export const warnIfAccessTokenCloseToExpiry = () => {
|
|
111
132
|
const accessToken = getAccessToken();
|
|
133
|
+
if (!accessToken) {
|
|
134
|
+
throw new Error(ServiceErrorMessageConstants.NO_AUTH_ERROR.message);
|
|
135
|
+
}
|
|
112
136
|
const claims = parseJwt(accessToken);
|
|
113
137
|
const currentTime = Date.now();
|
|
114
138
|
if (isTokenExpiringSoon(claims.exp, currentTime)) {
|
|
@@ -117,38 +141,15 @@ export const warnIfAccessTokenCloseToExpiry = () => {
|
|
|
117
141
|
};
|
|
118
142
|
export const fetchOrValidateAccessToken = async (credential) => {
|
|
119
143
|
const entraIdAccessToken = createEntraIdAccessToken(credential);
|
|
120
|
-
|
|
144
|
+
// Fetch a token or refresh if needed in a single call
|
|
145
|
+
if (entraIdAccessToken.doesEntraIdAccessTokenNeedRotation()) {
|
|
121
146
|
await entraIdAccessToken.fetchEntraIdAccessToken();
|
|
122
147
|
}
|
|
123
|
-
|
|
148
|
+
const token = getAccessToken();
|
|
149
|
+
if (!token) {
|
|
124
150
|
throw new Error(ServiceErrorMessageConstants.NO_AUTH_ERROR.message);
|
|
125
151
|
}
|
|
126
|
-
return
|
|
127
|
-
};
|
|
128
|
-
const getPackageVersionFromFolder = (folder) => {
|
|
129
|
-
try {
|
|
130
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
131
|
-
const version = require(path.join(__dirname, folder, "package.json")).version;
|
|
132
|
-
return version;
|
|
133
|
-
}
|
|
134
|
-
catch (error) {
|
|
135
|
-
coreLogger.error("Error fetching package version:", error);
|
|
136
|
-
return "";
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
export const getPackageVersion = () => {
|
|
140
|
-
// hacky way to get package version
|
|
141
|
-
// try from dist folder first (customer perspective)
|
|
142
|
-
const distVersion = getPackageVersionFromFolder("../../../");
|
|
143
|
-
if (distVersion) {
|
|
144
|
-
return distVersion;
|
|
145
|
-
}
|
|
146
|
-
// if not found, try from src folder (internal test suite)
|
|
147
|
-
const srcVersion = getPackageVersionFromFolder("../../");
|
|
148
|
-
if (srcVersion) {
|
|
149
|
-
return srcVersion;
|
|
150
|
-
}
|
|
151
|
-
return "unknown-version";
|
|
152
|
+
return token;
|
|
152
153
|
};
|
|
153
154
|
export const getVersionInfo = (version) => {
|
|
154
155
|
const regex = /^(\d+)(?:\.(\d+))?(?:\.(\d+))?/;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EACL,SAAS,EACT,4BAA4B,EAC5B,0BAA0B,EAC1B,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,OAAO,EAAE,YAAY,EAAU,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,0CAA0C;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,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AAC,0BAA0B,CAAC,CAAC;QAC7F,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,UAAU,CAAC,KAAK,CAAC,wCAAwC,GAAG,GAAG,CAAC,CAAC;QACjE,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,YAAoB;IACtD,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC/C,IAAI,aAAa,CAAC,KAAK,IAAI,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YACvD,OAAO,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC;QACrC,CAAC;QACD,OAAO,YAAY,CAAC;IACtB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,YAAY,CAAC;IACtB,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessTokenClaims, VersionInfo, JwtPayload, RunConfig } from \"../common/types.js\";\nimport {\n Constants,\n InternalEnvironmentVariables,\n ServiceEnvironmentVariable,\n RunConfigConstants,\n GitHubActionsConstants,\n} from \"../common/constants.js\";\nimport { ServiceErrorMessageConstants } from \"../common/messages.js\";\nimport { coreLogger } from \"../common/logger.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport process from \"node:process\";\nimport path from \"node:path\";\nimport { randomUUID } from \"node:crypto\";\nimport { parseJwt } from \"./parseJwt.js\";\nimport { getPlaywrightVersion } from \"./getPlaywrightVersion.js\";\nimport { createEntraIdAccessToken } from \"../common/entraIdAccessToken.js\";\nimport { FullConfig } from \"@playwright/test\";\nimport { CI_PROVIDERS, CIInfo } from \"./cIInfoProvider.js\";\nimport { exec } from \"child_process\";\n\n// Re-exporting for backward compatibility\nexport { getPlaywrightVersion } from \"./getPlaywrightVersion.js\";\nexport { parseJwt } from \"./parseJwt.js\";\n\n// const playwrightServiceConfig = new PlaywrightServiceConfig();\n\nexport const exitWithFailureMessage = (\n error: {\n key: string;\n message: string;\n formatWithErrorDetails?: (errorDetails: string) => string;\n },\n errorDetails?: string,\n): never => {\n console.log();\n\n if (error.formatWithErrorDetails && errorDetails) {\n console.error(error.formatWithErrorDetails(errorDetails));\n } else {\n console.error(error.message);\n }\n\n // eslint-disable-next-line n/no-process-exit\n process.exit(1);\n};\n\nexport const populateValuesFromServiceUrl = (): {\n region: string;\n domain: string;\n accountId: string;\n} | null => {\n // Service URL format: wss://<region>.api.playwright.microsoft.com/accounts/<workspace-id>/browsers\n const url = process.env[\"PLAYWRIGHT_SERVICE_URL\"]!;\n if (url) {\n const parts = url.split(\"/\");\n\n if (parts.length > 2) {\n const subdomainParts = parts[2]!.split(\".\");\n const region = subdomainParts.length > 0 ? subdomainParts[0] : null;\n const domain = subdomainParts.slice(2).join(\".\");\n const accountId = parts[4];\n\n return { region: region!, domain: domain!, accountId: accountId! };\n }\n }\n return null;\n};\n\nexport const getAccessToken = (): string | undefined => {\n return process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_ACCESS_TOKEN];\n};\n\nexport const getServiceBaseURL = (): string | undefined => {\n return process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_URL];\n};\n\nexport const isValidGuid = (guid: string | null | undefined): boolean => {\n if (!guid) {\n return false;\n }\n const guidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n return guidRegex.test(guid);\n};\n\nexport const getAndSetRunId = (): string => {\n const runId = randomUUID();\n process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_ID] = runId;\n return runId;\n};\n\nexport const getServiceWSEndpoint = (runId: string, os: string, apiVersion: string): string => {\n return `${getServiceBaseURL()}?runId=${encodeURIComponent(runId)}&os=${os}&api-version=${apiVersion}`;\n};\n\nexport const validateServiceUrl = (): void => {\n const serviceUrl = getServiceBaseURL();\n if (!serviceUrl) {\n exitWithFailureMessage(ServiceErrorMessageConstants.NO_SERVICE_URL_ERROR);\n }\n};\n\nexport const ValidateRunID = (runID: string): void => {\n const isValidRunID = isValidGuid(runID);\n if (!isValidRunID) {\n const errorMessage = ServiceErrorMessageConstants.INVALID_RUN_ID_FORMAT.message;\n throw new Error(errorMessage);\n }\n};\nexport const validateMptPAT = (\n validationFailureCallback: (error: { key: string; message: string }) => void,\n): void => {\n try {\n const accessToken = getAccessToken();\n const result = populateValuesFromServiceUrl();\n if (!accessToken) {\n validationFailureCallback(ServiceErrorMessageConstants.NO_AUTH_ERROR);\n }\n const claims = parseJwt<Partial<AccessTokenClaims>>(accessToken!);\n if (!claims.exp) {\n validationFailureCallback(ServiceErrorMessageConstants.INVALID_MPT_PAT_ERROR);\n }\n if (Date.now() >= claims.exp! * 1000) {\n validationFailureCallback(ServiceErrorMessageConstants.EXPIRED_MPT_PAT_ERROR);\n }\n if (result!.accountId !== claims!.pwid) {\n validationFailureCallback(ServiceErrorMessageConstants.WORKSPACE_MISMATCH_ERROR);\n }\n } catch (err) {\n coreLogger.error(err);\n exitWithFailureMessage(ServiceErrorMessageConstants.INVALID_MPT_PAT_ERROR);\n }\n};\nconst isTokenExpiringSoon = (expirationTime: number, currentTime: number): boolean => {\n return expirationTime * 1000 - currentTime <= Constants.SevenDaysInMS;\n};\n\nconst warnAboutTokenExpiry = (expirationTime: number, currentTime: number): void => {\n const daysToExpiration = Math.ceil((expirationTime * 1000 - currentTime) / Constants.OneDayInMS);\n const expirationDate = new Date(expirationTime * 1000).toLocaleDateString();\n const expirationWarning = `Warning: The access token used for this test run will expire in ${daysToExpiration} days on ${expirationDate}. Generate a new token from the portal to avoid failures. For a simpler, more secure solution, switch to Microsoft Entra ID and eliminate token management. https://learn.microsoft.com/entra/identity/`;\n console.warn(expirationWarning);\n};\n\nexport const warnIfAccessTokenCloseToExpiry = (): void => {\n const accessToken = getAccessToken();\n const claims = parseJwt<JwtPayload>(accessToken!);\n const currentTime = Date.now();\n if (isTokenExpiringSoon(claims.exp!, currentTime)) {\n warnAboutTokenExpiry(claims.exp!, currentTime);\n }\n};\n\nexport const fetchOrValidateAccessToken = async (credential?: TokenCredential): Promise<string> => {\n const entraIdAccessToken = createEntraIdAccessToken(credential);\n if (entraIdAccessToken.token && entraIdAccessToken.doesEntraIdAccessTokenNeedRotation()) {\n await entraIdAccessToken.fetchEntraIdAccessToken();\n }\n if (!getAccessToken()) {\n throw new Error(ServiceErrorMessageConstants.NO_AUTH_ERROR.message);\n }\n return getAccessToken()!;\n};\n\nconst getPackageVersionFromFolder = (folder: string): string => {\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const version = require(path.join(__dirname, folder, \"package.json\")).version;\n return version;\n } catch (error) {\n coreLogger.error(\"Error fetching package version:\", error);\n return \"\";\n }\n};\n\nexport const getPackageVersion = (): string => {\n // hacky way to get package version\n // try from dist folder first (customer perspective)\n const distVersion = getPackageVersionFromFolder(\"../../../\");\n if (distVersion) {\n return distVersion;\n }\n // if not found, try from src folder (internal test suite)\n const srcVersion = getPackageVersionFromFolder(\"../../\");\n if (srcVersion) {\n return srcVersion;\n }\n return \"unknown-version\";\n};\n\nexport const getVersionInfo = (version: string): VersionInfo => {\n const regex = /^(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?/;\n const match = version.match(regex);\n const versionInfo = {\n major: 0,\n minor: 0,\n patch: 0,\n };\n versionInfo.major = match && match[1] ? parseInt(match[1], 10) : 0;\n versionInfo.minor = match && match[2] ? parseInt(match[2], 10) : 0;\n versionInfo.patch = match && match[3] ? parseInt(match[3], 10) : 0;\n return versionInfo;\n};\n\nexport const validatePlaywrightVersion = (): void => {\n const minimumSupportedVersion = Constants.MinimumSupportedPlaywrightVersion;\n const installedVersion = getPlaywrightVersion();\n\n const minimumSupportedVersionInfo = getVersionInfo(minimumSupportedVersion);\n const installedVersionInfo = getVersionInfo(installedVersion);\n\n const isInstalledVersionGreater =\n installedVersionInfo.major > minimumSupportedVersionInfo.major ||\n (installedVersionInfo.major === minimumSupportedVersionInfo.major &&\n installedVersionInfo.minor >= minimumSupportedVersionInfo.minor);\n if (!isInstalledVersionGreater) {\n exitWithFailureMessage(ServiceErrorMessageConstants.INVALID_PLAYWRIGHT_VERSION_ERROR);\n }\n};\n\nexport const getTestRunConfig = (config: FullConfig): RunConfig => {\n const maxWorkers = config.workers || config.metadata.actualWorkers;\n const frameWorkVersion = config.version;\n\n const testRunConfig: RunConfig = {\n framework: {\n name: RunConfigConstants.TEST_FRAMEWORK_NAME,\n version: frameWorkVersion,\n runnerName: RunConfigConstants.TEST_FRAMEWORK_RUNNERNAME,\n },\n sdkLanguage: RunConfigConstants.TEST_SDK_LANGUAGE,\n maxWorkers: maxWorkers,\n };\n return testRunConfig;\n};\n\nexport function getTestRunApiUrl(): string {\n const result = populateValuesFromServiceUrl();\n const runId = process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_ID];\n\n if (!result?.region || !result?.domain || !result?.accountId) {\n exitWithFailureMessage(ServiceErrorMessageConstants.NO_SERVICE_URL_ERROR);\n }\n const baseUrl = `https://${result?.region}.reporting.api.${result?.domain}/playwrightworkspaces/${result?.accountId}/test-runs`;\n const url = runId ? `${baseUrl}/${runId}` : baseUrl;\n\n return `${url}?api-version=${Constants.LatestAPIVersion}`;\n}\n\nexport function isNullOrEmpty(str: string | null | undefined): boolean {\n return !str || str.trim() === \"\";\n}\n\nasync function runCommand(command: string): Promise<string> {\n return new Promise((resolve, reject) => {\n exec(command, (error, stdout, stderr) => {\n if (error) {\n reject(error);\n return;\n }\n if (stderr) {\n reject(new Error(stderr));\n return;\n }\n resolve(stdout.trim());\n });\n });\n}\n\nexport async function getRunName(ciInfo: CIInfo): Promise<string> {\n if (\n ciInfo.providerName === CI_PROVIDERS.GITHUB &&\n process.env[\"GITHUB_EVENT_NAME\"] === \"pull_request\"\n ) {\n const prNumber: string = `${process.env[\"GITHUB_REF_NAME\"]?.split(\"/\")[0]}`;\n const prLink: string = `${process.env[\"GITHUB_REPOSITORY\"]}/pull/${prNumber}`;\n return `PR# ${prNumber} on Repo: ${process.env[\"GITHUB_REPOSITORY\"]} (${prLink})`;\n }\n\n try {\n const gitVersion = await runCommand(GitHubActionsConstants.GIT_VERSION_COMMAND);\n if (isNullOrEmpty(gitVersion)) {\n throw new Error(\"Git is not installed on the machine\");\n }\n const isInsideWorkTree = await runCommand(GitHubActionsConstants.GIT_REV_PARSE);\n if (isInsideWorkTree !== \"true\") {\n throw new Error(\"Not inside a git repository\");\n }\n const gitCommitMessage = await runCommand(GitHubActionsConstants.GIT_COMMIT_MESSAGE_COMMAND);\n return gitCommitMessage;\n } catch (err) {\n coreLogger.error(`Error in getting git commit message: ${err}.`);\n return \"\";\n }\n}\n\nexport function extractErrorMessage(responseBody: string): string {\n if (!responseBody) {\n return \"\";\n }\n\n try {\n const errorResponse = JSON.parse(responseBody);\n if (errorResponse.error && errorResponse.error.message) {\n return errorResponse.error.message;\n }\n return responseBody;\n } catch (e) {\n return responseBody;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EACL,SAAS,EACT,4BAA4B,EAC5B,0BAA0B,EAC1B,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,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AAU,CAAC,sBAAsB,CAAC,mBAAmB,CAAC,CAAC;QAChF,IAAI,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;QACD,MAAM,gBAAgB,GAAG,MAAM,UAAU,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC;QAChF,IAAI,gBAAgB,KAAK,MAAM,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QACD,MAAM,gBAAgB,GAAG,MAAM,UAAU,CAAC,sBAAsB,CAAC,0BAA0B,CAAC,CAAC;QAC7F,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,UAAU,CAAC,KAAK,CAAC,wCAAwC,GAAG,GAAG,CAAC,CAAC;QACjE,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,YAAoB;IACtD,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC/C,IAAI,aAAa,CAAC,KAAK,IAAI,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YACvD,OAAO,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC;QACrC,CAAC;QACD,OAAO,YAAY,CAAC;IACtB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,YAAY,CAAC;IACtB,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessTokenClaims, VersionInfo, JwtPayload, RunConfig } from \"../common/types.js\";\nimport {\n Constants,\n InternalEnvironmentVariables,\n ServiceEnvironmentVariable,\n RunConfigConstants,\n GitHubActionsConstants,\n} from \"../common/constants.js\";\nimport { ServiceErrorMessageConstants } from \"../common/messages.js\";\nimport { coreLogger } from \"../common/logger.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport process from \"node:process\";\nimport { randomUUID } from \"node:crypto\";\nimport { parseJwt } from \"./parseJwt.js\";\nimport { getPlaywrightVersion } from \"./getPlaywrightVersion.js\";\nimport { createEntraIdAccessToken } from \"../common/entraIdAccessToken.js\";\nimport { FullConfig } from \"@playwright/test\";\nimport { CI_PROVIDERS, CIInfo } from \"./cIInfoProvider.js\";\nimport { exec } from \"child_process\";\nimport { getPackageVersionFromFolder } from \"./getPackageVersion.js\";\n\n// Re-exporting for backward compatibility\nexport { getPlaywrightVersion } from \"./getPlaywrightVersion.js\";\nexport { parseJwt } from \"./parseJwt.js\";\n\nexport const getPackageVersion = (): string => {\n // hacky way to get package version\n // try from dist folder first (customer perspective)\n const distVersion = getPackageVersionFromFolder(\"../../../\");\n if (distVersion) {\n return distVersion;\n }\n // if not found, try from src folder (internal test suite)\n const srcVersion = getPackageVersionFromFolder(\"../../\");\n if (srcVersion) {\n return srcVersion;\n }\n return \"unknown-version\";\n};\n\n// const playwrightServiceConfig = new PlaywrightServiceConfig();\n\nexport const exitWithFailureMessage = (\n error: {\n key: string;\n message: string;\n formatWithErrorDetails?: (errorDetails: string) => string;\n },\n errorDetails?: string,\n): never => {\n console.log();\n\n if (error.formatWithErrorDetails && errorDetails) {\n console.error(error.formatWithErrorDetails(errorDetails));\n } else {\n console.error(error.message);\n }\n // eslint-disable-next-line n/no-process-exit\n process.exit(1);\n};\n\nexport const throwErrorWithFailureMessage = (\n error: {\n key: string;\n message: string;\n formatWithErrorDetails?: (errorDetails: string) => string;\n },\n errorDetails?: string,\n): never => {\n console.log();\n\n const finalMessage =\n error.formatWithErrorDetails && errorDetails\n ? error.formatWithErrorDetails(errorDetails)\n : error.message;\n\n throw new Error(finalMessage);\n};\n\nexport const populateValuesFromServiceUrl = (): {\n region: string;\n domain: string;\n accountId: string;\n} | null => {\n // Service URL format: wss://<region>.api.playwright.microsoft.com/accounts/<workspace-id>/browsers\n const url = process.env[\"PLAYWRIGHT_SERVICE_URL\"]!;\n if (url) {\n const parts = url.split(\"/\");\n\n if (parts.length > 2) {\n const subdomainParts = parts[2]!.split(\".\");\n const region = subdomainParts.length > 0 ? subdomainParts[0] : null;\n const domain = subdomainParts.slice(2).join(\".\");\n const accountId = parts[4];\n\n return { region: region!, domain: domain!, accountId: accountId! };\n }\n }\n return null;\n};\n\nexport const getAccessToken = (): string | undefined => {\n return process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_ACCESS_TOKEN];\n};\n\nexport const getServiceBaseURL = (): string | undefined => {\n return process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_URL];\n};\n\nexport const isValidGuid = (guid: string | null | undefined): boolean => {\n if (!guid) {\n return false;\n }\n const guidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n return guidRegex.test(guid);\n};\n\nexport const getAndSetRunId = (): string => {\n const runId = randomUUID();\n process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_ID] = runId;\n return runId;\n};\n\nexport const getServiceWSEndpoint = (runId: string, os: string, apiVersion: string): string => {\n return `${getServiceBaseURL()}?runId=${encodeURIComponent(runId)}&os=${os}&api-version=${apiVersion}`;\n};\n\nexport const validateServiceUrl = (): void => {\n const serviceUrl = getServiceBaseURL();\n if (!serviceUrl) {\n exitWithFailureMessage(ServiceErrorMessageConstants.NO_SERVICE_URL_ERROR);\n }\n};\n\nexport const ValidateRunID = (runID: string): void => {\n const isValidRunID = isValidGuid(runID);\n if (!isValidRunID) {\n const errorMessage = ServiceErrorMessageConstants.INVALID_RUN_ID_FORMAT.message;\n throw new Error(errorMessage);\n }\n};\nexport const validateMptPAT = (\n validationFailureCallback: (error: { key: string; message: string }) => void,\n): void => {\n try {\n const accessToken = getAccessToken();\n const result = populateValuesFromServiceUrl();\n if (!accessToken) {\n validationFailureCallback(ServiceErrorMessageConstants.NO_AUTH_ERROR);\n }\n const claims = parseJwt<Partial<AccessTokenClaims>>(accessToken!);\n if (!claims.exp) {\n validationFailureCallback(ServiceErrorMessageConstants.INVALID_MPT_PAT_ERROR);\n }\n if (Date.now() >= claims.exp! * 1000) {\n validationFailureCallback(ServiceErrorMessageConstants.EXPIRED_MPT_PAT_ERROR);\n }\n if (result!.accountId !== claims!.pwid) {\n validationFailureCallback(ServiceErrorMessageConstants.WORKSPACE_MISMATCH_ERROR);\n }\n } catch (err) {\n coreLogger.error(err);\n exitWithFailureMessage(ServiceErrorMessageConstants.INVALID_MPT_PAT_ERROR);\n }\n};\nconst isTokenExpiringSoon = (expirationTime: number, currentTime: number): boolean => {\n return expirationTime * 1000 - currentTime <= Constants.SevenDaysInMS;\n};\n\nconst warnAboutTokenExpiry = (expirationTime: number, currentTime: number): void => {\n const daysToExpiration = Math.ceil((expirationTime * 1000 - currentTime) / Constants.OneDayInMS);\n const expirationDate = new Date(expirationTime * 1000).toLocaleDateString();\n const expirationWarning = `Warning: The access token used for this test run will expire in ${daysToExpiration} days on ${expirationDate}. Generate a new token from the portal to avoid failures. For a simpler, more secure solution, switch to Microsoft Entra ID and eliminate token management. https://learn.microsoft.com/entra/identity/`;\n console.warn(expirationWarning);\n};\n\nexport const warnIfAccessTokenCloseToExpiry = (): void => {\n const accessToken = getAccessToken();\n if (!accessToken) {\n throw new Error(ServiceErrorMessageConstants.NO_AUTH_ERROR.message);\n }\n const claims = parseJwt<JwtPayload>(accessToken!);\n const currentTime = Date.now();\n if (isTokenExpiringSoon(claims.exp!, currentTime)) {\n warnAboutTokenExpiry(claims.exp!, currentTime);\n }\n};\n\nexport const fetchOrValidateAccessToken = async (credential?: TokenCredential): Promise<string> => {\n const entraIdAccessToken = createEntraIdAccessToken(credential);\n // Fetch a token or refresh if needed in a single call\n if (entraIdAccessToken.doesEntraIdAccessTokenNeedRotation()) {\n await entraIdAccessToken.fetchEntraIdAccessToken();\n }\n const token = getAccessToken();\n if (!token) {\n throw new Error(ServiceErrorMessageConstants.NO_AUTH_ERROR.message);\n }\n return token;\n};\n\nexport const getVersionInfo = (version: string): VersionInfo => {\n const regex = /^(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?/;\n const match = version.match(regex);\n const versionInfo = {\n major: 0,\n minor: 0,\n patch: 0,\n };\n versionInfo.major = match && match[1] ? parseInt(match[1], 10) : 0;\n versionInfo.minor = match && match[2] ? parseInt(match[2], 10) : 0;\n versionInfo.patch = match && match[3] ? parseInt(match[3], 10) : 0;\n return versionInfo;\n};\n\nexport const validatePlaywrightVersion = (): void => {\n const minimumSupportedVersion = Constants.MinimumSupportedPlaywrightVersion;\n const installedVersion = getPlaywrightVersion();\n\n const minimumSupportedVersionInfo = getVersionInfo(minimumSupportedVersion);\n const installedVersionInfo = getVersionInfo(installedVersion);\n\n const isInstalledVersionGreater =\n installedVersionInfo.major > minimumSupportedVersionInfo.major ||\n (installedVersionInfo.major === minimumSupportedVersionInfo.major &&\n installedVersionInfo.minor >= minimumSupportedVersionInfo.minor);\n if (!isInstalledVersionGreater) {\n exitWithFailureMessage(ServiceErrorMessageConstants.INVALID_PLAYWRIGHT_VERSION_ERROR);\n }\n};\n\nexport const getTestRunConfig = (config: FullConfig): RunConfig => {\n const maxWorkers = config.workers || config.metadata.actualWorkers;\n const frameWorkVersion = config.version;\n\n const testRunConfig: RunConfig = {\n framework: {\n name: RunConfigConstants.TEST_FRAMEWORK_NAME,\n version: frameWorkVersion,\n runnerName: RunConfigConstants.TEST_FRAMEWORK_RUNNERNAME,\n },\n sdkLanguage: RunConfigConstants.TEST_SDK_LANGUAGE,\n maxWorkers: maxWorkers,\n };\n return testRunConfig;\n};\n\nexport function getTestRunApiUrl(): string {\n const result = populateValuesFromServiceUrl();\n const runId = process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_ID];\n\n if (!result?.region || !result?.domain || !result?.accountId) {\n exitWithFailureMessage(ServiceErrorMessageConstants.NO_SERVICE_URL_ERROR);\n }\n const baseUrl = `https://${result?.region}.reporting.api.${result?.domain}/playwrightworkspaces/${result?.accountId}/test-runs`;\n const url = runId ? `${baseUrl}/${runId}` : baseUrl;\n\n return `${url}?api-version=${Constants.LatestAPIVersion}`;\n}\n\nexport function isNullOrEmpty(str: string | null | undefined): boolean {\n return !str || str.trim() === \"\";\n}\n\nasync function runCommand(command: string): Promise<string> {\n return new Promise((resolve, reject) => {\n exec(command, (error, stdout, stderr) => {\n if (error) {\n reject(error);\n return;\n }\n if (stderr) {\n reject(new Error(stderr));\n return;\n }\n resolve(stdout.trim());\n });\n });\n}\n\nexport async function getRunName(ciInfo: CIInfo): Promise<string> {\n if (\n ciInfo.providerName === CI_PROVIDERS.GITHUB &&\n process.env[\"GITHUB_EVENT_NAME\"] === \"pull_request\"\n ) {\n const prNumber: string = `${process.env[\"GITHUB_REF_NAME\"]?.split(\"/\")[0]}`;\n const prLink: string = `${process.env[\"GITHUB_REPOSITORY\"]}/pull/${prNumber}`;\n return `PR# ${prNumber} on Repo: ${process.env[\"GITHUB_REPOSITORY\"]} (${prLink})`;\n }\n\n try {\n const gitVersion = await runCommand(GitHubActionsConstants.GIT_VERSION_COMMAND);\n if (isNullOrEmpty(gitVersion)) {\n throw new Error(\"Git is not installed on the machine\");\n }\n const isInsideWorkTree = await runCommand(GitHubActionsConstants.GIT_REV_PARSE);\n if (isInsideWorkTree !== \"true\") {\n throw new Error(\"Not inside a git repository\");\n }\n const gitCommitMessage = await runCommand(GitHubActionsConstants.GIT_COMMIT_MESSAGE_COMMAND);\n return gitCommitMessage;\n } catch (err) {\n coreLogger.error(`Error in getting git commit message: ${err}.`);\n return \"\";\n }\n}\n\nexport function extractErrorMessage(responseBody: string): string {\n if (!responseBody) {\n return \"\";\n }\n\n try {\n const errorResponse = JSON.parse(responseBody);\n if (errorResponse.error && errorResponse.error.message) {\n return errorResponse.error.message;\n }\n return responseBody;\n } catch (e) {\n return responseBody;\n }\n}\n"]}
|