#if canImport(UIKit)importCottonValuesimportImageIOimportSwiftUIimportUniformTypeIdentifiersimport XCTest@testable importCottonUI/// A capture utility, not a guard: with `HOUSE_A_OUT=<dir>` set (through/// xcodebuild, `TEST_RUNNER_HOUSE_A_OUT`) it draws the birthday face on the/// numbers of the house references (a photo, a round portrait, a yearless/// day) — each on its stock, a 360 x 450 card at scale 3 — into/// `<dir>`, to be laid beside the references. Every name is invented; the/// portraits are the gallery's own. Without the out variable it skips.@MainActorfinalclassHouseTodoBirthdayShotsTests: XCTestCase {func testDrawTheTodoAndBirthdayReferences() throws {guardlet dir = ProcessInfo.processInfo.environment["HOUSE_A_OUT"], !dir.isEmpty else {throw XCTSkip("set HOUSE_A_OUT=<dir> to draw the birthday references") }let out = URL(fileURLWithPath: dir, isDirectory: true)tryFileManager.default.createDirectory(at: out, withIntermediateDirectories: true)let ananya = DeckCard(face: .birthday, corner: "Birthday in 3 days", fields: ["title": .text("Ananya Rao"), "subtitle": .text("Bengaluru"), "date": .text("Mon 26 Oct"),"turns": .text("turns 30"), "wishes": .bool(true), ])let ravi = DeckCard(face: .birthday, fields: ["title": .text("Ravi Menon"), "date": .text("Thu 29 Oct"), "turns": .text("turns 52"),"wishes": .bool(true), "last_wished": .text("Wed 29 Oct 2025"), ])let kiran = DeckCard(face: .birthday, fields: ["title": .text("Kiran"), "date": .text("Sat 14 Nov"), "wishes": .bool(false),"last_wished": .text("Fri 14 Nov 2025"), ]) shoot("birthday-photo", ananya, BirthdayFace(card: ananya, photo: GalleryFaces.picture("guest-0")), to: out) shoot("birthday-round", ravi, BirthdayFace(card: ravi, photo: GalleryFaces.picture("guest-1")), to: out) shoot("birthday-yearless", kiran, BirthdayFace<EmptyView>(card: kiran, photo: nil), to: out) }privatefunc shoot(_ name: String, _ card: DeckCard, _ face: someView, to out: URL) {let theme = Theme.paperlet renderer = ImageRenderer(content: face .environment(\.theme, theme) .environment(\.colorScheme, .light) .frame(width: 360, height: 450) .background(theme.colors.paper.color)) renderer.scale = 3guardlet image = renderer.cgImage,let dest = CGImageDestinationCreateWithURL(out.appendingPathComponent("\(name).png") as CFURL, UTType.png.identifier as CFString, 1, nil)else { return XCTFail("\(name) drew nothing") } CGImageDestinationAddImage(dest, image, nil) XCTAssertTrue(CGImageDestinationFinalize(dest), "\(name) was not written") }}#endif