670 lines · 40.0 KB · TypeScriptRaw
import { createHash } from "node:crypto";import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";import path from "node:path";import { fileURLToPath } from "node:url";import { describe, expect, it } from "vitest";import { blanksIn, blanksOf, forPreview, previewOf, refusal } from "../blanks";import { OWN_PATHS, STORE, TEST } from "../pages";import { checkShots, checkSite, links, linkAllowed, loads } from "../../site/checks";import { renderSite, webpSize } from "../../site/pages";import { CONTACT } from "../../site/contact";import { accountDeleteOn, forDelete, jsonc } from "../../site/switches";import { APP_PAGES, APPS, type App } from "../../site/registry";import { LOOSE, esc, keepTogether } from "../../site/html";import { status, waiting } from "../../site/state";import { cottonCss } from "../../site/style";/** * The site (the chosen second design, 23 Nov 2026, with the owner's words of 23 Nov placed on it): a home page with a sheet for each app from apps.json, a page * for each app on its own paper, the plain privacy page (/yours), the full privacy policy with a section per app, * Help, the terms and the 404. Every page is rendered by src/site/pages.ts; these tests read what it renders. * * Nothing is loaded from another host: fonts, icons and screenshots are the * site's own files, there is no script, frame or form, and links go only to * the site's pages, /delete, the contact address (site.json), the two Google pages a reader * is sent to, and the stores. */const site = renderSite();const CSS = cottonCss(APPS);const STATIC = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../../static");const text = (html: string) => html.replace(/<style>[\s\S]*?<\/style>/, "").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ");const page = (name: string) => { const p = site[name]; if (!p) throw new Error(`no page ${name}`); return p;};describe("the pages the site builds", () => { it("are the home, the plain privacy page, the policy, help, terms, the 404 and one per app with a page", () => { expect(Object.keys(site).sort()).toEqual( ["index.html", "yours.html", "privacy.html", "support.html", "terms.html", "delete.html", "invite.html", "404.html", ...APPS.filter((a) => a.page).map((a) => `${a.id}.html`)].sort(), ); }); it("pass the site's own checks: nothing from another host, every file there (the stylesheet's fonts too), each page under 200 KB as it travels", () => { expect(checkSite(site, STATIC, { "/cotton.css": CSS })).toEqual([]); }); it("the checks catch a page that loads from another host or names a file that is not there, and count the stylesheet's fonts", () => { const bad = { "x.html": '<link rel="stylesheet" href="/cotton.css"><img src="https://example.com/a.png" alt=""><img src="/nope.webp" alt="">' }; const said = checkSite(bad, STATIC, { "/cotton.css": CSS }).join("\n"); expect(said).toContain("loads https://example.com/a.png from another host"); expect(said).toContain("loads /nope.webp, which is not in static/"); expect(checkSite({ "y.html": '<link rel="stylesheet" href="/cotton.css">' }, STATIC, { "/cotton.css": 'a{background:url("/fonts/gone.woff2")}' }).join()).toContain("/fonts/gone.woff2"); // Text counts as it travels (compressed), fonts as they are: a page of 140 KB that compresses little, with the // design's 120 KB serif, is over. const noise = createHash("sha512").update("x").digest("base64").repeat(1); let big = ""; for (let i = 0; big.length < 140_000; i++) big += createHash("sha512").update(noise + i).digest("base64"); const heavy = checkSite({ "z.html": `<link rel="stylesheet" href="/cotton.css"><p>${big}</p>` }, STATIC, { "/cotton.css": 'a{src:url("/fonts/Fraunces.woff2")}' }); expect(heavy.join()).toMatch(/z\.html weighs \d+ KB without screenshots/); expect(checkSite({ "z.html": `<link rel="stylesheet" href="/cotton.css"><p>${"a".repeat(100_000)}</p>` }, STATIC, { "/cotton.css": 'a{src:url("/fonts/Fraunces.woff2")}' })).toEqual([]); }); it("every screenshot is there, not blank or one flat colour, measured as served", () => { expect(checkShots(APPS, STATIC)).toEqual([]); }); it("the screenshot check catches a blank screen, a missing one and a mark on empty ground", () => { const fake = path.join(STATIC, "..", "node_modules", ".tmp", "shots-check"); rmSync(fake, { recursive: true, force: true }); mkdirSync(path.join(fake, "shots", "x"), { recursive: true }); const webp = readFileSync(path.join(STATIC, "shots", "days", "today.webp")); writeFileSync(path.join(fake, "shots", "x", "a.webp"), webp); writeFileSync(path.join(fake, "shots", "x", "a@2x.webp"), webp); const sha256 = createHash("sha256").update(webp).digest("hex"); writeFileSync( path.join(fake, "shots", "x", "manifest.json"), JSON.stringify({ a: { sha256, spread: 0.4, flat: 0.99, mark: { ring: [50, 50, 10, 10] }, markSpread: 0, markFlat: 1 } }), ); const said = checkShots([{ id: "x", shots: [{ file: "a", mark: { ring: [50, 50, 10, 10] } }, { file: "gone" }] }], fake).join("\n"); expect(said).toContain("x/a: the screenshot is blank or nearly one flat colour"); expect(said).toContain("x/a: its pen mark lies on empty ground"); expect(said).toContain("x/gone: the screenshot is missing"); expect(checkShots([{ id: "x", shots: [{ file: "a", mark: { ring: [40, 50, 10, 10] } }] }], fake).join("\n")).toContain("moved since it was measured"); rmSync(fake, { recursive: true, force: true }); }); it("every own path a link may take is a page the site builds, or /delete", () => { const built = new Set(Object.keys(site).map((f) => (f === "index.html" ? "/" : `/${f.replace(/\.html$/, "")}`))); for (const p of OWN_PATHS) expect(built.has(p) || p === "/delete", p).toBe(true); }); it("the stylesheet is the design's, with each app's paper written from apps.json, light and dark, and loads only the site's fonts", () => { for (const a of APPS) { expect(CSS).toContain(`.${a.id} { --ground: ${a.look.paper["--ground"]};`); expect(CSS).toContain(` .${a.id} { --ground: ${a.look.paperDark["--ground"]};`); } expect(CSS).not.toContain("@papers"); for (const url of loads(CSS)) expect(url.startsWith("/fonts/") || url.startsWith("data:"), url).toBe(true); for (const url of loads(CSS).filter((u) => u.startsWith("/fonts/"))) expect(readFileSync(path.join(STATIC, url)).length, url).toBeGreaterThan(1000); // The design's one stray colour (owner, 23 Nov) is gone from the favicon. expect(readFileSync(path.join(STATIC, "favicon.svg"), "utf8")).not.toContain("#efe9dd"); });});describe.each(Object.keys(site))("%s", (name) => { const html = page(name); it("has no script, frame or form, and loads only the site's own files", () => { expect(html).not.toMatch(/<(script|iframe|form|object|embed)\b/i); for (const url of loads(html)) expect(url.startsWith("/") && !url.startsWith("//"), url).toBe(true); }); it("links only where a page may", () => { for (const href of links(html)) expect(linkAllowed(href), `${name} links to ${href}`).toBe(true); }); it("is legible on a phone and in the dark, and says what it is when shared", () => { expect(html).toContain('<meta name="viewport" content="width=device-width, initial-scale=1">'); expect(html).toContain('<meta name="color-scheme" content="light dark">'); expect(html).toContain('<link rel="stylesheet" href="/cotton.css">'); expect(html).toMatch(/<meta name="theme-color" content="#[0-9a-f]{6}" media="\(prefers-color-scheme: dark\)">/); expect(html).toMatch(/<title>[^<]+<\/title>/); expect(html).toMatch(/<meta name="description" content="[^"]{20,}">/); expect(html).toMatch(/<meta property="og:image" content="https:\/\/cottondb\.com\/og\/[a-z]+\.png\?v=[0-9a-f]{10}">/); }); it("ends with the copyright line and says the site does not track you", () => { expect(html).toContain('<p class="legal"><span>© 2026 DECEMBERFM, INC</span><span>This website sets no cookies and counts no visits.</span></p>'); }); it("links the plain privacy page at the top, and the policy, terms and help at the foot", () => { const top = html.slice(html.indexOf('<header class="top'), html.indexOf("</header>")); expect(links(top)).toEqual(["/", "/#apps", "/yours"]); const foot = html.slice(html.indexOf('<footer class="foot')); expect(links(foot)).toEqual(expect.arrayContaining(["/yours", "/privacy", "/terms", "/support", `mailto:${CONTACT}`])); }); it("gives no phone number: support is by email only", () => { expect(links(html).filter((h) => h.startsWith("tel:"))).toEqual([]); expect(text(html)).not.toMatch(/\+\d[\d ()-]{6,}/); }); it("writes every blank the one way the build knows", () => { const stray = text(html).replace(/\[\[blank: [^\]]+\]\]/g, "").match(/\[[^\]]*\]/g); expect(stray, name).toBeNull(); }); it("uses none of our internal words", () => { // cottondb.com/mcp is the real address an assistant connects at; the word on its own is ours. expect(text(html).replaceAll("cottondb.com/mcp", "")).not.toMatch(/\b(kit|lane|sealed|flavour|MCP)\b/i); }); it("gives every picture words for someone who cannot see it", () => { for (const m of html.matchAll(/<img\b[^>]*>/g)) expect(m[0], name).toMatch(/\balt="[^"]*"/); });});describe("the home page", () => { const home = page("index.html"); const pages = APPS.filter((a) => a.page); it("shows every app from apps.json, in its order: a sheet each with its status and its line", () => { expect([...home.matchAll(/<article class="sheet ([a-z-]+)">/g)].map((m) => m[1])).toEqual(pages.map((a) => a.id)); for (const a of pages) { for (const s of a.home) expect(home).toContain(`/shots/${a.id}/${s.file}.webp`); expect(home).toContain(`<h2><a href="/${a.id}">`); const sheet = home.slice(home.indexOf(`<article class="sheet ${a.id}">`), home.indexOf("</article>", home.indexOf(`<article class="sheet ${a.id}">`))); expect(sheet).toContain(status(a)); expect(text(sheet.replace(/<\/?span[^>]*>/g, ""))).toContain(a.line); } }); it("says once, under the list, who the test links open for", () => { if (!APPS.every(waiting)) return; expect(text(home).split("The test links open only for invited testers.").length).toBe(2); expect(links(home).filter((h) => STORE.test(h))).toEqual([]); }); // The words below are the owner's (25 Nov 2026), placed as he wrote them. const said = (html: string) => text(html).replace(/\s+([.,’])/g, "$1").replace(/— /g, "— "); it("is in the owner's order (25 Nov 2026): the letter, the footer's wavy rule, the apps, about me, and ends there", () => { const at = ['<h1 id="letter-h">', '<div class="wrap rule"><svg class="loose"', 'id="apps-h"', 'id="about-h"'].map((m) => home.indexOf(m)); expect(at.every((x) => x > 0)).toBe(true); expect([...at].sort((a, b) => a - b)).toEqual(at); expect(home).not.toContain('class="cover'); for (const gone of ['id="private"', 'id="assistant"', 'id="look"']) expect(home).not.toContain(gone); expect(home.indexOf("</section>", home.indexOf('id="about"'))).toBe(home.lastIndexOf("</section>")); }); it("opens with the letter as a note: no headline size, no button, the owner's words, the apps with a page linked and the others plain", () => { const letter = home.slice(home.indexOf('<section class="letter'), home.indexOf("</section>", home.indexOf('<section class="letter'))); const t = said(letter); for (const line of [ "Hello, I’m Mukesh.", "Cotton is a set of apps I’m building for myself. I’d like to share them with anyone who might find them useful, because my work is one of the ways I connect with other people.", "I often dream of utopia. I know the real world is far from it, but I like to imagine what software looks like there, and build it that way in my own bubble.", "Building now: Days Words Story Comms Next: Secrets Post Sites Data", ]) expect(t).toContain(line); expect(links(letter)).toEqual(["/days", "/words", "/story", "/comms"].filter((h) => APPS.some((a) => a.page && `/${a.id}` === h))); for (const n of ["Secrets", "Post", "Sites", "Data"]) if (!APPS.some((a) => a.page && a.name === n)) expect(letter).not.toContain(`>${n}</span></a>`); // Two rows of icons, the name below each: every app's real icon. const rows = [...letter.matchAll(/<ul class="letter-apps">([\s\S]*?)<\/ul>/g)].map((m) => m[1]!); expect(rows).toHaveLength(2); expect(rows.map((r) => [...r.matchAll(/<li>[\s\S]*?<span>(\w+)<\/span><\/(?:a|span)><\/li>/g)].map((m) => m[1]))).toEqual([ ["Days", "Words", "Story", "Comms"], ["Secrets", "Post", "Sites", "Data"], ]); for (const id of ["days", "words", "story", "comms", "secrets", "post", "sites", "data"]) { expect(letter).toContain(`<img class="icon" src="/icons/${id}.webp" width="256" height="256" alt="">`); expect(webpSize(path.join(STATIC, "icons", `${id}.webp`))).toEqual({ w: 256, h: 256 }); } expect(letter).not.toContain(`<span class="icon empty"></span>`); expect(letter).not.toMatch(/class="go"|<button/); // No drawn marks (owner, 25 Nov 2026): no underline; and no sign-off, since it opens with his name (25 Nov 2026). expect(letter).not.toMatch(/<svg\b/); expect(letter).not.toContain('class="sign"'); expect(said(letter)).not.toContain("— Mukesh"); expect(CSS).not.toMatch(/ink-line|ink-sign|days-ink|@keyframes ink\b/); }); it("has the footer's own wavy line between the letter and the apps and again between the apps and About me, and nothing else between them", () => { const between = home.slice(home.indexOf("</section>", home.indexOf('<section class="letter')) + "</section>".length, home.indexOf('<section class="band wrap" id="apps"')); expect(between.trim()).toBe(`<div class="wrap rule">${LOOSE}</div>`); const before = home.slice(home.indexOf("</section>", home.indexOf('id="apps"')) + "</section>".length, home.indexOf('<section class="band wrap" id="about"')); expect(before.trim()).toBe(`<div class="wrap rule">${LOOSE}</div>`); expect(home.split('<svg class="loose"').length).toBe(4); }); it("says nothing of what it costs (owner, 25 Nov 2026): no price band, no testing line under it, and no app page links to it", () => { expect(home).not.toContain('id="price"'); expect(text(home)).not.toContain("What it costs"); expect(text(home)).not.toContain("Cotton is in testing. The apps are not in the stores yet."); expect(text(home)).not.toMatch(/\$\d/); for (const [name, html] of Object.entries(site)) expect(links(html), name).not.toContain("/#price"); }); it("says who I am below the apps, and names TinFactory there and nowhere else", () => { const about = home.slice(home.indexOf('id="about"'), home.indexOf("</main>")); expect(said(about)).toContain( "I’ve worked in tech for sixteen years. From 2015 to 2020 I co-founded and ran Tinmen, a home-food company that delivered two million meals. I now run TinFactory, a small team that builds apps for other companies. I live in Hyderabad, India, and visit Leeds and Liverpool once in a while. More about me at mukeshmanda.com.", ); expect(about).toContain('<a href="https://tinfactory.co">TinFactory</a>'); expect(about).toContain('<a href="https://mukeshmanda.com">mukeshmanda.com</a>'); expect(text(home).split("TinFactory").length).toBe(2); for (const [name, html] of Object.entries(site)) if (name !== "index.html") expect(text(html), name).not.toContain("TinFactory"); }); it("the plans: no $1 plan anywhere; the terms keep the full list", () => { for (const [name, html] of Object.entries(site)) expect(text(html), name).not.toMatch(/\$1 a month|10 GB for|for 10 GB/); expect(text(page("terms.html"))).toContain("100 GB for $5 a month, 1 TB for $20 and 2 TB for $40."); }); it("shows the owner's four photos, sized, not links, from the site's own files: with About me", () => { const about = home.slice(home.indexOf('id="about"'), home.indexOf("</main>")); expect(about.match(/<img src="\/photos\/[a-z-]+-800\.webp" width="800" height="1067" alt="[^"]+" loading=lazy>/g)?.length).toBe(4); expect(home.split("/photos/").length).toBe(5); expect(about).not.toMatch(/<a\b[^>]*>\s*<img src="\/photos/); for (const [name, html] of Object.entries(site)) if (name !== "index.html") expect(html, name).not.toContain("/photos/"); }); it("links where who can read your data is set out in full", () => { expect(links(home)).toContain("/yours"); expect(page("yours.html")).toContain('id="sees"'); }); it("takes the Green ink of the apps' Look as its accent, light and dark, in one place, and leaves each app's paper alone", () => { const look = JSON.parse(readFileSync(path.join(__dirname, "../../../../../crates/cotton-core/kits/look/look.json"), "utf8")) as { apps: Record<string, { inks: { id: string; light: { accent: string }; dark: { accent: string } }[] }>; }; const green = look.apps.days!.inks.find((i) => i.id === "green")!; expect(CSS).toContain(`.home { --ground: #f3f3f0; --ink: #18181a; --muted: #5e5e5a; --accent: ${green.light.accent.toLowerCase()}; }`); expect(CSS).toContain(` .home { --ground: #151311; --ink: #ece6da; --muted: #a8a092; --accent: ${green.dark.accent.toLowerCase()}; }`); expect(home).toContain('<body class="home">'); });});describe("where an app stands: one status and four links per app, in apps.json", () => { const base = APPS[0]!; const with_ = (o: Partial<App>): App => ({ ...base, ...o }); it("in testing: In testing, then its TestFlight and Google Play test links, and no store link", () => { const html = status(with_({ status: "testing" })); expect(links(html)).toEqual([base.links.testFlight, base.links.playTest]); expect(text(html).trim()).toBe("In testing · TestFlight · Google Play (testing)"); expect(waiting(base)).toBe(true); }); it("released: On the App Store · On Google Play, and on its page no note about testers", () => { const a = with_({ status: "released" }); expect(links(status(a))).toEqual([base.links.appStore, base.links.googlePlay]); expect(text(status(a)).trim()).toBe("On the App Store · On Google Play"); expect(waiting(a)).toBe(false); }); it("every app's links are the right kind and name the app apps/registry.json names: its App Store Connect id and its package", () => { const registry = (JSON.parse(readFileSync(path.join(__dirname, "../../../../registry.json"), "utf8")) as { apps: { slug: string; ios?: { live?: { ascAppId: string | null } }; android?: { package: string } }[]; }).apps; for (const a of APPS) { const r = registry.find((x) => x.slug === a.registry)!; expect(r, a.id).toBeDefined(); const asc = r.ios!.live!.ascAppId!; expect(a.links.testFlight, a.id).toBe(`https://testflight.apple.com/v1/app/${asc}`); expect(a.links.appStore, a.id).toBe(`https://apps.apple.com/app/id${asc}`); expect(a.links.googlePlay, a.id).toBe(`https://play.google.com/store/apps/details?id=${r.android!.package}`); expect(TEST.test(a.links.testFlight) && TEST.test(a.links.playTest) && STORE.test(a.links.appStore) && STORE.test(a.links.googlePlay), a.id).toBe(true); } // The four the coordinator named (23 Nov 2026). expect(Object.fromEntries(APPS.map((a) => [a.id, a.links.testFlight.split("/").pop()]))).toEqual({ words: "6833869791", days: "6833872391", story: "6835689739", comms: "6833871333", }); });});describe("each app's page", () => { it.each(APPS.filter((a) => a.page).map((a) => a.id))("%s is on its own paper, shows its screens with no words under them, and says where it stands", (id) => { const a = APPS.find((x) => x.id === id)!; const html = page(`${id}.html`); expect(html).toContain(`<body class="app ${id}">`); expect(html).toContain(`<meta name="theme-color" content="${a.look.theme[0]}" media="(prefers-color-scheme: light)">`); expect(html.match(/<figure><img class="screen"/g)?.length).toBe(a.shots.length); for (const s of a.shots) expect(html).toContain(`/shots/${id}/${s.file}.webp`); expect(html).not.toContain("<figcaption"); expect(html).toContain(status(a)); if (waiting(a)) expect(text(html)).toContain("The links open only for invited testers."); // The owner's shape (25 Nov 2026): name and icon, why I built it, the pictures, what it has now, what's coming. const w = APP_PAGES[id]!; const at = [`<h1>`, `<p class="why">${keepTogether(esc(w.why))}</p>`, `<div class="strip"`, `<h2 id="has-h">What it has now</h2>\n <p class="lead">${keepTogether(esc(w.has))}</p>`, `<h2 id="coming-h">What’s coming</h2>\n <p class="lead">${keepTogether(esc(w.coming))}</p>`, `<section class="part plain wrap" id="account" aria-label="Accounts">\n <p class="lead">${keepTogether(esc(w.account))}</p>`, `id="others-h"`].map((m) => html.indexOf(m)); expect(at.every((x) => x > 0), JSON.stringify(at)).toBe(true); expect([...at].sort((x, y) => x - y)).toEqual(at); expect(html).not.toMatch(/<ul|<ol|class="sub"/); // The coordinator's account line (25 Nov 2026), checked against the code: Days, Words and Story work signed out // and sync once signed in, with the assistant reading and writing; Comms needs an account. expect(w.account).toBe( id === "comms" ? "Comms needs an account, because messages have to reach you." : "It works with or without an account. With one, it syncs across your devices, and an AI assistant you connect, like Claude, can read and write here if you allow it.", ); // Curled apostrophes in the owner's words. expect(Object.values(w).join(" ")).not.toContain("'"); expect(links(html)).toEqual(expect.arrayContaining(a.status === "released" ? [a.links.appStore, a.links.googlePlay] : [a.links.testFlight, a.links.playTest])); expect(links(html)).toEqual(expect.arrayContaining(["/yours", "/privacy", "/terms", "/support"])); expect(site["privacy.html"]).toContain(`id="${id}"`); for (const o of APPS.filter((x) => x.page && x.id !== id)) expect(links(html)).toContain(`/${o.id}`); });});// SHARE CARD (24 Nov 2026): what a shared link shows is the page's own title, description and picture, and a remade// picture gets a new address so WhatsApp does not keep the old one.describe("the link preview", () => { const meta = (html: string, key: string) => new RegExp(`<meta (?:property|name)="${key}" content="([^"]*)">`).exec(html)?.[1]; const pngSize = (file: string) => { const b = readFileSync(file); return { w: b.readUInt32BE(16), h: b.readUInt32BE(20) }; }; for (const name of ["index.html", ...APPS.filter((a) => a.page).map((a) => `${a.id}.html`), "yours.html", "privacy.html", "support.html"]) { it(`${name} says the page's own title and description, and its picture is the current one`, () => { const html = page(name); expect(meta(html, "og:title")).toBe(/<title>([^<]+)<\/title>/.exec(html)![1]); expect(meta(html, "og:description")).toBe(meta(html, "description")); const image = meta(html, "og:image")!; const [, card, version] = /\/og\/([a-z]+)\.png\?v=([0-9a-f]{10})$/.exec(image)!; const app = name.replace(/\.html$/, ""); expect(card).toBe(APPS.some((a) => a.id === app && a.page) ? app : "home"); const file = path.join(STATIC, "og", `${card}.png`); expect(createHash("sha256").update(readFileSync(file)).digest("hex").slice(0, 10)).toBe(version); expect(pngSize(file)).toEqual({ w: 1200, h: 630 }); }); }});// STALE.md (24 Nov 2026): what the pages said that was not true today, rewritten from FACTS.md by a clean writer.describe("what is true today, not at launch", () => { it("the website's only form is signing in to connect an assistant", () => { const t = text(page("privacy.html")); expect(t).toContain("Its only form is the one for signing in, which is used to connect an assistant"); expect(t).not.toContain("and for deleting an account. Signing in"); }); it("free space is today's 50 GB, and the 2 GB and friends rule is said as launch", () => { // The home page says the owner's own line instead (25 Nov 2026): "The first 2 GB are free." for (const name of ["support.html", "terms.html"]) { const t = text(page(name)); expect(t, name).toContain("up to 50 GB of"); expect(t, name).toMatch(/[Aa]t launch/); expect(t, name).not.toContain("get 2 GB free"); expect(t, name).not.toContain("the first 2 GB is free"); expect(t, name).not.toContain("More space is sold on this website"); } }); it("help says which apps are in testing and that Comms is private", () => { const t = text(page("support.html")); expect(t).not.toContain("All four apps are in testing"); expect(t).toContain("Cotton Days, Cotton Words and Cotton Story are in testing"); expect(t).toContain("Cotton Comms is private"); }); // The pitch sections are gone (owner, 25 Nov 2026): each page says what it has now and what's coming in one plain // sentence each (app-pages.json), every item checked against the code by the site-pages lane. it("the Days, Words and Story pages say what each does today (STALE.md, 25 Nov 2026)", () => { expect(text(page("days.html"))).not.toContain("Alerts, repeats"); expect(text(page("words.html"))).not.toContain("export them as plain text"); expect(text(page("story.html"))).not.toContain("then their scenes and lines"); }); it("Help's Comms answers are on the preview only (25 Nov 2026)", () => { const help = page("support.html"); expect(text(forPreview(help, true))).toContain("Why does Comms say “Waiting for your Mac”?"); expect(text(forPreview(help, true))).toContain("Gmail empties its Trash after 30 days"); expect(forPreview(help, false)).not.toContain("Waiting for your Mac"); expect(text(forPreview(help, true))).toContain("How do I make something repeat in Days?"); expect(forPreview(help, false)).not.toContain("make something repeat"); const privacy = page("privacy.html"); expect(text(forPreview(privacy, true))).toContain("B. True once the lock is live"); expect(forPreview(privacy, false)).not.toContain("work log"); const terms = page("terms.html"); expect(text(forPreview(terms, true))).toContain("Recording calls and meetings"); expect(forPreview(terms, false)).not.toContain("the minimum age"); expect(forPreview(help, true)).not.toContain("<!-- preview -->"); }); it("the Comms page says what Comms does today: no voice message written out, and no mail or sites (they move to Post and Sites)", () => { const t = text(page("comms.html")); expect(t).not.toContain("A voice message comes with its words written out"); const w = APP_PAGES.comms!; expect(`${w.has} ${w.coming}`).not.toMatch(/\bmail\b|\bsites?\b/i); }); it("the privacy policy says what Comms does with texts on Android and with a sender you block or delete", () => { const t = text(page("privacy.html")); expect(t).not.toContain("It is not released yet"); expect(t).toContain("Comms can become your phone's texts (SMS) app"); expect(t).toContain("On iPhone, Comms cannot read or send texts"); expect(t).toContain("it is erased 30 days after it came there"); expect(t).toContain("Delete everything erases every message that sender sent you"); });});describe("what Google's review reads", () => { const LIMITED_USE = 'Cotton\'s use and transfer of information received from Google APIs will adhere to the <a href="https://developers.google.com/terms/api-services-user-data-policy">Google API Services User Data Policy</a>, including the Limited Use requirements.'; it.each(["privacy.html", "yours.html"])("%s carries the Limited Use sentence word for word, and the permission Google asks for", (name) => { const html = page(name).replace(' rel="noopener"', "").replaceAll("’", "'"); expect(html).toContain(LIMITED_USE); expect(text(html)).toMatch(/[Ss]ee, create, change,? and delete events on (the )?Google calendars you own/); expect(text(html)).not.toContain("all your calendars"); }); it("the policy keeps its Google Calendar section where the verification packet points, and the Days page offers it", () => { expect(page("privacy.html")).toContain('id="days-google"'); // Old links to the section still land on it. expect(page("privacy.html")).toContain('id="google-calendar"'); expect(page("privacy.html")).toContain("not used to develop, improve or train AI or machine learning models"); // The Days page's Google Calendar section went with the pitch (owner, 25 Nov 2026); what Days does with Google data // is said in full on /yours#google and in this policy, both linked from every page's footer. expect(links(page("days.html"))).toEqual(expect.arrayContaining(["/yours", "/privacy"])); expect(page("yours.html")).toContain('id="google"'); }); // Google's Limited Use checklist for the privacy policy; the Days page links to it. it.each(["privacy.html"])("%s answers every point of Google's Limited Use checklist", (name) => { const t = text(page(name)); for (const said of [ "See, create, change, and delete events on Google calendars you own", "only when you do it in Days", "If you withdraw access there instead, Days stops bringing in events and says so in its settings", "Cotton never sends your Google Calendar data to an AI company itself", "keeps no copy of it", "email address, only to show which account is connected", "only to show your calendar in Days, to keep it up to date, and to make in Google the changes and invitations you ask for", "encrypted to your own key as soon as it arrives", "no person at Cotton reads it", "not sold", "advertising", "not used to develop, improve or train AI or machine learning models", "does not pass it to anyone", "are kept in Days until you disconnect Google Calendar", "Disconnect", ]) expect(t, `${name}: ${said}`).toContain(said); expect(links(page(name)), `${name}: where to withdraw access at Google`).toContain("https://myaccount.google.com/connections"); }); it("the Days page describes the app, not only the calendar", () => { const html = page("days.html"); expect(html).toContain('<h1>Cotton <span class="ring draw">Days'); expect(html).toContain("Sometime"); }); it("support names the permission Google asks for now, never an older one", () => { const t = text(page("support.html")); expect(t).toContain("See, create, change, and delete events on Google calendars you own"); expect(t).not.toContain("all your calendars"); expect(t).not.toContain("read-only"); expect(t).toContain("the events already brought in stay in Days until you tap Disconnect there"); });});describe("what the pages say about reading", () => { // The owner, 23 Nov 2026: Memory is locked like everything else by launch, and the site describes launch, so no // page names an exception to what the server cannot read. it.each(Object.keys(site))("%s names no exception to what the server cannot read, and no Memory notes", (name) => { const t = text(page(name)); expect(t).not.toMatch(/\bexception\b/i); expect(t).not.toMatch(/\bmemory\b/i); expect(page(name)).not.toContain("#exception"); }); it.each(["privacy.html", "support.html", "yours.html"])("%s still says the server cannot read what you write", (name) => { expect(text(page(name))).toMatch(/cannot read|can read none of the words/); }); it("no page says Android may send speech to Google", () => { const t = text(page("privacy.html")); expect(t).toContain("never use a speech service that sends the audio off the phone"); expect(t).not.toMatch(/audio goes to Google/); }); it("the privacy policy covers all four apps and the website, each with its own anchor", () => { const html = page("privacy.html"); for (const id of ["days", "words", "story", "comms", "website", "google-calendar"]) expect(html).toContain(`id="${id}"`); expect(text(html)).toContain("Cotton Days, Cotton Words, Cotton Story and Cotton Comms"); });});describe("the owner's answers (22 Nov 2026)", () => { it("the company's address is on the privacy policy, support and the plain privacy page, and on no other page", () => { const flat = (html: string) => text(html).replace(/\s*,?\s+/g, " "); const address = "651 N Broad St Ste 206 Middletown DE 19709 United States"; for (const [name, html] of Object.entries(site)) expect(flat(html).replace(/,/g, "").includes(address), name).toBe(["privacy.html", "support.html", "yours.html"].includes(name)); }); it("with deleting switched on, the privacy policy and support say an account is deleted 30 days after asking, and signing in before then keeps it", () => { const on = renderSite({ accountDelete: true }); renderSite(); const page = (name: string) => on[name]!; const privacy = text(page("privacy.html")); expect(privacy).toContain("Your account is deleted 30 days after you ask. To keep it, sign in again before then and choose Keep my account."); // Round 2 (23 Nov 2026) names no retention for reports or backups: nothing in the code holds to one. expect(privacy).not.toMatch(/kept for 90 days|backups for up to 30 days/); expect(privacy).toContain("made by me, Mukesh, through my company, DECEMBERFM, INC"); const support = text(page("support.html")); expect(support).toContain("Your account is deleted 30 days after you ask"); expect(support).toContain("Keep my account"); expect(support).toContain("Reports are deleted with your account."); // Space cannot be bought yet: Help says it will be sold (coordinator, 23 Nov 2026), as the home page and the terms do. expect(support).toContain("Space will also be sold by the month on the website (cottondb.com), never inside the apps, from $5 a month for 100 GB."); expect(support.replace(/\s+\./g, ".")).toContain("The full prices are in the terms."); expect(support).not.toContain("space is sold on this website"); expect(support).toContain("support is by email only"); for (const t of [privacy, support]) expect(t).not.toContain("runs straight away"); }); it("a hyphenated word never breaks at its hyphen, and in the server-sees table it stays in its line", () => { expect(page("days.html")).toContain('<span class="nb">to-dos</span>'); expect(page("yours.html")).toContain('<dd>A <span class="nb">to-do</span>’s day'); expect(CSS).toContain(".sees dd .nb { display: inline; color: inherit; }"); }); it("every page links to /delete, which is a real page whether deleting is switched on or off (Play: reachable without the app)", () => { const on = renderSite({ accountDelete: true }); const off = renderSite({ accountDelete: false }); renderSite(); for (const [name, html] of Object.entries(on)) expect(links(html), name).toContain("/delete"); expect(text(on["support.html"]!)).toContain("Keep my account"); for (const [name, html] of Object.entries(off)) { expect(links(html), name).toContain("/delete"); expect(html, name).not.toContain("delete:o"); } }); it("/delete says what the privacy policy says about deleting, word for word, for the switch's state", () => { const off = renderSite({ accountDelete: false }); const on = renderSite({ accountDelete: true }); renderSite(); const chapter = (html: string) => { const t = text(html); return t.slice(t.indexOf("Deleting your data and your account"), t.indexOf("Who I am and how to reach me")); }; for (const [state, pages] of [["off", off], ["on", on]] as const) { const page = text(pages["delete.html"]!); expect(page, state).toContain("Delete your Cotton account"); // Every sentence of the policy's chapter (but its heading) is on the page. for (const sentence of chapter(pages["privacy.html"]!).split(/(?<=[.;:])\s+/).slice(1).filter((s) => s.trim().length > 20)) expect(page, `${state}: ${sentence}`).toContain(sentence.trim()); expect(pages["delete.html"], state).toContain('<link rel="canonical" href="https://cottondb.com/delete">'); } const asking = text(off["delete.html"]!); expect(asking).toContain("You cannot delete your account yourself yet, in the apps or on this website."); expect(asking).toContain(`Write to ${CONTACT} and give the phone number you signed in with.`); expect(asking).toContain("What is not deleted"); expect(asking).not.toContain("Keep my account"); expect(links(off["delete.html"]!)).toContain(`mailto:${CONTACT}`); const deleting = text(on["delete.html"]!); expect(deleting).toContain("In Cotton Story, Cotton Days or Cotton Words, while signed in, open the app's settings"); expect(deleting).toContain("Keep my account"); }); it("while deleting is off, help and the privacy policy say to ask by email, and nothing describes the button or the page", () => { const off = renderSite({ accountDelete: false }); renderSite(); const support = off["support.html"]!; expect(support).toContain('<h3 id="delete-account">How do I delete my account?</h3>'); expect(support.indexOf('id="delete-account"')).toBeGreaterThan(support.indexOf('<section class="chapter"')); const answer = text(support.slice(support.indexOf('id="delete-account"'), support.indexOf("How do I connect Google Calendar"))); expect(answer).toContain("You cannot delete your account yourself yet"); expect(answer).toContain(CONTACT); expect(answer).toContain("30 days after I confirm your request"); const privacy = text(off["privacy.html"]!); expect(privacy).toContain(`For now, ask me by email at ${CONTACT}.`); expect(privacy).toContain(`write to me again at ${CONTACT} before the deletion date`); for (const t of [text(support), privacy, text(off["delete.html"]!)]) { expect(t).not.toContain("Keep my account"); expect(t).not.toContain("cottondb.com/delete"); } }); it("every address a page shows is the one in site.json, and the old one is on no page", () => { expect(CONTACT).toBe("mukesh@tinfactory.co"); for (const [name, html] of Object.entries(site)) { expect(html, name).not.toContain("hello@cottondb.com"); expect(html, name).not.toContain("{{contact}}"); for (const m of html.matchAll(/[\w.+-]+@[a-z][\w-]*\.[a-z]{2,}\b(?!@)/g)) if (!/@2x\./.test(m[0])) expect(m[0], name).toBe(CONTACT); } expect(links(site["support.html"]!)).toContain(`mailto:${CONTACT}`); }); it("the site reads the switch from live's own config, the one place it is set", () => { const wrangler = readFileSync(path.join(__dirname, "../../../../business/wrangler.jsonc"), "utf8"); const live = (jsonc(wrangler) as { vars: Record<string, string> }).vars.ACCOUNT_DELETE; expect(live).toBeDefined(); expect(accountDeleteOn()).toBe(live === "on"); expect(jsonc('{ // a\n "a": "https://x", /* b */ "b": [1,], }')).toEqual({ a: "https://x", b: [1] }); expect(forDelete("x<!-- delete:on -->ON<!-- /delete:on -->\n<!-- delete:off -->OFF<!-- /delete:off -->\ny", true)).toBe("xONy"); expect(forDelete("x<!-- delete:on -->ON<!-- /delete:on -->\n<!-- delete:off -->OFF<!-- /delete:off -->\ny", false)).toBe("xOFFy"); });});describe("blanks", () => { it("finds each blank by its words", () => { expect(blanksIn("a [[blank: the date]] b [[blank: a link ]]")).toEqual(["the date", "a link"]); expect(blanksOf({ "a.html": "x", "b.html": "[[blank: y]]" })).toEqual({ "b.html": ["y"] }); }); it("a live build names every blank, page by page", () => { const r = refusal({ "privacy.html": ["date of publishing"] }); expect(r).toContain("privacy.html"); expect(r).toContain("- date of publishing"); }); it("a preview marks a blank in the text and a blank link", () => { expect(previewOf("<p>[[blank: date]]</p>")).toContain('<mark class="blank">[date]</mark>'); expect(previewOf('<a href="[[blank: store link]]">x</a>')).toContain('href="#blank" class="blank" title="Blank: store link"'); }); it("no blank is left: the privacy policy carries its date of publishing", () => { // What the live build publishes: a draft inside <!-- preview --> may hold a blank for the owner. const live = Object.fromEntries(Object.entries(site).map(([k, v]) => [k, forPreview(v, false)])); expect(blanksOf(live)).toEqual({}); });});