fix: match Notes footer to shared window insets

This commit is contained in:
Valdemar Lorenzen
2026-10-21 12:46:04 +02:00
parent a3afbdc286
commit b5a0edd5bf
4 changed files with 37 additions and 2 deletions
@@ -3,6 +3,33 @@ import ConjureKit
import Testing
@testable import Conjure
@Test @MainActor
func notesActionPillKeepsWindowInsetsWhenResized() throws {
_ = NSApplication.shared
let directory = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
let suite = "NotesLayout.\(UUID().uuidString)"
let defaults = try #require(UserDefaults(suiteName: suite))
defer {
try? FileManager.default.removeItem(at: directory)
defaults.removePersistentDomain(forName: suite)
}
let controller = NotesController(defaults: defaults, directory: directory)
let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 750, height: 390),
styleMask: [.borderless], backing: .buffered, defer: false)
window.contentViewController = controller
defer { _ = controller.close(); window.orderOut(nil) }
func descendants(_ view: NSView) -> [NSView] { [view] + view.subviews.flatMap(descendants) }
let pill = try #require(descendants(controller.view).first { $0 is ActionPill })
for size in [NSSize(width: 750, height: 390), NSSize(width: 570, height: 260)] {
window.setContentSize(size)
controller.view.layoutSubtreeIfNeeded()
let frame = pill.convert(pill.bounds, to: controller.view)
#expect(abs(frame.minY - controller.view.bounds.minY - 8) < 0.5)
#expect(abs(controller.view.bounds.maxX - frame.maxX - 8) < 0.5)
#expect(abs(frame.height - 36) < 0.5)
}
}
@Test @MainActor
func notesSwitchWithoutLeakingEditsUndoOrAttachmentsAndRestoreSelection() throws {
_ = NSApplication.shared