importFoundationimport XCTest@testable importCottonUI/// Walker 298: a single tap on a link message opened nothing — the bubble's/// tap answered only a message that had failed to send.finalclassLinkMessageTapOpensTests: XCTestCase {/// RULE: a single tap on a message that carries a link opens that link (one act, the tap does it); a failed message's tap still offers its answers first, and a plain message's tap does nothing, because a link a person taps and nothing happens reads as broken.func testTappingALinkMessageCallsTheOpenURLPath() throws {let bare = "look https://example.com/menu?day=1 tonight" XCTAssertEqual(ConversationTap.of(failed: false, body: bare), .open(URL(string: "https://example.com/menu?day=1")!)) XCTAssertEqual(ConversationTap.of(failed: false, body: "[the menu](https://example.com/m)"), .open(URL(string: "https://example.com/m")!)) XCTAssertEqual(ConversationTap.of(failed: false, body: "see you at 7"), .nothing) XCTAssertEqual(ConversationTap.of(failed: false, body: nil), .nothing) XCTAssertEqual(ConversationTap.of(failed: true, body: bare), .failure, "a failed message offers its answers first")// The bubble's tap goes through that decision to the open-URL path.let page = SourceSweep.withoutComments(trySourceSweep.mustRead("apps/cotton/Sources/CottonUI/Surfaces/PageStyles/ConversationPage.swift", ownedBy: "phonefixes")).filter { !$0.isWhitespace } XCTAssertTrue(page.contains("switchConversationTap.of(failed:mayActOnFailure(message),body:message[layout.body].text)")) XCTAssertTrue(page.contains("case.open(letlink):open(link)")) XCTAssertTrue(page.contains("RecordAddress.open(link,taps:pendingTaps,external:{openURL($0)})")) }}