// The event's rolodex (the design session's card, 3 Nov 2026): the shared// rotary card file, an event typed on its front card — the day on the tab// with the accent's dot while an invitation waits, the time where the// person's name sits, the title on the rules under it, the place and who it// is with under that; past events dimmed; a line the card lacks a bare rule;// every line its part, as the invitation tags them; standing on the// calendar's baize, turned on its rail.@testable importCottonFacesimportCottonPaperimportCottonSpecimensimportCottonValuesimportSwiftUIimport XCTest@MainActorfinalclassEventRolodexTests: XCTestCase {privatetypealiasCatalogue = EventRolodexFaceCatalogue/// A phone's front card, as the person's rolodex is measured.privatelet size: CGSize = {let frame = 350 * RolodexKnobs.fillWidthreturn CGSize(width: RolodexKnobs.card.width * frame, height: RolodexKnobs.card.height * frame / RolodexKnobs.aspect) }()/// RULE: The tab says the day ("Thu 5"), an event over several days its first to its last ("12 to 14"); the big line says the time, its end after it, or "All day"; every word the core's or a shipped line.func testTheTabAndTheTime() {let dinner = EventRolodexSetting.set(Catalogue.dinner, size: size) XCTAssertEqual(dinner.tab, "Thu 5") XCTAssertEqual(dinner.time, "6:30 pm to 10:00 pm")let allDay = EventRolodexSetting.set(Catalogue.allDay, size: size) XCTAssertEqual(allDay.tab, "Sun 8") XCTAssertEqual(allDay.time, ShellLines.line("dates", "all_day"))let days = EventRolodexSetting.set(Catalogue.days, size: size) XCTAssertEqual(days.tab, "12 to 14") XCTAssertEqual(days.time, "6:00 am to 9:00 pm") XCTAssertEqual(EventRolodexSetting.set(Catalogue.past, size: size).time, "11:00 am", "no end: the start alone") }/// RULE: The details are the place and who it is with, first names, three of them and the count of the rest; a card with neither leaves the rule bare.func testTheDetails() {let dinner = EventRolodexSetting.set(Catalogue.dinner, size: size) XCTAssertEqual(dinner.details.map(\.words), ["Indiranagar", "with Ananya, Rahul, Meera +2"]) XCTAssertEqual(dinner.details.map(\.part), [.place, .people]) XCTAssertEqual(EventRolodexSetting.set(Catalogue.invitation, size: size).details.map(\.words), ["with Meera, Arjun"]) XCTAssertTrue(EventRolodexSetting.set(Catalogue.past, size: size).details.isEmpty)let laid = EventRolodexSetting.laid(dinner.details, size: size) XCTAssertEqual(laid.map(\.part), [.place, nil, .people], "the middle dot between, of no part")let room = EventRolodexSetting.room(size) XCTAssertLessThanOrEqual(laid.last.map { $0.lead + $0.width } ?? 0, room.lead + room.width + 0.001, "squeezed to the room, never cut") }/// RULE: A long title takes two rules at most, broken at whole words, and none of its words is lost.func testALongTitleTakesTwoRules() {let invitation = EventRolodexSetting.set(Catalogue.invitation, size: size) XCTAssertEqual(invitation.title.count, 2) XCTAssertEqual(invitation.title.joined(separator: " "), Catalogue.invitation.text("title")) XCTAssertEqual(EventRolodexSetting.set(Catalogue.past, size: size).title, ["Pick up the cake"]) }/// RULE: An invitation waiting for an answer carries the accent's dot; a past or declined event sits dimmed; a date still to be added is no date.func testTheDotAndTheDim() { XCTAssertTrue(EventRolodexSetting.set(Catalogue.invitation, size: size).asks) XCTAssertFalse(EventRolodexSetting.set(Catalogue.dinner, size: size).asks) XCTAssertTrue(EventRolodexSetting.set(Catalogue.past, size: size).dimmed)var declined = Catalogue.dinner declined.pace = .done XCTAssertTrue(EventRolodexSetting.set(declined, size: size).dimmed) XCTAssertFalse(EventRolodexSetting.set(Catalogue.dinner, size: size).dimmed)var undated = Catalogue.past undated.fields["date"] = .text(ShellLines.line("cards", "date.add"))let bare = EventRolodexSetting.set(undated, size: size) XCTAssertNil(bare.tab) XCTAssertNil(bare.time) }/// RULE: Every line drawn is its part, as the invitation tags them: the day the when, the title the title, the place the place, the prints the people; a line the card lacks tags nothing.func testEveryLineIsItsPart() {func parts(_ card: DeckCard) -> Set<FacePart> {finalclassTagged { var parts: Set<FacePart> = [] }let tagged = Tagged()let drawn = EventRolodexFace(card: card) .frame(width: 350, height: 437) .backgroundPreferenceValue(FacePartsKey.self) { regions inlet _ = tagged.parts.formUnion(regions.map(\.part))Color.clear } XCTAssertNotNil(ImageRenderer(content: drawn).cgImage)return tagged.parts } XCTAssertEqual(parts(Catalogue.dinner), [.when, .title, .place, .people]) XCTAssertEqual(parts(Catalogue.invitation), [.when, .title, .people]) XCTAssertEqual(parts(Catalogue.past), [.when, .title]) XCTAssertFalse(Catalogue.face.tagsNoPart) }/// RULE: The event's rolodex stands on the calendar's kitchen tile by its own id beside the board and the invitation, and turns on its rail as People's does.func testItStandsOnTheKitchenTileAndTurns() { XCTAssertEqual(FaceRegistry.ground("event.rolodex"), .kitchenTile) XCTAssertEqual(FaceRegistry.stock("event.rolodex"), .own) XCTAssertEqual(Catalogue.face.steps, .turns) XCTAssertEqual(Catalogue.face.specimens.map(\.name), ["dinner", "all-day", "days", "invitation", "past"]) }/// RULE: The event's card turns through the same wheel: a phase of the turn draws differently from rest, both ways.func testTheTurnDrawsBothWays() throws {let face = Catalogue.facelet leaving = face.specimens[0]let arriving = face.specimens[2]func drawn(_ progress: Double) throws -> Data {let view = SpecimenCard(face, leaving) .environment(\.faceTurn, FaceTurn(progress: progress, window: [-1: arriving.card, 1: arriving.card])) .frame(width: 340, height: 451)let renderer = ImageRenderer(content: view) renderer.scale = 2returntry XCTUnwrap(renderer.cgImage?.dataProvider?.data asData?) }let still = try drawn(0)for progress in [-0.5, 0.5] { XCTAssertNotEqual(try drawn(progress), still, "phase \(progress) draws the turn") } }}