fix: match Notes footer to shared window insets
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user