24 lines
1.5 KiB
JavaScript
24 lines
1.5 KiB
JavaScript
'use strict';
|
|
const {vm,app,assert,functionSource,buildMeta}=require('./helpers/app-source');
|
|
const removed=[],deleted=[];
|
|
const staleSessionJournal='bend-field:v30:v47-field-reset-20260727:journal:stale-session',retired=[
|
|
{schema:31,generation:'v47-field-reset-20260728-bugfix'},
|
|
{schema:30,generation:'v47-field-reset-20260727'}
|
|
];
|
|
const context={
|
|
RETIRED_WORLD_STORES:retired,
|
|
safeLocalRemove:key=>{removed.push(key);return true},
|
|
safeLocalKeys:prefix=>staleSessionJournal.startsWith(prefix)?[staleSessionJournal]:[],
|
|
indexedDB:{deleteDatabase:name=>deleted.push(name)}
|
|
};
|
|
vm.createContext(context);
|
|
vm.runInContext(`${functionSource('deleteRetiredWorldData')}\nthis.run=deleteRetiredWorldData;`,context);
|
|
context.run();
|
|
for(const item of retired){
|
|
const prefix=`bend-field:v${item.schema}:${item.generation}`;
|
|
for(const suffix of[':compact',':recovery',':journal',':revision',':signal',':world:lease'])assert(removed.includes(prefix+suffix),`Old save ${suffix} was not removed`);
|
|
assert(deleted.includes(`${prefix}:world`),'Old IndexedDB was not deleted');
|
|
}
|
|
assert(removed.includes(staleSessionJournal),'Old per-session recovery journal was not removed');
|
|
assert(buildMeta.SAVE_SCHEMA===31&&buildMeta.STORAGE_SCHEMA===30&&buildMeta.IDB_LAYOUT_VERSION===8&&buildMeta.FIELD_STORAGE_FORMAT===2&&buildMeta.GAMEPLAY_DATA_VERSION===3&&buildMeta.WORLD_GENERATION==='linkfield-single-world-20260801','Seed-refresh field reset generation is not active');
|
|
console.log('Full field reset test passed');
|