// What the owner saw on Comms build 23 (23 Nov 2026): he replied to a// message, and the reply he sent showed no quote of it (the iPhone asked the// core for the reply strip, then sent without it). Over Chat Dev's invented// chats (-chat-warm-seed YES, the core's own answers from// write_chat_warm_fixture): a reply to Asha's message carries the quote, her// name and her words, inside the sent bubble; a reply received in the fixture// shows its quote too; and a tap on a quote goes to the message it quotes.// Shots reply-*.import XCTestfinalclassChatReplyTests: XCTestCase {privatelet asha = "11111111-1111-4111-8111-0000000000a1"privatestaticlet largestText = ["-UIPreferredContentSizeCategoryName", "UICTContentSizeCategoryAccessibilityXXXL"]privatelet written = "I will, thank you"overridefunc setUp() { continueAfterFailure = false XCUIDevice.shared.orientation = .portrait }overridefunc tearDown() { XCUIDevice.shared.appearance = .light }privatefunc keep(_ name: String) {let shot = XCTAttachment(screenshot: XCUIScreen.main.screenshot()) shot.name = name shot.lifetime = .keepAlways add(shot) } @MainActor privatefunc opened(_ extra: [String]) -> XCUIApplication {let app = XCUIApplication() app.launchArguments += ["-chat-warm-seed", "YES", "-chat-warm-open", asha] + extra app.launch() XCTAssertTrue(app.tables["chat-thread"].waitForExistence(timeout: 30), "the chat opened")// The card of a device asking to be let in can come down a few seconds in and move things: wait for it. _ = ShellCard.refuse(app).waitForExistence(timeout: 6)return app } @MainActor privatefunc bubble(_ id: String, in app: XCUIApplication) -> XCUIElement { app.descendants(matching: .any)["chat-bubble-\(id)"].firstMatch }/// Brings a bubble into view by pulling the chat down (to older messages) until it can be touched. @MainActor privatefunc reach(_ element: XCUIElement, in app: XCUIApplication) {for _ in0..<12where !(element.exists && element.isHittable) { app.tables["chat-thread"].swipeDown() } XCTAssertTrue(element.isHittable, "\(element) in reach") }/// Holds `id`, answers it with Reply, writes, sends: the reply's own bubble. @MainActor privatefunc reply(to id: String, in app: XCUIApplication, shots: String) -> XCUIElement {let theirs = bubble(id, in: app) XCTAssertTrue(theirs.waitForExistence(timeout: 10), "\(id) stands") reach(theirs, in: app) theirs.press(forDuration: 1.0)let answer = app.buttons["chat-act-reply"] XCTAssertTrue(answer.waitForExistence(timeout: 5), "Reply is offered") answer.tap()let strip = app.descendants(matching: .any)["chat-strip"].firstMatch XCTAssertTrue(strip.waitForExistence(timeout: 5), "the reply strip stands over the field")let field = app.textViews["chat-composer-text"] XCTAssertTrue(field.waitForExistence(timeout: 5)) field.typeText(written) XCTAssertTrue(strip.exists, "the strip stays while writing") keep("reply-\(shots)-writing") app.buttons["chat-composer-send"].tap()let sent = bubble("seed-sent-1", in: app) XCTAssertTrue(sent.waitForExistence(timeout: 10), "the reply landed") XCTAssertFalse(strip.exists, "the strip goes with the send")return sent } @MainActor privatefunc walk(_ extra: [String], _ shots: String) {let app = opened(extra)// A reply received: Asha's answer quotes the person's own question.let received = bubble("m-a5", in: app) XCTAssertTrue(received.waitForExistence(timeout: 10)) XCTAssertTrue(received.label.contains("Replying to You, Coffee on Saturday?"), "the received reply quotes it: \(received.label)")// The person's own reply to Asha's words quotes her, by name, inside the sent bubble.let sent = reply(to: "m-a8", in: app, shots: shots)let said = sent.label XCTAssertTrue(said.contains("Replying to Asha Verma, Keep the umbrella, it suits you"), "the sent reply quotes Asha: \(said)") XCTAssertTrue(said.contains(written), "and carries its own words: \(said)")iflet quote = said.range(of: "Replying to"), let words = said.range(of: written) { XCTAssertLessThan(quote.lowerBound, words.lowerBound, "the quote is read before the words: \(said)") }let box = app.descendants(matching: .any)["chat-composer"].firstMatch XCTAssertLessThanOrEqual(sent.frame.maxY, box.frame.minY + 1, "the sent reply stands above the writing box")Thread.sleep(forTimeInterval: 1) keep("reply-\(shots)-sent") }// RULE (owner, Comms build 23): a reply sent shows the quote of what it answers, and a reply received shows its own. @MainActor func testARepliesQuoteStandsInItsBubble() { walk([], "default") }// RULE: the same at the largest text. @MainActor func testARepliesQuoteStandsInItsBubbleAtTheLargestText() { walk(Self.largestText, "largest") }// RULE: the same at night (the phone's dark setting). @MainActor func testARepliesQuoteStandsInItsBubbleAtNight() { XCUIDevice.shared.appearance = .dark walk([], "dark") }// RULE: a tap on a reply's quote goes to the message it quotes, out of view above. @MainActor func testTappingAQuoteGoesToItsMessage() {// At the default size: the sent reply's quote stands in view under the header, Asha's first words far above.let app = opened([])let sent = reply(to: "m-a1", in: app, shots: "far") XCTAssertTrue(sent.label.contains("Replying to Asha Verma, Did you see the light this morning?"), sent.label)let first = bubble("m-a1", in: app)let table = app.tables["chat-thread"] XCTAssertFalse(first.exists && table.frame.intersects(first.frame) && first.isHittable, "Asha's first words are out of view after the send")// The quote is the top of the bubble: its first line, a few points in.let header = app.descendants(matching: .any)["chat-person"].firstMatch XCTAssertGreaterThan(sent.frame.minY, header.frame.maxY, "the sent reply's quote is in view") sent.coordinate(withNormalizedOffset: .zero).withOffset(CGVector(dx: sent.frame.width / 2, dy: 24)).tap()let there = XCTNSPredicateExpectation(predicate: NSPredicate(format: "exists == true AND hittable == true"), object: first) XCTAssertEqual(XCTWaiter().wait(for: [there], timeout: 8), .completed, "the chat stands on the quoted message")Thread.sleep(forTimeInterval: 1) keep("reply-far-tapped") }}