test(sidebar): restore idsFromStore coverage in parameterized merge-lane storage suite

The shared mergeLaneStorage suite was missing two tests that existed in the
original per-lane files: idsFromStore returns the set of IDs where the value
field is true, and idsFromStore returns an empty set for all-false/empty
stores. The idsFromStore helper was advertised in the usage comment but never
added to the config destructure or exercised by the suite.

Add idsFromStore to the suite's config parameter, add the two parameterized
tests, pass starredChannelIdsFromStore / mutedChannelIdsFromStore from the
respective wrappers, and remove the stale isSubsumedBy line from the usage
comment (it was never wired).

Stars and mutes storage suites now each register 47 tests, matching the
original per-lane count.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
This commit is contained in:
Duncan
2026-08-29 19:24:12 -04:00
parent ac40eb2af9
commit a7cba45a85
3 changed files with 32 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ import {
DEFAULT_STORE,
MAX_CHANNEL_MUTE_ENTRIES,
mergeStores,
mutedChannelIdsFromStore,
parseMutePayload,
readChannelMutesStore,
storageKey,
@@ -23,6 +24,7 @@ runMergeLaneStorageSuite({
falseLabel: "unmute",
boundStore: boundMuteStore,
mergeStores,
idsFromStore: mutedChannelIdsFromStore,
readStore: readChannelMutesStore,
writeStore: writeChannelMutesStore,
storageKey,

View File

@@ -5,6 +5,7 @@ import {
mergeStores,
parseStarPayload,
readChannelStarsStore,
starredChannelIdsFromStore,
storageKey,
writeChannelStarsStore,
} from "./channelStarsStorage.ts";
@@ -23,6 +24,7 @@ runMergeLaneStorageSuite({
falseLabel: "unstar",
boundStore: boundStarStore,
mergeStores,
idsFromStore: starredChannelIdsFromStore,
readStore: readChannelStarsStore,
writeStore: writeChannelStarsStore,
storageKey,

View File

@@ -15,7 +15,6 @@
// falseLabel: "unstar",
// boundStore: boundStarStore,
// mergeStores,
// isSubsumedBy: isStarsStoreSubsumedBy,
// idsFromStore: starredChannelIdsFromStore,
// readStore: readChannelStarsStore,
// writeStore: writeChannelStarsStore,
@@ -53,6 +52,8 @@ if (typeof globalThis.window === "undefined") {
* @param {string} cfg.falseLabel - Action name when value=false (e.g. "unstar").
* @param {Function} cfg.boundStore - bound{Star|Mute}Store(store, preservedKey?).
* @param {Function} cfg.mergeStores - mergeStores(a, b, preservedKey?).
* @param {Function} cfg.isSubsumedBy - is{Stars|Mutes}StoreSubsumedBy(a, b).
* @param {Function} cfg.idsFromStore - {starred|muted}ChannelIdsFromStore(store).
* @param {Function} cfg.readStore - readChannel{Stars|Mutes}Store(pubkey, relay?).
* @param {Function} cfg.writeStore - writeChannel{Stars|Mutes}Store(pubkey, store, relay?).
* @param {Function} cfg.storageKey - storageKey(pubkey, relay?).
@@ -69,6 +70,7 @@ export function runMergeLaneStorageSuite({
falseLabel,
boundStore,
mergeStores,
idsFromStore,
readStore,
writeStore,
storageKey,
@@ -490,6 +492,31 @@ export function runMergeLaneStorageSuite({
);
});
// ── idsFromStore ─────────────────────────────────────────────────────────
test(`${label}: idsFromStore: returns set of IDs where ${entryValueField}=true`, () => {
const result = idsFromStore({
version: 1,
channels: {
a: E(true, 100, 0),
b: E(true, 200, 0),
c: E(false, 300, 0),
},
});
assert.deepEqual([...result].sort(), ["a", "b"]);
});
test(`${label}: idsFromStore: all-false / empty returns empty set`, () => {
assert.equal(
idsFromStore({
version: 1,
channels: { x: E(false, 1, 0) },
}).size,
0,
);
assert.equal(idsFromStore({ version: 1, channels: {} }).size, 0);
});
// ── storageKey + readStore/writeStore ─────────────────────────────────────
test(`${label}: storageKey: with relayUrl includes normalized+encoded relay in key`, () => {