Skip to content

Commit

Permalink
chore: update MPT service api signature (#2943)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sid200026 authored Jun 5, 2024
1 parent 929a44c commit 062fbe9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
13 changes: 5 additions & 8 deletions src/Playwright.MSTest/Services/BrowserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.Playwright.TestAdapter;

Expand All @@ -51,19 +50,17 @@ public async Task BuildAsync(PlaywrightTest parentTest)
else
{
var exposeNetwork = Environment.GetEnvironmentVariable("PLAYWRIGHT_SERVICE_EXPOSE_NETWORK") ?? "<loopback>";
var caps = new Dictionary<string, string>
{
["os"] = Environment.GetEnvironmentVariable("PLAYWRIGHT_SERVICE_OS") ?? "linux",
["runId"] = Environment.GetEnvironmentVariable("PLAYWRIGHT_SERVICE_RUN_ID") ?? DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture),
};
var wsEndpoint = $"{serviceUrl}?cap={JsonSerializer.Serialize(caps)}";
var os = Uri.EscapeDataString(Environment.GetEnvironmentVariable("PLAYWRIGHT_SERVICE_OS") ?? "linux");
var runId = Uri.EscapeDataString(Environment.GetEnvironmentVariable("PLAYWRIGHT_SERVICE_RUN_ID") ?? DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture));
var apiVersion = "2023-10-01-preview";
var wsEndpoint = $"{serviceUrl}?os={os}&runId={runId}&api-version={apiVersion}";
var connectOptions = new BrowserTypeConnectOptions
{
Timeout = 3 * 60 * 1000,
ExposeNetwork = exposeNetwork,
Headers = new Dictionary<string, string>
{
["x-mpt-access-key"] = accessToken
["Authorization"] = $"Bearer {accessToken}"
}
};

Expand Down
13 changes: 5 additions & 8 deletions src/Playwright.NUnit/BrowserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.Playwright.TestAdapter;

Expand Down Expand Up @@ -56,19 +55,17 @@ private static async Task<IBrowser> CreateBrowser(IBrowserType browserType)
}

var exposeNetwork = Environment.GetEnvironmentVariable("PLAYWRIGHT_SERVICE_EXPOSE_NETWORK") ?? "<loopback>";
var caps = new Dictionary<string, string>
{
["os"] = Environment.GetEnvironmentVariable("PLAYWRIGHT_SERVICE_OS") ?? "linux",
["runId"] = Environment.GetEnvironmentVariable("PLAYWRIGHT_SERVICE_RUN_ID") ?? DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture),
};
var wsEndpoint = $"{serviceUrl}?cap={JsonSerializer.Serialize(caps)}";
var os = Uri.EscapeDataString(Environment.GetEnvironmentVariable("PLAYWRIGHT_SERVICE_OS") ?? "linux");
var runId = Uri.EscapeDataString(Environment.GetEnvironmentVariable("PLAYWRIGHT_SERVICE_RUN_ID") ?? DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture));
var apiVersion = "2023-10-01-preview";
var wsEndpoint = $"{serviceUrl}?os={os}&runId={runId}&api-version={apiVersion}";
var connectOptions = new BrowserTypeConnectOptions
{
Timeout = 3 * 60 * 1000,
ExposeNetwork = exposeNetwork,
Headers = new Dictionary<string, string>
{
["x-mpt-access-key"] = accessToken
["Authorization"] = $"Bearer {accessToken}"
}
};

Expand Down

0 comments on commit 062fbe9

Please sign in to comment.