Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Add appsettings.json for E2E test local config override (#98)

Leendert de Borst08e550f46fc4
diff --git a/.gitignore b/.gitignore
index 245e7141e..97215b611 100644
--- a/.gitignore
+++ b/.gitignore
@@ -376,6 +376,8 @@ FodyWeavers.xsd
src/AliasVault.WebApp/wwwroot/index.html
# appsettings.Development.json is generated by the build process from appsettings.Development.template.json and therefore should be ignored
src/AliasVault.WebApp/wwwroot/appsettings.Development.json
+# appsettings.Development.json is added manually if needed, it should not be committed.
+src/Tests/AliasVault.E2ETests/appsettings.Development.json
# .env is generated by init.sh and therefore should be ignored
.env
diff --git a/src/Tests/AliasVault.E2ETests/AliasVault.E2ETests.csproj b/src/Tests/AliasVault.E2ETests/AliasVault.E2ETests.csproj
index ade11ffcd..050519fe5 100644
--- a/src/Tests/AliasVault.E2ETests/AliasVault.E2ETests.csproj
+++ b/src/Tests/AliasVault.E2ETests/AliasVault.E2ETests.csproj
@@ -49,4 +49,15 @@
<ProjectReference Include="..\Server\AliasVault.E2ETests.WebApp.Server\AliasVault.E2ETests.WebApp.Server.csproj" />
</ItemGroup>
+ <ItemGroup>
+ <None Remove="appsettings.json" />
+ <Content Include="appsettings.json">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <None Remove="appsettings.Development.json" />
+ <Content Include="appsettings.Development.json">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ </ItemGroup>
+
</Project>
diff --git a/src/Tests/AliasVault.E2ETests/Common/PlaywrightTest.cs b/src/Tests/AliasVault.E2ETests/Common/PlaywrightTest.cs
index f666f9409..814bdaa0d 100644
--- a/src/Tests/AliasVault.E2ETests/Common/PlaywrightTest.cs
+++ b/src/Tests/AliasVault.E2ETests/Common/PlaywrightTest.cs
@@ -9,6 +9,7 @@ namespace AliasVault.E2ETests.Common;
using AliasServerDb;
using AliasVault.Shared.Providers.Time;
+using Microsoft.Extensions.Configuration;
using Microsoft.Playwright;
/// <summary>
@@ -291,10 +292,15 @@ public class PlaywrightTest
_wasmFactory.HostUrl = "http://localhost:" + appPort;
_wasmFactory.CreateDefaultClient();
- // Set Playwright headless mode true if not in debug mode.
- bool isDebugMode = System.Diagnostics.Debugger.IsAttached;
- bool headless = !isDebugMode;
- headless = false;
+ // Set Playwright headless mode based on appsettings.json value.
+ var configuration = new ConfigurationBuilder()
+ .SetBasePath(Directory.GetCurrentDirectory())
+ .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
+ .AddJsonFile($"appsettings.Development.json", optional: true, reloadOnChange: true)
+ .AddEnvironmentVariables()
+ .Build();
+
+ bool headless = configuration.GetValue("PlaywrightSettings:Headless", true);
var playwright = await Playwright.CreateAsync();
Browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions { Headless = headless });
diff --git a/src/Tests/AliasVault.E2ETests/appsettings.json b/src/Tests/AliasVault.E2ETests/appsettings.json
new file mode 100644
index 000000000..3730d2f7d
--- /dev/null
+++ b/src/Tests/AliasVault.E2ETests/appsettings.json
@@ -0,0 +1,5 @@
+{
+ "PlaywrightSettings" : {
+ "Headless": true
+ }
+}