fix: isolate camp save modal input

This commit is contained in:
2026-07-29 10:10:31 +09:00
parent ed5b6b2a8a
commit f0fae7199a
2 changed files with 185 additions and 13 deletions

View File

@@ -678,12 +678,21 @@ async function verifyPreparationModalKeyboardIsolation(page) {
const campaignModule = await import(
'/heros_web/src/game/state/campaignState.ts'
);
const manualSaveModule = await import(
'/heros_web/src/game/state/manualSaveStorage.ts'
);
const snapshot = campaignModule.getCampaignState();
campaignModule.saveCampaignState(snapshot, 2);
campaignModule.saveCampaignState(snapshot, 1);
const currentCampaign =
campaignModule.getCampaignState();
manualSaveModule.writeManualSave(2, {
campaign: currentCampaign,
context: 'camp'
});
const scene =
window.__HEROS_GAME__?.scene.getScene('CampScene');
scene.campaign = campaignModule.getCampaignState();
scene.campaign = currentCampaign;
scene.showSortiePrep();
});
await page.waitForFunction(
@@ -706,7 +715,15 @@ async function verifyPreparationModalKeyboardIsolation(page) {
assert.equal(
camp.campaign.activeSaveSlot,
1,
'The 1 key must save to slot 1 instead of selecting the first preparation card.'
'A protected manual save must preserve the active automatic slot.'
);
let manualSave =
await readCampManualSave(page, 1);
assert.equal(manualSave?.context, 'camp');
assert.equal(
manualSave?.selectedPriorityId,
'companion',
'The 1 key must save the current preparation to protected manual record 1.'
);
await selectPreparationCard(page, 'equipment');
@@ -718,8 +735,15 @@ async function verifyPreparationModalKeyboardIsolation(page) {
assertPreparationSelection(camp, 'equipment');
assert.equal(
camp.campaign.activeSaveSlot,
3,
'The 3 key must save to slot 3 instead of selecting the third preparation card.'
1,
'Manual record 3 must not switch the active automatic slot.'
);
manualSave = await readCampManualSave(page, 3);
assert.equal(manualSave?.context, 'camp');
assert.equal(
manualSave?.selectedPriorityId,
'equipment',
'The 3 key must save to protected manual record 3 instead of selecting the third preparation card.'
);
await selectPreparationCard(page, 'information');
@@ -758,8 +782,15 @@ async function verifyPreparationModalKeyboardIsolation(page) {
assertPreparationSelection(camp, 'information');
assert.equal(
camp.campaign.activeSaveSlot,
2,
'Enter must confirm the pending overwrite instead of confirming the focused preparation card.'
1,
'Confirming a manual overwrite must preserve the active automatic slot.'
);
manualSave = await readCampManualSave(page, 2);
assert.equal(manualSave?.context, 'camp');
assert.equal(
manualSave?.selectedPriorityId,
'information',
'Enter must overwrite protected manual record 2 instead of confirming the focused preparation card.'
);
}
@@ -2199,6 +2230,30 @@ async function readCampSaveModalState(page) {
});
}
async function readCampManualSave(page, slot) {
return page.evaluate(async (requestedSlot) => {
const manualSaveModule = await import(
'/heros_web/src/game/state/manualSaveStorage.ts'
);
const save =
manualSaveModule.readManualSave(
requestedSlot
);
return save
? {
slot: save.slot,
context: save.context,
activeSaveSlot:
save.campaign.activeSaveSlot,
selectedPriorityId:
save.campaign
.thirdCampPreparationSelection
?.priorityId ?? null
}
: null;
}, slot);
}
async function openPreparationBrowser(page) {
let lastState = await readCamp(page);
for (let attempt = 0; attempt < 2; attempt += 1) {