diigo-cache: test that a cached page replays fetch-time order
A hit must replay diigo's order as fetched (page_members.pos), not a column sort. The fake webapp's link_id and updated_at are scrambled so neither column sorts back into diigo's order; ordering the replay by updated or item_id fails the new test. Generated-by: Claude Opus 5.5
This commit is contained in:
1 parent
a1b1640e06
commit
80c9279825
2 files changed
+23
-3
No files matched your search
@@ -79,6 +79,23 @@ describe("DiigoCache", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("page replay order", () => {
|
||||
it("a hit replays diigo's fetch-time order (page_members), not a column sort", async () => {
|
||||
const stub = testEnv.CACHE_DO.get(testEnv.CACHE_DO.newUniqueId());
|
||||
await stub.setup({ webappId: WEBAPP_ID });
|
||||
const titles = (items: string[]) => parse(items).map((i) => i.title);
|
||||
const expected = Array.from({ length: 24 }, (_, k) => `bookmark ${k + 1}`);
|
||||
|
||||
const miss = await stub.page(1, 24);
|
||||
expect(titles(miss.items)).toEqual(expected);
|
||||
// page 2's etch upserts other rows; page 1's replay must not shift
|
||||
await stub.page(2, 24);
|
||||
const hit = await stub.page(1, 24);
|
||||
expect(hit.cached).toBe(true);
|
||||
expect(titles(hit.items)).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe("worker routes", () => {
|
||||
const call = (path: string, init?: RequestInit) =>
|
||||
worker.fetch(new Request(`https://diigo-cache.test${path}`, init), env as never);
|
||||
|
||||
Reference in new issue
Block a user