* fix(e2e): guard marketplace webServer and exclude per-app tests from main Playwright config Root cause: playwright.config.ts unconditionally started the marketplace dev server at ../worldwideview-marketplace. In CI only worldwideview is checked out, so spawn() received a non-existent cwd which Node.js surfaces as "spawn /bin/sh ENOENT", crashing the entire test run before any browser launched. Two targeted fixes: 1. Wrap the marketplace webServer entry in fs.existsSync(MARKETPLACE_DIR) so CI skips it gracefully. Use playwright.marketplace.config.ts to run cross-app marketplace tests locally. 2. Add testIgnore for web-auth.spec.ts and marketplace-from-instance.spec.ts — both target sibling repos (worldwideview-web / worldwideview-marketplace) and have their own dedicated configs (playwright.web.config.ts / playwright.marketplace.config.ts). The main config should only exercise the worldwideview app itself. * feat(09-02): add playwright.cross-app.config.ts and .env.test for cross-origin specs - Add playwright.cross-app.config.ts with dual webServer array (wwv.local:3001 + marketplace.wwv.local:3002) - testMatch targets both upcoming cross-app spec files; baseURL set to marketplace.wwv.local:3002 - Create worldwideview/.env.test with PLAYWRIGHT_TEST_EMAIL + PLAYWRIGHT_TEST_PASSWORD (gitignored) - Add explicit .env.test entry to .gitignore (was not covered by existing .env/.env.local patterns) - Bump version 2.20.2 -> 2.21.0 (feat: minor) * feat(09-02): add cross-app Playwright specs for redirect handshake and sign-out (REQ-16) - Add marketplace-redirect-handshake.spec.ts: 2 tests verifying next= param construction and login-then-redirect-back flow - Add marketplace-sign-out.spec.ts: 1 test verifying avatar dropdown sign-out clears session and returns to marketplace home - Update playwright.cross-app.config.ts to load .env.test credentials via fs (no dotenv package required) - All specs target https://marketplace.wwv.local:3002 (never localhost:3002) for correct .wwv.local cookie domain - 3 tests total listed by playwright --list * feat: add planning-sync hook script for .planning branch isolation * fix: guard planning-sync against missing .planning, wrong repo, and silent checkout failures - Exit early if .planning/.git doesn't exist (avoids false-success on machines without the private repo) - Exit early if CWD is not a worldwideview repo or worktree (prevents syncing from wwv-data-engine etc.) - Wrap both checkout calls in exit-code checks so failures emit WARNING messages instead of false success * feat: add post-checkout hook for .planning auto-sync * fix: add existence guard to post-checkout hook before calling planning-sync * docs: add .planning branch convention to worktree-bootstrap skill * feat(11-01): add LegalFooter component and .legal-footer CSS class - Create src/components/layout/LegalFooter.tsx as a Server Component - Export named function LegalFooter with two external anchors - Both anchors use target="_blank" rel="noopener noreferrer" (T-11-01) - Links target locked URLs: privacy-policy and cloud-terms-of-service - Append .legal-footer + a + a:hover rules to globals.css - position:fixed bottom:0 z-index:10 per UI-SPEC - Bump version 2.23.2 -> 2.23.3 * feat(11-01): remove Vercel Analytics, mount LegalFooter in root layout - Remove @vercel/analytics/next import from layout.tsx (D-02) - Remove {process.env.VERCEL && <Analytics />} JSX (D-02, T-11-02) - Add import { LegalFooter } from @/components/layout/LegalFooter - Render <LegalFooter /> as last child of <body> (D-04) - Remove @vercel/analytics from dependencies in package.json - Regenerate pnpm-lock.yaml after dependency removal - AdSense block (lines 27-37) untouched per D-03 - Bump version 2.23.3 -> 2.23.4 * fix(worktree): fix link_planning hook path conversion for Windows Worktrunk substitutes {{ worktree_path }} as a Unix-style path (/c/dev/...) which cmd.exe cannot resolve. It also strips $ sigils from variable names before executing hook commands, making inline PowerShell variables unusable. Extract junction logic to .agents/scripts/link-planning.ps1 and unlink-planning.ps1. The hooks now call powershell -File with the path as an argument, avoiding both issues entirely. * docs: add ADR-004 and phase-2 implementation plans Adds the Supabase session cookies httponly ADR alongside the six implementation plan documents produced during the auth gate phase. * feat(auth): implement Phase 2 cloud auth gate (ADR-003 closeout) - Cloud edition login page redirects to NEXT_PUBLIC_AUTH_HOST_URL; local/demo editions keep the NextAuth credentials form - Delete signup pages and Supabase PKCE callback route from worldwideview (auth host owns them per ADR-003) - Add Supabase SSR helpers (cookieOptions, server, client) with httpOnly:true cookies per ADR-004 - Dual-dispatch install-redirect and grant-token: Supabase on cloud, NextAuth on local/demo; redirect param unified to ?next= - Add streaming mode to safeFetch for MJPEG camera proxy streams - Extract LoginForm into its own component - Update Playwright config to conditionally start marketplace dev server * fix(types): cast undici ReadableStream body to BodyInit to satisfy DOM types node:stream/web ReadableStream is structurally incompatible with the DOM ReadableStream expected by the Response constructor -- the pipeThrough signature differs on the T | undefined generic bound. Cast to BodyInit (which is the correct type for the streaming pass-through) to resolve the TS2345 error in ssrf.ts line 112. * fix(e2e): exclude cross-app marketplace specs from default Playwright run marketplace-redirect-handshake.spec.ts and marketplace-sign-out.spec.ts require a running marketplace.wwv.local:3002 instance (cross-app environment). They were being picked up by playwright.config.ts in CI where that host does not exist, causing ERR_NAME_NOT_RESOLVED failures. Added both files to testIgnore alongside the existing exclusions; they should be run via playwright.cross-app.config.ts only. * fix: add pointer event support to bottom panel resize for webkit Playwright's webkit engine dispatches pointermove/pointerup reliably during synthetic drags but mousemove sometimes does not fire. Add pointermove and pointerup listeners alongside the existing mouse listeners, and add onPointerDown to the drag handle, so the resize test passes across all three browser engines.
209 lines
9.3 KiB
TypeScript
209 lines
9.3 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
/**
|
|
* Marketplace instance auto-discovery E2E tests.
|
|
*
|
|
* Two test groups:
|
|
*
|
|
* 1. "capture side" — navigates directly to the marketplace with
|
|
* ?from_instance=... and verifies InstanceCapture stores it.
|
|
* Runs with playwright.marketplace.config.ts (no worldwideview / Docker needed).
|
|
*
|
|
* 2. "full flow" — opens worldwideview, clicks Browse Plugins, and verifies
|
|
* the marketplace receives the param. Needs the main playwright.config.ts
|
|
* (Docker + Postgres required for auth).
|
|
*/
|
|
|
|
const MARKETPLACE_URL = 'http://localhost:3002';
|
|
const WWV_ORIGIN = 'http://localhost:3001';
|
|
const FROM_INSTANCE_PARAM = `from_instance=${encodeURIComponent(WWV_ORIGIN)}`;
|
|
|
|
// ─── Marketplace capture side (no worldwideview auth needed) ────────────────
|
|
|
|
test.describe('InstanceCapture — marketplace receives from_instance', () => {
|
|
test('captures valid origin, writes localStorage, cleans URL', async ({ page }) => {
|
|
// Navigate as the marketplace would be opened by worldwideview.
|
|
// InstanceCapture runs during React hydration (useEffect), so by the time
|
|
// page.goto() resolves the URL may already be clean — that is correct behavior.
|
|
await page.goto(`${MARKETPLACE_URL}/?${FROM_INSTANCE_PARAM}`);
|
|
|
|
// Wait for InstanceCapture to write to localStorage (may already be set)
|
|
await page.waitForFunction(
|
|
() => localStorage.getItem('wwv_instance_url') !== null,
|
|
{ timeout: 15000 }
|
|
);
|
|
|
|
// localStorage has the correct origin-only value
|
|
const stored = await page.evaluate(() => localStorage.getItem('wwv_instance_url'));
|
|
expect(stored).toBe(WWV_ORIGIN);
|
|
|
|
// from_instance param was stripped by history.replaceState
|
|
expect(page.url()).not.toContain('from_instance');
|
|
});
|
|
|
|
test('rejects javascript: protocol and leaves localStorage empty', async ({ page }) => {
|
|
// Clear any prior localStorage from the same origin
|
|
await page.goto(MARKETPLACE_URL);
|
|
await page.evaluate(() => localStorage.removeItem('wwv_instance_url'));
|
|
|
|
await page.goto(`${MARKETPLACE_URL}/?from_instance=${encodeURIComponent('javascript:alert(1)')}`);
|
|
|
|
// Give InstanceCapture time to run
|
|
await page.waitForTimeout(1500);
|
|
|
|
const stored = await page.evaluate(() => localStorage.getItem('wwv_instance_url'));
|
|
expect(stored).toBeNull();
|
|
});
|
|
|
|
test('rejects self-referential origin and leaves localStorage empty', async ({ page }) => {
|
|
await page.goto(MARKETPLACE_URL);
|
|
await page.evaluate(() => localStorage.removeItem('wwv_instance_url'));
|
|
|
|
// from_instance points at the marketplace itself — should be rejected
|
|
await page.goto(`${MARKETPLACE_URL}/?from_instance=${encodeURIComponent(MARKETPLACE_URL)}`);
|
|
await page.waitForTimeout(1500);
|
|
|
|
const stored = await page.evaluate(() => localStorage.getItem('wwv_instance_url'));
|
|
expect(stored).toBeNull();
|
|
});
|
|
|
|
test('direct navigation without param leaves localStorage unchanged', async ({ page }) => {
|
|
await page.goto(MARKETPLACE_URL);
|
|
await page.evaluate(() => localStorage.removeItem('wwv_instance_url'));
|
|
|
|
await page.reload();
|
|
await page.waitForLoadState('load');
|
|
await page.waitForTimeout(1000);
|
|
|
|
const stored = await page.evaluate(() => localStorage.getItem('wwv_instance_url'));
|
|
expect(stored).toBeNull();
|
|
});
|
|
});
|
|
|
|
// ─── Linked-instance API surface (anonymous, marketplace-only) ──────────────
|
|
|
|
test.describe('linked-instance API — anonymous surface', () => {
|
|
test('GET /api/instances returns 401 when no session cookie', async ({ request }) => {
|
|
const res = await request.get(`${MARKETPLACE_URL}/api/instances`);
|
|
expect(res.status()).toBe(401);
|
|
const body = await res.json();
|
|
expect(body).toEqual({ error: 'unauthenticated' });
|
|
});
|
|
|
|
test('POST /api/instances/link returns 401 when anonymous (fire-and-forget safe)', async ({ request }) => {
|
|
const res = await request.post(`${MARKETPLACE_URL}/api/instances/link`, {
|
|
data: { url: WWV_ORIGIN },
|
|
headers: { 'content-type': 'application/json' },
|
|
});
|
|
expect(res.status()).toBe(401);
|
|
});
|
|
|
|
test('GET /api/install/start with no session 302s to AUTH_HOST/login?next=...', async ({ request }) => {
|
|
const installUrl = new URL(`${MARKETPLACE_URL}/api/install/start`);
|
|
installUrl.searchParams.set('pluginId', 'aviation');
|
|
installUrl.searchParams.set('version', '1.0.0');
|
|
installUrl.searchParams.set('manifest', 'eyJpZCI6ImF2aWF0aW9uIn0='); // {"id":"aviation"}
|
|
installUrl.searchParams.set('instanceUrl', WWV_ORIGIN);
|
|
installUrl.searchParams.set('redirectTo', `${MARKETPLACE_URL}/browse/aviation`);
|
|
|
|
const res = await request.get(installUrl.toString(), { maxRedirects: 0 });
|
|
expect(res.status()).toBe(307);
|
|
|
|
const location = res.headers().location ?? '';
|
|
expect(location).toMatch(/\/login\?next=/);
|
|
// The next param should round-trip the entire install/start URL
|
|
const next = new URL(location).searchParams.get('next');
|
|
expect(next).toContain('/api/install/start');
|
|
expect(next).toContain('pluginId=aviation');
|
|
});
|
|
|
|
test('POST /api/install/start with javascript: scheme returns 400 before auth check', async ({ request }) => {
|
|
// The validator runs before the auth gate, so this should 400 even anonymous
|
|
const installUrl = new URL(`${MARKETPLACE_URL}/api/install/start`);
|
|
installUrl.searchParams.set('pluginId', 'aviation');
|
|
installUrl.searchParams.set('version', '1.0.0');
|
|
installUrl.searchParams.set('manifest', 'eyJpZCI6ImF2aWF0aW9uIn0=');
|
|
installUrl.searchParams.set('instanceUrl', 'javascript:alert(1)');
|
|
installUrl.searchParams.set('redirectTo', `${MARKETPLACE_URL}/browse/aviation`);
|
|
|
|
const res = await request.get(installUrl.toString(), { maxRedirects: 0 });
|
|
expect(res.status()).toBe(400);
|
|
});
|
|
});
|
|
|
|
// ─── InstanceCapture → server-link fire-and-forget ──────────────────────────
|
|
|
|
test.describe('InstanceCapture also POSTs to /api/instances/link', () => {
|
|
test('fires a link POST after writing localStorage', async ({ page }) => {
|
|
// Spy on the outgoing POST. The server will 401 (we're anonymous) and
|
|
// the InstanceCapture promise swallows that — we just want to confirm
|
|
// the request was made, not that it succeeded.
|
|
const linkPromise = page.waitForRequest(
|
|
(req) => req.url().endsWith('/api/instances/link') && req.method() === 'POST',
|
|
{ timeout: 10000 },
|
|
);
|
|
|
|
await page.goto(`${MARKETPLACE_URL}/?${FROM_INSTANCE_PARAM}`);
|
|
|
|
const req = await linkPromise;
|
|
const body = JSON.parse(req.postData() ?? '{}');
|
|
expect(body).toEqual({ url: WWV_ORIGIN });
|
|
});
|
|
});
|
|
|
|
// ─── Full flow (worldwideview → marketplace, requires Docker + auth) ─────────
|
|
|
|
test.describe('Full flow — Browse Plugins in worldwideview opens marketplace', () => {
|
|
test.beforeEach(async ({ page, baseURL }) => {
|
|
// Skip when running with the marketplace-only config (baseURL = 3002)
|
|
test.skip(baseURL !== WWV_ORIGIN, 'Requires worldwideview running (main config + Docker)');
|
|
|
|
await page.goto('/');
|
|
await page.waitForSelector('[data-testid="app-ready"]', { state: 'attached', timeout: 45000 });
|
|
|
|
// Dismiss unverified plugin dialog if it appears
|
|
try {
|
|
const installBtn = page.getByRole('button', { name: /Install Selected/ });
|
|
await installBtn.waitFor({ state: 'visible', timeout: 2000 });
|
|
await installBtn.click();
|
|
} catch { /* not present */ }
|
|
|
|
// Ensure left panel is open
|
|
const leftToggle = page.locator('[data-testid="panel-toggle-left"]');
|
|
const isOpen = await leftToggle.evaluate((el) => el.classList.contains('panel-toggle-btn--open'));
|
|
if (!isOpen) await leftToggle.click();
|
|
});
|
|
|
|
test('Browse Plugins appends from_instance and marketplace captures it', async ({ page }) => {
|
|
// Navigate to Plugins tab
|
|
const pluginsTab = page.locator('button.panel-tab[title="Plugins"]');
|
|
await expect(pluginsTab).toBeVisible({ timeout: 10000 });
|
|
await pluginsTab.click();
|
|
|
|
const browseBtn = page.locator('[data-testid="browse-plugins-btn"]');
|
|
await expect(browseBtn).toBeVisible({ timeout: 5000 });
|
|
|
|
// Click and capture the popup
|
|
const popupPromise = page.waitForEvent('popup');
|
|
await browseBtn.click();
|
|
const popup = await popupPromise;
|
|
|
|
// Initial URL has from_instance
|
|
expect(popup.url()).toContain(FROM_INSTANCE_PARAM);
|
|
|
|
// InstanceCapture writes to localStorage
|
|
await popup.waitForFunction(
|
|
() => localStorage.getItem('wwv_instance_url') !== null,
|
|
{ timeout: 15000 }
|
|
);
|
|
|
|
const stored = await popup.evaluate(() => localStorage.getItem('wwv_instance_url'));
|
|
expect(stored).toBe(WWV_ORIGIN);
|
|
|
|
// URL cleaned up
|
|
expect(popup.url()).not.toContain('from_instance');
|
|
|
|
await popup.close();
|
|
});
|
|
});
|