Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add global api reachable check (#1404)
Leendert de Borst0687dbcf002b
diff --git a/.github/workflows/browser-extension-build.yml b/.github/workflows/browser-extension-build.ymlindex b8cf9b54f..08be44b63 100644--- a/.github/workflows/browser-extension-build.yml+++ b/.github/workflows/browser-extension-build.yml@@ -70,6 +70,11 @@ jobs:steps:- uses: actions/checkout@v4+ - name: Setup .NET+ uses: actions/setup-dotnet@v4+ with:+ dotnet-version: 9.0.x+- name: Setup Node.jsuses: actions/setup-node@v4with:@@ -77,7 +82,40 @@ jobs:cache: 'npm'cache-dependency-path: apps/browser-extension/package-lock.json- - name: Install dependencies+ - name: Install .NET dependencies+ working-directory: apps/server+ run: dotnet workload install wasm-tools++ - name: Build API server+ working-directory: apps/server+ run: dotnet build AliasVault.Api++ - name: Start dev database+ run: ./install.sh configure-dev-db start++ - name: Start API server+ working-directory: apps/server/AliasVault.Api+ run: |+ dotnet run --no-build &+ # Wait for API to be ready+ echo "Waiting for API to start..."+ for i in {1..30}; do+ if curl -s http://localhost:5092/v1/Auth/status > /dev/null 2>&1; then+ echo "API is ready!"+ break+ fi+ echo "Attempt $i: API not ready yet..."+ sleep 2+ done+ env:+ ConnectionStrings__AliasServerDbContext: "Host=localhost;Port=5433;Database=aliasdb_e2e_extension;Username=aliasvault;Password=password"+ JWT_KEY: "12345678901234567890123456789012"+ DATA_PROTECTION_CERT_PASS: "Development"+ PUBLIC_REGISTRATION_ENABLED: "true"+ ADMIN_PASSWORD_HASH: "AQAAAAIAAYagAAAAEKWfKfa2gh9Z72vjAlnNP1xlME7FsunRznzyrfqFte40FToufRwa3kX8wwDwnEXZag=="+ ADMIN_PASSWORD_GENERATED: "2024-01-01T00:00:00Z"++ - name: Install browser extension dependenciesrun: npm ciworking-directory: apps/browser-extension@@ -88,6 +126,8 @@ jobs:- name: Build and run E2E testsrun: xvfb-run --auto-servernum npm run test:e2e:buildworking-directory: apps/browser-extension+ env:+ ALIASVAULT_API_URL: "http://localhost:5092"- name: Upload Playwright reportif: always()diff --git a/apps/browser-extension/playwright.config.ts b/apps/browser-extension/playwright.config.tsindex 471854595..cc04f0b42 100644--- a/apps/browser-extension/playwright.config.ts+++ b/apps/browser-extension/playwright.config.ts@@ -14,6 +14,9 @@ import { defineConfig, devices } from '@playwright/test';export default defineConfig({testDir: './tests/e2e',+ // Global setup to check API availability before tests+ globalSetup: './tests/global-setup.ts',+// Global teardown to clean up browser contextsglobalTeardown: './tests/global-teardown.ts',diff --git a/apps/browser-extension/tests/fixtures/fixtures.ts b/apps/browser-extension/tests/fixtures/fixtures.tsindex ec500f8cd..509edadaf 100644--- a/apps/browser-extension/tests/fixtures/fixtures.ts+++ b/apps/browser-extension/tests/fixtures/fixtures.ts@@ -2,7 +2,7 @@ import { test as base, chromium, type BrowserContext, type Page } from '@playwriimport path from 'path';import { fileURLToPath } from 'url';-import { createTestUser, isApiAvailable, type TestUser } from '../helpers/test-api';+import { createTestUser, type TestUser } from '../helpers/test-api';const __filename = fileURLToPath(import.meta.url);const __dirname = path.dirname(__filename);@@ -100,18 +100,7 @@ export const test = base.extend<TestFixtures>({},testUser: async ({ apiUrl }, use) => {- // Check if the API is available- const apiAvailable = await isApiAvailable(apiUrl);- if (!apiAvailable) {- console.warn(`API not available at ${apiUrl}. Tests requiring authentication will fail.`);- // Return a placeholder user - tests should handle this gracefully- await use({- username: 'api_unavailable',- password: 'api_unavailable',- });- return;- }-+ // API availability is checked in global setup// Create a test user for this test runconst testUser = await createTestUser(apiUrl);await use(testUser);diff --git a/apps/browser-extension/tests/global-setup.ts b/apps/browser-extension/tests/global-setup.tsnew file mode 100644index 000000000..a7cac314b--- /dev/null+++ b/apps/browser-extension/tests/global-setup.ts@@ -0,0 +1,28 @@+/**+ * Global setup for E2E tests.+ *+ * Runs before any tests to ensure prerequisites are met.+ */++import { isApiAvailable } from './helpers/test-api';++/**+ * Default API URL for local development.+ */+const DEFAULT_API_URL = process.env.ALIASVAULT_API_URL || 'http://localhost:5092';++export default async function globalSetup(): Promise<void> {+ console.log(`Checking API availability at ${DEFAULT_API_URL}...`);++ const apiAvailable = await isApiAvailable(DEFAULT_API_URL);++ if (!apiAvailable) {+ throw new Error(+ `API is not available at ${DEFAULT_API_URL}. ` ++ 'Please ensure the AliasVault API server is running before running E2E tests. ' ++ 'You can set a custom API URL via the ALIASVAULT_API_URL environment variable.'+ );+ }++ console.log('API is available. Proceeding with tests...');+}