Cotton code
38 lines · 2.2 KB · TypeScriptRaw
// RULE (walk on dev, 22 Nov 2026): an Android app that draws the shell's cards in its own column (`drawsSealedKey`)// also draws the sign-in ask card there (`drawsSignInAsk`, SignInAskCard in that column). Else the shell lays the card// over the app's top, on the app's own cards: in Days it covered the recovery code card. And the card's title, sub and// Not me lines say "your Cotton", never this app's name (the getting-in lane: the request is for the whole account).import { readdirSync, readFileSync, existsSync } from "node:fs";import { dirname, join, resolve } from "node:path";import { fileURLToPath } from "node:url";import { describe, expect, it } from "vitest";const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "../..");const SRC = join(ROOT, "apps/android/app/src");function files(dir: string): string[] {  return readdirSync(dir, { withFileTypes: true }).flatMap((e) => (e.isDirectory() ? files(join(dir, e.name)) : e.name.endsWith(".kt") ? [join(dir, e.name)] : []));}const apps = readdirSync(SRC).filter((app) => !app.startsWith("test") && existsSync(join(SRC, app, "kotlin")));const drawing = apps.filter((app) => files(join(SRC, app, "kotlin")).some((f) => /override val drawsSealedKey(: Boolean get\(\))? = true/.test(readFileSync(f, "utf8"))));describe("the sign-in ask card on Android", () => {  it("is drawn by some apps in their own column", () => {    expect(drawing).toEqual(expect.arrayContaining(["days", "story", "messages", "keys", "health"]));  });  it.each(drawing)("%s draws it in its own column, with its other cards", (app) => {    const sources = files(join(SRC, app, "kotlin")).map((f) => readFileSync(f, "utf8"));    expect(sources.some((s) => /override val drawsSignInAsk(: Boolean get\(\))? = true/.test(s))).toBe(true);    expect(sources.some((s) => /SignInAskCard\(/.test(s))).toBe(true);  });  it("never names this app in the account's request", () => {    const card = readFileSync(join(ROOT, "apps/android/shell/src/main/kotlin/com/cottondb/shell/SignInAskCard.kt"), "utf8");    expect(card).not.toMatch(/named\(asking\.str\("(title|sub|notMeConfirm|notMeDone)"\)/);    expect(card).not.toMatch(/str\("sub"\)\?\.let \{ CardText\(named/);    expect(card).not.toMatch(/named\(cannot\.str\("title"\)/);  });});