Skip to content

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

Add GitHub workflow for running e2e browser extension tests (#1274)

Leendert de Borst7eef9b986f4b
diff --git a/.github/workflows/dotnet-e2e-tests.yml b/.github/workflows/dotnet-e2e-tests.yml
index 9609a398f..7cf25e8ee 100644
--- a/.github/workflows/dotnet-e2e-tests.yml
+++ b/.github/workflows/dotnet-e2e-tests.yml
@@ -86,3 +86,53 @@ jobs:
timeout_minutes: 60
max_attempts: 3
command: cd apps/server && dotnet test Tests/AliasVault.E2ETests --no-build --verbosity normal --filter "FullyQualifiedName~.E2ETests.Tests.Client.Shard${{ matrix.shard }}."
+
+ browser-extension-tests:
+ timeout-minutes: 60
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v4
+ with:
+ dotnet-version: 9.0.x
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: '18'
+
+ - name: Install dependencies
+ run: dotnet workload install wasm-tools
+
+ - name: Build server
+ working-directory: apps/server
+ run: dotnet build
+
+ - name: Build browser extension
+ working-directory: apps/browser-extension
+ run: |
+ npm install
+ npm run build:chrome
+
+ - name: Start dev database
+ run: ./install.sh configure-dev-db start
+
+ - name: Ensure browsers are installed
+ working-directory: apps/server
+ run: pwsh Tests/AliasVault.E2ETests/bin/Debug/net9.0/playwright.ps1 install --with-deps
+
+ - name: Run ExtensionTests with retry
+ uses: nick-fields/retry@v3
+ with:
+ timeout_minutes: 60
+ max_attempts: 3
+ command: cd apps/server && dotnet test Tests/AliasVault.E2ETests --no-build --verbosity normal --filter "Category=ExtensionTests"
+
+ - name: Upload Test Results
+ if: always()
+ uses: actions/upload-artifact@v4
+ with:
+ name: extension-test-results
+ path: TestResults-Extension.xml
diff --git a/apps/server/Tests/AliasVault.E2ETests/Tests/Extensions/ChromeExtensionTests.cs b/apps/server/Tests/AliasVault.E2ETests/Tests/Extensions/ChromeExtensionTests.cs
index 7764ce655..35f2d081a 100644
--- a/apps/server/Tests/AliasVault.E2ETests/Tests/Extensions/ChromeExtensionTests.cs
+++ b/apps/server/Tests/AliasVault.E2ETests/Tests/Extensions/ChromeExtensionTests.cs
@@ -249,4 +249,58 @@ public class ChromeExtensionTests : BrowserExtensionPlaywrightTest
// Clean up the temporary file after the test
File.Delete(tempHtmlPath);
}*/
+
+ /// <summary>
+ /// Tests if the extension popup can be opened and displays available credentials.
+ /// </summary>
+ /// <returns>Async task.</returns>
+ [Order(3)]
+ [Test]
+ public async Task ExtensionPopupDisplaysCredentials()
+ {
+ // Create a credential to display
+ var serviceName = "Test Popup Display";
+ await CreateCredentialEntry(new Dictionary<string, string>
+ {
+ { "service-name", serviceName },
+ });
+
+ var extensionPopup = await LoginToExtension();
+
+ // Create a temporary HTML file with the test form
+ var tempHtmlPath = Path.Combine(Path.GetTempPath(), "test-popup-display.html");
+ var testFormHtml = @"
+ <html>
+ <head>
+ <title>Popup Display Test</title>
+ </head>
+ <body>
+ <h1>AliasVault extension popup display test</h1>
+ <form>
+ <input type='text' id='username' placeholder='Username'>
+ <input type='password' id='password' placeholder='Password'>
+ <button type='submit'>Login</button>
+ </form>
+ </body>
+ </html>
+ ";
+
+ await File.WriteAllTextAsync(tempHtmlPath, testFormHtml);
+
+ // Navigate to the file using the file:// protocol
+ await extensionPopup.GotoAsync($"file://{tempHtmlPath}");
+
+ // Focus the username field which should trigger the AliasVault popup
+ await extensionPopup.FocusAsync("input#username");
+
+ // Wait for the AliasVault popup to appear
+ await extensionPopup.Locator("aliasvault-ui >> #aliasvault-credential-popup").WaitForAsync();
+
+ // Verify the credential appears in the popup
+ var popupContent = await extensionPopup.Locator("aliasvault-ui").TextContentAsync();
+ Assert.That(popupContent, Does.Contain(serviceName), "Created credential should appear in the extension popup");
+
+ // Clean up the temporary file after the test
+ File.Delete(tempHtmlPath);
+ }
}
diff --git a/apps/server/Tests/AliasVault.E2ETests/Tests/Extensions/TestVaultGeneratorTests.cs b/apps/server/Tests/AliasVault.E2ETests/Tests/Extensions/TestVaultGeneratorTests.cs
index 17af548f1..9323a7c2e 100644
--- a/apps/server/Tests/AliasVault.E2ETests/Tests/Extensions/TestVaultGeneratorTests.cs
+++ b/apps/server/Tests/AliasVault.E2ETests/Tests/Extensions/TestVaultGeneratorTests.cs
@@ -30,8 +30,7 @@ using Microsoft.EntityFrameworkCore;
/// - Static test account (username: [email protected], password: aaaaaaaaaa (10 characters))
/// - 5 predefined credentials with known values.
/// </summary>
-[Category("ManualTests")]
-[Category("ExtensionTests")]
+[Category("ManualExtensionTests")]
[TestFixture]
public class TestVaultGeneratorTests : BrowserExtensionPlaywrightTest
{