// What the owner could not find on Comms build 24 (FEEDBACK-2 B.1, 23 Nov// 2026): a Disappearing messages row on a chat's page. No iPhone build had// drawn it, though the core answers it (CONTRACT.md "Disappearing messages").// Over Chat Dev's invented chats (-chat-warm-seed YES, the core's own answers// from write_chat_warm_fixture): the row stands near the top of Asha's page,// above Mute; its sheet offers the four lengths, the one on ticked, and the// core's note; 7 days chosen stands on the row, the chat's header says it and// the chat holds its line; Off clears it. The Hill trip is a WhatsApp chat:// its page has the row exactly when the core answers its timer (B.2, the core// lane's), never words the phone made up. At the default size and the largest.import XCTestfinalclassChatDisappearingTests: XCTestCase {privatelet asha = "11111111-1111-4111-8111-0000000000a1"privatelet hillTrip = "11111111-1111-4111-8111-0000000000b1"privatestaticlet largestText = ["-UIPreferredContentSizeCategoryName", "UICTContentSizeCategoryAccessibilityXXXL"]privatelet turnedOn = "You turned on disappearing messages. New messages will disappear 7 days after they're sent."privatelet turnedOff = "You turned off disappearing messages."overridefunc setUp() { continueAfterFailure = false XCUIDevice.shared.orientation = .portrait } @MainActor privatefunc page(_ thread: String, _ extra: [String]) -> XCUIApplication {let app = XCUIApplication() app.launchArguments += ["-chat-warm-seed", "YES", "-chat-warm-open", thread, "-chat-warm-person", "YES"] + extra app.launch()return app }/// Waits until `element`'s frame has stood still for two seconds (the cover's rise). @MainActor privatefunc settled(_ element: XCUIElement) {var last = element.frame, still = 0for _ in0..<40where still < 5 {Thread.sleep(forTimeInterval: 0.4)let now = element.frame still = now == last ? still + 1 : 0 last = now } } @MainActor privatefunc element(_ id: String, in app: XCUIApplication) -> XCUIElement { app.descendants(matching: .any)[id].firstMatch }/// Scrolls the page until `element` can be touched: up (toward the foot) or down (back to the top). @MainActor privatefunc reach(_ element: XCUIElement, in app: XCUIApplication, up: Bool = true, _ what: String) {for _ in0..<8where !(element.exists && element.isHittable) { if up { app.swipeUp() } else { app.swipeDown() } } XCTAssertTrue(element.exists && element.isHittable, "\(what) can be reached") }/// The row says `length` at its end ("Disappearing messages, 7 days"). @MainActor privatefunc says(_ row: XCUIElement, _ length: String) {let said = XCTNSPredicateExpectation(predicate: NSPredicate(format: "label BEGINSWITH %@ AND label ENDSWITH %@", "Disappearing messages", length), object: row) XCTAssertEqual(XCTWaiter.wait(for: [said], timeout: 8), .completed, "the row says \(length): \(row.label)") }/// Opens the sheet from the row, checks the four lengths with `ticked` ticked and the note, and chooses `choose`. @MainActor privatefunc choose(_ choose: Int, ticked: Int, from row: XCUIElement, in app: XCUIApplication) { row.tap() XCTAssertTrue(element("chat-timer-sheet", in: app).waitForExistence(timeout: 5), "its sheet opens")for (seconds, label) in [(0, "Off"), (86_400, "24 hours"), (604_800, "7 days"), (7_776_000, "90 days")] {let length = app.buttons["chat-timer-\(seconds)"] XCTAssertTrue(length.exists, "\(label) is offered") XCTAssertEqual(length.label, label) XCTAssertEqual(length.isSelected, seconds == ticked, "\(label) ticked only if on") }let note = app.staticTexts["chat-timer-note"] XCTAssertTrue(note.exists && note.label.contains("screenshot"), "what it cannot stop: \(note.label)")let chosen = app.buttons["chat-timer-\(choose)"] reach(chosen, in: app, "the length") chosen.tap() XCTAssertTrue(element("chat-timer-sheet", in: app).waitForNonExistence(timeout: 5), "the sheet goes") } @MainActor privatefunc backToTheChat(_ app: XCUIApplication) {let back = app.buttons["chat-person-back"] reach(back, in: app, up: false, "Back") back.tap() XCTAssertTrue(app.tables["chat-thread"].waitForExistence(timeout: 10), "the chat") } @MainActor privatefunc walk(_ extra: [String]) {let app = page(asha, extra)let row = app.buttons["chat-timer"] XCTAssertTrue(row.waitForExistence(timeout: 30), "Disappearing messages on Asha's page") settled(app.buttons["chat-person-back"])// Near the top: above what is between them and above Mute.let mute = app.buttons["chat-person-mute"] reach(mute, in: app, "Mute") XCTAssertLessThan(row.frame.minY, mute.frame.minY, "the row stands above Mute") reach(row, in: app, up: false, "Disappearing messages")if extra.isEmpty { XCTAssertTrue(row.isHittable, "seen as the page opens, with no scrolling") } says(row, "Off") choose(604_800, ticked: 0, from: row, in: app) says(row, "7 days") backToTheChat(app) XCTAssertTrue(app.staticTexts[turnedOn].waitForExistence(timeout: 10), "the line in the chat")let header = app.buttons["chat-person"] XCTAssertTrue(header.label.contains("Disappearing messages: 7 days"), "the header says it: \(header.label)")// Off clears it. header.tap() XCTAssertTrue(row.waitForExistence(timeout: 10), "her page again") reach(row, in: app, up: false, "Disappearing messages") says(row, "7 days") choose(0, ticked: 604_800, from: row, in: app) says(row, "Off") backToTheChat(app) XCTAssertTrue(app.staticTexts[turnedOff].waitForExistence(timeout: 10), "the line it was turned off") XCTAssertFalse(app.buttons["chat-person"].label.contains("Disappearing messages"), "the header no longer says it: \(app.buttons["chat-person"].label)") }// RULE: Disappearing messages stands near the top of a person's page; its sheet offers the four lengths with the// one on ticked and says what it cannot stop; 7 days chosen stands on the row, in the header and as the chat's// line; Off clears it. @MainActor func testTheRowOnAshasPageSetsAndClearsTheTimer() { walk([]) }// RULE: the same at the largest text: the row, the lengths and the note can all be reached. @MainActor func testTheTimerAtTheLargestText() { walk(Self.largestText) }// RULE: a group's page has the row under its pills when the core answers the group's timer, and none when it does// not: the Hill trip is a WhatsApp chat, whose timer the core answers once B.2 lands (and the fixture is// written again). @MainActor func testAGroupsPageDrawsTheRowFromTheCoresAnswer() throws {for extra in [[], Self.largestText] {let app = page(hillTrip, extra)let members = app.staticTexts["4 members"] XCTAssertTrue(members.waitForExistence(timeout: 30), "the Hill trip's page") settled(app.buttons["chat-group-back"])let row = app.buttons["chat-timer"]guardtrySelf.answersTimer(hillTrip) else { XCTAssertFalse(element("chat-timer", in: app).exists, "no row the core does not answer")continue } XCTAssertTrue(row.exists, "Disappearing messages on the Hill trip's page")let heading = app.staticTexts["Members"]if heading.exists { XCTAssertLessThan(row.frame.minY, heading.frame.minY, "above the members") } row.tap() XCTAssertTrue(element("chat-timer-sheet", in: app).waitForExistence(timeout: 5), "its sheet opens") XCTAssertTrue(app.staticTexts["chat-timer-note"].exists, "with the core's note") } }/// Whether the warm fixture's answer for `thread` carries a timer (the core's, written by write_chat_warm_fixture).privatestaticfunc answersTimer(_ thread: String) throws -> Bool {let url = URL(fileURLWithPath: #filePath).deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent() .appendingPathComponent("Sources/CottonUI/Resources/Fixtures/chat-warm.json")let fixture = try JSONSerialization.jsonObject(with: Data(contentsOf: url)) as? [String: Any]let page = (fixture?["threads"] as? [String: Any])?[thread] as? [String: Any]return page?["timer"] is [String: Any] }}