Recover stalled platform progress and missing saves with bounded reloads

This commit is contained in:
2026-10-12 18:08:54 +08:00
parent 1f6706efbb
commit 27293ad195
8 changed files with 173 additions and 25 deletions
+2 -2
View File
@@ -45,10 +45,10 @@ function site(h){
const h=harness();h.api.begin();visibility(h,'hidden');h.advance(61000);
const lease=JSON.parse(h.storage.get('icampus.study.v1.lease'));assert.ok(lease.until>h.context.Date.now());
});
await test('background delay allows a real heartbeat to arrive but missing saves still stop',()=>{
await test('background delay allows a real heartbeat to arrive before missing saves refresh',()=>{
const h=harness();h.api.begin();h.api.track(h.video);visibility(h,'hidden');
h.advance(80000);h.video.currentTime+=160;h.api.monitor();assert.equal(h.api.state.running,true);
h.advance(101000);h.video.currentTime+=202;h.api.monitor();assert.equal(h.api.state.running,false);assert.match(h.api.state.status,/180秒/);
h.advance(101000);h.video.currentTime+=202;h.api.monitor();assert.equal(h.api.state.running,false);assert.match(h.api.state.status,/180秒/);assert.equal(h.context.location.reloadCount,1);
});
await test('foreground return gives the restarted heartbeat 20 seconds to respond',()=>{
const h=harness();h.api.begin();h.api.track(h.video);visibility(h,'hidden');h.advance(80000);visibility(h,'visible');