import CottonKit import Foundation import XCTest @testable import CottonUI /// Walker 298: Today's Sleep tile (a repeating event) opened the series' /// start — "Yesterday 12:00 am – 8:00 am" — not tonight's occurrence. The /// row's route dropped its start and the event screen ignored `at`. What a /// day card opens is the core's now (`shell.today`'s `opens`, held by /// `shell_today_tests.rs`); Home routes it by its table's `record_route` /// with its start, and the event screen opens that occurrence. final class TodayOccurrenceOpensItsDayTests: XCTestCase { /// RULE: a repeating event's tile opens that day's occurrence — Home routes the core's `opens` with the occurrence's start (`at`), and the page reads `@`, which the core opens at that occurrence's when — because a person tapping tonight's Sleep means tonight, not the night the series began. func testARepeatingEventsTileOpensTheOccurrenceOnTheTilesDay() throws { let today = SourceSweep.withoutComments(try SourceSweep.mustRead( "apps/cotton/Sources/CottonUI/Surfaces/Board/HomeToday.swift", ownedBy: "home")).filter { !$0.isWhitespace } XCTAssertTrue(today.contains("letown=BoardRecord.route(table:opens.table,id:opens.id,definition:definitions[opens.table])"), "Home's day card opens the record's own screen, as its definition routes it") XCTAssertTrue(today.contains("letroute=opens.at.flatMap{Route.parse(Route.join(own.path,[(\"at\",$0)]))}??own"), "Home's day card routes the occurrence's start") // The event definition's route, with the start the core names, is that occurrence. let own = try XCTUnwrap(Route.record("/calendar/event/[id]", id: "invented-walk")) XCTAssertEqual(Route.parse(Route.join(own.path, [("at", "2026-11-08T07:00:00+05:30")])), .calendarEvent(id: "invented-walk", date: nil, at: "2026-11-08T07:00:00+05:30")) let screen = SourceSweep.withoutComments(try SourceSweep.mustRead( "apps/cotton/Sources/CottonUI/Boot/RouteScreen.swift", ownedBy: "phonefixes")).filter { !$0.isWhitespace } XCTAssertTrue(screen.contains("case.calendarEvent(letid,_,letat):returnany(TablePageRoute(table:\"event\",id:at.map{"), "the event screen opens the occurrence the route names") } }