End-to-end testing infrastructure for the Powernode platform using Playwright.
Playwright provides cross-browser E2E testing for AI functionality and other platform features. Tests are organized using the Page Object Model pattern and cover the 25 phases from the manual testing guide.
/e2e/
├── fixtures/
│ ├── auth.ts # Authentication helpers
│ └── test-data.ts # Test data and constants
├── pages/ # Page Object Models
│ ├── login.page.ts
│ └── ai/
│ ├── providers.page.ts
│ ├── agents.page.ts
│ ├── workflows.page.ts
│ ├── conversations.page.ts
│ ├── agent-teams.page.ts
│ └── monitoring.page.ts
├── ai/ # AI test specs
│ ├── providers.spec.ts
│ ├── agents.spec.ts
│ ├── conversations.spec.ts
│ ├── workflows.spec.ts
│ ├── agent-teams.spec.ts
│ └── monitoring.spec.ts
└── global-setup.ts # Auth state setup
npx playwright installTests use credentials from test-credentials.json (generated by rails db:seed).
Alternatively, set environment variables:
export TEST_USER_EMAIL="admin@powernode.test"
export TEST_USER_PASSWORD="password123"sudo systemctl start powernode.target# Run all tests
npm run test:e2e
# Run with UI (interactive mode)
npm run test:e2e:ui
# Run in headed mode (see browser)
npm run test:e2e:headed
# Run with debugging
npm run test:e2e:debug
# View HTML report
npm run test:e2e:report# Run specific spec file
npm run test:e2e -- e2e/ai/providers.spec.ts
# Run tests matching pattern
npm run test:e2e -- --grep "providers"
# Run only chromium
npm run test:e2e:chromium
# Run only firefox
npm run test:e2e:firefox
# Run only webkit (Safari)
npm run test:e2e:webkit| Phase | Spec File | Coverage |
|---|---|---|
| Phase 1: Providers | providers.spec.ts |
Connection testing, model sync, credentials |
| Phase 2: Agents | agents.spec.ts |
CRUD, execution, history |
| Phase 3: Conversations | conversations.spec.ts |
Multi-turn chat, context retention |
| Phase 4: Workflows | workflows.spec.ts |
Builder, execution, validation |
| Phase 5: Agent Teams | agent-teams.spec.ts |
Team creation, execution, monitoring |
| Phase 10: Monitoring | monitoring.spec.ts |
Dashboard, tabs, circuit breakers |
| Phase 17: Messages | conversations.spec.ts |
Rating, copy, regenerate |
| Phase 18: Validation | workflows.spec.ts |
Health score, issues |
| Phase 19: Circuit Breakers | monitoring.spec.ts |
States, reset |
import { test, expect } from '@playwright/test';
import { ProvidersPage } from '../pages/ai/providers.page';
test.describe('AI Providers', () => {
let providersPage: ProvidersPage;
test.beforeEach(async ({ page }) => {
providersPage = new ProvidersPage(page);
await providersPage.goto();
await providersPage.waitForReady();
});
test('should test provider connection', async () => {
await providersPage.testConnection('Ollama');
await providersPage.verifyConnectionSuccess();
});
});import { TEST_AGENT, uniqueTestData } from '../fixtures/test-data';
test('should create agent', async () => {
const testAgent = uniqueTestData(TEST_AGENT); // Adds unique suffix
await agentsPage.createAgent(testAgent);
await agentsPage.verifyAgentExists(testAgent.name);
});Available in e2e/fixtures/test-data.ts:
TEST_PROVIDER- Provider test dataTEST_AGENT- Agent test dataTEST_CONVERSATION- Conversation test dataTEST_WORKFLOW- Workflow test dataTEST_AGENT_TEAM- Agent team test dataTEST_CONTEXT- Context/memory test dataROUTES- Frontend route constantsAPI_ENDPOINTS- API endpoint constants
Key configuration options:
{
testDir: './e2e',
fullyParallel: true,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
use: {
baseURL: 'http://localhost:3001',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'on-first-retry',
},
projects: [
{ name: 'setup', testMatch: /global-setup\.ts/ },
{ name: 'chromium', dependencies: ['setup'] },
{ name: 'firefox', dependencies: ['setup'] },
{ name: 'webkit', dependencies: ['setup'] },
],
}| Variable | Description | Default |
|---|---|---|
PLAYWRIGHT_BASE_URL |
Frontend URL | http://localhost:3001 |
TEST_USER_EMAIL |
Test user email | admin@powernode.test |
TEST_USER_PASSWORD |
Test user password | password123 |
CI |
CI environment flag | - |
Tests use stored authentication state for efficiency:
global-setup.tslogs in once- Auth state saved to
e2e/.auth/user.json - All test projects reuse stored state
To reset authentication:
rm -rf e2e/.auth/
npm run test:e2eInstall "Playwright Test for VS Code" for:
- Run tests from editor
- Debug with breakpoints
- View traces
npm run test:e2e:debugOpens Playwright Inspector with step-through debugging.
View traces for failed tests:
npx playwright show-trace test-results/path/to/trace.zipFailed test screenshots are saved to test-results/.
- name: Install Playwright
run: npx playwright install --with-deps
- name: Run E2E Tests
run: npm run test:e2e
- name: Upload Report
uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/Encapsulate page interactions for maintainability:
// Good
await providersPage.testConnection('Ollama');
// Avoid
await page.locator('button:has-text("Test Connection")').click();// Good
await page.waitForSelector('[class*="success"]');
// Avoid
await page.waitForTimeout(2000);const testAgent = uniqueTestData(TEST_AGENT);const hasAgents = await page.locator('[class*="card"]').count() > 0;
const hasEmptyState = await page.locator(':text("No agents")').count() > 0;
expect(hasAgents || hasEmptyState).toBeTruthy();AI operations may take time:
await page.waitForSelector('[class*="response"]', { timeout: 60000 });- Increase timeouts for CI
- Use single worker:
workers: 1 - Check server startup times
- Delete
e2e/.auth/directory - Verify credentials in
test-credentials.json - Check login page selectors
- Add explicit waits
- Use
networkidleload state - Handle async operations properly
# Install all browsers
npx playwright install
# Install specific browser
npx playwright install chromiumPlaywright supersedes Cypress for E2E tests. Key differences:
| Aspect | Cypress | Playwright |
|---|---|---|
| Syntax | cy.get() |
page.locator() |
| Waits | Automatic | Explicit await |
| Multi-browser | Limited | Full support |
| Parallel | Plugin required | Built-in |
Cypress tests remain in frontend/cypress/ for reference during migration.