Cotton code
45 lines · 3.2 KB · SwiftRaw
// The record button is the dock Home's box mounts (`HomeInput.mount`), and it// can only be mounted once the capture service exists. On the owner's phone// (build 288) the button was missing until a database switch and back: boot// went ready before the workspace id was known, so the capture service was// nil at Home's first draw and `mount` returned with no dock — and its task,// keyed on the shown database alone, never ran again when the service came.import XCTest@testable import CottonUIfinal class RecordButtonMountTests: XCTestCase {    /// RULE: Home's dock is mounted again whenever the capture service changes, not only when the shown database does — every `mount()` task is keyed on `dockMount`, which holds both; keyed on the database alone, a service arriving after Home was drawn left the record button away until a switch and back (owner's phone, build 288).    func testTheDockMountsWhenTheCaptureServiceArrives() throws {        let source = SourceSweep.withoutComments(            try SourceSweep.mustRead("apps/cotton/Sources/CottonUI/Surfaces/HomeInput.swift", ownedBy: "home"))        let mounts = source.components(separatedBy: "await mount()").count - 1        let keyed = source.components(separatedBy: ".task(id: dockMount) { await mount() }").count - 1        XCTAssertGreaterThan(mounts, 0, "HomeInput mounts its dock")        XCTAssertEqual(keyed, mounts, "every mount task is keyed on dockMount, never on the shown database alone")        XCTAssertTrue(            source.contains("DockMount(shown: scene?.shownId, capture: capture.map(ObjectIdentifier.init))"),            "the key holds the capture service as well as the database")        XCTAssertNotEqual(            DockMount(shown: "personal", capture: nil),            DockMount(shown: "personal", capture: ObjectIdentifier(NSObject.self)),            "a service arriving for the same database is a new key: the task runs again")    }    /// RULE (owner, 13 Nov 2026): the top-row microphone is gone from every app (it did not work), and nothing of it stays: no row mounts one, and the box's dock keeps only the kept thought's receipt over the fan.    func testNoTopRowMicrophoneAndTheDockTakesNoFootRoom() throws {        for file in ["Deck/DeckSurface.swift", "Deck/CardDeck.swift", "Surfaces/Board/BoardHead.swift", "Surfaces/HomeInput.swift"] {            let source = SourceSweep.withoutComments(try SourceSweep.mustRead("apps/cotton/Sources/CottonUI/" + file, ownedBy: "fan"))            XCTAssertFalse(source.contains("FanMicrophone"), file)            XCTAssertFalse(source.contains("mic.fill"), file)        }        let source = SourceSweep.withoutComments(try SourceSweep.mustRead("apps/cotton/Sources/CottonUI/Surfaces/Board/FanRecord.swift", ownedBy: "fan"))        XCTAssertTrue(source.contains(".frame(width: 0, height: 0)"))        XCTAssertFalse(source.contains("startDictation"), "the receipt starts no take")        XCTAssertFalse(source.contains("fanMicrophone"))        let input = SourceSweep.withoutComments(try SourceSweep.mustRead("apps/cotton/Sources/CottonUI/Surfaces/HomeInput.swift", ownedBy: "fan"))        XCTAssertTrue(input.contains(".frame(height: 0)"))        XCTAssertEqual(FanButton.of(editing: false, inWhole: false), .fan)    }}