From a7cba45a8553983a39bc00f118de98b689975519 Mon Sep 17 00:00:00 2001 From: Duncan Date: Sat, 29 Aug 2026 19:24:12 -0400 Subject: [PATCH] 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 Signed-off-by: Will Pfleger --- .../sidebar/lib/channelMutesStorage.test.mjs | 2 ++ .../sidebar/lib/channelStarsStorage.test.mjs | 2 ++ .../lib/mergeLaneStorage.shared.test.mjs | 29 ++++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/desktop/src/features/sidebar/lib/channelMutesStorage.test.mjs b/desktop/src/features/sidebar/lib/channelMutesStorage.test.mjs index a9734cb33e..2efbb2e64c 100644 --- a/desktop/src/features/sidebar/lib/channelMutesStorage.test.mjs +++ b/desktop/src/features/sidebar/lib/channelMutesStorage.test.mjs @@ -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, diff --git a/desktop/src/features/sidebar/lib/channelStarsStorage.test.mjs b/desktop/src/features/sidebar/lib/channelStarsStorage.test.mjs index c86668807e..0757704d82 100644 --- a/desktop/src/features/sidebar/lib/channelStarsStorage.test.mjs +++ b/desktop/src/features/sidebar/lib/channelStarsStorage.test.mjs @@ -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, diff --git a/desktop/src/features/sidebar/lib/mergeLaneStorage.shared.test.mjs b/desktop/src/features/sidebar/lib/mergeLaneStorage.shared.test.mjs index 81846dd412..70c9c063cc 100644 --- a/desktop/src/features/sidebar/lib/mergeLaneStorage.shared.test.mjs +++ b/desktop/src/features/sidebar/lib/mergeLaneStorage.shared.test.mjs @@ -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`, () => {