Cotton code
57 lines · 3.4 KB · SwiftRaw
// The board replaced Home on the phone (ws-m5b18, 1 Oct). Nothing the old// Home showed may be lost: each item it drew is placed on the board — above// the tiles, in the cap, or one tap away — and each placement is held here.// The audit that lists every item and where it went is in the pull request.//// This target has no renderer, so a placement is held in the two forms that// ARE available: the pure words and pairings, as values; and the shape, as a// by-path source guard over the board's own files.import CottonKitimport XCTest@testable import CottonUIfinal class HomeBoardNoLossTests: XCTestCase {    private static let lane = "the board that replaced Home (ws-m5b18)"    private static let board = "apps/cotton/Sources/CottonUI/Surfaces/Board/HomeBoard.swift"    private static let notices = "apps/cotton/Sources/CottonUI/Surfaces/Board/BoardNotices.swift"    private static let surface = "apps/cotton/Sources/CottonUI/Surfaces/BoardSurface.swift"    private static let cap = "apps/cotton/Sources/CottonUI/Surfaces/CapBar.swift"    private static let box = "apps/cotton/Sources/CottonUI/Surfaces/HomeInput.swift"    private static let root = "apps/cotton/Sources/CottonUI/Boot/RootView.swift"    private static let routes = "apps/cotton/Sources/CottonUI/Boot/RouteScreen.swift"    private static let stack = "apps/cotton/Sources/CottonUI/Boot/StackHost.swift"    private static let captureSurface = "apps/cotton/Sources/CottonUI/Capture/CaptureSurface.swift"    private func code(_ path: String) throws -> String {        SourceSweep.withoutComments(try SourceSweep.mustRead(path, ownedBy: Self.lane))    }    private func count(_ needle: String, in text: String) -> Int {        text.components(separatedBy: needle).count - 1    }    // ── One source, both hosts ───────────────────────────────────────────    // ── Above the tiles ──────────────────────────────────────────────────    // RULE: A Done for you receipt keeps the old row's three facts — what Cotton did, when, the owner's own words — and its one verb.    func testADoneReceiptSaysWhatWhenAndOffersItsOneVerb() throws {        let now = Date(timeIntervalSince1970: 1_790_000_000)        let item = DoneItem(            kind: .filed, recordId: "t1", label: "Filed as a todo", text: "Buy milk",            when: "", action: .undo, path: "/todos/todo/t1")        XCTAssertEqual(BoardNoticeWords.doneLabel(item, now: now), "Filed as a todo", "no age, no dangling dot")        let dated = DoneItem(            kind: .filed, recordId: "t1", label: "Filed as a todo", text: "Buy milk",            when: "Yesterday", action: .undo, path: "/todos/todo/t1")        XCTAssertEqual(BoardNoticeWords.doneLabel(dated, now: now), "Filed as a todo \u{00B7} Yesterday")    }    // ── One tap away ─────────────────────────────────────────────────────    // ── The cap: search and capture in place ─────────────────────────────    // ── The project, and the names a test taps ───────────────────────────}