Cotton code
27 lines · 2.0 KB · SwiftRaw
import CottonKitimport XCTest@testable import CottonUI/// S1 extended (architect, 5 Oct): a slip opens ITS RECORD wherever it is/// drawn — Home, a board, search, a section — never the tool's list.final class BoardSlipOpensRecordTests: XCTestCase {    /// RULE: A record whose screen is not its kind's route opens the screen its definition names (`record_route`, a route pattern filled with its id) — a chat, a mail conversation, a password; a table that names none opens its table's page. The app keeps no table-to-screen map and knows no table by its id (architect, 13 Oct 2026).    @MainActor func testTheRouteARecordOpensAt() throws {        let bundle = Bundle(url: SourceSweep.iosSources.appendingPathComponent("CottonUI/Resources"))        let shipped = TableDefinitions(FixtureDefinitions.load(from: bundle).definitions)        func route(_ table: String, _ id: String) -> Route { BoardRecord.route(table: table, id: id, definition: shipped[table]) }        XCTAssertEqual(route("thread", "t1"), .messagesThread(thread: "t1"))        XCTAssertEqual(route("email_thread", "e1"), .emailId(id: "e1"))        XCTAssertEqual(route("secret", "p w"), .passwordsSecret(id: "p w"), "the id is filled in as the screen reads it")        XCTAssertEqual(route("story", "x"), .tableRecord(table: "story", id: "x"), "a story names no route: it opens its table's page route")        XCTAssertEqual(route("face", "x"), .tableRecord(table: "face", id: "x"), "a kit tool's row with no route opens its table's page route")        for definition in shipped.all {            guard let pattern = definition.recordRoutePattern else { continue }            XCTAssertNotNil(Route.record(pattern, id: "x"), "\(definition.id) names a route this app has no screen for")        }        XCTAssertNil(Route.record("/messages", id: "x"), "a pattern with no parameter addresses no record")        XCTAssertNil(Route.record("/no-such/[id]", id: "x"), "a pattern this app has no screen for opens nothing")    }}