// Me's page is drawn inside the fan's live page (`FanLivePage`), which is // `.equatable()` on its tile and the tiles: it redraws for what its body // observes and never for a value its page closure captured. On the owner's // phone (build 288) Me's face read landed after the page's first draw and was // never drawn — head "Me" with a blank picture — until the next opening. // Today's rows are the core's page now (`shell.today`), read by `HomeModel`. import Observation import XCTest @testable import CottonUI @MainActor final class LatePageReadsTests: XCTestCase { /// RULE: a read Me's page draws that lands after the page's first draw is drawn — Me's face lives in an observable box (`HomeRead`) read inside the live page, never in BoardSurface view state a page closure captures, because the fan's equatable live page skips its body for anything it did not observe (owner's phone, build 288: head "Me" blank until the next opening). func testHomesFaceLandingLateRedrawsThePage() throws { let me = HomeRead() let redrawn = Redrawn() withObservationTracking { _ = me.face } onChange: { redrawn.fired = true } me.take(HomeFace(name: "Heron", picture: nil, seed: "p-heron"), print: nil) XCTAssertTrue(redrawn.fired, "a page that read the face is invalidated when the face lands") let surface = SourceSweep.withoutComments( try SourceSweep.mustRead("apps/cotton/Sources/CottonUI/Surfaces/BoardSurface.swift", ownedBy: "home")) XCTAssertTrue(surface.contains("@State private var ownHomeRead = HomeRead()"), "the face is one observable box") XCTAssertTrue(surface.contains("private var personRead: HomeRead { keptHomeRead ?? ownHomeRead }"), "the window's box when it holds one: a switch draws Me's head and card at once (293 row 2)") XCTAssertFalse(surface.contains("@State private var meFace"), "never view state the live page captures") XCTAssertTrue(surface.contains("HomeHead(face: personRead.face"), "Home's head reads the box where it is drawn") } } private final class Redrawn: @unchecked Sendable { var fired = false }