From 9ca58b3101825c7d54ab97cd1cd853aa653bfa9b Mon Sep 17 00:00:00 2001 From: dingo Date: Sat, 12 Sep 2026 18:10:28 -0400 Subject: [PATCH] Separate gathering from movement timing and report full failure state --- tests/game.spec.ts | 49 ++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/tests/game.spec.ts b/tests/game.spec.ts index a5bad92..6d56a67 100644 --- a/tests/game.spec.ts +++ b/tests/game.spec.ts @@ -35,30 +35,45 @@ test('desktop renders models, moves authoritatively, gathers, and reconnects', a page.on('pageerror', error => errors.push(error.message)); await page.setViewportSize({ width: 1440, height: 900 }); await enter(page); + // Gather from the spawn clearing before testing keyboard movement. A delayed + // key release can otherwise change the nearest resource (including its risk + // and required confirmation), coupling gathering success to the walk's length. + await page.getByRole('button', { name: 'Gather', exact: true }).click(); + let gatherDiagnostics: unknown; + try { + await expect.poll(async () => { + gatherDiagnostics = await page.evaluate(() => { + const game = (window as any).__aeternalis, s = game.snapshot; + return { + gainedXP: Object.values(s.self.gathering).some((skill: any) => skill.xp > 0), + attempt: s.self.gatherAttempt, + position: s.self.entity.position, + movementFactor: s.self.movementFactor, + ack: s.self.ack, + tick: s.tick, + connection: document.querySelector('#connection-status')?.textContent, + message: s.message, + target: document.querySelector('#target')?.textContent, + notice: document.querySelector('#notice')?.textContent, + walkTo: game.walkTo, + pendingAction: game.pendingAction, + keys: game.keys, + }; + }); + return (gatherDiagnostics as { gainedXP: boolean }).gainedXP; + }, { timeout: 15000, message: 'Gather must award profession XP' }).toBe(true); + } catch (error) { + // toMatchObject omits unmatched properties from its diff. Put the complete + // last sample in the error so CI's text log actually includes diagnostics. + throw new Error(`${String(error)}\nGather diagnostics: ${JSON.stringify(gatherDiagnostics, null, 2)}`); + } const before = await page.evaluate(() => (window as any).__aeternalis.snapshot.self.entity.position); - // Stop on authoritative progress instead of assuming a one-second browser - // sleep produces a bounded walk on a software-rendered CI worker. Overshooting - // the arrival clearing changes which resource the Gather button selects. await page.keyboard.down('d'); try { await expect.poll(() => page.evaluate(() => (window as any).__aeternalis.snapshot.self.entity.position.x), { timeout: 15000 }).toBeGreaterThan(before.x + 3); } finally { await page.keyboard.up('d'); } - await page.getByRole('button', { name: 'Gather', exact: true }).click(); - await expect.poll(() => page.evaluate(() => { - const s = (window as any).__aeternalis.snapshot; - return { - gainedXP: Object.values(s.self.gathering).some((skill: any) => skill.xp > 0), - attempt: s.self.gatherAttempt, - position: s.self.entity.position, - movementFactor: s.self.movementFactor, - ack: s.self.ack, - message: s.message, - target: document.querySelector('#target')?.textContent, - notice: document.querySelector('#notice')?.textContent, - }; - }), { timeout: 15000, message: 'Gather must award profession XP; failure output includes the attempt, target, position and server response' }).toMatchObject({ gainedXP: true }); await page.getByRole('button', { name: 'Inventory and crafting' }).click(); await expect(page.locator('#inventory')).toBeVisible(); await expect(page.locator('#inventory-items')).toContainText('Knife');