From ef2e832f5608c20fe730bc8da74c59d900bbf1dc Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Mon, 10 Jun 2024 16:34:20 +0200 Subject: [PATCH] Update test --- .../AliasVault.E2ETests/PlaywrightTest.cs | 2 +- .../AliasVault.E2ETests/WebAppManager.cs | 73 +------------------ 2 files changed, 3 insertions(+), 72 deletions(-) diff --git a/src/Tests/AliasVault.E2ETests/PlaywrightTest.cs b/src/Tests/AliasVault.E2ETests/PlaywrightTest.cs index af827010f..6101123dc 100644 --- a/src/Tests/AliasVault.E2ETests/PlaywrightTest.cs +++ b/src/Tests/AliasVault.E2ETests/PlaywrightTest.cs @@ -43,7 +43,7 @@ public class PlaywrightTest await _webAppManager.StartBlazorWasmAsync(appPort); var playwright = await Playwright.CreateAsync(); - Browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions { Headless = false }); + Browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions { Headless = true }); Context = await Browser.NewContextAsync(); // Intercept requests and override appsettings.json diff --git a/src/Tests/AliasVault.E2ETests/WebAppManager.cs b/src/Tests/AliasVault.E2ETests/WebAppManager.cs index b6f0fd113..ec3bbf2fd 100644 --- a/src/Tests/AliasVault.E2ETests/WebAppManager.cs +++ b/src/Tests/AliasVault.E2ETests/WebAppManager.cs @@ -5,8 +5,6 @@ using System.Net; public class WebAppManager { - private Process _webApiProcess; - private List _webApiErrors = new(); private Process _blazorWasmProcess; private List _blazorWasmErrors = new(); @@ -18,54 +16,6 @@ public class WebAppManager return baseDir; } - public async Task StartWebApiAsync(int port) - { - var projectPath = $"{GetBaseDirectory()}/../../AliasVault.Api/AliasVault.Api.csproj"; - _webApiProcess = new Process - { - StartInfo = new ProcessStartInfo - { - FileName = "dotnet", - Arguments = $"run --project {projectPath} --urls=http://localhost:{port}", - RedirectStandardOutput = true, - RedirectStandardError = true, - UseShellExecute = false, - CreateNoWindow = true - } - }; - - _webApiProcess.OutputDataReceived += (sender, args) => - { - TestContext.Progress.WriteLine("WebAPI: " + args.Data); - if (args.Data != null && args.Data.Contains("error")) - { - _webApiErrors.Add(args.Data); - } - }; - _webApiProcess.ErrorDataReceived += (sender, args) => - { - if (args.Data != null && !string.IsNullOrEmpty(args.Data)) - { - _webApiErrors.Add(args.Data); - } - }; - - try - { - _webApiProcess.Start(); - _webApiProcess.BeginOutputReadLine(); - _webApiProcess.BeginErrorReadLine(); - TestContext.Progress.WriteLine("WebAPI process started, waiting for startup..."); - - await WaitForStartupAsync(port); - TestContext.Progress.WriteLine("WebAPI started successfully."); - } - catch (Exception ex) - { - TestContext.Progress.WriteLine($"Failed to start WebAPI: {ex.Message}"); - } - } - public async Task StartBlazorWasmAsync(int port) { var projectPath = $"{GetBaseDirectory()}/../../AliasVault.WebApp/AliasVault.WebApp.csproj"; @@ -113,15 +63,9 @@ public class WebAppManager } catch (Exception e) { - if (_webApiErrors != null && _webApiErrors.Count > 0) + if (_blazorWasmErrors.Count > 0) { - // Concatenate all errors and fail the test - Assert.Fail($"WebAPI failed to start: {string.Join(Environment.NewLine, _webApiErrors)}"); - return; - } - if (_blazorWasmErrors != null && _blazorWasmErrors.Count > 0) - { - Assert.Fail($"WASM failed to start: {string.Join(Environment.NewLine, _webApiErrors)}"); + Assert.Fail($"WASM failed to start: {string.Join(Environment.NewLine, _blazorWasmErrors)}"); return; } @@ -131,19 +75,6 @@ public class WebAppManager } } - public void StopWebApi() - { - if (_webApiProcess.HasExited) - { -#if WINDOWS - KillProcessAndChildrenWindows(_webApiProcess.Id); -#else - KillProcessAndChildrenUnix(_webApiProcess.Id); -#endif - _webApiProcess.Dispose(); - } - } - public void StopBlazorWasm() { if (!_blazorWasmProcess.HasExited)