mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 17:22:19 +00:00
test: format stale thumbnail cancellation proof
This commit is contained in:
1 parent
455d36fe92
commit
8b4952415e
1 file changed
+26
-20
@@ -316,26 +316,32 @@ test('a request queued behind an aborted fetch still starts once the abort settl
|
||||
});
|
||||
});
|
||||
|
||||
test(
|
||||
'retain aborts stale acquisition while allowing the current intent to start',
|
||||
async () => {
|
||||
const { loader, fetch } = fixture({ maxInFlight: 1 });
|
||||
const stale = candidate('S30', '2026-09-10');
|
||||
const current = candidate('S30', '2026-09-11');
|
||||
|
||||
test('retain aborts stale acquisition while allowing the current intent to start', async () => {
|
||||
const { loader, fetch } = fixture({ maxInFlight: 1 });
|
||||
const stale = candidate('S30', '2026-09-10');
|
||||
const current = candidate('S30', '2026-09-11');
|
||||
loader.request(stale, BOX, 0);
|
||||
loader.request(current, BOX, 1);
|
||||
assert.equal(fetch.calls.length, 1);
|
||||
assert.match(fetch.calls[0].url, /TIME=2026-09-10/);
|
||||
|
||||
loader.request(stale, BOX, 0);
|
||||
loader.request(current, BOX, 1);
|
||||
assert.equal(fetch.calls.length, 1);
|
||||
assert.match(fetch.calls[0].url, /TIME=2026-09-10/);
|
||||
loader.retain([current.key]);
|
||||
assert.equal(fetch.calls[0].signal.aborted, true);
|
||||
await settle();
|
||||
|
||||
loader.retain([current.key]);
|
||||
assert.equal(fetch.calls[0].signal.aborted, true);
|
||||
await settle();
|
||||
|
||||
assert.equal(fetch.calls.length, 2, 'current intent starts after stale abort');
|
||||
assert.match(fetch.calls[1].url, /TIME=2026-09-11/);
|
||||
assert.deepEqual(loader.refinementStats(), {
|
||||
supersededQueued: 0,
|
||||
supersededInFlight: 1,
|
||||
});
|
||||
assert.equal(loader.get(stale.key).status, 'unknown');
|
||||
});
|
||||
assert.equal(
|
||||
fetch.calls.length,
|
||||
2,
|
||||
'current intent starts after stale abort',
|
||||
);
|
||||
assert.match(fetch.calls[1].url, /TIME=2026-09-11/);
|
||||
assert.deepEqual(loader.refinementStats(), {
|
||||
supersededQueued: 0,
|
||||
supersededInFlight: 1,
|
||||
});
|
||||
assert.equal(loader.get(stale.key).status, 'unknown');
|
||||
},
|
||||
);
|
||||
Reference in new issue
Block a user