diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/src/core/playwrightService.ts b/sdk/playwrighttesting/microsoft-playwright-testing/src/core/playwrightService.ts index 7a030ffc4e30..b6c4a81a6a46 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/src/core/playwrightService.ts +++ b/sdk/playwrighttesting/microsoft-playwright-testing/src/core/playwrightService.ts @@ -97,6 +97,7 @@ const getServiceConfig = ( connectOptions: { wsEndpoint: getServiceWSEndpoint( playwrightServiceConfig.runId, + playwrightServiceConfig.runName, playwrightServiceConfig.serviceOs, ), headers: { @@ -150,6 +151,7 @@ const getConnectOptions = async ( return { wsEndpoint: getServiceWSEndpoint( playwrightServiceConfig.runId, + playwrightServiceConfig.runName, playwrightServiceConfig.serviceOs, ), options: { diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/src/utils/utils.ts b/sdk/playwrighttesting/microsoft-playwright-testing/src/utils/utils.ts index 3411f4444081..d143d51067f5 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/src/utils/utils.ts +++ b/sdk/playwrighttesting/microsoft-playwright-testing/src/utils/utils.ts @@ -68,8 +68,8 @@ export const getAndSetRunId = (): string => { return runId; }; -export const getServiceWSEndpoint = (runId: string, os: string): string => { - return `${getServiceBaseURL()}?runId=${encodeURIComponent(runId)}&os=${os}&api-version=${API_VERSION}`; +export const getServiceWSEndpoint = (runId: string, runName: string, os: string): string => { + return `${getServiceBaseURL()}?runId=${encodeURIComponent(runId)}&runName=${encodeURIComponent(runName)}&os=${os}&api-version=${API_VERSION}`; }; export const validateServiceUrl = (): void => { diff --git a/sdk/playwrighttesting/microsoft-playwright-testing/test/core/playwrightService.spec.ts b/sdk/playwrighttesting/microsoft-playwright-testing/test/core/playwrightService.spec.ts index a8c608904d1c..95cc4917e3c0 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/test/core/playwrightService.spec.ts +++ b/sdk/playwrighttesting/microsoft-playwright-testing/test/core/playwrightService.spec.ts @@ -137,7 +137,7 @@ describe("getServiceConfig", () => { expect(config).to.deep.equal({ use: { connectOptions: { - wsEndpoint: `wss://eastus.playwright.microsoft.com/accounts/1234/browsers?runId=${playwrightServiceConfig.runId}&os=${playwrightServiceConfig.serviceOs}&api-version=${API_VERSION}`, + wsEndpoint: `wss://eastus.playwright.microsoft.com/accounts/1234/browsers?runId=${playwrightServiceConfig.runId}&runName=${playwrightServiceConfig.runName}&os=${playwrightServiceConfig.serviceOs}&api-version=${API_VERSION}`, headers: { Authorization: "Bearer token", "x-ms-package-version": `@azure/microsoft-playwright-testing/${encodeURIComponent(mockVersion)}`, @@ -208,7 +208,7 @@ describe("getConnectOptions", () => { const connectOptions = await getConnectOptions({}); const playwrightServiceConfig = new PlaywrightServiceConfig(); expect(connectOptions).to.deep.equal({ - wsEndpoint: `wss://eastus.playwright.microsoft.com/accounts/1234/browsers?runId=${playwrightServiceConfig.runId}&os=${playwrightServiceConfig.serviceOs}&api-version=${API_VERSION}`, + wsEndpoint: `wss://eastus.playwright.microsoft.com/accounts/1234/browsers?runId=${playwrightServiceConfig.runId}&runName=${playwrightServiceConfig.runName}&os=${playwrightServiceConfig.serviceOs}&api-version=${API_VERSION}`, options: { headers: { Authorization: "Bearer token", 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..596eaa31807b 100644 --- a/sdk/playwrighttesting/microsoft-playwright-testing/test/utils/utils.spec.ts +++ b/sdk/playwrighttesting/microsoft-playwright-testing/test/utils/utils.spec.ts @@ -75,21 +75,24 @@ describe("Service Utils", () => { "wss://eastus.api.playwright.microsoft.com/accounts/1234/browsers"; const runId = "2021-10-11T07:00:00.000Z"; const escapeRunId = encodeURIComponent(runId); + const runName = "runName"; const os = "windows"; - const expected = `wss://eastus.api.playwright.microsoft.com/accounts/1234/browsers?runId=${escapeRunId}&os=${os}&api-version=${API_VERSION}`; - expect(getServiceWSEndpoint(runId, os)).to.equal(expected); + const expected = `wss://eastus.api.playwright.microsoft.com/accounts/1234/browsers?runId=${escapeRunId}&runName=${runName}&os=${os}&api-version=${API_VERSION}`; + expect(getServiceWSEndpoint(runId, runName, os)).to.equal(expected); delete process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_URL]; }); - it("should escape special character in runId", () => { + it("should escape special character in runName and runId", () => { process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_URL] = "wss://eastus.api.playwright.microsoft.com/accounts/1234/browsers"; const runId = "2021-10-11T07:00:00.000Z"; const escapeRunId = encodeURIComponent(runId); + const runName = "run#Name-12/09"; + const escapeRunName = encodeURIComponent(runName); const os = "windows"; - const expected = `wss://eastus.api.playwright.microsoft.com/accounts/1234/browsers?runId=${escapeRunId}&os=${os}&api-version=${API_VERSION}`; - expect(getServiceWSEndpoint(runId, os)).to.equal(expected); + const expected = `wss://eastus.api.playwright.microsoft.com/accounts/1234/browsers?runId=${escapeRunId}&runName=${escapeRunName}&os=${os}&api-version=${API_VERSION}`; + expect(getServiceWSEndpoint(runId, runName, os)).to.equal(expected); delete process.env[ServiceEnvironmentVariable.PLAYWRIGHT_SERVICE_URL]; });