@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"}
|
|
@@ -53,5 +53,9 @@ exports.ServiceErrorMessageConstants = {
|
|
|
53
53
|
key: "InvalidRunIdFormat",
|
|
54
54
|
message: "The Run ID must be a valid GUID format. Please provide a valid GUID for the Run ID.",
|
|
55
55
|
},
|
|
56
|
+
INVALID_AUTH_TYPE_ERROR: {
|
|
57
|
+
key: "InvalidAuthTypeError",
|
|
58
|
+
message: "Invalid authentication type specified. Please use either ENTRA_ID or ACCESS_TOKEN.",
|
|
59
|
+
},
|
|
56
60
|
};
|
|
57
61
|
//# sourceMappingURL=messages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/common/messages.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAErB,QAAA,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;;;AAErB,QAAA,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,CAAC;IAClB,KAAK,EA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D,OAAO,gBAAK,CAAC,uBAAuB,CAAC;IACvC,CAAC;IAED,IAAW,eAAe;QACxB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED,IAAW,eAAe,CAAC,KAAa;QACtC,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;IAChC,CAAC;IAEM,KAAK,CAAC,UAAU;QACrB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,YAAY,GAAG,kCAAc,CAAC,SAAS,EAAE,CAAC;YAChD,IAAI,CAAC,OAAO,GAAG,MAAM,IAAA,qBAAU,EAAC,YAAY,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,eAAe,GAAG,CAAC,OAA4C,EAAQ,EAAE;QACvE,IAAI,CAAC,OAAO;YAAE,OAAO;QAErB,MAAM,oBAAoB,GACxB,OAAO,CAAC,GAAG,CAAC,2CAA4B,CAAC,oBAAoB,CAAC,KAAK,MAAM,CAAC;QAC5E,IAAI,oBAAoB,EAAE,CAAC;YACzB,IAAI,OAAO,CAAC,eAAe,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;gBAChE,MAAM,YAAY,GAAG,0CAA4B,CAAC,iCAAiC,CAAC,OAAO,CAAC;gBAC5F,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;YAChC,CAAC;YACD,OAAO;QACT,CAAC;IACH,CAAC,CAAC;IAEF,UAAU,GAAG,CACX,OAA4C,EAC5C,sBAA+B,KAAK,EAC9B,EAAE;QACR,IAAI,mBAAmB,EAAE,CAAC;YACxB,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;
|
|
1
|
+
{"version":3,"file":"playwrightServiceConfig.js","sourceRoot":"","sources":["../../../src/common/playwrightServiceConfig.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,iDAKwB;AAExB,gDAA8E;AAC9E,kEAA4D;AAC5D,yC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C,OAAO,CAAC,GAAG,CAAC,2CAA4B,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAClE,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC;gBACnB,IAAA,wBAAa,EAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gBAC7B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;gBAC3B,OAAO,CAAC,GAAG,CAAC,2CAA4B,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;YAC5E,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,KAAK,GAAG,IAAA,yBAAc,GAAE,CAAC;YAChC,CAAC;QACH,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,2CAA4B,CAAC,oBAAoB,CAAC,IAAI,OAAO,EAAE,OAAO,EAAE,CAAC;YACxF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;YAC/B,OAAO,CAAC,GAAG,CAAC,2CAA4B,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC;QAChF,CAAC;QACD,IAAI,OAAO,EAAE,EAAE,EAAE,CAAC;YAChB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,EAAE,CAAC;YAC5B,OAAO,CAAC,GAAG,CAAC,2CAA4B,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;AAEQ,0DAAuB","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,CAAC;IAEZ;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;;;OAMG;IACH,
|
|
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,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AC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACtD,oBAAoB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,WAAW,CAAC,EAAE,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAC;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"}
|
|
@@ -126,11 +126,6 @@ const getServiceConfig = (config, options) => {
|
|
|
126
126
|
globalFunctions.globalTeardown = playwrightServiceUtils_js_1.globalPaths.teardown;
|
|
127
127
|
}
|
|
128
128
|
performOneTimeOperation(options);
|
|
129
|
-
if (options?.useCloudHostedBrowsers === false) {
|
|
130
|
-
return {
|
|
131
|
-
...globalFunctions,
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
129
|
if (!process.env[constants_js_1.InternalEnvironmentVariables.MPT_CLOUD_HOSTED_BROWSER_USED]) {
|
|
135
130
|
process.env[constants_js_1.InternalEnvironmentVariables.MPT_CLOUD_HOSTED_BROWSER_USED] = "true";
|
|
136
131
|
console.log("\nRunning tests using Azure Playwright service.");
|
|
@@ -181,9 +176,29 @@ exports.getServiceConfig = getServiceConfig;
|
|
|
181
176
|
* ```
|
|
182
177
|
*/
|
|
183
178
|
const getConnectOptions = async (options) => {
|
|
184
|
-
const playwrightServiceConfig =
|
|
179
|
+
const playwrightServiceConfig = playwrightServiceConfig_js_1.PlaywrightServiceConfig.instance;
|
|
185
180
|
playwrightServiceConfig.setOptions(options, true);
|
|
186
|
-
|
|
181
|
+
performOneTimeOperation(options);
|
|
182
|
+
playwrightServiceConfig.serviceAuthType =
|
|
183
|
+
options?.serviceAuthType || constants_js_1.DefaultConnectOptionsConstants.DEFAULT_SERVICE_AUTH_TYPE;
|
|
184
|
+
let token;
|
|
185
|
+
if (playwrightServiceConfig.serviceAuthType === constants_js_1.ServiceAuth.ENTRA_ID) {
|
|
186
|
+
if (!options?.credential) {
|
|
187
|
+
throw new Error(messages_js_1.ServiceErrorMessageConstants.NO_CRED_ENTRA_AUTH_ERROR.message);
|
|
188
|
+
}
|
|
189
|
+
playwrightServiceEntra_js_1.default.entraIdAccessToken = options.credential;
|
|
190
|
+
token = await (0, utils_js_1.fetchOrValidateAccessToken)(options.credential);
|
|
191
|
+
}
|
|
192
|
+
else if (playwrightServiceConfig.serviceAuthType === constants_js_1.ServiceAuth.ACCESS_TOKEN) {
|
|
193
|
+
(0, utils_js_1.validateMptPAT)(utils_js_1.throwErrorWithFailureMessage);
|
|
194
|
+
token = (0, utils_js_1.getAccessToken)();
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
throw new Error(messages_js_1.ServiceErrorMessageConstants.INVALID_AUTH_TYPE_ERROR.message);
|
|
198
|
+
}
|
|
199
|
+
if (!token) {
|
|
200
|
+
throw new Error(messages_js_1.ServiceErrorMessageConstants.NO_AUTH_ERROR.message);
|
|
201
|
+
}
|
|
187
202
|
return {
|
|
188
203
|
wsEndpoint: (0, utils_js_1.getServiceWSEndpoint)(playwrightServiceConfig.runId, playwrightServiceConfig.serviceOs, playwrightServiceConfig.apiVersion),
|
|
189
204
|
options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playwrightService.js","source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;KACF,CAAC;AACJ,CAAC,CAAC;AAEyB,8CAAiB","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,yDAIgC;AAChC,4FAAyD;AACzD,qFAA+E;AAC/E,oGAAiE;AAEjE,gDAa2B;AAC3B,uDAAqE;AAErE,2EAA0D;AAE1D,MAAM,uBAAuB,GAAG,CAAC,OAA4C,EAAQ,EAAE;IACrF,MAAM,oBAAoB,GACxB,OAAO,CAAC,GAAG,CAA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AC,aAAa,CAAC,OAAO,CAAC,CAAC;IACtE,CAAC;IAED,OAAO;QACL,UAAU,EAAE,IAAA,+BAAoB,EAC9B,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,IAAA,4BAAiB,GAAE,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;AAEyB,8CAAiB","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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playwrightServiceUtils-cjs.cjs","sourceRoot":"","sources":["../../../src/core/playwrightServiceUtils-cjs.cts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAElC,kEAA6B;AAEhB,QAAA,WAAW,GAAG;IACzB,KAAK,EAAE,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,6CAA6C,CAAC;IAC1E,QAAQ,EAAE,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,gDAAgD,CAAC;CACjF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport path from \"node:path\";\n\nexport const globalPaths = {\n setup: path.join(__dirname, \"./global/playwright-service-global-setup.js\"),\n teardown: path.join(__dirname, \"./global/playwright-service-global-teardown.js\"),\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playwrightServiceUtils-cjs.d.cts","sourceRoot":"","sources":["../../../src/core/playwrightServiceUtils-cjs.cts"],"names":[],"mappings":"AAKA,eAAO,MAAM,WAAW;;;CAGvB,CAAC"}
|
|
@@ -9,4 +9,4 @@ exports.globalPaths = {
|
|
|
9
9
|
setup: node_path_1.default.join(__dirname, "./global/playwright-service-global-setup.js"),
|
|
10
10
|
teardown: node_path_1.default.join(__dirname, "./global/playwright-service-global-teardown.js"),
|
|
11
11
|
};
|
|
12
|
-
//# sourceMappingURL=playwrightServiceUtils.
|
|
12
|
+
//# sourceMappingURL=playwrightServiceUtils-cjs.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPackageVersion-cjs.cjs","sourceRoot":"","sources":["../../../src/utils/getPackageVersion-cjs.cts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAElC,kEAA6B;AAC7B,mDAAiD;AAE1C,MAAM,2BAA2B,GAAG,CAAC,MAAc,EAAU,EAAE;IACpE,IAAI,CAAC;QACH,iEAAiE;QACjE,MAAM,OAAO,GAAG,OAAO,CAAC,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC;QAC9E,OAAO,OAAO,CAAC;IACjB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,sBAAU,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;QAC3D,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC;AATW,QAAA,2BAA2B,+BAStC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport path from \"node:path\";\nimport { coreLogger } from \"../common/logger.js\";\n\nexport const 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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPackageVersion-cjs.d.cts","sourceRoot":"","sources":["../../../src/utils/getPackageVersion-cjs.cts"],"names":[],"mappings":"AAMA,eAAO,MAAM,2BAA2B,GAAI,QAAQ,MAAM,KAAG,MAS5D,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.getPackageVersionFromFolder = void 0;
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
8
|
+
const logger_js_1 = require("../common/logger.js");
|
|
9
|
+
const getPackageVersionFromFolder = (folder) => {
|
|
10
|
+
try {
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
12
|
+
const version = require(node_path_1.default.join(__dirname, folder, "package.json")).version;
|
|
13
|
+
return version;
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
logger_js_1.coreLogger.error("Error fetching package version:", error);
|
|
17
|
+
return "";
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.getPackageVersionFromFolder = getPackageVersionFromFolder;
|
|
21
|
+
//# sourceMappingURL=getPackageVersion-cjs.cjs.map
|
|
@@ -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,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;
|
|
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,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAMxD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAgB,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAK3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,eAAO,MAAM,iBAAiB,QAAO,MAapC,CAAC;AAIF,eAAO,MAAM,s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Ae,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"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright (c) Microsoft Corporation.
|
|
3
3
|
// Licensed under the MIT License.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.getTestRunConfig = exports.validatePlaywrightVersion = exports.getVersionInfo = exports.
|
|
5
|
+
exports.getTestRunConfig = exports.validatePlaywrightVersion = exports.getVersionInfo = exports.fetchOrValidateAccessToken = exports.warnIfAccessTokenCloseToExpiry = exports.validateMptPAT = exports.ValidateRunID = exports.validateServiceUrl = exports.getServiceWSEndpoint = exports.getAndSetRunId = exports.isValidGuid = exports.getServiceBaseURL = exports.getAccessToken = exports.populateValuesFromServiceUrl = exports.throwErrorWithFailureMessage = exports.exitWithFailureMessage = exports.getPackageVersion = exports.parseJwt = exports.getPlaywrightVersion = void 0;
|
|
6
6
|
exports.getTestRunApiUrl = getTestRunApiUrl;
|
|
7
7
|
exports.isNullOrEmpty = isNullOrEmpty;
|
|
8
8
|
exports.getRunName = getRunName;
|
|
@@ -12,18 +12,33 @@ const constants_js_1 = require("../common/constants.js");
|
|
|
12
12
|
const messages_js_1 = require("../common/messages.js");
|
|
13
13
|
const logger_js_1 = require("../common/logger.js");
|
|
14
14
|
const node_process_1 = tslib_1.__importDefault(require("node:process"));
|
|
15
|
-
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
16
15
|
const node_crypto_1 = require("node:crypto");
|
|
17
16
|
const parseJwt_js_1 = require("./parseJwt.js");
|
|
18
17
|
const getPlaywrightVersion_js_1 = require("./getPlaywrightVersion.js");
|
|
19
18
|
const entraIdAccessToken_js_1 = require("../common/entraIdAccessToken.js");
|
|
20
19
|
const cIInfoProvider_js_1 = require("./cIInfoProvider.js");
|
|
21
20
|
const child_process_1 = require("child_process");
|
|
21
|
+
const getPackageVersion_js_1 = require("./getPackageVersion.js");
|
|
22
22
|
// Re-exporting for backward compatibility
|
|
23
23
|
var getPlaywrightVersion_js_2 = require("./getPlaywrightVersion.js");
|
|
24
24
|
Object.defineProperty(exports, "getPlaywrightVersion", { enumerable: true, get: function () { return getPlaywrightVersion_js_2.getPlaywrightVersion; } });
|
|
25
25
|
var parseJwt_js_2 = require("./parseJwt.js");
|
|
26
26
|
Object.defineProperty(exports, "parseJwt", { enumerable: true, get: function () { return parseJwt_js_2.parseJwt; } });
|
|
27
|
+
const getPackageVersion = () => {
|
|
28
|
+
// hacky way to get package version
|
|
29
|
+
// try from dist folder first (customer perspective)
|
|
30
|
+
const distVersion = (0, getPackageVersion_js_1.getPackageVersionFromFolder)("../../../");
|
|
31
|
+
if (distVersion) {
|
|
32
|
+
return distVersion;
|
|
33
|
+
}
|
|
34
|
+
// if not found, try from src folder (internal test suite)
|
|
35
|
+
const srcVersion = (0, getPackageVersion_js_1.getPackageVersionFromFolder)("../../");
|
|
36
|
+
if (srcVersion) {
|
|
37
|
+
return srcVersion;
|
|
38
|
+
}
|
|
39
|
+
return "unknown-version";
|
|
40
|
+
};
|
|
41
|
+
exports.getPackageVersion = getPackageVersion;
|
|
27
42
|
// const playwrightServiceConfig = new PlaywrightServiceConfig();
|
|
28
43
|
const exitWithFailureMessage = (error, errorDetails) => {
|
|
29
44
|
console.log();
|
|
@@ -37,6 +52,14 @@ const exitWithFailureMessage = (error, errorDetails) => {
|
|
|
37
52
|
node_process_1.default.exit(1);
|
|
38
53
|
};
|
|
39
54
|
exports.exitWithFailureMessage = exitWithFailureMessage;
|
|
55
|
+
const throwErrorWithFailureMessage = (error, errorDetails) => {
|
|
56
|
+
console.log();
|
|
57
|
+
const finalMessage = error.formatWithErrorDetails && errorDetails
|
|
58
|
+
? error.formatWithErrorDetails(errorDetails)
|
|
59
|
+
: error.message;
|
|
60
|
+
throw new Error(finalMessage);
|
|
61
|
+
};
|
|
62
|
+
exports.throwErrorWithFailureMessage = throwErrorWithFailureMessage;
|
|
40
63
|
const populateValuesFromServiceUrl = () => {
|
|
41
64
|
// Service URL format: wss://<region>.api.playwright.microsoft.com/accounts/<workspace-id>/browsers
|
|
42
65
|
const url = node_process_1.default.env["PLAYWRIGHT_SERVICE_URL"];
|
|
@@ -129,6 +152,9 @@ const warnAboutTokenExpiry = (expirationTime, currentTime) => {
|
|
|
129
152
|
};
|
|
130
153
|
const warnIfAccessTokenCloseToExpiry = () => {
|
|
131
154
|
const accessToken = (0, exports.getAccessToken)();
|
|
155
|
+
if (!accessToken) {
|
|
156
|
+
throw new Error(messages_js_1.ServiceErrorMessageConstants.NO_AUTH_ERROR.message);
|
|
157
|
+
}
|
|
132
158
|
const claims = (0, parseJwt_js_1.parseJwt)(accessToken);
|
|
133
159
|
const currentTime = Date.now();
|
|
134
160
|
if (isTokenExpiringSoon(claims.exp, currentTime)) {
|
|
@@ -138,41 +164,17 @@ const warnIfAccessTokenCloseToExpiry = () => {
|
|
|
138
164
|
exports.warnIfAccessTokenCloseToExpiry = warnIfAccessTokenCloseToExpiry;
|
|
139
165
|
const fetchOrValidateAccessToken = async (credential) => {
|
|
140
166
|
const entraIdAccessToken = (0, entraIdAccessToken_js_1.createEntraIdAccessToken)(credential);
|
|
141
|
-
|
|
167
|
+
// Fetch a token or refresh if needed in a single call
|
|
168
|
+
if (entraIdAccessToken.doesEntraIdAccessTokenNeedRotation()) {
|
|
142
169
|
await entraIdAccessToken.fetchEntraIdAccessToken();
|
|
143
170
|
}
|
|
144
|
-
|
|
171
|
+
const token = (0, exports.getAccessToken)();
|
|
172
|
+
if (!token) {
|
|
145
173
|
throw new Error(messages_js_1.ServiceErrorMessageConstants.NO_AUTH_ERROR.message);
|
|
146
174
|
}
|
|
147
|
-
return
|
|
175
|
+
return token;
|
|
148
176
|
};
|
|
149
177
|
exports.fetchOrValidateAccessToken = fetchOrValidateAccessToken;
|
|
150
|
-
const getPackageVersionFromFolder = (folder) => {
|
|
151
|
-
try {
|
|
152
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
153
|
-
const version = require(node_path_1.default.join(__dirname, folder, "package.json")).version;
|
|
154
|
-
return version;
|
|
155
|
-
}
|
|
156
|
-
catch (error) {
|
|
157
|
-
logger_js_1.coreLogger.error("Error fetching package version:", error);
|
|
158
|
-
return "";
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
const getPackageVersion = () => {
|
|
162
|
-
// hacky way to get package version
|
|
163
|
-
// try from dist folder first (customer perspective)
|
|
164
|
-
const distVersion = getPackageVersionFromFolder("../../../");
|
|
165
|
-
if (distVersion) {
|
|
166
|
-
return distVersion;
|
|
167
|
-
}
|
|
168
|
-
// if not found, try from src folder (internal test suite)
|
|
169
|
-
const srcVersion = getPackageVersionFromFolder("../../");
|
|
170
|
-
if (srcVersion) {
|
|
171
|
-
return srcVersion;
|
|
172
|
-
}
|
|
173
|
-
return "unknown-version";
|
|
174
|
-
};
|
|
175
|
-
exports.getPackageVersion = getPackageVersion;
|
|
176
178
|
const getVersionInfo = (version) => {
|
|
177
179
|
const regex = /^(\d+)(?:\.(\d+))?(?:\.(\d+))?/;
|
|
178
180
|
const match = version.match(regex);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils/utils.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAk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ACrC,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;;;AAyPlC,4CAWC;AAED,sCAEC;AAkBD,gCAyBC;AAED,kDAcC;;AAhUD,yDAMgC;AAChC,uDAAqE;AACrE,mDAAiD;AAEjD,wEAAmC;AACnC,6CAAyC;AACzC,+CAAyC;AACzC,uEAAiE;AACjE,2EAA2E;AAE3E,2DAA2D;AAC3D,iDAAqC;AACrC,iEAAqE;AAErE,0CAA0C;AAC1C,qEAAiE;AAAxD,+HAAA,oBAAoB,OAAA;AAC7B,6CAAyC;AAAhC,uGAAA,QAAQ,OAAA;AAEV,MAAM,iBAAiB,GAAG,GAAW,EAAE;IAC5C,mCAAmC;IACnC,oDAAoD;IACpD,MAAM,WAAW,GAAG,IAAA,kDAA2B,EAAC,WAAW,CAAC,CAAC;IAC7D,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,0DAA0D;IAC1D,MAAM,UAAU,GAAG,IAAA,kDAA2B,EAAC,QAAQ,CAAC,CAAC;IACzD,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAbW,QAAA,iBAAiB,qBAa5B;AAEF,iEAAiE;AAE1D,MAAM,sBAAsB,GAAG,CACpC,KAIC,EACD,YAAqB,EACd,EAAE;IACT,OAAO,CAAC,GAAG,EAAE,CAAC;IAEd,IAAI,KAAK,CAAC,sBAAsB,IAAI,YAAY,EAAE,CAAC;QACjD,OAAO,CAAC,KAAK,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AAK,CAAC,wCAAwC,GAAG,GAAG,CAAC,CAAC;QACjE,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,SAAgB,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"]}
|