diff options
| author | Adam Soltys <[email protected]> | 2026-10-08 13:50:44 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-10-08 13:50:44 -0700 |
| commit | e76d643835c45f6624856850137e71e986315eb0 (patch) | |
| tree | a84e1ffffe4389f4a55c0fa797da6ab24c4e0df9 /tools/thread-cache-test.js | |
| parent | 175e513273bfb2a362f9a08e3da5d5460a1d91c0 (diff) | |
| download | coinosv3-e76d643835c45f6624856850137e71e986315eb0.tar.gz coinosv3-e76d643835c45f6624856850137e71e986315eb0.zip | |
Prefetch visible post threads after a bounded reading dwell
Diffstat (limited to 'tools/thread-cache-test.js')
| -rw-r--r-- | tools/thread-cache-test.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/thread-cache-test.js b/tools/thread-cache-test.js index 6bac353..67b191b 100644 --- a/tools/thread-cache-test.js +++ b/tools/thread-cache-test.js @@ -139,6 +139,24 @@ try { assert.equal(restored.root.id, r.id); assert.equal(restored.replies.length, 2); }); + for (const clickWhileLoading of [false, true]) { + const warm = makeFeature(), seed = note(clickWhileLoading ? 501 : 500); + const answer = note(clickWhileLoading ? 511 : 510, [['e', seed.id, '', 'root']]); + requests = []; + const prefetched = warm.feature.testThread(seed, true); + await wait(() => waiting.length === 1); + if (clickWhileLoading) assert.equal(warm.feature.testThread(seed), prefetched); + for (const q of waiting.splice(0)) q.resolve([answer]); + await prefetched.loading; + if (!clickWhileLoading) assert.equal(store.find(seed.id), null, 'speculation does not evict persisted visits'); + const opened = warm.feature.testThread(seed); + assert.equal(opened, prefetched); + assert.equal(opened.status, 'ready'); + assert.equal(opened.replies[0].id, answer.id); + assert.equal(requests.length, 1, 'click shares the existing relay query'); + assert.equal(store.find(seed.id).replies[0].id, answer.id); + } + console.log('✓ clicks reuse completed and in-flight prefetches and persist visited threads'); const deepLink = makeFeature(); requests = []; await deepLink.feature.testOpen({ id: e.id }); |
