RPGTheory/aeternalis-portal had diverged from this repo (the git/CI/CD copy) with an in-progress control portal feature that was never synced back here, so none of it had gone through CI or been deployed: - New site/game/control routing split: index.html becomes a world directory landing page (site.ts), game.html is the renamed former index.html (main.ts), control.html is a new admin panel (control.ts, portal-shared.ts, portal.css). - Server: new internal/store/portal.go (character/world registry, command queue, admin grants) and internal/transport/control.go (portal API routes), plus a new internal/gitops package that lets the portal provision new worlds via a GitOps repo commit. - game.World gains BornAt/DiedAt/DeathReason and an operator Control() path (close/open admissions, awaken boss, end world, per-character rename/heal/unstuck/retire); death no longer reuses the same character id on rejoin, matching the "new life" permadeath model in Plan.md rather than the old bypass-prevention test's expectations. - deploy/: new control-egress network policy and portal/control values (admin role, GitOps repo/branch/values file/CIDRs). - New e2e coverage: tests/portal.spec.ts, tools/capture-world.mjs. Verified this repo's own independent commits (800ms movement-staleness window, 20s boss-attack poll, SRS/TLS deploy values, ubuntu-22.04 runner pin, DOCKER_HOST fix) were already present in the portal copy before merging, so nothing here regresses them. `tsc --noEmit`, the vite client build, and the protocol contract check all pass; no go.mod changes. Could not run `go build`/`go test` locally (no Go toolchain on PATH, Docker daemon not running) — every new/changed Go symbol was manually cross-referenced and resolves, but this should still be built and tested in CI before merging to master. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
74 lines
5.1 KiB
TypeScript
74 lines
5.1 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test('public directory and account history fit desktop and mobile', async ({ page }) => {
|
|
const errors: string[] = []; page.on('pageerror', e => errors.push(e.message));
|
|
await page.setViewportSize({ width: 1440, height: 1000 });
|
|
await page.goto('/');
|
|
await expect(page.getByRole('heading', { name: 'Aeternalis', exact: true })).toBeVisible();
|
|
await expect(page.locator('.world-row')).toHaveCount(1);
|
|
await expect(page.locator('.world-hero img')).toBeVisible();
|
|
await expect.poll(() => page.locator('.world-hero img').evaluate((img: HTMLImageElement) => img.naturalWidth)).toBeGreaterThan(100);
|
|
await page.getByRole('button', { name: 'Sign in', exact: true }).click();
|
|
await expect(page.getByRole('button', { name: 'Sign out', exact: true })).toBeVisible();
|
|
await page.screenshot({ path: 'test-results/website-desktop.png', fullPage: true });
|
|
await page.setViewportSize({ width: 390, height: 844 });
|
|
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true);
|
|
await page.screenshot({ path: 'test-results/website-mobile.png', fullPage: true });
|
|
expect(errors).toEqual([]);
|
|
});
|
|
|
|
test('admin actions are audited and death permits a distinct replacement', async ({ page }) => {
|
|
const origin = 'http://127.0.0.1:18089';
|
|
await page.request.post('/auth/dev', { data: {}, headers: { Origin: origin } });
|
|
const joined = await page.request.post('/worlds/e2e/api/join', { data: { name: 'Portal life', passage: '' }, headers: { Origin: origin } });
|
|
expect(joined.status()).toBe(200); const old = await joined.json();
|
|
await page.setViewportSize({ width: 1440, height: 1000 });
|
|
await page.goto('/control');
|
|
await expect(page.locator('#workspace')).toBeVisible();
|
|
await page.getByRole('button', { name: 'Characters', exact: true }).click();
|
|
await expect(page.locator('#view-title')).toHaveText('Characters');
|
|
await page.getByRole('searchbox', { name: 'Search records' }).fill('Portal life');
|
|
await expect(page.locator('tbody tr')).toHaveCount(1);
|
|
await page.getByRole('button', { name: 'Portal life', exact: true }).click();
|
|
await expect(page.locator('#character-dialog')).toBeVisible();
|
|
await expect(page.locator('#character-detail')).toContainText(old.entity.id);
|
|
await page.getByRole('button', { name: 'Close character', exact: true }).click();
|
|
await page.getByLabel(`Action for ${old.entity.id}`).selectOption('rename');
|
|
await page.getByLabel('Character name', { exact: true }).fill('Portal renamed');
|
|
await page.getByLabel('Reason', { exact: true }).fill('Rename verification');
|
|
await page.getByRole('button', { name: 'Queue action' }).click();
|
|
await expect.poll(async () => (await (await page.request.get('/api/account')).json()).active?.name).toBe('Portal renamed');
|
|
await page.getByRole('searchbox', { name: 'Search records' }).fill('Portal renamed');
|
|
await page.getByRole('button', { name: 'Refresh', exact: true }).click();
|
|
await expect(page.locator('tbody tr')).toHaveCount(1);
|
|
await page.screenshot({ path: 'test-results/control-desktop.png', fullPage: true });
|
|
await page.getByLabel(`Action for ${old.entity.id}`).selectOption('retire');
|
|
await page.getByLabel('Reason', { exact: true }).fill('Permanent death verification');
|
|
await page.getByLabel(`Confirm character ID: ${old.entity.id}`).fill(old.entity.id);
|
|
await page.getByRole('button', { name: 'Queue action' }).click();
|
|
await expect.poll(async () => (await (await page.request.get('/api/account')).json()).active).toBeNull();
|
|
await page.goto('/game?world=e2e');
|
|
await expect(page.locator('#connection-status')).toHaveText('World online');
|
|
await page.getByLabel('Character name', { exact: true }).fill('Portal second life');
|
|
await page.getByRole('button', { name: 'Enter world' }).click();
|
|
await expect(page.locator('#connection-status')).toHaveText('Connected');
|
|
await expect.poll(() => page.evaluate(() => (window as any).__aeternalis?.snapshot?.self?.entity?.id)).toBeTruthy();
|
|
const current = await page.evaluate(() => (window as any).__aeternalis.snapshot.self.entity.id);
|
|
expect(current).not.toBe(old.entity.id);
|
|
const account = await (await page.request.get('/api/account')).json();
|
|
expect(account.characters.find(c => c.id === old.entity.id).state).toBe('dead');
|
|
expect(account.characters.find(c => c.id === old.entity.id).character.deathReason).toContain('Permanent death verification');
|
|
await page.goto('/control'); await page.getByRole('button', { name: 'Audit log', exact: true }).click();
|
|
await expect(page.locator('tbody')).toContainText('Permanent death verification');
|
|
await page.setViewportSize({ width: 390, height: 844 });
|
|
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true);
|
|
await page.screenshot({ path: 'test-results/control-mobile.png', fullPage: true });
|
|
});
|
|
|
|
test('control gives anonymous visitors a sign-in state', async ({ page }) => {
|
|
await page.goto('/control');
|
|
await expect(page.getByRole('heading', { name: 'Sign in to Control' })).toBeVisible();
|
|
await expect(page.locator('#workspace')).toBeHidden();
|
|
expect((await page.request.get('/api/control')).status()).toBe(401);
|
|
});
|