Same failure signature as the boss test fixed last round ("Test
timeout of 45000ms exceeded", the whole test's hard deadline, not a
specific assertion), this time landing on this test instead -- not
caused by the Helm chart fix or the boss test.slow() change, both of
which touch entirely disjoint code (a Kubernetes manifest template
never exercised by npm run test:e2e, and a different test block).
Consistent with a CI runner that's intermittently slow enough that
whichever test draws the short straw on a given run can blow its
budget before its own poll timeout gets to report cleanly -- this is
the most elaborate test here (WebGL pixel readback, model diagnostics,
a full reload/reconnect cycle), so the most likely next candidate.
Verified: full local e2e suite (7/7) still passes.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
99 lines
6.5 KiB
TypeScript
99 lines
6.5 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
async function enter(page, name = 'Wayfarer') {
|
|
await page.goto('/game?world=e2e');
|
|
await expect(page.locator('#connection-status')).toHaveText('World online');
|
|
await page.getByLabel('Character name').fill(name);
|
|
await page.getByRole('button', { name: 'Enter world' }).click();
|
|
await expect(page.locator('#connection-status')).toHaveText('Connected');
|
|
await expect(page.locator('#game-controls')).toBeVisible();
|
|
await expect.poll(() => page.evaluate(() => (window as any).__aeternalis?.diagnostics().chunks)).toBe(9);
|
|
}
|
|
|
|
test('desktop renders models, moves authoritatively, gathers, and reconnects', async ({ page }) => {
|
|
// Same reasoning as the boss test's test.slow(): this is the most elaborate test here
|
|
// (WebGL pixel readback, model diagnostics, a full reload/reconnect cycle), so it's the
|
|
// most likely to hit the config's 45s per-test deadline before its own poll timeouts do
|
|
// on a slow CI run.
|
|
test.slow();
|
|
const errors: string[] = [];
|
|
page.on('pageerror', error => errors.push(error.message));
|
|
await page.setViewportSize({ width: 1440, height: 900 });
|
|
await enter(page);
|
|
const before = await page.evaluate(() => (window as any).__aeternalis.snapshot.self.entity.position);
|
|
await page.keyboard.down('d'); await page.waitForTimeout(1000); await page.keyboard.up('d');
|
|
await expect.poll(() => page.evaluate(() => (window as any).__aeternalis.snapshot.self.entity.position.x)).toBeGreaterThan(before.x + 3);
|
|
await page.getByRole('button', { name: 'Gather', exact: true }).click();
|
|
await expect.poll(() => page.evaluate(() => Object.values((window as any).__aeternalis.snapshot.self.skills).reduce((sum: number, n: any) => sum + n, 0)), { timeout: 15000 }).toBeGreaterThan(0);
|
|
await page.getByRole('button', { name: 'Inventory and crafting' }).click();
|
|
await expect(page.locator('#inventory')).toBeVisible();
|
|
await expect(page.locator('#inventory-items')).toContainText('Knife');
|
|
await page.getByRole('button', { name: 'Close inventory', exact: true }).click();
|
|
const id = await page.evaluate(() => (window as any).__aeternalis.snapshot.self.entity.id);
|
|
await page.screenshot({ path: 'test-results/desktop.png' });
|
|
const pixels = await page.evaluate(async () => {
|
|
const canvas = document.getElementById('world') as HTMLCanvasElement;
|
|
// Read in the animation frame immediately after rendering; avoid a cleared backbuffer.
|
|
return new Promise<number>(resolve => requestAnimationFrame(() => {
|
|
const gl = canvas.getContext('webgl2')!;
|
|
const data = new Uint8Array(64 * 64 * 4);
|
|
gl.readPixels(Math.floor(canvas.width / 2) - 32, Math.floor(canvas.height / 2) - 32, 64, 64, gl.RGBA, gl.UNSIGNED_BYTE, data);
|
|
const colors = new Set<string>(); for (let i = 0; i < data.length; i += 4) colors.add(`${data[i]},${data[i+1]},${data[i+2]}`);
|
|
resolve(colors.size);
|
|
}));
|
|
});
|
|
expect(pixels).toBeGreaterThan(8);
|
|
const diagnostics = await page.evaluate(() => (window as any).__aeternalis.diagnostics());
|
|
expect(diagnostics.models).toBe(6); expect(diagnostics.frames).toBeGreaterThan(10); expect(diagnostics.triangles).toBeGreaterThan(1000);
|
|
await page.reload();
|
|
await expect(page.locator('#connection-status')).toHaveText('Connected');
|
|
await expect.poll(() => page.evaluate(() => (window as any).__aeternalis?.snapshot?.self.entity.id)).toBe(id);
|
|
expect(errors).toEqual([]);
|
|
});
|
|
|
|
test('mobile controls fit and move the character', async ({ page }) => {
|
|
await page.setViewportSize({ width: 390, height: 844 });
|
|
await enter(page, 'Mobile');
|
|
await expect(page.getByRole('button', { name: 'Move north' })).toBeVisible();
|
|
const before = await page.evaluate(() => (window as any).__aeternalis.snapshot.self.entity.position.z);
|
|
const button = page.getByRole('button', { name: 'Move north' });
|
|
await button.dispatchEvent('pointerdown', { pointerId: 1 }); await page.waitForTimeout(650); await button.dispatchEvent('pointerup', { pointerId: 1 });
|
|
await expect.poll(() => page.evaluate(() => (window as any).__aeternalis.snapshot.self.entity.position.z)).toBeLessThan(before - 2);
|
|
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true);
|
|
await page.getByRole('button', { name: 'Inventory and crafting' }).click();
|
|
const box = await page.locator('#inventory').boundingBox();
|
|
expect(box!.x).toBeGreaterThanOrEqual(0); expect(box!.x + box!.width).toBeLessThanOrEqual(390);
|
|
await page.screenshot({ path: 'test-results/mobile.png' });
|
|
await page.getByRole('button', { name: 'Close inventory', exact: true }).click();
|
|
await page.setViewportSize({ width: 844, height: 390 });
|
|
await page.screenshot({ path: 'test-results/mobile-landscape.png' });
|
|
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true);
|
|
});
|
|
|
|
test('unauthenticated API and hostile origins cannot mutate state', async ({ request }) => {
|
|
expect((await request.post('/api/join', { data: { name: 'Intruder' }, headers: { Origin: 'https://evil.example' } })).status()).toBe(403);
|
|
expect((await request.get('/api/me')).status()).toBe(401);
|
|
const response = await request.get('/api/config');
|
|
expect(response.headers()['content-security-policy']).toContain("frame-ancestors 'none'");
|
|
expect(response.headers()['x-content-type-options']).toBe('nosniff');
|
|
});
|
|
|
|
test('boss event is visible and accepts server-authoritative combat', async ({ page }) => {
|
|
// The 20s poll below has its own budget, but on slow CI hardware the cumulative time
|
|
// for enter() + awakening the boss + closing settings can eat far enough into the
|
|
// config's 45s per-test timeout that the whole test gets killed before that poll's own
|
|
// timeout ever gets to fire and report cleanly. slow() triples this test's budget.
|
|
test.slow();
|
|
await page.setViewportSize({ width: 1440, height: 900 });
|
|
await enter(page, 'Boss witness');
|
|
await page.getByRole('button', { name: 'Display settings' }).click();
|
|
await page.getByRole('button', { name: 'Awaken Harbinger' }).click();
|
|
await expect(page.locator('#phase-label')).toHaveText('THE UNRAVELING');
|
|
await page.getByRole('button', { name: 'Close display settings' }).click();
|
|
const hp = await page.evaluate(() => (window as any).__aeternalis.snapshot.world.bossHp);
|
|
await page.getByRole('button', { name: 'Target Harbinger', exact: true }).click();
|
|
await expect.poll(() => page.evaluate(() => (window as any).__aeternalis.snapshot.world.bossHp), { timeout: 20000 }).toBeLessThan(hp);
|
|
await expect(page.locator('#boss-bar')).toBeVisible();
|
|
await page.screenshot({ path: 'test-results/boss.png' });
|
|
});
|