Filter stale sortie save ids

This commit is contained in:
2026-07-05 09:50:31 +09:00
parent 49b2b2300f
commit 6fa502432e
2 changed files with 56 additions and 6 deletions

View File

@@ -118,6 +118,41 @@ try {
`Expected malformed inventory and sortie assignments to normalize: ${JSON.stringify(malformed)}`
);
storage.clear();
storage.set(
campaignStorageKey,
JSON.stringify({
version: 1,
updatedAt: '2026-07-03T12:00:00.000Z',
step: 'third-camp',
activeSaveSlot: 1,
roster: [{ id: 'liu-bei', name: 'Liu Bei', faction: 'ally' }],
selectedSortieUnitIds: ['liu-bei', 'ghost-unit', 'guan-yu', 'liu-bei'],
sortieFormationAssignments: {
'liu-bei': 'front',
'ghost-unit': 'flank',
'guan-yu': 'support',
broken: 'center'
},
sortieItemAssignments: {
'liu-bei': { bean: '2' },
'ghost-unit': { bean: '1' },
'guan-yu': { wine: '1' }
}
})
);
const staleSortie = loadCampaignState();
assert(
staleSortie.selectedSortieUnitIds.length === 1 &&
staleSortie.selectedSortieUnitIds[0] === 'liu-bei' &&
staleSortie.sortieFormationAssignments['liu-bei'] === 'front' &&
staleSortie.sortieFormationAssignments['ghost-unit'] === undefined &&
staleSortie.sortieItemAssignments['liu-bei']?.bean === 2 &&
staleSortie.sortieItemAssignments['ghost-unit'] === undefined &&
staleSortie.sortieItemAssignments['guan-yu'] === undefined,
`Expected stale sortie ids to be filtered against the recovered roster: ${JSON.stringify(staleSortie)}`
);
storage.clear();
storage.set(
campaignStorageKey,
@@ -269,7 +304,7 @@ try {
const fallback = loadCampaignState();
assert(fallback.step === 'second-camp' && fallback.activeSaveSlot === 2, `Expected valid slotted save fallback: ${JSON.stringify(fallback)}`);
console.log('Verified campaign save normalization, malformed-field/bond/sortie-item/latest-history/detail recovery, unknown-step/report/history recovery, unsupported-version rejection, and slotted fallback.');
console.log('Verified campaign save normalization, malformed-field/bond/sortie-roster/latest-history/detail recovery, unknown-step/report/history recovery, unsupported-version rejection, and slotted fallback.');
} finally {
await server.close();
}