| 1 | import Foundation |
| 2 | import Testing |
| 3 | @testable import EquipoKit |
| 4 | #if os(macOS) |
| 5 | import AppKit |
| 6 | @testable import EquipoMac |
| 7 | #endif |
| 8 | |
| 9 | struct ComposerPolishTests { |
| 10 | // This suite follows the existing source-contract tests; there is no |
| 11 | // ViewInspector dependency. The simulator also exercises a real drag. |
| 12 | @Test(arguments: ["ConversationScreen.swift", "TaskDetailScreen.swift", "NeedsScreen.swift"]) |
| 13 | func scrollsContainingReplyFieldsDismissInteractively(_ file: String) throws { |
| 14 | let sources = URL(fileURLWithPath: #filePath).deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent().appendingPathComponent("Sources/EquipoKit/UI/Screens") |
| 15 | let source = try String(contentsOf: sources.appendingPathComponent(file), encoding: .utf8) |
| 16 | #expect(source.contains(".scrollDismissesKeyboard(.interactively)")) |
| 17 | } |
| 18 | |
| 19 | #if os(macOS) |
| 20 | @MainActor @Test func attachmentButtonIsOutsideFieldWithFullTarget() throws { |
| 21 | let composer = MacComposer() |
| 22 | composer.attach(AttachmentDraft(client: EquipoClient(transport: AttachmentServer(), token: "fixture"))) |
| 23 | composer.frame = NSRect(x: 0, y: 0, width: 600, height: 80) |
| 24 | composer.layoutSubtreeIfNeeded() |
| 25 | let button = try #require(composer.subviews.compactMap { $0 as? NSButton }.first { $0.accessibilityLabel() == EquipoStrings.text("chat.attach.add") }) |
| 26 | #expect(button.frame.width >= 44) |
| 27 | #expect(button.frame.height >= 44) |
| 28 | #expect(button.frame.maxX < composer.pill.frame.minX) |
| 29 | #expect(composer.send.frame.width >= 44) |
| 30 | #expect(composer.send.frame.height >= 44) |
| 31 | } |
| 32 | @MainActor @Test func macPanelAcceptsMultipleFilesOnly() { |
| 33 | let panel = MacComposer.makeAttachmentPanel() |
| 34 | #expect(panel.canChooseFiles) |
| 35 | #expect(!panel.canChooseDirectories) |
| 36 | #expect(panel.allowsMultipleSelection) |
| 37 | } |
| 38 | #endif |
| 39 | } |
| 40 | |