test: target semantic turn prompt action

This commit is contained in:
2026-07-29 04:39:18 +09:00
parent 1f805a718d
commit c3a80cd343

View File

@@ -508,8 +508,16 @@ async function verifyBattlePointerFlow(page) {
); );
await page.waitForTimeout(120); await page.waitForTimeout(120);
await clickTurnPromptSecondary(page); const automaticTurnPromptSecondaryClick = await clickTurnPromptSecondary(page);
await page.waitForFunction(() => window.__HEROS_DEBUG__?.battle()?.turnPromptVisible === false); try {
await page.waitForFunction(() => window.__HEROS_DEBUG__?.battle()?.turnPromptVisible === false);
} catch (error) {
const diagnostic = await turnPromptPointerDiagnostic(page, automaticTurnPromptSecondaryClick);
throw new Error(
`The battlefield-review pointer click did not close the turn-end prompt: ${JSON.stringify(diagnostic)}`,
{ cause: error }
);
}
const persistentTurnEndBounds = await page.evaluate(() => { const persistentTurnEndBounds = await page.evaluate(() => {
const scene = window.__HEROS_GAME__?.scene.getScene('BattleScene'); const scene = window.__HEROS_GAME__?.scene.getScene('BattleScene');
const text = (scene?.sidePanelObjects ?? []).find((object) => ( const text = (scene?.sidePanelObjects ?? []).find((object) => (
@@ -1903,23 +1911,51 @@ async function startDeploymentIfNeeded(page, battleId) {
} }
async function clickTurnPromptSecondary(page) { async function clickTurnPromptSecondary(page) {
const bounds = await page.evaluate(() => { const button = await page.evaluate(() => {
const scene = window.__HEROS_GAME__?.scene.getScene('BattleScene'); const prompt = window.__HEROS_DEBUG__?.battle()?.turnPrompt;
const buttons = (scene?.turnPromptObjects ?? []) return prompt?.buttons?.find((candidate) => candidate.id === 'secondary') ?? null;
.filter((object) => (
object.type === 'Rectangle' &&
object.active &&
object.input?.enabled &&
object.displayWidth < 500 &&
object.displayHeight < 100
))
.map((object) => object.getBounds())
.sort((left, right) => right.centerX - left.centerX);
const button = buttons[0];
return button ? { x: button.x, y: button.y, width: button.width, height: button.height } : null;
}); });
assert(bounds, 'Expected the battlefield-review button in the turn-end prompt.'); assert(
await clickSceneBounds(page, 'BattleScene', bounds); button?.bounds && button.meaning === 'review-battlefield',
`Expected the battlefield-review button in the turn-end prompt: ${JSON.stringify(button)}`
);
const point = await clickSceneBounds(page, 'BattleScene', button.bounds);
return { button, point };
}
async function turnPromptPointerDiagnostic(page, click) {
return page.evaluate((requestedClick) => {
const scene = window.__HEROS_GAME__?.scene.getScene('BattleScene');
const canvas = document.querySelector('canvas');
const canvasBounds = canvas?.getBoundingClientRect();
const pointer = scene?.input?.activePointer;
return {
click: requestedClick,
turnPrompt: window.__HEROS_DEBUG__?.battle()?.turnPrompt ?? null,
canvasBounds: canvasBounds
? {
x: canvasBounds.x,
y: canvasBounds.y,
width: canvasBounds.width,
height: canvasBounds.height
}
: null,
sceneSize: scene
? { width: scene.scale.width, height: scene.scale.height }
: null,
activePointer: pointer
? {
x: pointer.x,
y: pointer.y,
downX: pointer.downX,
downY: pointer.downY,
upX: pointer.upX,
upY: pointer.upY,
isDown: pointer.isDown
}
: null
};
}, click);
} }
async function findRightmostEmptyBattleTile(page) { async function findRightmostEmptyBattleTile(page) {