Files
waggle-os/tests/e2e/polish-verification.spec.ts
shumeiko.it 20567ecb10 test(e2e): align specs with the community edition and record the e2e baseline
The first full e2e run on this branch failed 19 tests, all on features the
community edition removed: /api/tier, Stripe, /api/compliance, the billing
settings tab, the payment pages and the upgrade dialog. Those checks now
assert that the endpoints and pages are gone (404); tier, billing and
team-settings probes are dropped from the remaining journeys. The rerun is
410 passed, 18 skipped, 0 failed.
2026-10-20 01:36:38 +02:00

184 lines
7.1 KiB
TypeScript

/**
* Polish Plan Verification — E2E tests for Phase 1-3 changes.
*
* Covers:
* Phase 1: Health check cache, marketplace redirect, knowledge graph fallback
* Phase 2: Tier gating (Mission Control, Custom Skills, /spawn, connectors, sidebar)
* Phase 3: Error handling, skip button, workspace switcher trigger
*
* Run: npx playwright test tests/e2e/polish-verification.spec.ts --reporter=list
*/
import { test, expect, type Page } from '@playwright/test';
const API = process.env.WAGGLE_E2E_BASE_URL ?? 'http://127.0.0.1:3333';
// ── Helpers ────────────────────────────────────────────────────────────────
async function skipOnboarding(page: Page) {
await page.request.patch(`${API}/api/settings`, {
data: { onboardingCompleted: true },
headers: { 'Content-Type': 'application/json' },
}).catch(() => {});
await page.addInitScript(() => {
localStorage.setItem('waggle:onboarding', JSON.stringify({ completed: true, step: 7 }));
localStorage.setItem('waggle:first-run', 'done');
});
}
async function waitForApp(page: Page) {
await page.waitForSelector(
'.waggle-app-shell, .waggle-sidebar, [role="navigation"], [class*="onboarding"]',
{ timeout: 15_000 },
).catch(() => {});
}
// ── Phase 1: Backend Fixes ────────────────────────────────────────────────
test.describe('Phase 1 — Backend Fixes', () => {
test('health check returns status', async () => {
const res = await fetch(`${API}/health`);
expect(res.ok).toBeTruthy();
const data = await res.json();
expect(data).toHaveProperty('status');
// Should not be permanently stuck in degraded if no key
expect(['ok', 'degraded', 'unavailable']).toContain(data.status);
});
test('marketplace /packs returns 200', async () => {
const res = await fetch(`${API}/api/marketplace/packs`);
// 200 if marketplace DB loaded, 503 if not — both are acceptable
expect([200, 503]).toContain(res.status);
});
test('marketplace /plugins returns 301 redirect hint', async () => {
const res = await fetch(`${API}/api/marketplace/plugins`, { redirect: 'manual' });
expect(res.status).toBe(301);
const data = await res.json();
expect(data.redirect).toBe('/api/marketplace/search');
});
test('knowledge graph returns empty for nonexistent workspace', async () => {
const res = await fetch(`${API}/api/memory/graph?workspace=nonexistent-ws-12345`);
expect(res.ok).toBeTruthy();
const data = await res.json();
expect(data).toEqual({ nodes: [], edges: [] });
});
});
// ── Phase 3: UX Fixes ────────────────────────────────────────────────────
test.describe('Phase 3 — UX Fixes', () => {
test('connector connect shows error on invalid token', async () => {
// Get list of connectors
const listRes = await fetch(`${API}/api/connectors`);
if (!listRes.ok) {
test.skip(true, 'Connectors endpoint not available');
return;
}
const { connectors } = await listRes.json() as { connectors: { id: string; status: string }[] };
const disconnected = connectors.find(c => c.status === 'disconnected');
if (!disconnected) {
test.skip(true, 'No disconnected connectors to test');
return;
}
// Try to connect with obviously bad token
const res = await fetch(`${API}/api/connectors/${disconnected.id}/connect`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ token: 'invalid-test-token' }),
});
// Should respond (not hang/crash) — may succeed or fail depending on connector
expect(res.status).toBeLessThan(500);
});
test('workspace creation returns error on missing data', async () => {
const res = await fetch(`${API}/api/workspaces`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({}), // Missing required 'name'
});
// Should respond with an error, not crash
expect(res.status).toBeLessThan(500);
});
test('onboarding skip button is visible on API key step', async ({ page }) => {
// Reset onboarding state
await page.addInitScript(() => {
localStorage.removeItem('waggle:onboarding');
localStorage.removeItem('waggle:first-run');
});
await page.request.patch(`${API}/api/settings`, {
data: { onboardingCompleted: false },
headers: { 'Content-Type': 'application/json' },
}).catch(() => {});
await page.goto(`${API}`);
// Wait for onboarding to appear
const onboarding = page.locator('[class*="onboarding"], [data-testid*="onboarding"]');
const visible = await onboarding.isVisible({ timeout: 10_000 }).catch(() => false);
if (!visible) {
test.skip(true, 'Onboarding did not appear');
return;
}
// Navigate to API key step (step 5) — click through wizard
// The skip button should be a proper Button component, not just underlined text
const skipButton = page.locator('button', { hasText: /Skip.*key.*later/i });
// It may take several clicks to reach step 5
// Just verify the button exists somewhere in the wizard
test.info().annotations.push({ type: 'note', description: 'Skip button presence check' });
});
test('workspace switcher trigger exists in sidebar', async ({ page }) => {
await skipOnboarding(page);
await page.goto(`${API}`);
await waitForApp(page);
// Look for the workspace switcher trigger button with ^Tab hint
const switcherTrigger = page.locator('button[title*="Switch workspace"]');
const visible = await switcherTrigger.isVisible({ timeout: 5000 }).catch(() => false);
if (visible) {
// Click it and verify workspace switcher opens
await switcherTrigger.click();
// WorkspaceSwitcher should appear
await page.waitForTimeout(500);
}
});
test('zero React key warnings in console', async ({ page }) => {
const keyWarnings: string[] = [];
page.on('console', (msg) => {
const text = msg.text();
if (text.includes('same key') || text.includes('Each child in a list should have a unique')) {
keyWarnings.push(text);
}
});
await skipOnboarding(page);
await page.goto(`${API}`);
await waitForApp(page);
// Navigate through main views to trigger renders
const views = ['chat', 'capabilities', 'cockpit', 'memory', 'events'];
for (const view of views) {
const btn = page.locator(`button[title*="${view}"]`).first();
if (await btn.isVisible({ timeout: 2000 }).catch(() => false)) {
await btn.click();
await page.waitForTimeout(300);
}
}
// Check for key warnings
if (keyWarnings.length > 0) {
test.info().annotations.push({
type: 'warning',
description: `Found ${keyWarnings.length} React key warning(s): ${keyWarnings[0]?.slice(0, 100)}`,
});
}
expect(keyWarnings.length).toBe(0);
});
});