aboutsummaryrefslogtreecommitdiffstats
path: root/tools/thread-cache-test.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/thread-cache-test.js')
-rw-r--r--tools/thread-cache-test.js18
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 });