refactor: eliminate remaining duplicate blocks across draft streams and tests

This commit is contained in:
Peter Steinberger
2026-02-21 23:56:58 +00:00
parent abf3dfc375
commit ad1c07e7c0
16 changed files with 316 additions and 199 deletions

View File

@@ -147,6 +147,13 @@ export function requireSessionStorePath(cfg: { session?: { store?: string } }):
return storePath;
}
export async function readSessionStore(cfg: {
session?: { store?: string };
}): Promise<Record<string, { elevatedLevel?: string }>> {
const storeRaw = await fs.readFile(requireSessionStorePath(cfg), "utf-8");
return JSON.parse(storeRaw) as Record<string, { elevatedLevel?: string }>;
}
export function makeWhatsAppElevatedCfg(
home: string,
opts?: { elevatedEnabled?: boolean; requireMentionInGroups?: boolean },
@@ -196,8 +203,7 @@ export async function runDirectElevatedToggleAndLoadStore(params: {
if (!storePath) {
throw new Error("session.store is required in test config");
}
const storeRaw = await fs.readFile(storePath, "utf-8");
const store = JSON.parse(storeRaw) as Record<string, { elevatedLevel?: string }>;
const store = await readSessionStore(params.cfg);
return { text, store };
}