From e1c06f812899cf466942b958e71f6e6a0b98e19d Mon Sep 17 00:00:00 2001 From: Tanay Parikh Date: Mon, 15 Nov 2021 12:53:18 -0800 Subject: [PATCH 01/35] Upgrade `playwright-sharp-tool` https://www.nuget.org/packages/playwright-sharp-tool Contributes towards https://github.com/dotnet/aspnetcore/issues/30882. --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 7010490e921e..92120faf771c 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -9,7 +9,7 @@ ] }, "playwright-sharp-tool": { - "version": "0.170.2", + "version": "0.192.0", "commands": [ "playwright-sharp" ] From f5963462f866a45587ceeaf5a38fbc52580295e5 Mon Sep 17 00:00:00 2001 From: Tanay Parikh Date: Mon, 15 Nov 2021 12:58:36 -0800 Subject: [PATCH 02/35] Update to latest v1.16.1 from GitHub https://github.com/microsoft/playwright-dotnet/releases/tag/v1.16.1 --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 92120faf771c..5949d5c1ebc3 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -9,7 +9,7 @@ ] }, "playwright-sharp-tool": { - "version": "0.192.0", + "version": "1.16.1", "commands": [ "playwright-sharp" ] From 86c9a57de41ce0e08c9c74e764beacf36f930739 Mon Sep 17 00:00:00 2001 From: Tanay Parikh Date: Mon, 15 Nov 2021 13:17:09 -0800 Subject: [PATCH 03/35] Update to use Microsoft.Playwright --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 5949d5c1ebc3..20d0038f7936 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -8,7 +8,7 @@ "dotnet-serve" ] }, - "playwright-sharp-tool": { + "Microsoft.Playwright": { "version": "1.16.1", "commands": [ "playwright-sharp" From 29e93b5c8a6c925e8c06009e57f5780159674df5 Mon Sep 17 00:00:00 2001 From: Tanay Parikh Date: Mon, 15 Nov 2021 13:36:50 -0800 Subject: [PATCH 04/35] Update references to reflect `Microsoft.Playwright` --- eng/Dependencies.props | 2 +- eng/Versions.props | 2 +- eng/helix/content/RunTests/RunTests.csproj | 2 +- eng/helix/content/RunTests/TestRunner.cs | 2 +- .../BlazorTemplates.Tests/BlazorServerTemplateTest.cs | 2 +- .../BlazorTemplates.Tests/BlazorTemplates.Tests.csproj | 4 ++-- .../BlazorTemplates.Tests/BlazorWasmTemplateTest.cs | 2 +- src/ProjectTemplates/Shared/AspNetProcess.cs | 2 +- src/Shared/BrowserTesting/src/BrowserManager.cs | 6 +++--- .../BrowserTesting/src/BrowserManagerConfiguration.cs | 2 +- src/Shared/BrowserTesting/src/BrowserTestBase.cs | 2 +- src/Shared/BrowserTesting/src/ContextInformation.cs | 2 +- .../src/Microsoft.AspNetCore.BrowserTesting.csproj | 4 ++-- src/Shared/BrowserTesting/src/PageInformation.cs | 2 +- 14 files changed, 18 insertions(+), 18 deletions(-) diff --git a/eng/Dependencies.props b/eng/Dependencies.props index c35b4c33c752..dfb71cecbb13 100644 --- a/eng/Dependencies.props +++ b/eng/Dependencies.props @@ -188,7 +188,7 @@ and are generated based on the last package release. - + diff --git a/eng/Versions.props b/eng/Versions.props index 3b0d6c6a15e9..ca04436de9a3 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -252,7 +252,7 @@ 13.0.1 13.0.4 1.1.6 - 0.192.0 + 1.16.1 3.0.0 7.2.2 4.0.1 diff --git a/eng/helix/content/RunTests/RunTests.csproj b/eng/helix/content/RunTests/RunTests.csproj index 486e4bb10748..78fa90a19e40 100644 --- a/eng/helix/content/RunTests/RunTests.csproj +++ b/eng/helix/content/RunTests/RunTests.csproj @@ -8,6 +8,6 @@ - + diff --git a/eng/helix/content/RunTests/TestRunner.cs b/eng/helix/content/RunTests/TestRunner.cs index 4713e4bb00b1..fed65e841d73 100644 --- a/eng/helix/content/RunTests/TestRunner.cs +++ b/eng/helix/content/RunTests/TestRunner.cs @@ -9,7 +9,7 @@ using System.Threading; using System.Threading.Tasks; #if INSTALLPLAYWRIGHT -using PlaywrightSharp; +using Microsoft.Playwright; #endif namespace RunTests diff --git a/src/ProjectTemplates/BlazorTemplates.Tests/BlazorServerTemplateTest.cs b/src/ProjectTemplates/BlazorTemplates.Tests/BlazorServerTemplateTest.cs index 0897a48c9e2b..d90b3b093e63 100644 --- a/src/ProjectTemplates/BlazorTemplates.Tests/BlazorServerTemplateTest.cs +++ b/src/ProjectTemplates/BlazorTemplates.Tests/BlazorServerTemplateTest.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.BrowserTesting; using Microsoft.AspNetCore.Testing; -using PlaywrightSharp; +using Microsoft.Playwright; using ProjectTemplates.Tests.Infrastructure; using Templates.Test.Helpers; using Xunit; diff --git a/src/ProjectTemplates/BlazorTemplates.Tests/BlazorTemplates.Tests.csproj b/src/ProjectTemplates/BlazorTemplates.Tests/BlazorTemplates.Tests.csproj index eaebd7faec6f..28d22d2f5b79 100644 --- a/src/ProjectTemplates/BlazorTemplates.Tests/BlazorTemplates.Tests.csproj +++ b/src/ProjectTemplates/BlazorTemplates.Tests/BlazorTemplates.Tests.csproj @@ -44,8 +44,8 @@ - - + + - - + + diff --git a/src/Shared/BrowserTesting/src/PageInformation.cs b/src/Shared/BrowserTesting/src/PageInformation.cs index a5d381e6fa2f..87babea144b2 100644 --- a/src/Shared/BrowserTesting/src/PageInformation.cs +++ b/src/Shared/BrowserTesting/src/PageInformation.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.Extensions.Logging; -using PlaywrightSharp; +using Microsoft.Playwright; namespace Microsoft.AspNetCore.BrowserTesting; From e922f9900b64a54065bd3d228ecfbe31b8475a99 Mon Sep 17 00:00:00 2001 From: Tanay Parikh Date: Mon, 15 Nov 2021 14:28:33 -0800 Subject: [PATCH 05/35] Update dotnet-tools.json --- .config/dotnet-tools.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 20d0038f7936..da342a486663 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -7,12 +7,6 @@ "commands": [ "dotnet-serve" ] - }, - "Microsoft.Playwright": { - "version": "1.16.1", - "commands": [ - "playwright-sharp" - ] } } } From cc46e9cfb7a5bd75cb6454aac07fbeb96e6040f7 Mon Sep 17 00:00:00 2001 From: Tanay Parikh Date: Tue, 16 Nov 2021 09:25:04 -0800 Subject: [PATCH 06/35] Upgrade System.CommandLine --- eng/helix/content/RunTests/RunTests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/helix/content/RunTests/RunTests.csproj b/eng/helix/content/RunTests/RunTests.csproj index 78fa90a19e40..2f3238e2ab9d 100644 --- a/eng/helix/content/RunTests/RunTests.csproj +++ b/eng/helix/content/RunTests/RunTests.csproj @@ -7,7 +7,7 @@ - + From cb00cdca2a87f8fd64a9cb0e08d41a054c96b115 Mon Sep 17 00:00:00 2001 From: Tanay Parikh Date: Tue, 16 Nov 2021 09:25:56 -0800 Subject: [PATCH 07/35] Adapt to breaking API changes in Playwright --- .../BlazorServerTemplateTest.cs | 26 +++- .../BlazorWasmTemplateTest.cs | 30 ++-- src/ProjectTemplates/Shared/AspNetProcess.cs | 2 +- .../BrowserTesting/src/BrowserManager.cs | 28 ++-- .../src/BrowserManagerConfiguration.cs | 144 +++++++++--------- .../BrowserTesting/src/ContextInformation.cs | 27 ++-- .../BrowserTesting/src/PageInformation.cs | 27 ++-- 7 files changed, 145 insertions(+), 139 deletions(-) diff --git a/src/ProjectTemplates/BlazorTemplates.Tests/BlazorServerTemplateTest.cs b/src/ProjectTemplates/BlazorTemplates.Tests/BlazorServerTemplateTest.cs index d90b3b093e63..afafc61b051c 100644 --- a/src/ProjectTemplates/BlazorTemplates.Tests/BlazorServerTemplateTest.cs +++ b/src/ProjectTemplates/BlazorTemplates.Tests/BlazorServerTemplateTest.cs @@ -137,19 +137,31 @@ public async Task BlazorServerTemplateWorks_IndividualAuth(BrowserKind browserKi private async Task TestBasicNavigation(Project project, IPage page) { var socket = BrowserContextInfo.Pages[page].WebSockets.SingleOrDefault() ?? - (await page.WaitForEventAsync(PageEvent.WebSocket)).WebSocket; + (await page.WaitForWebSocketAsync()); + + var receivedSemaphore = new SemaphoreSlim(0, 1); + var sentSemaphore = new SemaphoreSlim(0, 1); + + void FrameReceived(object sender, IWebSocketFrame frame) { receivedSemaphore.Release(); } + void FrameSent(object sender, IWebSocketFrame frame) { sentSemaphore.Release(); } + + socket.FrameReceived += FrameReceived; + socket.FrameSent += FrameSent; // Receive render batch - await socket.WaitForEventAsync(WebSocketEvent.FrameReceived); - await socket.WaitForEventAsync(WebSocketEvent.FrameSent); + await receivedSemaphore.WaitAsync(); + await sentSemaphore.WaitAsync(); // JS interop call to intercept navigation - await socket.WaitForEventAsync(WebSocketEvent.FrameReceived); - await socket.WaitForEventAsync(WebSocketEvent.FrameSent); + await receivedSemaphore.WaitAsync(); + await sentSemaphore.WaitAsync(); + + socket.FrameReceived -= FrameReceived; + socket.FrameSent -= FrameSent; await page.WaitForSelectorAsync("nav"); // element gets project ID injected into it during template execution - Assert.Equal("Index", (await page.GetTitleAsync()).Trim()); + Assert.Equal("Index", (await page.TitleAsync()).Trim()); // Initially displays the home page await page.WaitForSelectorAsync("h1 >> text=Hello, world!"); @@ -168,7 +180,7 @@ private async Task TestBasicNavigation(Project project, IPage page) // Asynchronously loads and displays the table of weather forecasts await page.WaitForSelectorAsync("table>tbody>tr"); - Assert.Equal(5, (await page.QuerySelectorAllAsync("p+table>tbody>tr")).Count()); + Assert.Equal(5, (await page.QuerySelectorAllAsync("p+table>tbody>tr")).Count); } [Theory] diff --git a/src/ProjectTemplates/BlazorTemplates.Tests/BlazorWasmTemplateTest.cs b/src/ProjectTemplates/BlazorTemplates.Tests/BlazorWasmTemplateTest.cs index c9de5d0863b8..9f0794dd30ea 100644 --- a/src/ProjectTemplates/BlazorTemplates.Tests/BlazorWasmTemplateTest.cs +++ b/src/ProjectTemplates/BlazorTemplates.Tests/BlazorWasmTemplateTest.cs @@ -63,7 +63,7 @@ public async Task BlazorWasmStandaloneTemplate_Works(BrowserKind browserKind) private async Task<IPage> NavigateToPage(IBrowserContext browser, string listeningUri) { var page = await browser.NewPageAsync(); - await page.GoToAsync(listeningUri, LifecycleEvent.Networkidle); + await page.GotoAsync(listeningUri, new () { WaitUntil = WaitUntilState.NetworkIdle }); return page; } @@ -140,9 +140,9 @@ public async Task BlazorWasmStandalonePwaTemplate_Works(BrowserKind browserKind) // The PWA template supports offline use. By now, the browser should have cached everything it needs, // so we can continue working even without the server. - await page.GoToAsync("about:blank"); + await page.GotoAsync("about:blank"); await browser.SetOfflineAsync(true); - await page.GoToAsync(listeningUri); + await page.GotoAsync(listeningUri); await TestBasicNavigation(project.ProjectName, page, skipFetchData: true); await page.CloseAsync(); } @@ -188,9 +188,9 @@ public async Task BlazorWasmHostedPwaTemplate_Works(BrowserKind browserKind) // The PWA template supports offline use. By now, the browser should have cached everything it needs, // so we can continue working even without the server. // Since this is the hosted project, backend APIs won't work offline, so we need to skip "fetchdata" - await page.GoToAsync("about:blank"); + await page.GotoAsync("about:blank"); await browser.SetOfflineAsync(true); - await page.GoToAsync(listeningUri); + await page.GotoAsync(listeningUri); await TestBasicNavigation(project.ProjectName, page, skipFetchData: true); await page.CloseAsync(); } @@ -423,11 +423,11 @@ private async Task TestBasicNavigation(string appName, IPage page, bool usesAuth // Initially displays the home page await page.WaitForSelectorAsync("h1 >> text=Hello, world!"); - Assert.Equal("Index", (await page.GetTitleAsync()).Trim()); + Assert.Equal("Index", (await page.TitleAsync()).Trim()); // Can navigate to the counter page await Task.WhenAll( - page.WaitForNavigationAsync("**/counter"), + page.WaitForNavigationAsync(new () { UrlString = "**/counter" }), page.WaitForSelectorAsync("h1 >> text=Counter"), page.WaitForSelectorAsync("p >> text=Current count: 0"), page.ClickAsync("a[href=counter]")); @@ -440,12 +440,12 @@ private async Task TestBasicNavigation(string appName, IPage page, bool usesAuth if (usesAuth) { await Task.WhenAll( - page.WaitForNavigationAsync("**/Identity/Account/Login**", LifecycleEvent.Networkidle), + page.WaitForNavigationAsync(new () { UrlString = "**/Identity/Account/Login**", WaitUntil = WaitUntilState.NetworkIdle }), page.ClickAsync("text=Log in")); await Task.WhenAll( page.WaitForSelectorAsync("[name=\"Input.Email\"]"), - page.WaitForNavigationAsync("**/Identity/Account/Register**", LifecycleEvent.Networkidle), + page.WaitForNavigationAsync(new () { UrlString = "**/Identity/Account/Register**", WaitUntil = WaitUntilState.NetworkIdle }), page.ClickAsync("text=Register as a new user")); var userName = $"{Guid.NewGuid()}@example.com"; @@ -457,12 +457,12 @@ private async Task TestBasicNavigation(string appName, IPage page, bool usesAuth // We will be redirected to the RegisterConfirmation await Task.WhenAll( - page.WaitForNavigationAsync("**/Identity/Account/RegisterConfirmation**", LifecycleEvent.Networkidle), + page.WaitForNavigationAsync(new () { UrlString = "**/Identity/Account/RegisterConfirmation**", WaitUntil = WaitUntilState.NetworkIdle }), page.ClickAsync("#registerSubmit")); // We will be redirected to the ConfirmEmail await Task.WhenAll( - page.WaitForNavigationAsync("**/Identity/Account/ConfirmEmail**", LifecycleEvent.Networkidle), + page.WaitForNavigationAsync(new () { UrlString = "**/Identity/Account/ConfirmEmail**", WaitUntil = WaitUntilState.NetworkIdle }), page.ClickAsync("text=Click here to confirm your account")); // Now we can login @@ -473,21 +473,21 @@ private async Task TestBasicNavigation(string appName, IPage page, bool usesAuth await page.ClickAsync("#login-submit"); // Need to navigate to fetch page - await page.GoToAsync(new Uri(page.Url).GetLeftPart(UriPartial.Authority)); - Assert.Equal(appName.Trim(), (await page.GetTitleAsync()).Trim()); + await page.GotoAsync(new Uri(page.Url).GetLeftPart(UriPartial.Authority)); + Assert.Equal(appName.Trim(), (await page.TitleAsync()).Trim()); } if (!skipFetchData) { // Can navigate to the 'fetch data' page await Task.WhenAll( - page.WaitForNavigationAsync("**/fetchdata"), + page.WaitForNavigationAsync(new () { UrlString = "**/fetchdata" }), page.WaitForSelectorAsync("h1 >> text=Weather forecast"), page.ClickAsync("text=Fetch data")); // Asynchronously loads and displays the table of weather forecasts await page.WaitForSelectorAsync("table>tbody>tr"); - Assert.Equal(5, (await page.QuerySelectorAllAsync("p+table>tbody>tr")).Count()); + Assert.Equal(5, (await page.QuerySelectorAllAsync("p+table>tbody>tr")).Count); } } diff --git a/src/ProjectTemplates/Shared/AspNetProcess.cs b/src/ProjectTemplates/Shared/AspNetProcess.cs index 5a24acac90bf..389b2529adc6 100644 --- a/src/ProjectTemplates/Shared/AspNetProcess.cs +++ b/src/ProjectTemplates/Shared/AspNetProcess.cs @@ -109,7 +109,7 @@ public class AspNetProcess : IDisposable public async Task VisitInBrowserAsync(IPage page) { _output.WriteLine($"Opening browser at {ListeningUri}..."); - await page.GoToAsync(ListeningUri.AbsoluteUri); + await page.GotoAsync(ListeningUri.AbsoluteUri); } diff --git a/src/Shared/BrowserTesting/src/BrowserManager.cs b/src/Shared/BrowserTesting/src/BrowserManager.cs index cb71331ca102..9de981c8fac6 100644 --- a/src/Shared/BrowserTesting/src/BrowserManager.cs +++ b/src/Shared/BrowserTesting/src/BrowserManager.cs @@ -47,20 +47,21 @@ private async Task InitializeAsync() async Task InitializeCore() { - var driverPath = Environment.GetEnvironmentVariable("PLAYWRIGHT_DRIVER_PATH"); - if (!string.IsNullOrEmpty(driverPath)) - { - Playwright = await Playwright.CreateAsync(_loggerFactory, driverExecutablePath: driverPath, debug: "pw:api"); - } - else - { - Playwright = await Playwright.CreateAsync(_loggerFactory, debug: "pw:api"); - } + // var driverPath = Environment.GetEnvironmentVariable("PLAYWRIGHT_DRIVER_PATH"); + // if (!string.IsNullOrEmpty(driverPath)) + // { + // Playwright = await Playwright.CreateAsync(_loggerFactory, driverExecutablePath: driverPath, debug: "pw:api"); + // } + // else + // { + // Playwright = await Playwright.CreateAsync(_loggerFactory, debug: "pw:api"); + // } + Playwright = await Microsoft.Playwright.Playwright.CreateAsync(); foreach (var (browserName, options) in _browserManagerConfiguration.BrowserOptions) { if (!_launchBrowsers.ContainsKey(browserName)) { - var effectiveLaunchOptions = _browserManagerConfiguration.GetLaunchOptions(options.BrowserLaunchOptions); + var effectiveLaunchOptions = _browserManagerConfiguration.GetBrowserTypeLaunchOptions(options.BrowserLaunchOptions); var browser = options.BrowserKind switch { @@ -108,10 +109,10 @@ public Task<IBrowserContext> GetBrowserInstance(string browserInstance, string c contextInfo); } - public Task<IBrowserContext> GetBrowserInstance(BrowserKind browserInstance, string contextName, BrowserContextOptions options, ContextInformation contextInfo) => + public Task<IBrowserContext> GetBrowserInstance(BrowserKind browserInstance, string contextName, BrowserNewContextOptions options, ContextInformation contextInfo) => GetBrowserInstance(browserInstance.ToString(), contextName, options, contextInfo); - public Task<IBrowserContext> GetBrowserInstance(string browserInstance, string contextName, BrowserContextOptions options, ContextInformation contextInfo) + public Task<IBrowserContext> GetBrowserInstance(string browserInstance, string contextName, BrowserNewContextOptions options, ContextInformation contextInfo) { if (_launchBrowsers.TryGetValue(browserInstance, out var browser)) { @@ -126,9 +127,10 @@ public Task<IBrowserContext> GetBrowserInstance(string browserInstance, string c private async Task<IBrowserContext> AttachContextInfo(Task<IBrowserContext> browserContextTask, ContextInformation contextInfo) { var context = await browserContextTask; - context.DefaultTimeout = HasFailedTests ? + var defaultTimeout = HasFailedTests ? _browserManagerConfiguration.TimeoutAfterFirstFailureInMilliseconds : _browserManagerConfiguration.TimeoutInMilliseconds; + context.SetDefaultTimeout(defaultTimeout); contextInfo.Attach(context); return context; diff --git a/src/Shared/BrowserTesting/src/BrowserManagerConfiguration.cs b/src/Shared/BrowserTesting/src/BrowserManagerConfiguration.cs index ed451e10f151..e2602ad473ad 100644 --- a/src/Shared/BrowserTesting/src/BrowserManagerConfiguration.cs +++ b/src/Shared/BrowserTesting/src/BrowserManagerConfiguration.cs @@ -25,9 +25,9 @@ public BrowserManagerConfiguration(IConfiguration configuration) public bool IsDisabled { get; private set; } - public LaunchOptions GlobalBrowserOptions { get; private set; } + public BrowserTypeLaunchOptions GlobalBrowserOptions { get; private set; } - public BrowserContextOptions GlobalContextOptions { get; private set; } + public BrowserNewContextOptions GlobalContextOptions { get; private set; } public IDictionary<string, BrowserOptions> BrowserOptions { get; } = new Dictionary<string, BrowserOptions>(StringComparer.OrdinalIgnoreCase); @@ -35,10 +35,10 @@ public BrowserManagerConfiguration(IConfiguration configuration) public ISet<string> DisabledBrowsers { get; } = new HashSet<string>(StringComparer.OrdinalIgnoreCase); - public IDictionary<string, BrowserContextOptions> ContextOptions { get; private set; } = - new Dictionary<string, BrowserContextOptions>(StringComparer.OrdinalIgnoreCase); + public IDictionary<string, BrowserNewContextOptions> ContextOptions { get; private set; } = + new Dictionary<string, BrowserNewContextOptions>(StringComparer.OrdinalIgnoreCase); - public LaunchOptions GetLaunchOptions(LaunchOptions browserLaunchOptions) + public BrowserTypeLaunchOptions GetBrowserTypeLaunchOptions(BrowserTypeLaunchOptions browserLaunchOptions) { if (browserLaunchOptions == null) { @@ -50,7 +50,7 @@ public LaunchOptions GetLaunchOptions(LaunchOptions browserLaunchOptions) } } - public BrowserContextOptions GetContextOptions(string browser) + public BrowserNewContextOptions GetContextOptions(string browser) { if (!BrowserOptions.TryGetValue(browser, out var browserOptions)) { @@ -66,10 +66,10 @@ public BrowserContextOptions GetContextOptions(string browser) } } - public BrowserContextOptions GetContextOptions(string browser, string contextName) => + public BrowserNewContextOptions GetContextOptions(string browser, string contextName) => Combine(GetContextOptions(browser.ToString()), ContextOptions.TryGetValue(contextName, out var context) ? context : throw new InvalidOperationException("Invalid context name")); - public BrowserContextOptions GetContextOptions(string browser, string contextName, BrowserContextOptions options) => + public BrowserNewContextOptions GetContextOptions(string browser, string contextName, BrowserNewContextOptions options) => Combine(GetContextOptions(browser, contextName), options); private void Load(IConfiguration configuration) @@ -126,37 +126,37 @@ private void Load(IConfiguration configuration) } } - private BrowserContextOptions LoadContextOptions(IConfiguration configuration) => EnsureFoldersExist(new BrowserContextOptions + private BrowserNewContextOptions LoadContextOptions(IConfiguration configuration) => EnsureFoldersExist(new BrowserNewContextOptions { - Proxy = BindValue<ProxySettings>(configuration, nameof(BrowserContextOptions.Proxy)), - RecordVideo = BindValue<RecordVideoOptions>(configuration, nameof(BrowserContextOptions.RecordVideo)), - RecordHar = BindValue<RecordHarOptions>(configuration, nameof(BrowserContextOptions.RecordHar)), + Proxy = BindValue<Proxy>(configuration, nameof(BrowserNewContextOptions.Proxy)), + RecordVideoDir = configuration.GetValue<string>(nameof(BrowserNewContextOptions.RecordVideoDir)), + RecordVideoSize = BindValue<RecordVideoSize>(configuration, nameof(BrowserNewContextOptions.RecordVideoSize)), + RecordHarPath = configuration.GetValue<string>(nameof(BrowserNewContextOptions.RecordHarPath)), + RecordHarOmitContent = configuration.GetValue<bool?>(nameof(BrowserNewContextOptions.RecordHarOmitContent)), ExtraHTTPHeaders = BindMultiValueMap( - configuration.GetSection(nameof(BrowserContextOptions.ExtraHTTPHeaders)), + configuration.GetSection(nameof(BrowserNewContextOptions.ExtraHTTPHeaders)), argsMap => argsMap.ToDictionary(kvp => kvp.Key, kvp => string.Join(", ", kvp.Value))), - Locale = configuration.GetValue<string>(nameof(BrowserContextOptions.Locale)), - ColorScheme = configuration.GetValue<ColorScheme?>(nameof(BrowserContextOptions.ColorScheme)), - AcceptDownloads = configuration.GetValue<bool?>(nameof(BrowserContextOptions.AcceptDownloads)), - HasTouch = configuration.GetValue<bool?>(nameof(BrowserContextOptions.HasTouch)), - HttpCredentials = configuration.GetValue<Credentials>(nameof(BrowserContextOptions.HttpCredentials)), - DeviceScaleFactor = configuration.GetValue<decimal?>(nameof(BrowserContextOptions.DeviceScaleFactor)), - Offline = configuration.GetValue<bool?>(nameof(BrowserContextOptions.Offline)), - IsMobile = configuration.GetValue<bool?>(nameof(BrowserContextOptions.IsMobile)), + Locale = configuration.GetValue<string>(nameof(BrowserNewContextOptions.Locale)), + ColorScheme = configuration.GetValue<ColorScheme?>(nameof(BrowserNewContextOptions.ColorScheme)), + AcceptDownloads = configuration.GetValue<bool?>(nameof(BrowserNewContextOptions.AcceptDownloads)), + HasTouch = configuration.GetValue<bool?>(nameof(BrowserNewContextOptions.HasTouch)), + HttpCredentials = configuration.GetValue<HttpCredentials>(nameof(BrowserNewContextOptions.HttpCredentials)), + DeviceScaleFactor = configuration.GetValue<float?>(nameof(BrowserNewContextOptions.DeviceScaleFactor)), + Offline = configuration.GetValue<bool?>(nameof(BrowserNewContextOptions.Offline)), + IsMobile = configuration.GetValue<bool?>(nameof(BrowserNewContextOptions.IsMobile)), // TODO: Map this properly - Permissions = configuration.GetValue<ContextPermission[]>(nameof(BrowserContextOptions.Permissions)), - - Geolocation = BindValue<Geolocation>(configuration, nameof(BrowserContextOptions.Geolocation)), - TimezoneId = configuration.GetValue<string>(nameof(BrowserContextOptions.TimezoneId)), - IgnoreHTTPSErrors = configuration.GetValue<bool?>(nameof(BrowserContextOptions.IgnoreHTTPSErrors)), - JavaScriptEnabled = configuration.GetValue<bool?>(nameof(BrowserContextOptions.JavaScriptEnabled)), - BypassCSP = configuration.GetValue<bool?>(nameof(BrowserContextOptions.BypassCSP)), - UserAgent = configuration.GetValue<string>(nameof(BrowserContextOptions.UserAgent)), - Viewport = BindValue<ViewportSize>(configuration, nameof(BrowserContextOptions.Viewport)), - StorageStatePath = configuration.GetValue<string>(nameof(BrowserContextOptions.StorageStatePath)), - - // TODO: Map this properly - StorageState = BindValue<StorageState>(configuration, nameof(BrowserContextOptions.StorageState)) + Permissions = configuration.GetValue<IEnumerable<string>>(nameof(BrowserNewContextOptions.Permissions)), + + Geolocation = BindValue<Geolocation>(configuration, nameof(BrowserNewContextOptions.Geolocation)), + TimezoneId = configuration.GetValue<string>(nameof(BrowserNewContextOptions.TimezoneId)), + IgnoreHTTPSErrors = configuration.GetValue<bool?>(nameof(BrowserNewContextOptions.IgnoreHTTPSErrors)), + JavaScriptEnabled = configuration.GetValue<bool?>(nameof(BrowserNewContextOptions.JavaScriptEnabled)), + BypassCSP = configuration.GetValue<bool?>(nameof(BrowserNewContextOptions.BypassCSP)), + UserAgent = configuration.GetValue<string>(nameof(BrowserNewContextOptions.UserAgent)), + ViewportSize = BindValue<ViewportSize>(configuration, nameof(BrowserNewContextOptions.ViewportSize)), + StorageStatePath = configuration.GetValue<string>(nameof(BrowserNewContextOptions.StorageStatePath)), + StorageState = configuration.GetValue<string>(nameof(BrowserNewContextOptions.StorageState)) }); private static T BindValue<T>(IConfiguration configuration, string key) where T : new() @@ -167,16 +167,16 @@ private static T BindValue<T>(IConfiguration configuration, string key) where T return section.Exists() ? instance : default; } - private BrowserContextOptions EnsureFoldersExist(BrowserContextOptions browserContextOptions) + private BrowserNewContextOptions EnsureFoldersExist(BrowserNewContextOptions browserContextOptions) { - if (browserContextOptions?.RecordVideo?.Dir != null) + if (browserContextOptions?.RecordVideoDir != null) { - browserContextOptions.RecordVideo.Dir = EnsureFolderExists(browserContextOptions.RecordVideo.Dir); + browserContextOptions.RecordVideoDir = EnsureFolderExists(browserContextOptions.RecordVideoDir); } - if (browserContextOptions?.RecordHar?.Path != null) + if (browserContextOptions?.RecordHarPath != null) { - browserContextOptions.RecordHar.Path = EnsureFolderExists(browserContextOptions.RecordHar.Path); + browserContextOptions.RecordHarPath = EnsureFolderExists(browserContextOptions.RecordHarPath); } return browserContextOptions; @@ -197,28 +197,28 @@ string EnsureFolderExists(string folderPath) } } - private LaunchOptions LoadBrowserLaunchOptions(IConfiguration configuration) => new LaunchOptions + private BrowserTypeLaunchOptions LoadBrowserLaunchOptions(IConfiguration configuration) => new BrowserTypeLaunchOptions { - IgnoreDefaultArgs = BindArgumentMap(configuration.GetSection(nameof(LaunchOptions.IgnoreAllDefaultArgs))), - ChromiumSandbox = configuration.GetValue<bool?>(nameof(LaunchOptions.ChromiumSandbox)), - HandleSIGHUP = configuration.GetValue<bool?>(nameof(LaunchOptions.HandleSIGHUP)), - HandleSIGTERM = configuration.GetValue<bool?>(nameof(LaunchOptions.HandleSIGTERM)), - HandleSIGINT = configuration.GetValue<bool?>(nameof(LaunchOptions.HandleSIGINT)), - IgnoreAllDefaultArgs = configuration.GetValue<bool?>(nameof(LaunchOptions.IgnoreAllDefaultArgs)), - SlowMo = configuration.GetValue<int?>(nameof(LaunchOptions.SlowMo)), - Env = configuration.GetValue<Dictionary<string, string>>(nameof(LaunchOptions.Env)), - DumpIO = configuration.GetValue<bool?>(nameof(LaunchOptions.DumpIO)), - IgnoreHTTPSErrors = configuration.GetValue<bool?>(nameof(LaunchOptions.IgnoreHTTPSErrors)), - DownloadsPath = configuration.GetValue<string>(nameof(LaunchOptions.DownloadsPath)), - ExecutablePath = configuration.GetValue<string>(nameof(LaunchOptions.ExecutablePath)), - Devtools = configuration.GetValue<bool?>(nameof(LaunchOptions.Devtools)), - UserDataDir = configuration.GetValue<string>(nameof(LaunchOptions.UserDataDir)), + IgnoreDefaultArgs = BindArgumentMap(configuration.GetSection(nameof(BrowserTypeLaunchOptions.IgnoreAllDefaultArgs))), + ChromiumSandbox = configuration.GetValue<bool?>(nameof(BrowserTypeLaunchOptions.ChromiumSandbox)), + HandleSIGHUP = configuration.GetValue<bool?>(nameof(BrowserTypeLaunchOptions.HandleSIGHUP)), + HandleSIGTERM = configuration.GetValue<bool?>(nameof(BrowserTypeLaunchOptions.HandleSIGTERM)), + HandleSIGINT = configuration.GetValue<bool?>(nameof(BrowserTypeLaunchOptions.HandleSIGINT)), + IgnoreAllDefaultArgs = configuration.GetValue<bool?>(nameof(BrowserTypeLaunchOptions.IgnoreAllDefaultArgs)), + SlowMo = configuration.GetValue<int?>(nameof(BrowserTypeLaunchOptions.SlowMo)), + Env = configuration.GetValue<Dictionary<string, string>>(nameof(BrowserTypeLaunchOptions.Env)), + // DumpIO = configuration.GetValue<bool?>(nameof(BrowserTypeLaunchOptions.DumpIO)), + // IgnoreHTTPSErrors = configuration.GetValue<bool?>(nameof(BrowserTypeLaunchOptions.IgnoreHTTPSErrors)), + DownloadsPath = configuration.GetValue<string>(nameof(BrowserTypeLaunchOptions.DownloadsPath)), + ExecutablePath = configuration.GetValue<string>(nameof(BrowserTypeLaunchOptions.ExecutablePath)), + Devtools = configuration.GetValue<bool?>(nameof(BrowserTypeLaunchOptions.Devtools)), + // UserDataDir = configuration.GetValue<string>(nameof(BrowserTypeLaunchOptions.UserDataDir)), Args = BindMultiValueMap( - configuration.GetSection(nameof(LaunchOptions.Args)), + configuration.GetSection(nameof(BrowserTypeLaunchOptions.Args)), argsMap => argsMap.SelectMany(argNameValue => argNameValue.Value.Prepend(argNameValue.Key)).ToArray()), - Headless = configuration.GetValue<bool?>(nameof(LaunchOptions.Headless)), - Timeout = configuration.GetValue<int?>(nameof(LaunchOptions.Timeout)), - Proxy = configuration.GetValue<ProxySettings>(nameof(LaunchOptions.Proxy)) + Headless = configuration.GetValue<bool?>(nameof(BrowserTypeLaunchOptions.Headless)), + Timeout = configuration.GetValue<int?>(nameof(BrowserTypeLaunchOptions.Timeout)), + Proxy = configuration.GetValue<Proxy>(nameof(BrowserTypeLaunchOptions.Proxy)) }; private T BindMultiValueMap<T>(IConfigurationSection processArgsMap, Func<Dictionary<string, HashSet<string>>, T> mapper) @@ -307,20 +307,14 @@ static HashSet<string> InitializeMapValue(Dictionary<string, HashSet<string>> ar true => configuration.Get<Dictionary<string, bool>>().Where(kvp => kvp.Value == true).Select(kvp => kvp.Key).ToArray() }; - private static BrowserContextOptions Combine(BrowserContextOptions defaultOptions, BrowserContextOptions overrideOptions) => + private static BrowserNewContextOptions Combine(BrowserNewContextOptions defaultOptions, BrowserNewContextOptions overrideOptions) => new() { Proxy = overrideOptions?.Proxy != default ? overrideOptions.Proxy : defaultOptions.Proxy, - RecordVideo = overrideOptions?.RecordVideo != default ? - new() { Dir = overrideOptions.RecordVideo.Dir, Size = overrideOptions.RecordVideo.Size?.Clone() } : - defaultOptions != default ? - new() { Dir = defaultOptions.RecordVideo.Dir, Size = defaultOptions.RecordVideo.Size?.Clone() } : - default, - RecordHar = overrideOptions?.RecordHar != default ? - new() { Path = overrideOptions.RecordHar.Path, OmitContent = overrideOptions.RecordHar.OmitContent } : - defaultOptions?.RecordHar != default ? - new() { Path = defaultOptions.RecordHar.Path, OmitContent = defaultOptions.RecordHar.OmitContent } : - default, + RecordVideoDir = overrideOptions?.RecordVideoDir != default ? overrideOptions.RecordVideoDir : defaultOptions.RecordVideoDir, + RecordVideoSize = overrideOptions?.RecordVideoSize != default ? overrideOptions.RecordVideoSize : defaultOptions.RecordVideoSize, + RecordHarPath = overrideOptions?.RecordHarPath != default ? overrideOptions.RecordHarPath : defaultOptions.RecordHarPath, + RecordHarOmitContent = overrideOptions?.RecordHarOmitContent != default ? overrideOptions.RecordHarOmitContent : defaultOptions.RecordHarOmitContent, ExtraHTTPHeaders = overrideOptions?.ExtraHTTPHeaders != default ? overrideOptions.ExtraHTTPHeaders : defaultOptions.ExtraHTTPHeaders, Locale = overrideOptions?.Locale != default ? overrideOptions.Locale : defaultOptions.Locale, ColorScheme = overrideOptions?.ColorScheme != default ? overrideOptions.ColorScheme : defaultOptions.ColorScheme, @@ -337,12 +331,12 @@ static HashSet<string> InitializeMapValue(Dictionary<string, HashSet<string>> ar JavaScriptEnabled = overrideOptions?.JavaScriptEnabled != default ? overrideOptions.JavaScriptEnabled : defaultOptions.JavaScriptEnabled, BypassCSP = overrideOptions?.BypassCSP != default ? overrideOptions.BypassCSP : defaultOptions.BypassCSP, UserAgent = overrideOptions?.UserAgent != default ? overrideOptions.UserAgent : defaultOptions.UserAgent, - Viewport = overrideOptions?.Viewport != default ? overrideOptions.Viewport : defaultOptions.Viewport, + ViewportSize = overrideOptions?.ViewportSize != default ? overrideOptions.ViewportSize : defaultOptions.ViewportSize, StorageStatePath = overrideOptions?.StorageStatePath != default ? overrideOptions.StorageStatePath : defaultOptions.StorageStatePath, StorageState = overrideOptions?.StorageState != default ? overrideOptions.StorageState : defaultOptions.StorageState }; - private LaunchOptions Combine(LaunchOptions defaultOptions, LaunchOptions overrideOptions) => + private BrowserTypeLaunchOptions Combine(BrowserTypeLaunchOptions defaultOptions, BrowserTypeLaunchOptions overrideOptions) => new() { IgnoreDefaultArgs = overrideOptions.IgnoreDefaultArgs != default ? overrideOptions.IgnoreDefaultArgs : defaultOptions.IgnoreDefaultArgs, @@ -353,12 +347,12 @@ static HashSet<string> InitializeMapValue(Dictionary<string, HashSet<string>> ar IgnoreAllDefaultArgs = overrideOptions.IgnoreAllDefaultArgs != default ? overrideOptions.IgnoreAllDefaultArgs : defaultOptions.IgnoreAllDefaultArgs, SlowMo = overrideOptions.SlowMo != default ? overrideOptions.SlowMo : defaultOptions.SlowMo, Env = overrideOptions.Env != default ? overrideOptions.Env : defaultOptions.Env, - DumpIO = overrideOptions.DumpIO != default ? overrideOptions.DumpIO : defaultOptions.DumpIO, - IgnoreHTTPSErrors = overrideOptions.IgnoreHTTPSErrors != default ? overrideOptions.IgnoreHTTPSErrors : defaultOptions.IgnoreHTTPSErrors, + // DumpIO = overrideOptions.DumpIO != default ? overrideOptions.DumpIO : defaultOptions.DumpIO, + // IgnoreHTTPSErrors = overrideOptions.IgnoreHTTPSErrors != default ? overrideOptions.IgnoreHTTPSErrors : defaultOptions.IgnoreHTTPSErrors, DownloadsPath = overrideOptions.DownloadsPath != default ? overrideOptions.DownloadsPath : defaultOptions.DownloadsPath, ExecutablePath = overrideOptions.ExecutablePath != default ? overrideOptions.ExecutablePath : defaultOptions.ExecutablePath, Devtools = overrideOptions.Devtools != default ? overrideOptions.Devtools : defaultOptions.Devtools, - UserDataDir = overrideOptions.UserDataDir != default ? overrideOptions.UserDataDir : defaultOptions.UserDataDir, + // UserDataDir = overrideOptions.UserDataDir != default ? overrideOptions.UserDataDir : defaultOptions.UserDataDir, Args = overrideOptions.Args != default ? overrideOptions.Args : defaultOptions.Args, Headless = overrideOptions.Headless != default ? overrideOptions.Headless : defaultOptions.Headless, Timeout = overrideOptions.Timeout != default ? overrideOptions.Timeout : defaultOptions.Timeout, @@ -366,4 +360,4 @@ static HashSet<string> InitializeMapValue(Dictionary<string, HashSet<string>> ar }; } -public record BrowserOptions(BrowserKind BrowserKind, LaunchOptions BrowserLaunchOptions, BrowserContextOptions DefaultContextOptions); +public record BrowserOptions(BrowserKind BrowserKind, BrowserTypeLaunchOptions BrowserLaunchOptions, BrowserNewContextOptions DefaultContextOptions); diff --git a/src/Shared/BrowserTesting/src/ContextInformation.cs b/src/Shared/BrowserTesting/src/ContextInformation.cs index a4b683d790fd..f266edd1c055 100644 --- a/src/Shared/BrowserTesting/src/ContextInformation.cs +++ b/src/Shared/BrowserTesting/src/ContextInformation.cs @@ -26,7 +26,7 @@ internal void Attach(IBrowserContext context) context.Page += AttachToPage; } - private void AttachToPage(object sender, PageEventArgs args) + private void AttachToPage(object sender, IPage page) { var logger = _factory.CreateLogger<PageInformation>(); if (_harPath != null) @@ -34,15 +34,14 @@ private void AttachToPage(object sender, PageEventArgs args) logger.LogInformation($"Network trace will be saved at '{_harPath}'"); } - var pageInfo = new PageInformation(args.Page, logger); - Pages.Add(args.Page, pageInfo); - args.Page.Close += CleanupPage; - args.Page.Crash += CleanupPage; + var pageInfo = new PageInformation(page, logger); + Pages.Add(page, pageInfo); + page.Close += CleanupPage; + page.Crash += CleanupPage; } - private void CleanupPage(object sender, EventArgs e) + private void CleanupPage(object sender, IPage page) { - var page = (IPage)sender; if (Pages.TryGetValue(page, out var info)) { info.Dispose(); @@ -50,23 +49,23 @@ private void CleanupPage(object sender, EventArgs e) } } - internal BrowserContextOptions ConfigureUniqueHarPath(BrowserContextOptions browserContextOptions) + internal BrowserNewContextOptions ConfigureUniqueHarPath(BrowserNewContextOptions browserContextOptions) { var uploadDir = Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT"); - if (browserContextOptions?.RecordHar?.Path != null) + if (browserContextOptions?.RecordHarPath != null) { var identifier = Guid.NewGuid().ToString("N"); - browserContextOptions.RecordHar.Path = Path.Combine( - string.IsNullOrEmpty(uploadDir) ? browserContextOptions.RecordHar.Path : uploadDir, + browserContextOptions.RecordHarPath = Path.Combine( + string.IsNullOrEmpty(uploadDir) ? browserContextOptions.RecordHarPath : uploadDir, $"{identifier}.har"); - _harPath = browserContextOptions.RecordHar.Path; + _harPath = browserContextOptions.RecordHarPath; } - if (browserContextOptions?.RecordVideo?.Dir != null) + if (browserContextOptions?.RecordVideoDir != null) { if (!string.IsNullOrEmpty(uploadDir)) { - browserContextOptions.RecordVideo.Dir = uploadDir; + browserContextOptions.RecordVideoDir = uploadDir; } } diff --git a/src/Shared/BrowserTesting/src/PageInformation.cs b/src/Shared/BrowserTesting/src/PageInformation.cs index 87babea144b2..7cd9a2c68e21 100644 --- a/src/Shared/BrowserTesting/src/PageInformation.cs +++ b/src/Shared/BrowserTesting/src/PageInformation.cs @@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.BrowserTesting; public class PageInformation : IDisposable { - private readonly Page _page; + private readonly IPage _page; private readonly ILogger<PageInformation> _logger; public List<string> FailedRequests { get; } = new(); @@ -22,7 +22,7 @@ public class PageInformation : IDisposable public List<IWebSocket> WebSockets { get; set; } = new(); - public PageInformation(Page page, ILogger<PageInformation> logger) + public PageInformation(IPage page, ILogger<PageInformation> logger) { page.Console += RecordConsoleMessage; page.PageError += RecordPageError; @@ -34,16 +34,16 @@ public PageInformation(Page page, ILogger<PageInformation> logger) _ = LogPageVideoPath(); } - private void CaptureWebSocket(object sender, WebSocketEventArgs e) + private void CaptureWebSocket(object sender, IWebSocket e) { - WebSockets.Add(e.WebSocket); + WebSockets.Add(e); } private async Task LogPageVideoPath() { try { - var path = _page.Video != null ? await _page.Video.GetPathAsync() : null; + var path = _page.Video != null ? await _page.Video.PathAsync() : null; if (path != null) { _logger.LogInformation($"Page video recorded at: {path}"); @@ -63,41 +63,40 @@ public void Dispose() _page.RequestFailed -= RecordFailedRequest; } - private void RecordFailedRequest(object sender, RequestFailedEventArgs e) + private void RecordFailedRequest(object sender, IRequest e) { try { - _logger.LogError(e.FailureText); + _logger.LogError(e.Failure); } catch { } - FailedRequests.Add(e.FailureText); + FailedRequests.Add(e.Failure); } - private void RecordPageError(object sender, PageErrorEventArgs e) + private void RecordPageError(object sender, string e) { // There needs to be a bit of experimentation with this, but message should be a good start. try { - _logger.LogError(e.Message); + _logger.LogError(e); } catch { } - PageErrors.Add(e.Message); + PageErrors.Add(e); } - private void RecordConsoleMessage(object sender, ConsoleEventArgs e) + private void RecordConsoleMessage(object sender, IConsoleMessage message) { try { - var message = e.Message; var messageText = message.Text.Replace(Environment.NewLine, $"{Environment.NewLine} "); var location = message.Location; - var logMessage = $"[{_page.Url}]{Environment.NewLine} {messageText}{Environment.NewLine} ({location.URL}:{location.LineNumber}:{location.ColumnNumber})"; + var logMessage = $"[{_page.Url}]{Environment.NewLine} {messageText}{Environment.NewLine} ({location})"; _logger.Log(MapLogLevel(message.Type), logMessage); From bca219710698f16bda324a1158926e3745ce36ae Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Tue, 16 Nov 2021 12:27:56 -0800 Subject: [PATCH 08/35] Upgrade dotnet-serve --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index da342a486663..0d8ae2413a9b 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "dotnet-serve": { - "version": "1.7.139", + "version": "1.8.15", "commands": [ "dotnet-serve" ] From 534b8d64cf6574093f6aee67819ce356d60f20cd Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Tue, 16 Nov 2021 12:30:56 -0800 Subject: [PATCH 09/35] Add Microsoft.Playwright.CLI --- .config/dotnet-tools.json | 6 ++++++ eng/helix/content/RunTests/TestRunner.cs | 24 +++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 0d8ae2413a9b..12cd2f7fa7bd 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -7,6 +7,12 @@ "commands": [ "dotnet-serve" ] + }, + "Microsoft.Playwright.CLI": { + "version": "1.2.0", + "commands": [ + "playwright" + ] } } } diff --git a/eng/helix/content/RunTests/TestRunner.cs b/eng/helix/content/RunTests/TestRunner.cs index fed65e841d73..a272a93554e4 100644 --- a/eng/helix/content/RunTests/TestRunner.cs +++ b/eng/helix/content/RunTests/TestRunner.cs @@ -55,9 +55,6 @@ public bool SetupEnvironment() var playwrightBrowsers = Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH"); Console.WriteLine($"Setting PLAYWRIGHT_BROWSERS_PATH: {playwrightBrowsers}"); EnvironmentVariables.Add("PLAYWRIGHT_BROWSERS_PATH", playwrightBrowsers); - var playrightDriver = Environment.GetEnvironmentVariable("PLAYWRIGHT_DRIVER_PATH"); - Console.WriteLine($"Setting PLAYWRIGHT_DRIVER_PATH: {playrightDriver}"); - EnvironmentVariables.Add("PLAYWRIGHT_DRIVER_PATH", playrightDriver); #else Console.WriteLine($"Skipping setting PLAYWRIGHT_BROWSERS_PATH"); #endif @@ -112,8 +109,25 @@ public async Task<bool> InstallPlaywrightAsync() { try { - Console.WriteLine($"Installing Playwright to Browsers: {Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH")} Driver: {Environment.GetEnvironmentVariable("PLAYWRIGHT_DRIVER_PATH")}"); - await Playwright.InstallAsync(Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH"), Environment.GetEnvironmentVariable("PLAYWRIGHT_DRIVER_PATH")); + Console.WriteLine($"Installing Microsoft.Playwright.CLI dotnet tool to {Options.HELIX_WORKITEM_ROOT}"); + + await ProcessUtil.RunAsync($"{Options.DotnetRoot}/dotnet", + $"tool install Microsoft.Playwright.CLI --tool-path {Options.HELIX_WORKITEM_ROOT}", + environmentVariables: EnvironmentVariables, + outputDataReceived: Console.WriteLine, + errorDataReceived: Console.Error.WriteLine, + throwOnError: false, + cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token); + + Console.WriteLine($"Installing Playwright Browsers: {Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH")}"); + + await ProcessUtil.RunAsync($"playwright install", + environmentVariables: EnvironmentVariables, + outputDataReceived: Console.WriteLine, + errorDataReceived: Console.Error.WriteLine, + throwOnError: false, + cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token); + DisplayContents(Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH")); return true; } From 3d5511b075aabb07814439bd72a6dc39d44b6152 Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Wed, 17 Nov 2021 08:19:59 -0800 Subject: [PATCH 10/35] Revert "Upgrade System.CommandLine" This reverts commit cc46e9cfb7a5bd75cb6454aac07fbeb96e6040f7. --- eng/helix/content/RunTests/RunTests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/helix/content/RunTests/RunTests.csproj b/eng/helix/content/RunTests/RunTests.csproj index 2f3238e2ab9d..78fa90a19e40 100644 --- a/eng/helix/content/RunTests/RunTests.csproj +++ b/eng/helix/content/RunTests/RunTests.csproj @@ -7,7 +7,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="System.CommandLine" Version="2.0.0-beta1.21308.1" /> + <PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20158.1" /> <PackageReference Condition=" '$(InstallPlaywright)' == 'true' " Include="Microsoft.Playwright" Version="$(MicrosoftPlaywrightVersion)" /> </ItemGroup> </Project> From 8311458f743a4b11b99a7578236740470c6106d8 Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Wed, 17 Nov 2021 15:58:37 -0800 Subject: [PATCH 11/35] Fix build The build failed. Fix the build errors and run again. C:\h\w\AA180980\w\9ED808A4\e\RunTests\RunTests.csproj : warning NU1604: Project dependency Microsoft.Playwright does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results. C:\h\w\AA180980\w\9ED808A4\e\RunTests\TestRunner.cs(124,35): error CS7036: There is no argument given that corresponds to the required formal parameter 'arguments' of 'ProcessUtil.RunAsync(string, string, string?, string?, bool, IDictionary<string, string?>?, Action<string>?, Action<string>?, Action<int>?, CancellationToken)' [C:\h\w\AA180980\w\9ED808A4\e\RunTests\RunTests.csproj] --- eng/helix/content/RunTests/TestRunner.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eng/helix/content/RunTests/TestRunner.cs b/eng/helix/content/RunTests/TestRunner.cs index a272a93554e4..e72fb1549e3a 100644 --- a/eng/helix/content/RunTests/TestRunner.cs +++ b/eng/helix/content/RunTests/TestRunner.cs @@ -121,7 +121,8 @@ public async Task<bool> InstallPlaywrightAsync() Console.WriteLine($"Installing Playwright Browsers: {Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH")}"); - await ProcessUtil.RunAsync($"playwright install", + await ProcessUtil.RunAsync($"playwright", + "install", environmentVariables: EnvironmentVariables, outputDataReceived: Console.WriteLine, errorDataReceived: Console.Error.WriteLine, From 9d07167b345e023600a3654fa29e961cd99d5789 Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Wed, 17 Nov 2021 15:58:50 -0800 Subject: [PATCH 12/35] Remove semaphore for websocket events --- .../BlazorServerTemplateTest.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/ProjectTemplates/BlazorTemplates.Tests/BlazorServerTemplateTest.cs b/src/ProjectTemplates/BlazorTemplates.Tests/BlazorServerTemplateTest.cs index afafc61b051c..883e14af7262 100644 --- a/src/ProjectTemplates/BlazorTemplates.Tests/BlazorServerTemplateTest.cs +++ b/src/ProjectTemplates/BlazorTemplates.Tests/BlazorServerTemplateTest.cs @@ -136,25 +136,24 @@ public async Task BlazorServerTemplateWorks_IndividualAuth(BrowserKind browserKi private async Task TestBasicNavigation(Project project, IPage page) { - var socket = BrowserContextInfo.Pages[page].WebSockets.SingleOrDefault() ?? - (await page.WaitForWebSocketAsync()); + var socket = await page.WaitForWebSocketAsync(); - var receivedSemaphore = new SemaphoreSlim(0, 1); - var sentSemaphore = new SemaphoreSlim(0, 1); + var framesReceived = 0; + var framesSent = 0; - void FrameReceived(object sender, IWebSocketFrame frame) { receivedSemaphore.Release(); } - void FrameSent(object sender, IWebSocketFrame frame) { sentSemaphore.Release(); } + void FrameReceived(object sender, IWebSocketFrame frame) { framesReceived++; } + void FrameSent(object sender, IWebSocketFrame frame) { framesSent++; } socket.FrameReceived += FrameReceived; socket.FrameSent += FrameSent; // Receive render batch - await receivedSemaphore.WaitAsync(); - await sentSemaphore.WaitAsync(); + await page.WaitForWebSocketAsync(new() { Predicate = (s) => framesReceived == 1 }); + await page.WaitForWebSocketAsync(new() { Predicate = (s) => framesSent == 1 }); // JS interop call to intercept navigation - await receivedSemaphore.WaitAsync(); - await sentSemaphore.WaitAsync(); + await page.WaitForWebSocketAsync(new() { Predicate = (s) => framesReceived == 2 }); + await page.WaitForWebSocketAsync(new() { Predicate = (s) => framesSent == 2 }); socket.FrameReceived -= FrameReceived; socket.FrameSent -= FrameSent; From e701fc30c8ac2638192234addb80932b66fd1916 Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Wed, 17 Nov 2021 15:59:16 -0800 Subject: [PATCH 13/35] Update playwrightSettings based on breaking changes --- .../BlazorTemplates.Tests/playwrightSettings.json | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/ProjectTemplates/BlazorTemplates.Tests/playwrightSettings.json b/src/ProjectTemplates/BlazorTemplates.Tests/playwrightSettings.json index 48f1423de9fb..bc41cc7de930 100644 --- a/src/ProjectTemplates/BlazorTemplates.Tests/playwrightSettings.json +++ b/src/ProjectTemplates/BlazorTemplates.Tests/playwrightSettings.json @@ -4,18 +4,12 @@ "BaseArtifactsFolder": ".", "GlobalBrowserOptions": { "ChromiumSandbox": true, - "DumpIO": true, - "IgnoreHTTPSErrors": true, "Headless": true, "Timeout": 30000 }, "GlobalContextOptions": { - "RecordVideo": { - "Dir": "videos" - }, - "RecordHar": { - "Path": "har" - }, + "RecordVideoDir": "videos", + "RecordHarPath": "har", "IgnoreHTTPSErrors": true }, "BrowserOptions": { From 643392e23fd220e1cadaa6189b4ebfe0410d1069 Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Wed, 17 Nov 2021 20:13:12 -0800 Subject: [PATCH 14/35] npx based playwright install --- eng/helix/content/RunTests/TestRunner.cs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/eng/helix/content/RunTests/TestRunner.cs b/eng/helix/content/RunTests/TestRunner.cs index e72fb1549e3a..2b54762b94a0 100644 --- a/eng/helix/content/RunTests/TestRunner.cs +++ b/eng/helix/content/RunTests/TestRunner.cs @@ -111,18 +111,8 @@ public async Task<bool> InstallPlaywrightAsync() { Console.WriteLine($"Installing Microsoft.Playwright.CLI dotnet tool to {Options.HELIX_WORKITEM_ROOT}"); - await ProcessUtil.RunAsync($"{Options.DotnetRoot}/dotnet", - $"tool install Microsoft.Playwright.CLI --tool-path {Options.HELIX_WORKITEM_ROOT}", - environmentVariables: EnvironmentVariables, - outputDataReceived: Console.WriteLine, - errorDataReceived: Console.Error.WriteLine, - throwOnError: false, - cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token); - - Console.WriteLine($"Installing Playwright Browsers: {Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH")}"); - - await ProcessUtil.RunAsync($"playwright", - "install", + await ProcessUtil.RunAsync($"npx", + $"playwright install", environmentVariables: EnvironmentVariables, outputDataReceived: Console.WriteLine, errorDataReceived: Console.Error.WriteLine, From 31c93b1eb5d59850d96e36bc9d39b9b786488bbd Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Wed, 17 Nov 2021 23:24:52 -0800 Subject: [PATCH 15/35] npm install playwright --- eng/helix/content/RunTests/TestRunner.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/eng/helix/content/RunTests/TestRunner.cs b/eng/helix/content/RunTests/TestRunner.cs index 2b54762b94a0..cd51b4e5fbb0 100644 --- a/eng/helix/content/RunTests/TestRunner.cs +++ b/eng/helix/content/RunTests/TestRunner.cs @@ -109,10 +109,20 @@ public async Task<bool> InstallPlaywrightAsync() { try { - Console.WriteLine($"Installing Microsoft.Playwright.CLI dotnet tool to {Options.HELIX_WORKITEM_ROOT}"); + Console.WriteLine($"Installing playwright npm package"); - await ProcessUtil.RunAsync($"npx", - $"playwright install", + await ProcessUtil.RunAsync($"npm", + $"install playwright", + environmentVariables: EnvironmentVariables, + outputDataReceived: Console.WriteLine, + errorDataReceived: Console.Error.WriteLine, + throwOnError: false, + cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token); + + Console.WriteLine($"Installing playwright Browsers"); + + await ProcessUtil.RunAsync($"playwright", + $"install", environmentVariables: EnvironmentVariables, outputDataReceived: Console.WriteLine, errorDataReceived: Console.Error.WriteLine, From 0474781d9688e57fc2138910c62b89281d1c880e Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Thu, 18 Nov 2021 15:56:11 -0800 Subject: [PATCH 16/35] Install node in helix env --- .azure/pipelines/ci.yml | 1 + .azure/pipelines/quarantined-pr.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.azure/pipelines/ci.yml b/.azure/pipelines/ci.yml index bd175b72af32..945fda787708 100644 --- a/.azure/pipelines/ci.yml +++ b/.azure/pipelines/ci.yml @@ -712,6 +712,7 @@ stages: jobDisplayName: 'Tests: Helix x64' agentOs: Windows timeoutInMinutes: 240 + installNodeJs: true steps: # Build the shared framework - script: ./eng/build.cmd -ci -nobl -all -pack -arch x64 diff --git a/.azure/pipelines/quarantined-pr.yml b/.azure/pipelines/quarantined-pr.yml index 9abbc1a7339d..21eb39b52a4c 100644 --- a/.azure/pipelines/quarantined-pr.yml +++ b/.azure/pipelines/quarantined-pr.yml @@ -55,6 +55,7 @@ jobs: jobDisplayName: 'Tests: Helix' agentOs: Windows timeoutInMinutes: 120 + installNodeJs: true steps: # Build the shared framework - script: ./eng/build.cmd -ci -nobl -all -pack -arch x64 From 0d1dd355b59a0b0933803fa49f2eacd50a25ac91 Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Mon, 29 Nov 2021 11:32:23 -0800 Subject: [PATCH 17/35] Use DOTNET_ROLL_FORWARD with `dotnet` `playwright` tool --- .azure/pipelines/ci.yml | 2 +- .azure/pipelines/quarantined-pr.yml | 2 +- eng/helix/content/RunTests/TestRunner.cs | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.azure/pipelines/ci.yml b/.azure/pipelines/ci.yml index 945fda787708..82bf93f68649 100644 --- a/.azure/pipelines/ci.yml +++ b/.azure/pipelines/ci.yml @@ -712,7 +712,6 @@ stages: jobDisplayName: 'Tests: Helix x64' agentOs: Windows timeoutInMinutes: 240 - installNodeJs: true steps: # Build the shared framework - script: ./eng/build.cmd -ci -nobl -all -pack -arch x64 @@ -728,6 +727,7 @@ stages: env: HelixApiAccessToken: $(HelixApiAccessToken) # Needed for internal queues SYSTEM_ACCESSTOKEN: $(System.AccessToken) # We need to set this env var to publish helix results to Azure Dev Ops + DOTNET_ROLL_FORWARD: Major # Force Microsoft.Playwright.CLI to work with pre-release versions of .NET artifacts: - name: Helix_logs diff --git a/.azure/pipelines/quarantined-pr.yml b/.azure/pipelines/quarantined-pr.yml index 21eb39b52a4c..57404e9f54d9 100644 --- a/.azure/pipelines/quarantined-pr.yml +++ b/.azure/pipelines/quarantined-pr.yml @@ -55,7 +55,6 @@ jobs: jobDisplayName: 'Tests: Helix' agentOs: Windows timeoutInMinutes: 120 - installNodeJs: true steps: # Build the shared framework - script: ./eng/build.cmd -ci -nobl -all -pack -arch x64 @@ -73,6 +72,7 @@ jobs: env: HelixApiAccessToken: $(HelixApiAccessToken) # Needed for internal queues SYSTEM_ACCESSTOKEN: $(System.AccessToken) # We need to set this env var to publish helix results to Azure Dev Ops + DOTNET_ROLL_FORWARD: Major # Force Microsoft.Playwright.CLI to work with pre-release versions of .NET artifacts: - name: Helix_logs path: artifacts/log/ diff --git a/eng/helix/content/RunTests/TestRunner.cs b/eng/helix/content/RunTests/TestRunner.cs index cd51b4e5fbb0..b65a888c284d 100644 --- a/eng/helix/content/RunTests/TestRunner.cs +++ b/eng/helix/content/RunTests/TestRunner.cs @@ -111,18 +111,18 @@ public async Task<bool> InstallPlaywrightAsync() { Console.WriteLine($"Installing playwright npm package"); - await ProcessUtil.RunAsync($"npm", - $"install playwright", + await ProcessUtil.RunAsync($"{Options.DotnetRoot}/dotnet", + $"tool install Microsoft.Playwright.CLI --tool-path {Options.HELIX_WORKITEM_ROOT}", environmentVariables: EnvironmentVariables, outputDataReceived: Console.WriteLine, errorDataReceived: Console.Error.WriteLine, throwOnError: false, cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token); - Console.WriteLine($"Installing playwright Browsers"); + Console.WriteLine($"Installing Playwright Browsers: {Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH")}"); - await ProcessUtil.RunAsync($"playwright", - $"install", + await ProcessUtil.RunAsync($"{Options.DotnetRoot}/dotnet", + "playwright install", environmentVariables: EnvironmentVariables, outputDataReceived: Console.WriteLine, errorDataReceived: Console.Error.WriteLine, From 77fed0f28e7fe57e3203495e000e373fe8c2849b Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Mon, 29 Nov 2021 11:32:52 -0800 Subject: [PATCH 18/35] Cleanup --- .../BrowserTesting/src/BrowserManagerConfiguration.cs | 6 ------ src/Shared/Process/ProcessEx.cs | 1 - 2 files changed, 7 deletions(-) diff --git a/src/Shared/BrowserTesting/src/BrowserManagerConfiguration.cs b/src/Shared/BrowserTesting/src/BrowserManagerConfiguration.cs index e2602ad473ad..660fa5c05ef0 100644 --- a/src/Shared/BrowserTesting/src/BrowserManagerConfiguration.cs +++ b/src/Shared/BrowserTesting/src/BrowserManagerConfiguration.cs @@ -207,12 +207,9 @@ string EnsureFolderExists(string folderPath) IgnoreAllDefaultArgs = configuration.GetValue<bool?>(nameof(BrowserTypeLaunchOptions.IgnoreAllDefaultArgs)), SlowMo = configuration.GetValue<int?>(nameof(BrowserTypeLaunchOptions.SlowMo)), Env = configuration.GetValue<Dictionary<string, string>>(nameof(BrowserTypeLaunchOptions.Env)), - // DumpIO = configuration.GetValue<bool?>(nameof(BrowserTypeLaunchOptions.DumpIO)), - // IgnoreHTTPSErrors = configuration.GetValue<bool?>(nameof(BrowserTypeLaunchOptions.IgnoreHTTPSErrors)), DownloadsPath = configuration.GetValue<string>(nameof(BrowserTypeLaunchOptions.DownloadsPath)), ExecutablePath = configuration.GetValue<string>(nameof(BrowserTypeLaunchOptions.ExecutablePath)), Devtools = configuration.GetValue<bool?>(nameof(BrowserTypeLaunchOptions.Devtools)), - // UserDataDir = configuration.GetValue<string>(nameof(BrowserTypeLaunchOptions.UserDataDir)), Args = BindMultiValueMap( configuration.GetSection(nameof(BrowserTypeLaunchOptions.Args)), argsMap => argsMap.SelectMany(argNameValue => argNameValue.Value.Prepend(argNameValue.Key)).ToArray()), @@ -347,12 +344,9 @@ static HashSet<string> InitializeMapValue(Dictionary<string, HashSet<string>> ar IgnoreAllDefaultArgs = overrideOptions.IgnoreAllDefaultArgs != default ? overrideOptions.IgnoreAllDefaultArgs : defaultOptions.IgnoreAllDefaultArgs, SlowMo = overrideOptions.SlowMo != default ? overrideOptions.SlowMo : defaultOptions.SlowMo, Env = overrideOptions.Env != default ? overrideOptions.Env : defaultOptions.Env, - // DumpIO = overrideOptions.DumpIO != default ? overrideOptions.DumpIO : defaultOptions.DumpIO, - // IgnoreHTTPSErrors = overrideOptions.IgnoreHTTPSErrors != default ? overrideOptions.IgnoreHTTPSErrors : defaultOptions.IgnoreHTTPSErrors, DownloadsPath = overrideOptions.DownloadsPath != default ? overrideOptions.DownloadsPath : defaultOptions.DownloadsPath, ExecutablePath = overrideOptions.ExecutablePath != default ? overrideOptions.ExecutablePath : defaultOptions.ExecutablePath, Devtools = overrideOptions.Devtools != default ? overrideOptions.Devtools : defaultOptions.Devtools, - // UserDataDir = overrideOptions.UserDataDir != default ? overrideOptions.UserDataDir : defaultOptions.UserDataDir, Args = overrideOptions.Args != default ? overrideOptions.Args : defaultOptions.Args, Headless = overrideOptions.Headless != default ? overrideOptions.Headless : defaultOptions.Headless, Timeout = overrideOptions.Timeout != default ? overrideOptions.Timeout : defaultOptions.Timeout, diff --git a/src/Shared/Process/ProcessEx.cs b/src/Shared/Process/ProcessEx.cs index 7b86d3b7441d..3fe20633e935 100644 --- a/src/Shared/Process/ProcessEx.cs +++ b/src/Shared/Process/ProcessEx.cs @@ -48,7 +48,6 @@ public ProcessEx(ITestOutputHelper output, Process proc, TimeSpan timeout) proc.BeginOutputReadLine(); proc.BeginErrorReadLine(); - // We greedily create a timeout exception message even though a timeout is unlikely to happen for two reasons: // 1. To make it less likely for Process getters to throw exceptions like "System.InvalidOperationException: Process has exited, ..." // 2. To ensure if/when exceptions are thrown from Process getters, these exceptions can easily be observed. From 4ecb7ba3b907082003252518a84f272dfd79986c Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Mon, 29 Nov 2021 14:03:48 -0800 Subject: [PATCH 19/35] Update playwright tool usage --- eng/helix/content/RunTests/TestRunner.cs | 8 ++++---- eng/helix/content/runtests.cmd | 1 - eng/helix/content/runtests.sh | 1 - 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/eng/helix/content/RunTests/TestRunner.cs b/eng/helix/content/RunTests/TestRunner.cs index b65a888c284d..e8cebd6b8592 100644 --- a/eng/helix/content/RunTests/TestRunner.cs +++ b/eng/helix/content/RunTests/TestRunner.cs @@ -109,7 +109,7 @@ public async Task<bool> InstallPlaywrightAsync() { try { - Console.WriteLine($"Installing playwright npm package"); + Console.WriteLine($"Installing Microsoft.Playwright.CLI"); await ProcessUtil.RunAsync($"{Options.DotnetRoot}/dotnet", $"tool install Microsoft.Playwright.CLI --tool-path {Options.HELIX_WORKITEM_ROOT}", @@ -119,10 +119,10 @@ public async Task<bool> InstallPlaywrightAsync() throwOnError: false, cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token); - Console.WriteLine($"Installing Playwright Browsers: {Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH")}"); + Console.WriteLine($"Installing Playwright Browsers to {Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH")}"); - await ProcessUtil.RunAsync($"{Options.DotnetRoot}/dotnet", - "playwright install", + await ProcessUtil.RunAsync($"playwright", + "install", environmentVariables: EnvironmentVariables, outputDataReceived: Console.WriteLine, errorDataReceived: Console.Error.WriteLine, diff --git a/eng/helix/content/runtests.cmd b/eng/helix/content/runtests.cmd index 3aab373c69c9..e105281f343f 100644 --- a/eng/helix/content/runtests.cmd +++ b/eng/helix/content/runtests.cmd @@ -16,7 +16,6 @@ set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 set DOTNET_MULTILEVEL_LOOKUP=0 set InstallPlaywright=%$installPlaywright% set PLAYWRIGHT_BROWSERS_PATH=%CD%\ms-playwright -set PLAYWRIGHT_DRIVER_PATH=%CD%\.playwright\win-x64\native\playwright.cmd set "PATH=%HELIX_WORKITEM_ROOT%;%PATH%;%HELIX_WORKITEM_ROOT%\node\bin" echo Set path to: "%PATH%" diff --git a/eng/helix/content/runtests.sh b/eng/helix/content/runtests.sh index d900837b94ba..1fd36f19974f 100644 --- a/eng/helix/content/runtests.sh +++ b/eng/helix/content/runtests.sh @@ -18,7 +18,6 @@ export PATH="$PATH:$DIR:$DIR/node/bin" # Set playwright stuff export PLAYWRIGHT_BROWSERS_PATH="$DIR/ms-playwright" if [[ "$helixQueue" == *"OSX"* ]]; then - export PLAYWRIGHT_DRIVER_PATH="$DIR/.playwright/osx/native/playwright.sh" PLAYWRIGHT_NODE_PATH=$DIR/.playwright/osx/native/node else export PLAYWRIGHT_DRIVER_PATH="$DIR/.playwright/unix/native/playwright.sh" From 487a78f850c3a8a478fad62e4bc5be886ac7898e Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Mon, 29 Nov 2021 16:08:22 -0800 Subject: [PATCH 20/35] DOTNET_ROLL_FORWARD in TestRunner --- eng/helix/content/RunTests/TestRunner.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eng/helix/content/RunTests/TestRunner.cs b/eng/helix/content/RunTests/TestRunner.cs index e8cebd6b8592..6a5d947a48d5 100644 --- a/eng/helix/content/RunTests/TestRunner.cs +++ b/eng/helix/content/RunTests/TestRunner.cs @@ -55,8 +55,12 @@ public bool SetupEnvironment() var playwrightBrowsers = Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH"); Console.WriteLine($"Setting PLAYWRIGHT_BROWSERS_PATH: {playwrightBrowsers}"); EnvironmentVariables.Add("PLAYWRIGHT_BROWSERS_PATH", playwrightBrowsers); + + Console.WriteLine($"Setting DOTNET_ROLL_FORWARD: Major"); + EnvironmentVariables.Add("DOTNET_ROLL_FORWARD", "Major"); #else Console.WriteLine($"Skipping setting PLAYWRIGHT_BROWSERS_PATH"); + Console.WriteLine($"Skipping setting DOTNET_ROLL_FORWARD"); #endif Console.WriteLine($"Creating nuget restore directory: {nugetRestore}"); From de75d47dc3051c8a642d47c66f427c1006e24e18 Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Tue, 30 Nov 2021 14:38:07 -0800 Subject: [PATCH 21/35] Specify project dir --- eng/helix/content/RunTests/TestRunner.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/helix/content/RunTests/TestRunner.cs b/eng/helix/content/RunTests/TestRunner.cs index 6a5d947a48d5..a0995002a263 100644 --- a/eng/helix/content/RunTests/TestRunner.cs +++ b/eng/helix/content/RunTests/TestRunner.cs @@ -126,7 +126,7 @@ public async Task<bool> InstallPlaywrightAsync() Console.WriteLine($"Installing Playwright Browsers to {Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH")}"); await ProcessUtil.RunAsync($"playwright", - "install", + "install -p /_/src/ProjectTemplates/BlazorTemplates.Tests/BlazorTemplates.Tests.csproj", environmentVariables: EnvironmentVariables, outputDataReceived: Console.WriteLine, errorDataReceived: Console.Error.WriteLine, From 291477f8e77f8ec77caead32c6c2ca9b871a99a3 Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Tue, 30 Nov 2021 20:36:22 -0800 Subject: [PATCH 22/35] Playwright install without cli --- eng/helix/content/RunTests/TestRunner.cs | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/eng/helix/content/RunTests/TestRunner.cs b/eng/helix/content/RunTests/TestRunner.cs index a0995002a263..f9040e6182e2 100644 --- a/eng/helix/content/RunTests/TestRunner.cs +++ b/eng/helix/content/RunTests/TestRunner.cs @@ -113,25 +113,9 @@ public async Task<bool> InstallPlaywrightAsync() { try { - Console.WriteLine($"Installing Microsoft.Playwright.CLI"); + Console.WriteLine($"Installing Microsoft.Playwright"); - await ProcessUtil.RunAsync($"{Options.DotnetRoot}/dotnet", - $"tool install Microsoft.Playwright.CLI --tool-path {Options.HELIX_WORKITEM_ROOT}", - environmentVariables: EnvironmentVariables, - outputDataReceived: Console.WriteLine, - errorDataReceived: Console.Error.WriteLine, - throwOnError: false, - cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token); - - Console.WriteLine($"Installing Playwright Browsers to {Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH")}"); - - await ProcessUtil.RunAsync($"playwright", - "install -p /_/src/ProjectTemplates/BlazorTemplates.Tests/BlazorTemplates.Tests.csproj", - environmentVariables: EnvironmentVariables, - outputDataReceived: Console.WriteLine, - errorDataReceived: Console.Error.WriteLine, - throwOnError: false, - cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token); + Microsoft.Playwright.Program.Main(new[] { "install" }); DisplayContents(Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH")); return true; From 878f130b5f0a0efedbf4d3e5fdecbf5a5086f700 Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Tue, 30 Nov 2021 20:45:27 -0800 Subject: [PATCH 23/35] Update TestRunner.cs --- eng/helix/content/RunTests/TestRunner.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eng/helix/content/RunTests/TestRunner.cs b/eng/helix/content/RunTests/TestRunner.cs index f9040e6182e2..d4bdb609fd50 100644 --- a/eng/helix/content/RunTests/TestRunner.cs +++ b/eng/helix/content/RunTests/TestRunner.cs @@ -115,6 +115,8 @@ public async Task<bool> InstallPlaywrightAsync() { Console.WriteLine($"Installing Microsoft.Playwright"); + DisplayContents(Options.HELIX_WORKITEM_ROOT); + Microsoft.Playwright.Program.Main(new[] { "install" }); DisplayContents(Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH")); From 154b7ba144f0c6acad56f2b236cdf37725ba4954 Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Tue, 30 Nov 2021 20:53:21 -0800 Subject: [PATCH 24/35] Update TestRunner.cs --- eng/helix/content/RunTests/TestRunner.cs | 26 +++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/eng/helix/content/RunTests/TestRunner.cs b/eng/helix/content/RunTests/TestRunner.cs index d4bdb609fd50..7f7cc435d94b 100644 --- a/eng/helix/content/RunTests/TestRunner.cs +++ b/eng/helix/content/RunTests/TestRunner.cs @@ -113,11 +113,31 @@ public async Task<bool> InstallPlaywrightAsync() { try { - Console.WriteLine($"Installing Microsoft.Playwright"); + Console.WriteLine($"Installing Microsoft.Playwright.CLI"); - DisplayContents(Options.HELIX_WORKITEM_ROOT); + await ProcessUtil.RunAsync($"{Options.DotnetRoot}/dotnet", + $"tool install Microsoft.Playwright.CLI --tool-path {Options.HELIX_WORKITEM_ROOT}", + environmentVariables: EnvironmentVariables, + outputDataReceived: Console.WriteLine, + errorDataReceived: Console.Error.WriteLine, + throwOnError: false, + cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token); + + Console.WriteLine($"Installing Playwright Browsers to {Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH")}"); + + // Workaround https://github.com/microsoft/playwright-dotnet/blob/main/src/Playwright.CLI/Program.cs#L55-L65 + var tempProjectPath = Path.Combine("Options.HELIX_WORKITEM_ROOT", "TempProj.csproj"); + File.CreateFile(tempProjectPath); + + await ProcessUtil.RunAsync($"playwright", + "install", + environmentVariables: EnvironmentVariables, + outputDataReceived: Console.WriteLine, + errorDataReceived: Console.Error.WriteLine, + throwOnError: false, + cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token); - Microsoft.Playwright.Program.Main(new[] { "install" }); + File.Delete(tempProjectPath); DisplayContents(Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH")); return true; From 0b7adec135472292aa461cac0ab8afac6946928e Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Mon, 6 Dec 2021 08:34:50 -0800 Subject: [PATCH 25/35] Re-enable helix playwright tests --- .../BlazorTemplates.Tests/BlazorTemplates.Tests.csproj | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/ProjectTemplates/BlazorTemplates.Tests/BlazorTemplates.Tests.csproj b/src/ProjectTemplates/BlazorTemplates.Tests/BlazorTemplates.Tests.csproj index 034275768894..2741f15534ad 100644 --- a/src/ProjectTemplates/BlazorTemplates.Tests/BlazorTemplates.Tests.csproj +++ b/src/ProjectTemplates/BlazorTemplates.Tests/BlazorTemplates.Tests.csproj @@ -9,9 +9,6 @@ <BaseOutputPath /> <OutputPath /> - <!-- https://github.com/dotnet/aspnetcore/issues/38818 --> - <BuildHelixPayload>false</BuildHelixPayload> - <!-- Properties that affect test runs --> <!-- TestTemplateCreationFolder is the folder where the templates will be created. Will point out to $(OutputDir)$(TestTemplateCreationFolder) --> <TestTemplateCreationFolder>TestTemplates\</TestTemplateCreationFolder> From 0a37dc0703f34f1d9e7c7bf091ccdf1f01d84f3a Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Tue, 4 Jan 2022 08:22:38 -0800 Subject: [PATCH 26/35] Upgrade Playwright to 1.17.3, CLI to 1.2.2 --- .config/dotnet-tools.json | 2 +- eng/Versions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 12cd2f7fa7bd..00a32e6c111f 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -9,7 +9,7 @@ ] }, "Microsoft.Playwright.CLI": { - "version": "1.2.0", + "version": "1.2.2", "commands": [ "playwright" ] diff --git a/eng/Versions.props b/eng/Versions.props index bc9328c48c06..e60188fc2da4 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -260,7 +260,7 @@ <NewtonsoftJsonVersion>13.0.1</NewtonsoftJsonVersion> <NSwagApiDescriptionClientVersion>13.0.4</NSwagApiDescriptionClientVersion> <PhotinoNETVersion>1.1.6</PhotinoNETVersion> - <MicrosoftPlaywrightVersion>1.16.1</MicrosoftPlaywrightVersion> + <MicrosoftPlaywrightVersion>1.17.3</MicrosoftPlaywrightVersion> <PollyExtensionsHttpVersion>3.0.0</PollyExtensionsHttpVersion> <PollyVersion>7.2.2</PollyVersion> <SeleniumSupportVersion>4.1.0</SeleniumSupportVersion> From ac7c3662fccb9698889e8cff3c8156aaf66c891d Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Tue, 4 Jan 2022 11:18:18 -0800 Subject: [PATCH 27/35] Fix spacing --- .../BlazorWasmTemplateTest.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ProjectTemplates/BlazorTemplates.Tests/BlazorWasmTemplateTest.cs b/src/ProjectTemplates/BlazorTemplates.Tests/BlazorWasmTemplateTest.cs index c98cfa2dac22..9cc9e6b4e143 100644 --- a/src/ProjectTemplates/BlazorTemplates.Tests/BlazorWasmTemplateTest.cs +++ b/src/ProjectTemplates/BlazorTemplates.Tests/BlazorWasmTemplateTest.cs @@ -63,7 +63,7 @@ public async Task BlazorWasmStandaloneTemplate_Works(BrowserKind browserKind) private async Task<IPage> NavigateToPage(IBrowserContext browser, string listeningUri) { var page = await browser.NewPageAsync(); - await page.GotoAsync(listeningUri, new () { WaitUntil = WaitUntilState.NetworkIdle }); + await page.GotoAsync(listeningUri, new() { WaitUntil = WaitUntilState.NetworkIdle }); return page; } @@ -427,7 +427,7 @@ private async Task TestBasicNavigation(string appName, IPage page, bool usesAuth // Can navigate to the counter page await Task.WhenAll( - page.WaitForNavigationAsync(new () { UrlString = "**/counter" }), + page.WaitForNavigationAsync(new() { UrlString = "**/counter" }), page.WaitForSelectorAsync("h1 >> text=Counter"), page.WaitForSelectorAsync("p >> text=Current count: 0"), page.ClickAsync("a[href=counter]")); @@ -440,12 +440,12 @@ private async Task TestBasicNavigation(string appName, IPage page, bool usesAuth if (usesAuth) { await Task.WhenAll( - page.WaitForNavigationAsync(new () { UrlString = "**/Identity/Account/Login**", WaitUntil = WaitUntilState.NetworkIdle }), + page.WaitForNavigationAsync(new() { UrlString = "**/Identity/Account/Login**", WaitUntil = WaitUntilState.NetworkIdle }), page.ClickAsync("text=Log in")); await Task.WhenAll( page.WaitForSelectorAsync("[name=\"Input.Email\"]"), - page.WaitForNavigationAsync(new () { UrlString = "**/Identity/Account/Register**", WaitUntil = WaitUntilState.NetworkIdle }), + page.WaitForNavigationAsync(new() { UrlString = "**/Identity/Account/Register**", WaitUntil = WaitUntilState.NetworkIdle }), page.ClickAsync("text=Register as a new user")); var userName = $"{Guid.NewGuid()}@example.com"; @@ -457,12 +457,12 @@ private async Task TestBasicNavigation(string appName, IPage page, bool usesAuth // We will be redirected to the RegisterConfirmation await Task.WhenAll( - page.WaitForNavigationAsync(new () { UrlString = "**/Identity/Account/RegisterConfirmation**", WaitUntil = WaitUntilState.NetworkIdle }), + page.WaitForNavigationAsync(new() { UrlString = "**/Identity/Account/RegisterConfirmation**", WaitUntil = WaitUntilState.NetworkIdle }), page.ClickAsync("#registerSubmit")); // We will be redirected to the ConfirmEmail await Task.WhenAll( - page.WaitForNavigationAsync(new () { UrlString = "**/Identity/Account/ConfirmEmail**", WaitUntil = WaitUntilState.NetworkIdle }), + page.WaitForNavigationAsync(new() { UrlString = "**/Identity/Account/ConfirmEmail**", WaitUntil = WaitUntilState.NetworkIdle }), page.ClickAsync("text=Click here to confirm your account")); // Now we can login @@ -481,7 +481,7 @@ private async Task TestBasicNavigation(string appName, IPage page, bool usesAuth { // Can navigate to the 'fetch data' page await Task.WhenAll( - page.WaitForNavigationAsync(new () { UrlString = "**/fetchdata" }), + page.WaitForNavigationAsync(new() { UrlString = "**/fetchdata" }), page.WaitForSelectorAsync("h1 >> text=Weather forecast"), page.ClickAsync("text=Fetch data")); From 9baec00c562d619fba9ae5b1ac66f300e95fea8e Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Thu, 6 Jan 2022 10:48:30 -0800 Subject: [PATCH 28/35] Remove DOTNET_ROLL_FORWARD --- .azure/pipelines/ci.yml | 1 - .azure/pipelines/quarantined-pr.yml | 1 - eng/helix/content/RunTests/TestRunner.cs | 4 ---- 3 files changed, 6 deletions(-) diff --git a/.azure/pipelines/ci.yml b/.azure/pipelines/ci.yml index ea775034ae00..29333ca2053e 100644 --- a/.azure/pipelines/ci.yml +++ b/.azure/pipelines/ci.yml @@ -726,7 +726,6 @@ stages: env: HelixApiAccessToken: $(HelixApiAccessToken) # Needed for internal queues SYSTEM_ACCESSTOKEN: $(System.AccessToken) # We need to set this env var to publish helix results to Azure Dev Ops - DOTNET_ROLL_FORWARD: Major # Force Microsoft.Playwright.CLI to work with pre-release versions of .NET artifacts: - name: Helix_logs diff --git a/.azure/pipelines/quarantined-pr.yml b/.azure/pipelines/quarantined-pr.yml index 2b7af9b8724a..cc9b4688496a 100644 --- a/.azure/pipelines/quarantined-pr.yml +++ b/.azure/pipelines/quarantined-pr.yml @@ -69,7 +69,6 @@ jobs: env: HelixApiAccessToken: $(HelixApiAccessToken) # Needed for internal queues SYSTEM_ACCESSTOKEN: $(System.AccessToken) # We need to set this env var to publish helix results to Azure Dev Ops - DOTNET_ROLL_FORWARD: Major # Force Microsoft.Playwright.CLI to work with pre-release versions of .NET artifacts: - name: Helix_logs path: artifacts/log/ diff --git a/eng/helix/content/RunTests/TestRunner.cs b/eng/helix/content/RunTests/TestRunner.cs index 7f7cc435d94b..847f40e548ae 100644 --- a/eng/helix/content/RunTests/TestRunner.cs +++ b/eng/helix/content/RunTests/TestRunner.cs @@ -55,12 +55,8 @@ public bool SetupEnvironment() var playwrightBrowsers = Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH"); Console.WriteLine($"Setting PLAYWRIGHT_BROWSERS_PATH: {playwrightBrowsers}"); EnvironmentVariables.Add("PLAYWRIGHT_BROWSERS_PATH", playwrightBrowsers); - - Console.WriteLine($"Setting DOTNET_ROLL_FORWARD: Major"); - EnvironmentVariables.Add("DOTNET_ROLL_FORWARD", "Major"); #else Console.WriteLine($"Skipping setting PLAYWRIGHT_BROWSERS_PATH"); - Console.WriteLine($"Skipping setting DOTNET_ROLL_FORWARD"); #endif Console.WriteLine($"Creating nuget restore directory: {nugetRestore}"); From 9d630e20de15cfad42913e890f21ea89a8e072a4 Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Thu, 6 Jan 2022 10:56:26 -0800 Subject: [PATCH 29/35] PR Feedback --- eng/helix/content/RunTests/TestRunner.cs | 8 +------- .../BlazorTemplates.Tests/BlazorServerTemplateTest.cs | 2 +- .../BlazorTemplates.Tests/BlazorWasmTemplateTest.cs | 2 +- .../BlazorTemplates.Tests/playwrightSettings.json | 5 +---- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/eng/helix/content/RunTests/TestRunner.cs b/eng/helix/content/RunTests/TestRunner.cs index 847f40e548ae..99e412673838 100644 --- a/eng/helix/content/RunTests/TestRunner.cs +++ b/eng/helix/content/RunTests/TestRunner.cs @@ -125,13 +125,7 @@ public async Task<bool> InstallPlaywrightAsync() var tempProjectPath = Path.Combine("Options.HELIX_WORKITEM_ROOT", "TempProj.csproj"); File.CreateFile(tempProjectPath); - await ProcessUtil.RunAsync($"playwright", - "install", - environmentVariables: EnvironmentVariables, - outputDataReceived: Console.WriteLine, - errorDataReceived: Console.Error.WriteLine, - throwOnError: false, - cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token); + var exitCode = Microsoft.Playwright.Program.Main(new[] { "install" }); File.Delete(tempProjectPath); diff --git a/src/ProjectTemplates/BlazorTemplates.Tests/BlazorServerTemplateTest.cs b/src/ProjectTemplates/BlazorTemplates.Tests/BlazorServerTemplateTest.cs index 883e14af7262..b59787790c8c 100644 --- a/src/ProjectTemplates/BlazorTemplates.Tests/BlazorServerTemplateTest.cs +++ b/src/ProjectTemplates/BlazorTemplates.Tests/BlazorServerTemplateTest.cs @@ -179,7 +179,7 @@ private async Task TestBasicNavigation(Project project, IPage page) // Asynchronously loads and displays the table of weather forecasts await page.WaitForSelectorAsync("table>tbody>tr"); - Assert.Equal(5, (await page.QuerySelectorAllAsync("p+table>tbody>tr")).Count); + Assert.Equal(5, await page.Locator("p+table>tbody>tr").CountAsync()); } [Theory] diff --git a/src/ProjectTemplates/BlazorTemplates.Tests/BlazorWasmTemplateTest.cs b/src/ProjectTemplates/BlazorTemplates.Tests/BlazorWasmTemplateTest.cs index 9cc9e6b4e143..3284247a3014 100644 --- a/src/ProjectTemplates/BlazorTemplates.Tests/BlazorWasmTemplateTest.cs +++ b/src/ProjectTemplates/BlazorTemplates.Tests/BlazorWasmTemplateTest.cs @@ -487,7 +487,7 @@ private async Task TestBasicNavigation(string appName, IPage page, bool usesAuth // Asynchronously loads and displays the table of weather forecasts await page.WaitForSelectorAsync("table>tbody>tr"); - Assert.Equal(5, (await page.QuerySelectorAllAsync("p+table>tbody>tr")).Count); + Assert.Equal(5, await page.Locator("p+table>tbody>tr").CountAsync()); } } diff --git a/src/ProjectTemplates/BlazorTemplates.Tests/playwrightSettings.json b/src/ProjectTemplates/BlazorTemplates.Tests/playwrightSettings.json index bc41cc7de930..f97e60263b22 100644 --- a/src/ProjectTemplates/BlazorTemplates.Tests/playwrightSettings.json +++ b/src/ProjectTemplates/BlazorTemplates.Tests/playwrightSettings.json @@ -15,10 +15,7 @@ "BrowserOptions": { "Chromium": { "BrowserKind": "Chromium", - "IsEnabled": true, - "Args": { - "--ignore-certificate-errors": true - } + "IsEnabled": true }, "Firefox": { "BrowserKind": "Firefox", From 7673b275d109c566b2d3ad7a9effbe829257b752 Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Thu, 6 Jan 2022 11:11:52 -0800 Subject: [PATCH 30/35] Remove temp project workaround. --- eng/helix/content/RunTests/TestRunner.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/eng/helix/content/RunTests/TestRunner.cs b/eng/helix/content/RunTests/TestRunner.cs index 99e412673838..e7816c6f14de 100644 --- a/eng/helix/content/RunTests/TestRunner.cs +++ b/eng/helix/content/RunTests/TestRunner.cs @@ -121,14 +121,8 @@ public async Task<bool> InstallPlaywrightAsync() Console.WriteLine($"Installing Playwright Browsers to {Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH")}"); - // Workaround https://github.com/microsoft/playwright-dotnet/blob/main/src/Playwright.CLI/Program.cs#L55-L65 - var tempProjectPath = Path.Combine("Options.HELIX_WORKITEM_ROOT", "TempProj.csproj"); - File.CreateFile(tempProjectPath); - var exitCode = Microsoft.Playwright.Program.Main(new[] { "install" }); - File.Delete(tempProjectPath); - DisplayContents(Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH")); return true; } From 3c648039d7b69a0727b0fb6dcf18285c7d45e180 Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Thu, 6 Jan 2022 11:16:31 -0800 Subject: [PATCH 31/35] Fix package lowerbound issue --- eng/Versions.props | 1 - eng/helix/content/RunTests/RunTests.csproj | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index adf9c818bb80..fbcae1a1daee 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -260,7 +260,6 @@ <NewtonsoftJsonVersion>13.0.1</NewtonsoftJsonVersion> <NSwagApiDescriptionClientVersion>13.0.4</NSwagApiDescriptionClientVersion> <PhotinoNETVersion>1.1.6</PhotinoNETVersion> - <MicrosoftPlaywrightVersion>1.17.3</MicrosoftPlaywrightVersion> <PollyExtensionsHttpVersion>3.0.0</PollyExtensionsHttpVersion> <PollyVersion>7.2.2</PollyVersion> <SeleniumSupportVersion>4.1.0</SeleniumSupportVersion> diff --git a/eng/helix/content/RunTests/RunTests.csproj b/eng/helix/content/RunTests/RunTests.csproj index 78fa90a19e40..bc8b4f09cf7c 100644 --- a/eng/helix/content/RunTests/RunTests.csproj +++ b/eng/helix/content/RunTests/RunTests.csproj @@ -8,6 +8,6 @@ <ItemGroup> <PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20158.1" /> - <PackageReference Condition=" '$(InstallPlaywright)' == 'true' " Include="Microsoft.Playwright" Version="$(MicrosoftPlaywrightVersion)" /> + <PackageReference Condition=" '$(InstallPlaywright)' == 'true' " Include="Microsoft.Playwright" Version="1.17.3" /> </ItemGroup> </Project> From 43b9e1129181568f4c707b38e587ed1833b5462e Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Thu, 6 Jan 2022 11:41:50 -0800 Subject: [PATCH 32/35] Update Versions.props --- eng/Versions.props | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/Versions.props b/eng/Versions.props index fbcae1a1daee..adf9c818bb80 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -260,6 +260,7 @@ <NewtonsoftJsonVersion>13.0.1</NewtonsoftJsonVersion> <NSwagApiDescriptionClientVersion>13.0.4</NSwagApiDescriptionClientVersion> <PhotinoNETVersion>1.1.6</PhotinoNETVersion> + <MicrosoftPlaywrightVersion>1.17.3</MicrosoftPlaywrightVersion> <PollyExtensionsHttpVersion>3.0.0</PollyExtensionsHttpVersion> <PollyVersion>7.2.2</PollyVersion> <SeleniumSupportVersion>4.1.0</SeleniumSupportVersion> From fcc081d8f7a9a531dc743b2ce4a7db07699f14da Mon Sep 17 00:00:00 2001 From: Tanay Parikh <taparik@microsoft.com> Date: Thu, 6 Jan 2022 19:53:22 -0800 Subject: [PATCH 33/35] Update BrowserManager.cs --- src/Shared/BrowserTesting/src/BrowserManager.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/Shared/BrowserTesting/src/BrowserManager.cs b/src/Shared/BrowserTesting/src/BrowserManager.cs index 9de981c8fac6..b9296cec2411 100644 --- a/src/Shared/BrowserTesting/src/BrowserManager.cs +++ b/src/Shared/BrowserTesting/src/BrowserManager.cs @@ -47,15 +47,6 @@ private async Task InitializeAsync() async Task InitializeCore() { - // var driverPath = Environment.GetEnvironmentVariable("PLAYWRIGHT_DRIVER_PATH"); - // if (!string.IsNullOrEmpty(driverPath)) - // { - // Playwright = await Playwright.CreateAsync(_loggerFactory, driverExecutablePath: driverPath, debug: "pw:api"); - // } - // else - // { - // Playwright = await Playwright.CreateAsync(_loggerFactory, debug: "pw:api"); - // } Playwright = await Microsoft.Playwright.Playwright.CreateAsync(); foreach (var (browserName, options) in _browserManagerConfiguration.BrowserOptions) { From d11a0fbd18f019f7431930615b2373f0a905022d Mon Sep 17 00:00:00 2001 From: Tanay Parikh <TanayParikh@users.noreply.github.com> Date: Fri, 7 Jan 2022 12:30:09 -0800 Subject: [PATCH 34/35] Remove `Installing Microsoft.Playwright.CLI` --- eng/helix/content/RunTests/TestRunner.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/eng/helix/content/RunTests/TestRunner.cs b/eng/helix/content/RunTests/TestRunner.cs index e7816c6f14de..a88f4f9f455e 100644 --- a/eng/helix/content/RunTests/TestRunner.cs +++ b/eng/helix/content/RunTests/TestRunner.cs @@ -109,16 +109,6 @@ public async Task<bool> InstallPlaywrightAsync() { try { - Console.WriteLine($"Installing Microsoft.Playwright.CLI"); - - await ProcessUtil.RunAsync($"{Options.DotnetRoot}/dotnet", - $"tool install Microsoft.Playwright.CLI --tool-path {Options.HELIX_WORKITEM_ROOT}", - environmentVariables: EnvironmentVariables, - outputDataReceived: Console.WriteLine, - errorDataReceived: Console.Error.WriteLine, - throwOnError: false, - cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token); - Console.WriteLine($"Installing Playwright Browsers to {Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH")}"); var exitCode = Microsoft.Playwright.Program.Main(new[] { "install" }); From ad68c47407af5a07a8aa8021d4f48c02fa416363 Mon Sep 17 00:00:00 2001 From: Tanay Parikh <TanayParikh@users.noreply.github.com> Date: Tue, 11 Jan 2022 12:36:05 -0800 Subject: [PATCH 35/35] Disable playwright tests in helix --- .../BlazorTemplates.Tests/BlazorTemplates.Tests.csproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ProjectTemplates/BlazorTemplates.Tests/BlazorTemplates.Tests.csproj b/src/ProjectTemplates/BlazorTemplates.Tests/BlazorTemplates.Tests.csproj index 2741f15534ad..034275768894 100644 --- a/src/ProjectTemplates/BlazorTemplates.Tests/BlazorTemplates.Tests.csproj +++ b/src/ProjectTemplates/BlazorTemplates.Tests/BlazorTemplates.Tests.csproj @@ -9,6 +9,9 @@ <BaseOutputPath /> <OutputPath /> + <!-- https://github.com/dotnet/aspnetcore/issues/38818 --> + <BuildHelixPayload>false</BuildHelixPayload> + <!-- Properties that affect test runs --> <!-- TestTemplateCreationFolder is the folder where the templates will be created. Will point out to $(OutputDir)$(TestTemplateCreationFolder) --> <TestTemplateCreationFolder>TestTemplates\</TestTemplateCreationFolder>