// What the owner saw on Comms build 19 (22 Nov 2026): every picture he had// just sent, a grid of five and a single one, said "Picture not available"// while "Sending…" stood under it, and the grid's "+1" sat over those words.// Chat Dev's invented chats (-chat-warm-seed YES) send five pictures and then// one as the composer does (-chat-warm-send-picture <seconds>, the upload// over a slow line): each tile stands at once from the phone's own file, no// state shows for the core's quiet moment, "Sending" only once a send is slow,// and nothing once it has gone.import XCTestfinalclassChatWarmSendTests: XCTestCase {privatelet asha = "11111111-1111-4111-8111-0000000000a1"privatefunc launched(slow seconds: String) -> (XCUIApplication, (String) -> XCUIElement) {let app = XCUIApplication() app.launchArguments += ["-chat-warm-seed", "YES", "-chat-warm-open", asha, "-chat-warm-send-picture", seconds] app.launch() XCTAssertTrue(app.tables["chat-thread"].waitForExistence(timeout: 30), "the chat opened")let bubble = { (id: String) in app.descendants(matching: .any)["chat-bubble-\(id)"].firstMatch }return (app, bubble) }privatefunc keep(_ name: String) {let shot = XCTAttachment(screenshot: XCUIScreen.main.screenshot()) shot.name = name shot.lifetime = .keepAlways add(shot) }/// The colour at the middle of `frame` on the screen now.privatefunc ink(_ frame: CGRect) -> [Int] {let image = XCUIScreen.main.screenshot().imagelet cg = image.cgImage!let scale = CGFloat(cg.width) / image.size.widthvar bytes = [UInt8](repeating: 0, count: cg.width * cg.height * 4)let context = CGContext(data: &bytes, width: cg.width, height: cg.height, bitsPerComponent: 8, bytesPerRow: cg.width * 4, space: CGColorSpaceCreateDeviceRGB(), bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue)! context.draw(cg, in: CGRect(x: 0, y: 0, width: cg.width, height: cg.height))let x = min(cg.width - 1, Int(frame.midX * scale)), y = min(cg.height - 1, Int(frame.midY * scale))let i = (y * cg.width + x) * 4return [Int(bytes[i]), Int(bytes[i + 1]), Int(bytes[i + 2])] }privatefunc waits(_ element: XCUIElement, label holds: Bool, _ words: String, _ timeout: TimeInterval) -> Bool {let said = NSPredicate(format: holds ? "label CONTAINS %@" : "NOT (label CONTAINS %@)", words)return XCTWaiter().wait(for: [XCTNSPredicateExpectation(predicate: said, object: element)], timeout: timeout) == .completed }// RULE: pictures just sent stand at once from the phone's own file, every tile of a grid and a single one, and are// never "Picture not available" while they go; a slow send says "Sending" once the quiet moment has passed, and// nothing once it has gone.func testPicturesJustSentStandAtOnceAndNeverSayGone() {let (_, bubble) = launched(slow: "8")let grid = bubble("seed-sent-1"), single = bubble("seed-sent-2") XCTAssertTrue(single.waitForExistence(timeout: 10), "the single picture stands") XCTAssertTrue(grid.exists, "the grid of five stands")for sent in [grid, single] { XCTAssertFalse(sent.label.contains("Picture not available"), "never gone while it goes: \(sent.label)") }// The invented pictures are cool blue-green; the tile's own ground is warm.let drawn = ink(single.frame) XCTAssertGreaterThan(drawn[1], drawn[0] + 10, "the single tile shows the phone's own picture: \(drawn)") keep("fb-picture-sent-at-once") XCTAssertTrue(waits(single, label: true, "Sending", 6), "a slow send says Sending after its quiet moment: \(single.label)") XCTAssertFalse(single.label.contains("Picture not available"), single.label) XCTAssertFalse(grid.label.contains("Picture not available"), grid.label) keep("fb-picture-grid-sending") keep("fb-send-slow-sending") XCTAssertTrue(waits(single, label: false, "Sending", 12), "sent: nothing under it: \(single.label)") XCTAssertFalse(single.label.contains("Picture not available"), single.label) keep("fb-send-sent") }// RULE: a send that goes within the core's quiet moment never shows "Sending" at all.func testAFastSendNeverFlashesSending() {let (_, bubble) = launched(slow: "0.5")let single = bubble("seed-sent-2") XCTAssertTrue(single.waitForExistence(timeout: 10), "the picture stands")let end = Date().addingTimeInterval(4)whileDate() < end { XCTAssertFalse(single.label.contains("Sending"), "no Sending on a fast send: \(single.label)") XCTAssertFalse(single.label.contains("Picture not available"), single.label)Thread.sleep(forTimeInterval: 0.25) } keep("fb-send-fast") }}