| 1 | import XCTest |
| 2 | import SwiftUI |
| 3 | @testable import LChatCore |
| 4 | |
| 5 | // đŸ¤– The typing bubble must be EXACTLY one message line tall at every text |
| 6 | // size (Paul's spec). Measured against a REAL MessageBubble, not a |
| 7 | // reconstruction, so bubble-padding changes can't silently diverge the two. |
| 8 | final class SizeProbeTests: XCTestCase { |
| 9 | @MainActor |
| 10 | func testTypingBubbleMatchesOneLineBubbleAtEverySize() { |
| 11 | let msg = ChatFeedModel.Message(id: 1, name: "James", text: "hello", |
| 12 | mine: false, at: 1_700_000_000, edited: false) |
| 13 | for size: CGFloat in [11, 13, 15, 17, 20] { |
| 14 | let typing = ImageRenderer(content: |
| 15 | TypingBubble(theme: .named("classic")).environment(\.chatFontSize, size)) |
| 16 | let bubble = ImageRenderer(content: |
| 17 | MessageBubble(message: msg, showSender: false, theme: .named("classic")) |
| 18 | .environment(\.chatFontSize, size)) |
| 19 | let t = typing.nsImage?.size.height ?? 0 |
| 20 | let b = bubble.nsImage?.size.height ?? 0 |
| 21 | print("PROBE size \(size): typing \(t) bubble \(b)") |
| 22 | XCTAssertEqual(t, b, accuracy: 1.0, |
| 23 | "typing bubble \(t) vs real one-line bubble \(b) at size \(size)") |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 | |