From 0dcb6abb7f09f9f2f66bbafdd8c3cff5d952059d Mon Sep 17 00:00:00 2001 From: Siddharth Singha Roy Date: Fri, 20 Dec 2024 06:13:20 +0000 Subject: [PATCH 1/8] chore(playwrighttesting): use playwright OSS types --- .../microsoft-playwright-testing/package.json | 2 +- .../microsoft-playwright-testing.api.md | 11 +- .../src/common/types.ts | 103 ++++++------------ .../global/playwright-service-global-setup.ts | 2 +- .../playwright-service-global-teardown.ts | 2 +- .../microsoft-playwright-testing/src/index.ts | 2 - .../test/utils/clInfoProvider.spec.ts | 4 +- 7 files changed, 38 insertions(+), 88 deletions(-) diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/package.json b/sdk/playwrighttesting/microsoft-playwright-testing/package.json index 1f6abb6361c4..7079283fa48c 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/package.json +++ b/sdk/playwrighttesting/microsoft-playwright-testing/package.json @@ -89,7 +89,7 @@ "typescript": "~5.7.2" }, "peerDependencies": { - "@playwright/test": "^1.43.1" + "@playwright/test": "^1.47.0" }, "prettier": "@azure/eslint-plugin-azure-sdk/prettier.json", "//sampleConfiguration": { diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/review/microsoft-playwright-testing.api.md b/sdk/playwrighttesting/microsoft-playwright-testing/review/microsoft-playwright-testing.api.md index 306213858dd3..6628689ad04d 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/review/microsoft-playwright-testing.api.md +++ b/sdk/playwrighttesting/microsoft-playwright-testing/review/microsoft-playwright-testing.api.md @@ -4,6 +4,7 @@ ```ts +import type { ConnectOptions } from '@playwright/test'; import type { PlaywrightTestConfig } from '@playwright/test'; import type { TokenCredential } from '@azure/identity'; @@ -15,16 +16,6 @@ export type BrowserConnectOptions = EndpointOptions & { options: ConnectOptions; }; -// @public -export type ConnectOptions = { - headers?: { - [key: string]: string; - }; - exposeNetwork?: string; - timeout?: number; - slowMo?: number; -}; - // @public export type EndpointOptions = { wsEndpoint: string; diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/src/common/types.ts b/sdk/playwrighttesting/microsoft-playwright-testing/src/common/types.ts index b857cc4c7718..88ec8a78d6a3 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/src/common/types.ts +++ b/sdk/playwrighttesting/microsoft-playwright-testing/src/common/types.ts @@ -2,24 +2,11 @@ // Licensed under the MIT License. import type { Location, TestStep } from "@playwright/test/reporter"; +import type { ConnectOptions } from "@playwright/test"; import type { ServiceAuth, ServiceOS } from "./constants"; import type { TokenCredential } from "@azure/identity"; -export type JwtPayload = { - aid?: string; - iss?: string; - sub?: string; - aud?: string[] | string; - exp?: number; - nbf?: number; - iat?: number; - jti?: string; -}; - -export type AccessTokenClaims = JwtPayload & { - aid?: string; - accountId?: string; -}; +// Public APIs /** * @public @@ -35,47 +22,6 @@ export type EndpointOptions = { wsEndpoint: string; }; -/** - * @public - * - * Connect options for the service. - */ -export type ConnectOptions = { - /** - * @public - * - * Additional HTTP headers to be sent with web socket connect request. - */ - headers?: { [key: string]: string }; - - /** - * @public - * - * Exposes network available on the connecting client to the browser being connected to. - * - * @defaultValue `` - */ - exposeNetwork?: string; - - /** - * @public - * - * Maximum time in milliseconds to wait for the connection to be established. - * - * @defaultValue `30000` - */ - timeout?: number; - - /** - * @public - * - * Slows down Playwright operations by the specified amount of milliseconds. - * - * @defaultValue `0` - */ - slowMo?: number; -}; - /** * @public * @@ -206,15 +152,6 @@ export type OsType = (typeof ServiceOS)[keyof typeof ServiceOS]; */ export type AuthenticationType = (typeof ServiceAuth)[keyof typeof ServiceAuth]; -export type ErrorDetails = { - message: string; - location?: Location; -}; -export type ApiErrorMessage = { - [key: string]: { - [key: number]: string; - }; -}; /** * @public * @@ -251,6 +188,36 @@ export interface MPTReporterConfig { */ enableResultPublish?: boolean; } + +// Internal APIs + +export type JwtPayload = { + aid?: string; + iss?: string; + sub?: string; + aud?: string[] | string; + exp?: number; + nbf?: number; + iat?: number; + jti?: string; +}; + +export type AccessTokenClaims = JwtPayload & { + aid?: string; + accountId?: string; +}; + +export type ErrorDetails = { + message: string; + location?: Location; +}; + +export type ApiErrorMessage = { + [key: string]: { + [key: number]: string; + }; +}; + export type DedupedStep = { step: TestStep; count: number; duration: number }; export type RawTestStep = { @@ -283,9 +250,3 @@ export type PackageManager = { runCommand: (command: string, args: string) => string; getVersionFromStdout: (stdout: string) => string; }; - -// Playwright OSS Types - -export interface FullConfig { - configFile?: string; -} diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/src/core/global/playwright-service-global-setup.ts b/sdk/playwrighttesting/microsoft-playwright-testing/src/core/global/playwright-service-global-setup.ts index fe4a07fc8988..342dfef108a5 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/src/core/global/playwright-service-global-setup.ts +++ b/sdk/playwrighttesting/microsoft-playwright-testing/src/core/global/playwright-service-global-setup.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import { dirname } from "path"; -import type { FullConfig } from "../../common/types"; +import type { FullConfig } from "@playwright/test"; import playwrightServiceEntra from "../playwrightServiceEntra"; import { loadCustomerGlobalFunction } from "../../common/executor"; import customerConfig from "../../common/customerConfig"; diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/src/core/global/playwright-service-global-teardown.ts b/sdk/playwrighttesting/microsoft-playwright-testing/src/core/global/playwright-service-global-teardown.ts index 6bcee563f529..768c3f005b39 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/src/core/global/playwright-service-global-teardown.ts +++ b/sdk/playwrighttesting/microsoft-playwright-testing/src/core/global/playwright-service-global-teardown.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import { dirname } from "path"; -import type { FullConfig } from "../../common/types"; +import type { FullConfig } from "@playwright/test"; import playwrightServiceEntra from "../playwrightServiceEntra"; import { loadCustomerGlobalFunction } from "../../common/executor"; import customerConfig from "../../common/customerConfig"; diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/src/index.ts b/sdk/playwrighttesting/microsoft-playwright-testing/src/index.ts index a752b03e5ebd..563f13ab839b 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/src/index.ts +++ b/sdk/playwrighttesting/microsoft-playwright-testing/src/index.ts @@ -14,7 +14,6 @@ import type { BrowserConnectOptions, MPTReporterConfig, EndpointOptions, - ConnectOptions, PlaywrightServiceAdditionalOptions, } from "./common/types"; import { getServiceConfig, getConnectOptions } from "./core/playwrightService"; @@ -29,7 +28,6 @@ export { AuthenticationType, BrowserConnectOptions, EndpointOptions, - ConnectOptions, MPTReporterConfig, PlaywrightServiceAdditionalOptions, }; diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/test/utils/clInfoProvider.spec.ts b/sdk/playwrighttesting/microsoft-playwright-testing/test/utils/clInfoProvider.spec.ts index 18f1a577140e..341c0dd660b5 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/test/utils/clInfoProvider.spec.ts +++ b/sdk/playwrighttesting/microsoft-playwright-testing/test/utils/clInfoProvider.spec.ts @@ -4,11 +4,11 @@ import sinon from "sinon"; describe("CIInfoProvider", () => { let sandbox: sinon.SinonSandbox; - let environmentVariables: NodeJS.ProcessEnv; + let environmentVariables: NodeJS.ProcessEnv = process.env; beforeEach(() => { sandbox = sinon.createSandbox(); - environmentVariables = process.env; + process.env = {}; }); afterEach(() => { From baea8239395d1e820bbb1e6f41d81395750b342d Mon Sep 17 00:00:00 2001 From: Siddharth Singha Roy Date: Fri, 20 Dec 2024 08:51:07 +0000 Subject: [PATCH 2/8] chore(): change MPTReporterConfiguration to ReporterConfiguration as per APIView review --- .../microsoft-playwright-testing-reporter.api.md | 2 +- .../review/microsoft-playwright-testing.api.md | 12 ++++++------ .../microsoft-playwright-testing/src/common/types.ts | 4 ++-- .../microsoft-playwright-testing/src/index.ts | 4 ++-- .../src/reporter/mptReporter.ts | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/review/microsoft-playwright-testing-reporter.api.md b/sdk/playwrighttesting/microsoft-playwright-testing/review/microsoft-playwright-testing-reporter.api.md index 281bc0b48ee8..9ad2996166ce 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/review/microsoft-playwright-testing-reporter.api.md +++ b/sdk/playwrighttesting/microsoft-playwright-testing/review/microsoft-playwright-testing-reporter.api.md @@ -13,7 +13,7 @@ import type { TestResult } from '@playwright/test/reporter'; // @public class MPTReporter implements Reporter { - constructor(config: Partial); + constructor(config: Partial); onBegin(config: FullConfig, suite: Suite): void; onEnd(result: FullResult): Promise; onTestEnd(test: TestCase, result: TestResult): void; diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/review/microsoft-playwright-testing.api.md b/sdk/playwrighttesting/microsoft-playwright-testing/review/microsoft-playwright-testing.api.md index 6628689ad04d..dceb5819a552 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/review/microsoft-playwright-testing.api.md +++ b/sdk/playwrighttesting/microsoft-playwright-testing/review/microsoft-playwright-testing.api.md @@ -27,12 +27,6 @@ export const getConnectOptions: (options?: Omit PlaywrightTestConfig; -// @public -export interface MPTReporterConfig { - enableGitHubSummary?: boolean; - enableResultPublish?: boolean; -} - // @public export type OsType = (typeof ServiceOS)[keyof typeof ServiceOS]; @@ -49,6 +43,12 @@ export type PlaywrightServiceAdditionalOptions = { runName?: string; }; +// @public +export type ReporterConfiguration = { + enableGitHubSummary?: boolean; + enableResultPublish?: boolean; +}; + // @public export const ServiceAuth: { readonly ENTRA_ID: "ENTRA_ID"; diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/src/common/types.ts b/sdk/playwrighttesting/microsoft-playwright-testing/src/common/types.ts index 88ec8a78d6a3..fda9ee5bd7a2 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/src/common/types.ts +++ b/sdk/playwrighttesting/microsoft-playwright-testing/src/common/types.ts @@ -169,7 +169,7 @@ export type AuthenticationType = (typeof ServiceAuth)[keyof typeof ServiceAuth]; * }); * ``` */ -export interface MPTReporterConfig { +export type ReporterConfiguration = { /** * @public * @@ -187,7 +187,7 @@ export interface MPTReporterConfig { * @defaultValue `true` */ enableResultPublish?: boolean; -} +}; // Internal APIs diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/src/index.ts b/sdk/playwrighttesting/microsoft-playwright-testing/src/index.ts index 563f13ab839b..b19e81254815 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/src/index.ts +++ b/sdk/playwrighttesting/microsoft-playwright-testing/src/index.ts @@ -12,7 +12,7 @@ import type { OsType, AuthenticationType, BrowserConnectOptions, - MPTReporterConfig, + ReporterConfiguration, EndpointOptions, PlaywrightServiceAdditionalOptions, } from "./common/types"; @@ -28,6 +28,6 @@ export { AuthenticationType, BrowserConnectOptions, EndpointOptions, - MPTReporterConfig, + ReporterConfiguration, PlaywrightServiceAdditionalOptions, }; diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/src/reporter/mptReporter.ts b/sdk/playwrighttesting/microsoft-playwright-testing/src/reporter/mptReporter.ts index 18f5c33bb019..eaee446d15fa 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/src/reporter/mptReporter.ts +++ b/sdk/playwrighttesting/microsoft-playwright-testing/src/reporter/mptReporter.ts @@ -29,7 +29,7 @@ import { CIInfoProvider } from "../utils/cIInfoProvider"; import ReporterUtils from "../utils/reporterUtils"; import { ServiceClient } from "../utils/serviceClient"; import { StorageClient } from "../utils/storageClient"; -import type { MPTReporterConfig } from "../common/types"; +import type { ReporterConfiguration } from "../common/types"; import { ServiceErrorMessageConstants } from "../common/messages"; import { validateMptPAT, populateValuesFromServiceUrl } from "../utils/utils"; @@ -78,7 +78,7 @@ class MPTReporter implements Reporter { private testRunUrl: string = ""; private enableResultPublish: boolean = true; - constructor(config: Partial) { + constructor(config: Partial) { if (config?.enableGitHubSummary !== undefined) { this.enableGitHubSummary = config.enableGitHubSummary; } From 09b9ddeac079ee0377570e7bb0ef040dc5af56e4 Mon Sep 17 00:00:00 2001 From: Siddharth Singha Roy Date: Fri, 20 Dec 2024 15:29:02 +0530 Subject: [PATCH 3/8] Update sdk/playwrighttesting/microsoft-playwright-testing/test/utils/clInfoProvider.spec.ts Co-authored-by: Max Schmitt --- .../test/utils/clInfoProvider.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/test/utils/clInfoProvider.spec.ts b/sdk/playwrighttesting/microsoft-playwright-testing/test/utils/clInfoProvider.spec.ts index 341c0dd660b5..e97d1cd96c8c 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/test/utils/clInfoProvider.spec.ts +++ b/sdk/playwrighttesting/microsoft-playwright-testing/test/utils/clInfoProvider.spec.ts @@ -4,7 +4,7 @@ import sinon from "sinon"; describe("CIInfoProvider", () => { let sandbox: sinon.SinonSandbox; - let environmentVariables: NodeJS.ProcessEnv = process.env; + let environmentVariables = process.env; beforeEach(() => { sandbox = sinon.createSandbox(); From 8ab83066685633c69289872812b2c25240879595 Mon Sep 17 00:00:00 2001 From: Siddharth Singha Roy Date: Sun, 22 Dec 2024 15:29:22 +0000 Subject: [PATCH 4/8] chore(): update sample package version --- .../v1/javascript/customising-service-parameters/package.json | 2 +- .../v1/javascript/manually-connecting-to-browsers/package.json | 2 +- .../set-default-authentication-mechanism/package.json | 2 +- .../samples/v1/javascript/using-connect-options/package.json | 2 +- .../v1/typescript/customising-service-parameters/package.json | 2 +- .../v1/typescript/manually-connecting-to-browsers/package.json | 2 +- .../set-default-authentication-mechanism/package.json | 2 +- .../samples/v1/typescript/using-connect-options/package.json | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/customising-service-parameters/package.json b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/customising-service-parameters/package.json index d7407019a989..bfec58aa985f 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/customising-service-parameters/package.json +++ b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/customising-service-parameters/package.json @@ -8,7 +8,7 @@ "license": "ISC", "description": "", "devDependencies": { - "@azure/microsoft-playwright-testing": "1.0.0-beta.1", + "@azure/microsoft-playwright-testing": "^1.0.0-beta.1", "@azure/identity": "4.3.0", "@playwright/test": "next", "@types/node": "^20.14.6" diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/manually-connecting-to-browsers/package.json b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/manually-connecting-to-browsers/package.json index 96c706447172..69f18ca915b9 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/manually-connecting-to-browsers/package.json +++ b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/manually-connecting-to-browsers/package.json @@ -8,7 +8,7 @@ "license": "ISC", "description": "", "devDependencies": { - "@azure/microsoft-playwright-testing": "1.0.0-beta.1", + "@azure/microsoft-playwright-testing": "^1.0.0-beta.1", "@playwright/test": "next", "@types/node": "^20.14.6" } diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/set-default-authentication-mechanism/package.json b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/set-default-authentication-mechanism/package.json index 148793d5c9cf..4ecc65339dfd 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/set-default-authentication-mechanism/package.json +++ b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/set-default-authentication-mechanism/package.json @@ -8,7 +8,7 @@ "license": "ISC", "description": "", "devDependencies": { - "@azure/microsoft-playwright-testing": "1.0.0-beta.1", + "@azure/microsoft-playwright-testing": "^1.0.0-beta.1", "@playwright/test": "next", "@types/node": "^20.14.6" } diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/using-connect-options/package.json b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/using-connect-options/package.json index 3024a0e993ac..42763d240b55 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/using-connect-options/package.json +++ b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/using-connect-options/package.json @@ -8,7 +8,7 @@ "license": "ISC", "description": "", "devDependencies": { - "@azure/microsoft-playwright-testing": "1.0.0-beta.1", + "@azure/microsoft-playwright-testing": "^1.0.0-beta.1", "@playwright/test": "next", "@types/node": "^20.14.6" } diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/customising-service-parameters/package.json b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/customising-service-parameters/package.json index d7407019a989..bfec58aa985f 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/customising-service-parameters/package.json +++ b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/customising-service-parameters/package.json @@ -8,7 +8,7 @@ "license": "ISC", "description": "", "devDependencies": { - "@azure/microsoft-playwright-testing": "1.0.0-beta.1", + "@azure/microsoft-playwright-testing": "^1.0.0-beta.1", "@azure/identity": "4.3.0", "@playwright/test": "next", "@types/node": "^20.14.6" diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/manually-connecting-to-browsers/package.json b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/manually-connecting-to-browsers/package.json index 96c706447172..69f18ca915b9 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/manually-connecting-to-browsers/package.json +++ b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/manually-connecting-to-browsers/package.json @@ -8,7 +8,7 @@ "license": "ISC", "description": "", "devDependencies": { - "@azure/microsoft-playwright-testing": "1.0.0-beta.1", + "@azure/microsoft-playwright-testing": "^1.0.0-beta.1", "@playwright/test": "next", "@types/node": "^20.14.6" } diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/set-default-authentication-mechanism/package.json b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/set-default-authentication-mechanism/package.json index 148793d5c9cf..4ecc65339dfd 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/set-default-authentication-mechanism/package.json +++ b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/set-default-authentication-mechanism/package.json @@ -8,7 +8,7 @@ "license": "ISC", "description": "", "devDependencies": { - "@azure/microsoft-playwright-testing": "1.0.0-beta.1", + "@azure/microsoft-playwright-testing": "^1.0.0-beta.1", "@playwright/test": "next", "@types/node": "^20.14.6" } diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/using-connect-options/package.json b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/using-connect-options/package.json index 3024a0e993ac..42763d240b55 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/using-connect-options/package.json +++ b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/using-connect-options/package.json @@ -8,7 +8,7 @@ "license": "ISC", "description": "", "devDependencies": { - "@azure/microsoft-playwright-testing": "1.0.0-beta.1", + "@azure/microsoft-playwright-testing": "^1.0.0-beta.1", "@playwright/test": "next", "@types/node": "^20.14.6" } From f42202f6d611cff61e1b3382feeccd040d39d85f Mon Sep 17 00:00:00 2001 From: Siddharth Singha Roy Date: Sun, 22 Dec 2024 15:34:17 +0000 Subject: [PATCH 5/8] chore(): support any playwright version >=1.47 --- sdk/playwrighttesting/microsoft-playwright-testing/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/package.json b/sdk/playwrighttesting/microsoft-playwright-testing/package.json index 7079283fa48c..d26528d874bc 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/package.json +++ b/sdk/playwrighttesting/microsoft-playwright-testing/package.json @@ -89,7 +89,7 @@ "typescript": "~5.7.2" }, "peerDependencies": { - "@playwright/test": "^1.47.0" + "@playwright/test": ">=1.47.0" }, "prettier": "@azure/eslint-plugin-azure-sdk/prettier.json", "//sampleConfiguration": { From 0bede387e7986c2f54d7a4d0198e3ba06667d9c8 Mon Sep 17 00:00:00 2001 From: Siddharth Singha Roy Date: Sun, 22 Dec 2024 16:00:17 +0000 Subject: [PATCH 6/8] Revert "chore(): support any playwright version >=1.47" This reverts commit f42202f6d611cff61e1b3382feeccd040d39d85f. --- sdk/playwrighttesting/microsoft-playwright-testing/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/package.json b/sdk/playwrighttesting/microsoft-playwright-testing/package.json index d26528d874bc..7079283fa48c 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/package.json +++ b/sdk/playwrighttesting/microsoft-playwright-testing/package.json @@ -89,7 +89,7 @@ "typescript": "~5.7.2" }, "peerDependencies": { - "@playwright/test": ">=1.47.0" + "@playwright/test": "^1.47.0" }, "prettier": "@azure/eslint-plugin-azure-sdk/prettier.json", "//sampleConfiguration": { From 5bd76071cd5f216261fdc0299f16082a88b5a924 Mon Sep 17 00:00:00 2001 From: Siddharth Singha Roy Date: Sun, 22 Dec 2024 16:02:29 +0000 Subject: [PATCH 7/8] Revert "chore(): update sample package version" This reverts commit 8ab83066685633c69289872812b2c25240879595. --- .../v1/javascript/customising-service-parameters/package.json | 2 +- .../v1/javascript/manually-connecting-to-browsers/package.json | 2 +- .../set-default-authentication-mechanism/package.json | 2 +- .../samples/v1/javascript/using-connect-options/package.json | 2 +- .../v1/typescript/customising-service-parameters/package.json | 2 +- .../v1/typescript/manually-connecting-to-browsers/package.json | 2 +- .../set-default-authentication-mechanism/package.json | 2 +- .../samples/v1/typescript/using-connect-options/package.json | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/customising-service-parameters/package.json b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/customising-service-parameters/package.json index bfec58aa985f..d7407019a989 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/customising-service-parameters/package.json +++ b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/customising-service-parameters/package.json @@ -8,7 +8,7 @@ "license": "ISC", "description": "", "devDependencies": { - "@azure/microsoft-playwright-testing": "^1.0.0-beta.1", + "@azure/microsoft-playwright-testing": "1.0.0-beta.1", "@azure/identity": "4.3.0", "@playwright/test": "next", "@types/node": "^20.14.6" diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/manually-connecting-to-browsers/package.json b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/manually-connecting-to-browsers/package.json index 69f18ca915b9..96c706447172 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/manually-connecting-to-browsers/package.json +++ b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/manually-connecting-to-browsers/package.json @@ -8,7 +8,7 @@ "license": "ISC", "description": "", "devDependencies": { - "@azure/microsoft-playwright-testing": "^1.0.0-beta.1", + "@azure/microsoft-playwright-testing": "1.0.0-beta.1", "@playwright/test": "next", "@types/node": "^20.14.6" } diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/set-default-authentication-mechanism/package.json b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/set-default-authentication-mechanism/package.json index 4ecc65339dfd..148793d5c9cf 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/set-default-authentication-mechanism/package.json +++ b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/set-default-authentication-mechanism/package.json @@ -8,7 +8,7 @@ "license": "ISC", "description": "", "devDependencies": { - "@azure/microsoft-playwright-testing": "^1.0.0-beta.1", + "@azure/microsoft-playwright-testing": "1.0.0-beta.1", "@playwright/test": "next", "@types/node": "^20.14.6" } diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/using-connect-options/package.json b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/using-connect-options/package.json index 42763d240b55..3024a0e993ac 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/using-connect-options/package.json +++ b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/javascript/using-connect-options/package.json @@ -8,7 +8,7 @@ "license": "ISC", "description": "", "devDependencies": { - "@azure/microsoft-playwright-testing": "^1.0.0-beta.1", + "@azure/microsoft-playwright-testing": "1.0.0-beta.1", "@playwright/test": "next", "@types/node": "^20.14.6" } diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/customising-service-parameters/package.json b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/customising-service-parameters/package.json index bfec58aa985f..d7407019a989 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/customising-service-parameters/package.json +++ b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/customising-service-parameters/package.json @@ -8,7 +8,7 @@ "license": "ISC", "description": "", "devDependencies": { - "@azure/microsoft-playwright-testing": "^1.0.0-beta.1", + "@azure/microsoft-playwright-testing": "1.0.0-beta.1", "@azure/identity": "4.3.0", "@playwright/test": "next", "@types/node": "^20.14.6" diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/manually-connecting-to-browsers/package.json b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/manually-connecting-to-browsers/package.json index 69f18ca915b9..96c706447172 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/manually-connecting-to-browsers/package.json +++ b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/manually-connecting-to-browsers/package.json @@ -8,7 +8,7 @@ "license": "ISC", "description": "", "devDependencies": { - "@azure/microsoft-playwright-testing": "^1.0.0-beta.1", + "@azure/microsoft-playwright-testing": "1.0.0-beta.1", "@playwright/test": "next", "@types/node": "^20.14.6" } diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/set-default-authentication-mechanism/package.json b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/set-default-authentication-mechanism/package.json index 4ecc65339dfd..148793d5c9cf 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/set-default-authentication-mechanism/package.json +++ b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/set-default-authentication-mechanism/package.json @@ -8,7 +8,7 @@ "license": "ISC", "description": "", "devDependencies": { - "@azure/microsoft-playwright-testing": "^1.0.0-beta.1", + "@azure/microsoft-playwright-testing": "1.0.0-beta.1", "@playwright/test": "next", "@types/node": "^20.14.6" } diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/using-connect-options/package.json b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/using-connect-options/package.json index 42763d240b55..3024a0e993ac 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/using-connect-options/package.json +++ b/sdk/playwrighttesting/microsoft-playwright-testing/samples/v1/typescript/using-connect-options/package.json @@ -8,7 +8,7 @@ "license": "ISC", "description": "", "devDependencies": { - "@azure/microsoft-playwright-testing": "^1.0.0-beta.1", + "@azure/microsoft-playwright-testing": "1.0.0-beta.1", "@playwright/test": "next", "@types/node": "^20.14.6" } From dda1e3c00eabb2e422556f36cfa8aae94ada334f Mon Sep 17 00:00:00 2001 From: Siddharth Singha Roy Date: Sun, 22 Dec 2024 16:35:09 +0000 Subject: [PATCH 8/8] chore(): remove unused environment variables from public API --- .../review/microsoft-playwright-testing.api.md | 3 --- .../src/common/constants.ts | 5 ++--- .../src/common/playwrightServiceConfig.ts | 10 +++------- .../src/reporter/mptReporter.ts | 6 ++++-- .../src/utils/serviceClient.ts | 4 ++-- .../src/utils/utils.ts | 2 +- .../test/common/playwrightServiceConfig.spec.ts | 15 +++++++-------- .../test/utils/utils.spec.ts | 2 +- 8 files changed, 20 insertions(+), 27 deletions(-) diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/review/microsoft-playwright-testing.api.md b/sdk/playwrighttesting/microsoft-playwright-testing/review/microsoft-playwright-testing.api.md index dceb5819a552..ab11db2001eb 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/review/microsoft-playwright-testing.api.md +++ b/sdk/playwrighttesting/microsoft-playwright-testing/review/microsoft-playwright-testing.api.md @@ -57,11 +57,8 @@ export const ServiceAuth: { // @public export const ServiceEnvironmentVariable: { - PLAYWRIGHT_SERVICE_OS: string; - PLAYWRIGHT_SERVICE_EXPOSE_NETWORK_ENVIRONMENT_VARIABLE: string; PLAYWRIGHT_SERVICE_ACCESS_TOKEN: string; PLAYWRIGHT_SERVICE_URL: string; - PLAYWRIGHT_SERVICE_REPORTING_URL: string; }; // @public diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/src/common/constants.ts b/sdk/playwrighttesting/microsoft-playwright-testing/src/common/constants.ts index c2ffeb218b1e..fa5ac956c039 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/src/common/constants.ts +++ b/sdk/playwrighttesting/microsoft-playwright-testing/src/common/constants.ts @@ -31,11 +31,8 @@ export const ServiceAuth = { * Environment variables used by Microsoft Playwright Testing */ export const ServiceEnvironmentVariable = { - PLAYWRIGHT_SERVICE_OS: "PLAYWRIGHT_SERVICE_OS", - PLAYWRIGHT_SERVICE_EXPOSE_NETWORK_ENVIRONMENT_VARIABLE: "PLAYWRIGHT_SERVICE_EXPOSE_NETWORK", PLAYWRIGHT_SERVICE_ACCESS_TOKEN: "PLAYWRIGHT_SERVICE_ACCESS_TOKEN", PLAYWRIGHT_SERVICE_URL: "PLAYWRIGHT_SERVICE_URL", - PLAYWRIGHT_SERVICE_REPORTING_URL: "PLAYWRIGHT_SERVICE_REPORTING_URL", }; export const DefaultConnectOptionsConstants = { @@ -240,6 +237,8 @@ export const InternalEnvironmentVariables = { MPT_SERVICE_RUN_NAME: "_MPT_SERVICE_RUN_NAME", MPT_SERVICE_RUN_ID: "_MPT_SERVICE_RUN_ID", MPT_CLOUD_HOSTED_BROWSER_USED: "_MPT_CLOUD_HOSTED_BROWSER_USED", + MPT_SERVICE_OS: "_MPT_SERVICE_OS", + MPT_SERVICE_REPORTING_URL: "_MPT_SERVICE_REPORTING_URL", }; export const MINIMUM_SUPPORTED_PLAYWRIGHT_VERSION = "1.47.0"; diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/src/common/playwrightServiceConfig.ts b/sdk/playwrighttesting/microsoft-playwright-testing/src/common/playwrightServiceConfig.ts index a9ae49b54458..240fd9002d35 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/src/common/playwrightServiceConfig.ts +++ b/sdk/playwrighttesting/microsoft-playwright-testing/src/common/playwrightServiceConfig.ts @@ -1,11 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { - DefaultConnectOptionsConstants, - InternalEnvironmentVariables, - ServiceEnvironmentVariable, -} from "./constants"; +import { DefaultConnectOptionsConstants, InternalEnvironmentVariables } from "./constants"; import type { PlaywrightServiceAdditionalOptions, OsType } from "./types"; import { getAndSetRunId } from "../utils/utils"; @@ -17,7 +13,7 @@ class PlaywrightServiceConfig { public exposeNetwork: string; public runName: string; constructor() { - this.serviceOs = (process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_OS] || + this.serviceOs = (process.env[InternalEnvironmentVariables.MPT_SERVICE_OS] || DefaultConnectOptionsConstants.DEFAULT_SERVICE_OS) as OsType; this.runName = process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_NAME] || ""; this.runId = process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_ID] || ""; @@ -44,7 +40,7 @@ class PlaywrightServiceConfig { } if (options?.os) { this.serviceOs = options.os; - process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_OS] = this.serviceOs; + process.env[InternalEnvironmentVariables.MPT_SERVICE_OS] = this.serviceOs; } if (options?.slowMo) { this.slowMo = options.slowMo; diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/src/reporter/mptReporter.ts b/sdk/playwrighttesting/microsoft-playwright-testing/src/reporter/mptReporter.ts index eaee446d15fa..43aa8aa42503 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/src/reporter/mptReporter.ts +++ b/sdk/playwrighttesting/microsoft-playwright-testing/src/reporter/mptReporter.ts @@ -377,12 +377,14 @@ class MPTReporter implements Reporter { this.isTokenValid = false; return; } - if (!process.env["PLAYWRIGHT_SERVICE_REPORTING_URL"]) { + if (!process.env[InternalEnvironmentVariables.MPT_SERVICE_REPORTING_URL]) { process.stdout.write("\nReporting service url not found."); this.isTokenValid = false; return; } - reporterLogger.info(`Reporting url - ${process.env["PLAYWRIGHT_SERVICE_REPORTING_URL"]}`); + reporterLogger.info( + `Reporting url - ${process.env[InternalEnvironmentVariables.MPT_SERVICE_REPORTING_URL]}`, + ); if (this.envVariables.accessToken === undefined || this.envVariables.accessToken === "") { process.stdout.write(`\n${ServiceErrorMessageConstants.NO_AUTH_ERROR.message}`); this.isTokenValid = false; diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/src/utils/serviceClient.ts b/sdk/playwrighttesting/microsoft-playwright-testing/src/utils/serviceClient.ts index 63055c0999e8..fa42a7bdda1b 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/src/utils/serviceClient.ts +++ b/sdk/playwrighttesting/microsoft-playwright-testing/src/utils/serviceClient.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import type { FullResult } from "@playwright/test/reporter"; -import { Constants } from "../common/constants"; +import { Constants, InternalEnvironmentVariables } from "../common/constants"; import type { EnvironmentVariables } from "../common/environmentVariables"; import { HttpService } from "../common/httpService"; import type { Shard, UploadMetadata } from "../model/shard"; @@ -170,7 +170,7 @@ export class ServiceClient { } private getServiceEndpoint(): string { - return process.env["PLAYWRIGHT_SERVICE_REPORTING_URL"]!; + return process.env[InternalEnvironmentVariables.MPT_SERVICE_REPORTING_URL]!; } private handleErrorResponse(response: PipelineResponse, action: string): void { diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/src/utils/utils.ts b/sdk/playwrighttesting/microsoft-playwright-testing/src/utils/utils.ts index 3411f4444081..d924693e9fbd 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/src/utils/utils.ts +++ b/sdk/playwrighttesting/microsoft-playwright-testing/src/utils/utils.ts @@ -122,7 +122,7 @@ export const emitReportingUrl = (): void => { const match = url?.match(regex); if (match && match.length >= 3) { const [, region, domain] = match; - process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_REPORTING_URL] = + process.env[InternalEnvironmentVariables.MPT_SERVICE_REPORTING_URL] = `https://${region}.reporting.api.${domain}`; } }; diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/test/common/playwrightServiceConfig.spec.ts b/sdk/playwrighttesting/microsoft-playwright-testing/test/common/playwrightServiceConfig.spec.ts index 7e5952f182a5..6769c5aac52f 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/test/common/playwrightServiceConfig.spec.ts +++ b/sdk/playwrighttesting/microsoft-playwright-testing/test/common/playwrightServiceConfig.spec.ts @@ -4,7 +4,6 @@ import { DefaultConnectOptionsConstants, InternalEnvironmentVariables, - ServiceEnvironmentVariable, } from "../../src/common/constants"; import { PlaywrightServiceConfig } from "../../src/common/playwrightServiceConfig"; import { expect } from "@azure-tools/test-utils"; @@ -46,11 +45,11 @@ describe("PlaywrightServiceConfig", () => { expect(process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_ID]).to.undefined; delete process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_ID]; - delete process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_OS]; + delete process.env[InternalEnvironmentVariables.MPT_SERVICE_OS]; }); it("should set service config object with values from env variables", () => { - process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_OS] = "windows"; + process.env[InternalEnvironmentVariables.MPT_SERVICE_OS] = "windows"; process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_NAME] = "runName"; process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_ID] = "runId"; @@ -61,7 +60,7 @@ describe("PlaywrightServiceConfig", () => { expect(playwrightServiceConfig.runName).to.equal("runName"); delete process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_ID]; - delete process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_OS]; + delete process.env[InternalEnvironmentVariables.MPT_SERVICE_OS]; delete process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_NAME]; }); @@ -83,11 +82,11 @@ describe("PlaywrightServiceConfig", () => { expect(playwrightServiceConfig.timeout).to.equal(200); expect(playwrightServiceConfig.exposeNetwork).to.equal("localhost"); expect(process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_ID]).to.equal("runId"); - expect(process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_OS]).to.equal("windows"); + expect(process.env[InternalEnvironmentVariables.MPT_SERVICE_OS]).to.equal("windows"); delete process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_NAME]; delete process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_ID]; - delete process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_OS]; + delete process.env[InternalEnvironmentVariables.MPT_SERVICE_OS]; }); it("should not set service config object with options if not provided", () => { @@ -111,7 +110,7 @@ describe("PlaywrightServiceConfig", () => { ); delete process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_NAME]; - delete process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_OS]; + delete process.env[InternalEnvironmentVariables.MPT_SERVICE_OS]; }); it("should set runName from options if provided and environment variable is not set", () => { const playwrightServiceConfig = new PlaywrightServiceConfig(); @@ -135,7 +134,7 @@ describe("PlaywrightServiceConfig", () => { ); delete process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_NAME]; delete process.env[InternalEnvironmentVariables.MPT_SERVICE_RUN_ID]; - delete process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_OS]; + delete process.env[InternalEnvironmentVariables.MPT_SERVICE_OS]; }); it("should set runId from options if provided and environment variable is not set", () => { const playwrightServiceConfig = new PlaywrightServiceConfig(); diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/test/utils/utils.spec.ts b/sdk/playwrighttesting/microsoft-playwright-testing/test/utils/utils.spec.ts index 09c487045c98..ad7066705a64 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/test/utils/utils.spec.ts +++ b/sdk/playwrighttesting/microsoft-playwright-testing/test/utils/utils.spec.ts @@ -354,7 +354,7 @@ describe("Service Utils", () => { testRubrics.forEach(({ serviceUrl, reportingUrl }) => { process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_URL] = serviceUrl; emitReportingUrl(); - expect(process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_REPORTING_URL]).to.equal( + expect(process.env[InternalEnvironmentVariables.MPT_SERVICE_REPORTING_URL]).to.equal( reportingUrl, ); delete process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_URL];