Add first battle outcome screen
This commit is contained in:
@@ -79,7 +79,42 @@ try {
|
||||
throw new Error(`Expected ready units to loop idle frames: ${JSON.stringify(readyUnits)}`);
|
||||
}
|
||||
|
||||
console.log(`Verified title-to-battle flow and debug API at ${targetUrl}`);
|
||||
await page.keyboard.press('F9');
|
||||
await page.waitForTimeout(100);
|
||||
|
||||
await page.evaluate(() => window.__HEROS_DEBUG__?.forceBattleOutcome('victory'));
|
||||
await page.waitForFunction(() => {
|
||||
const state = window.__HEROS_DEBUG__?.battle();
|
||||
return state?.battleOutcome === 'victory' && state?.phase === 'resolved' && state?.resultVisible === true;
|
||||
});
|
||||
|
||||
const victoryState = await page.evaluate(() => window.__HEROS_DEBUG__?.battle());
|
||||
const livingEnemiesAfterVictory = victoryState.units.filter((unit) => unit.faction === 'enemy' && unit.hp > 0);
|
||||
if (livingEnemiesAfterVictory.length > 0) {
|
||||
throw new Error(`Expected no living enemies after forced victory: ${JSON.stringify(livingEnemiesAfterVictory)}`);
|
||||
}
|
||||
|
||||
await page.screenshot({ path: 'dist/verification-battle-result-victory.png', fullPage: true });
|
||||
|
||||
await page.evaluate(() => window.__HEROS_DEBUG__?.goToBattle());
|
||||
await page.waitForFunction(() => {
|
||||
const state = window.__HEROS_DEBUG__?.battle();
|
||||
return state?.scene === 'BattleScene' && state?.battleOutcome === null && state?.phase === 'idle';
|
||||
});
|
||||
|
||||
await page.evaluate(() => window.__HEROS_DEBUG__?.forceBattleOutcome('defeat'));
|
||||
await page.waitForFunction(() => {
|
||||
const state = window.__HEROS_DEBUG__?.battle();
|
||||
return state?.battleOutcome === 'defeat' && state?.phase === 'resolved' && state?.resultVisible === true;
|
||||
});
|
||||
|
||||
const defeatState = await page.evaluate(() => window.__HEROS_DEBUG__?.battle());
|
||||
const liuBei = defeatState.units.find((unit) => unit.id === 'liu-bei');
|
||||
if (!liuBei || liuBei.hp > 0) {
|
||||
throw new Error(`Expected Liu Bei to be defeated after forced defeat: ${JSON.stringify(liuBei)}`);
|
||||
}
|
||||
|
||||
console.log(`Verified title-to-battle flow, result states, and debug API at ${targetUrl}`);
|
||||
} finally {
|
||||
await browser?.close();
|
||||
if (serverProcess && !serverProcess.killed) {
|
||||
|
||||
Reference in New Issue
Block a user