mirror of
https://github.com/aliasvault/aliasvault.git
synced 2025-12-23 22:28:22 -05:00
Add GitHub workflow for running e2e browser extension tests (#1274)
This commit is contained in:
committed by
Leendert de Borst
parent
af384ff6d1
commit
7eef9b986f
50
.github/workflows/dotnet-e2e-tests.yml
vendored
50
.github/workflows/dotnet-e2e-tests.yml
vendored
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
/// - Static test account (username: testvault@example.local, password: aaaaaaaaaa (10 characters))
|
||||
/// - 5 predefined credentials with known values.
|
||||
/// </summary>
|
||||
[Category("ManualTests")]
|
||||
[Category("ExtensionTests")]
|
||||
[Category("ManualExtensionTests")]
|
||||
[TestFixture]
|
||||
public class TestVaultGeneratorTests : BrowserExtensionPlaywrightTest
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user