Skip to content

Commit

Permalink
Revert "fix(playwrighttesting): Removed runName support from the wsEn…
Browse files Browse the repository at this point in the history
…dpoint"

This reverts commit 92469c2.
  • Loading branch information
kashish2508 committed Nov 19, 2024
1 parent b6cfcc6 commit 4e550db
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const getServiceConfig = (
connectOptions: {
wsEndpoint: getServiceWSEndpoint(
playwrightServiceConfig.runId,
playwrightServiceConfig.runName,
playwrightServiceConfig.serviceOs,
),
headers: {
Expand Down Expand Up @@ -150,6 +151,7 @@ const getConnectOptions = async (
return {
wsEndpoint: getServiceWSEndpoint(
playwrightServiceConfig.runId,
playwrightServiceConfig.runName,
playwrightServiceConfig.serviceOs,
),
options: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`,
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
});
Expand Down

0 comments on commit 4e550db

Please sign in to comment.