// A create whose record is one photo opens the camera, not a page of fields// (owner, 17 Oct 2026, 02:47 IST: "the minute we say add a meal, it should// just open up the camera"). The form's shape decides it — the definition,// never a table's id — and the shot makes the row with its moment as the time.importCottonKitimportCottonValuesimportFoundationimport XCTest@testable importCottonUI@MainActorfinalclassOnePhotoCreateTests: XCTestCase {privatestaticfunc table(_ columns: [ColumnDefinition]) -> TableDefinition {TableDefinition( id: "invented_meal", name: "Meal", plural: "Meals", columns: columns, title: "photo", date: "eaten_at", slip: SlipLayout(title: "photo"), tile: TileLayout(face: .slipList), page: [PageSection(heading: nil, columns: columns.map(\.key))] ) }privatestaticlet photo = ColumnDefinition(key: "photo", name: "Photo", type: .photo)privatestaticlet eatenAt = ColumnDefinition(key: "eaten_at", name: "Eaten", type: .date)privatestaticlet made = ColumnDefinition(key: "created_at", name: "Made", type: .date, readonly: true)privatestaticlet blank = TableRecord(id: "", values: [:])/// GUARD: a create whose only field is a photo is the camera, and a create that asks anything more is the page./// RULE: a create form whose one writable field (its time column aside, which the shot fills) is a photo opens the camera at once with no field page and no second tap; a second field makes it a page, so the camera never hides a field the person must fill (owner, 17 Oct 2026).func testOnlyAOnePhotoCreateOpensTheCamera() { XCTAssertEqual(Self.table([Self.photo]).onePhoto(of: Self.blank)?.key, "photo") XCTAssertEqual(Self.table([Self.photo, Self.eatenAt, Self.made]).onePhoto(of: Self.blank)?.key, "photo","the time column is the shot's moment and a read-only column is not asked")let twoFields = Self.table([Self.photo, ColumnDefinition(key: "dish", name: "Dish", type: .text)]) XCTAssertNil(twoFields.onePhoto(of: Self.blank), "a two-field create presents the page")let oneText = Self.table([ColumnDefinition(key: "dish", name: "Dish", type: .text)]) XCTAssertNil(oneText.onePhoto(of: Self.blank), "one field that is not a photo is a page") }/// GUARD: the shot makes the row at once, its picture in the photo column and its moment as the record's time, over what the create was opened with.func testTheShotKeepsTheRowWithItsMoment() asyncthrows {let meal = Self.table([Self.photo, Self.eatenAt])let store = FixtureRecords(definitions: [meal], records: ["invented_meal": []])let moment = Date(timeIntervalSince1970: 1_792_000_000)let values = meal.shotValues(Self.photo, key: "photo:invented", at: moment, preset: [:])let change = tryawait store.create(table: meal.id, data: values)let kept = try XCTUnwrap(change.after) XCTAssertEqual(kept["photo"], .text("photo:invented")) XCTAssertEqual(kept["eaten_at"], .text(CottonDate.format(moment)))let opened = meal.shotValues(Self.photo, key: "photo:invented", at: moment, preset: ["invented_note": .text("lunch")]) XCTAssertEqual(opened["invented_note"], .text("lunch"), "what the create was opened with rides with the shot") }}