// settings.privacy.hidePrivateSites on a channel's configure tab (review round // 1, S1): a private site is not DRAWN, but its membership is submitted exactly // as it was — a save must never drop a membership the operator cannot see. // // Run with: pnpm --filter editor test import { test } from "node:test"; import assert from "node:assert/strict"; import { membershipsJsonOf, type Row, type SiteMembershipOption } from "./SiteMembershipsSection"; const site = (siteId: string, hidden = false): SiteMembershipOption => ({ siteId, siteTitle: `T ${siteId}`, defaultGroupId: "default", groups: [{ id: "g1", name: "G1" }], ...(hidden ? { hidden: true as const } : {}), }); test("a hidden site's membership (and its group) is in what the form submits", () => { const sites = [site("pub"), site("priv", true), site("other")]; const selected = new Map([ ["pub", { groupId: "", newGroupName: "" }], ["priv", { groupId: "g1", newGroupName: "" }], ]); assert.deepEqual(JSON.parse(membershipsJsonOf(sites, selected)), [{ siteId: "pub" }, { siteId: "priv", groupId: "g1" }]); // The same answer with nothing hidden: the flag changes what is drawn only. const plain = [site("pub"), site("priv"), site("other")]; assert.equal(membershipsJsonOf(plain, selected), membershipsJsonOf(sites, selected)); });