Files
radicle-explorer/shared/core/tests/keys.test.ts
T
Rūdolfs Ošiņš 05d1a99fef desktop: Stop losing and wasting refreshes on events
An update that arrived while a route was still loading was lost, since the
loader's result then counted as fresh, so the events now invalidate through
the shared helper that marks such fetches stale. A repo arriving or renamed
without the update naming its refs left the sidebar list as it was, and
updates that changed nothing still dropped the hover caches.

A test now checks the frontend's ref update type against the generated
one.
2026-11-20 19:32:17 +01:00

43 lines
1.1 KiB
TypeScript

import { describe, expect, test } from "vitest";
import { isCobCacheKey, isJobsKey, isRepoInfoKey, keys } from "../src/keys";
const rid = "rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5";
const id = "d87dcfe8c2b3200e78b128d9b959cfdf7063fefe";
describe("key classifiers", () => {
test("job lists", () => {
expect(isJobsKey(keys.jobs(rid))).toBe(true);
expect(isJobsKey(keys.repo(rid))).toBe(false);
expect(isJobsKey(keys.issues(rid))).toBe(false);
});
test("repository info", () => {
expect(isRepoInfoKey(keys.repoInfo(rid))).toBe(true);
expect(isRepoInfoKey(keys.repos())).toBe(false);
});
test("data the COB cache holds", () => {
for (const key of [
keys.repoInfo(rid),
keys.issues(rid),
keys.issueList(rid, "open"),
keys.issue(rid, id),
keys.patches(rid),
keys.patch(rid, id),
]) {
expect(isCobCacheKey(key)).toBe(true);
}
for (const key of [
keys.repo(rid),
keys.code(rid),
keys.jobs(rid),
keys.releases(rid),
keys.boards(rid),
keys.notifications(),
]) {
expect(isCobCacheKey(key)).toBe(false);
}
});
});