// The root page is Home in every flavour, never Me (owner's ruling, 19 Oct // 2026): the fan card and the page say Home, and the page's sections are its // home board's — Cotton's shipped one, or the board a business app's manifest // names, which the core holds in Cotton's place (`declare_home`). import CottonKit import XCTest @testable import CottonUI final class HomeNeverMeTests: XCTestCase { /// Every business app the project builds (`apps/cotton/App/Flavours//flavour.json`). private func flavours() throws -> [(String, Data)] { let root = SourceSweep.repoRoot.appendingPathComponent("apps/cotton/App/Flavours") let names = try FileManager.default.contentsOfDirectory(atPath: root.path).filter { !$0.hasPrefix(".") }.sorted() XCTAssertFalse(names.isEmpty, "the project builds at least one business app") return try names.map { name in (name, try Data(contentsOf: root.appendingPathComponent(name).appendingPathComponent("flavour.json"))) } } /// RULE: every business app's manifest (`App/Flavours/*`) names its Home — a board with the id `home` and at least one section; only Cotton's own apps over the personal object (Cotton, Cotton Music) name none and draw the shipped Home. An app whose dial holds no Home card (`fan.home` false — Rigby, phone-only, opens on Todos) has no Home page to draw, so it names no board either: one it named would never be drawn. func testEveryBusinessManifestNamesItsHome() throws { for (name, data) in try flavours() { let manifest = try JSONDecoder().decode(FlavourManifest.self, from: data) guard manifest.fan.home else { XCTAssertNil(manifest.home, "\(name): its dial holds no Home, so it names no home board") continue } // One of Cotton's own apps over the personal object that keeps a // Home card and names none draws the shipped Home, the sync card // (Cotton Music, 4 Nov 2026; `board_tests.rs` says the same). if manifest.home == nil, manifest.genesis == .personal { continue } guard case .object(let home)? = manifest.home, case .array(let parts)? = home["parts"] else { return XCTFail("\(name): its home definition is not a board") } XCTAssertEqual(home["id"], .string("home"), name) XCTAssertFalse(parts.isEmpty, "\(name): its Home draws no sections") } } /// RULE: no flavour's fan carries a card called Me — the root page's card is Home, in Cotton and in every business app. func testNoFanCarriesMe() throws { XCTAssertEqual(GridTile.home.name, "Home") XCTAssertEqual(GridTile.home.key, "home") // The core names the fan's Home card in the kit's words (`shell.fan`). XCTAssertEqual(ShellLines.line("board", "dial.home"), "Home") } /// RULE: the Home page carries no title over its head — the head is the person's name, never the word Me — and draws the home board's sections, the head among them, in the board's order; on the phone with cards on, Home is one deck of cards (row C of the deck faces, 23 Oct 2026) — today's, the unread conversations, then each of Home's parts — under no title either. func testTheHomePageDrawsItsBoardsSectionsUnderNoTitle() throws { let surface = SourceSweep.withoutComments( try SourceSweep.mustRead("apps/cotton/Sources/CottonUI/Surfaces/BoardSurface.swift", ownedBy: "shell2")) .filter { !$0.isWhitespace } XCTAssertTrue(surface.contains("ifdecks{HomeToday(home:home.model,deckPage:true,devicePart:homeDevice,parts:homeCards)")) XCTAssertFalse(surface.contains("\"Me\"")) } }