importCottonKitimportCottonValuesimportFoundationimport XCTest@testable importCottonUI/// A Plus door that writes a new record (`accepts.draft`: Money's Add a/// spend, A bill to pay, Money in) asks its parts in the shell's input, as/// Android's `askDraftDoor` does. Before, the iPhone's offer did nothing for/// such a door (the iPhone sealed-tables walk of Money, 16 Nov 2026).@MainActorfinalclassDraftDoorTests: XCTestCase {/// RULE: A draft door's offer asks the core `shell.input {kind: door}` with its table and door, and the part the core asks next stands in the input after each commit.func testADraftDoorAsksItsPartsInTurn() asyncthrows {let plus = try JSONDecoder().decode(DeckAnswer.Plus.self, from: Data(#"{"does": "doors", "label": "Add", "doors": [{"id": "spend", "label": "Add a spend", "picture": null, "accepts": {"draft": {"door": "spend"}}}], "act": null, "route": null}"#.utf8))let core = InputCore { method, request inswitch (method, request["op"]?.string) {case ("shell.input", "ask"):return .success(InputCore.json(#"{"editor":"amount","mark":"\u20B9","words":"","hint":"Amount","keeps_words":false,"writes":{"kind":"column","table":"transaction","draft":"draft-1","column":"amount_minor","door":"spend"}}"#))case ("shell.input", "commit"):return .success(InputCore.json(#"{"next":{"editor":"line","words":"","hint":"Add a spend","keeps_words":true,"writes":{"kind":"new","table":"transaction","draft":"draft-1","door":"spend"}}}"#))default:return .failure(CottonCallError(code: "missing", message: "Not here")) } }let editor = DeckEditor()let offers = plus.offers(editor, table: "transaction", core: core, toasts: nil, landed: { _ in }, choose: { _ in }) XCTAssertEqual(offers.map(\.word), ["Add a spend"])await offers[0].perform([])tryawait eventually { editor.writing != nil }let asked = try XCTUnwrap(core.asked("shell.input", op: "ask").first) XCTAssertEqual(asked["kind"], "door") XCTAssertEqual(asked["table"], "transaction") XCTAssertEqual(asked["door"], "spend") XCTAssertEqual(editor.writing?.hint, "Amount") XCTAssertEqual(editor.writing?.editor, .amount, "the core's amount input is drawn, not refused") editor.commit("45")tryawait eventually { editor.writing?.hint == "Add a spend" } XCTAssertEqual(core.asked("shell.input", op: "commit").first?["writes"]?["column"], "amount_minor") }}