import AppKit import ConjureKit import Testing @testable import Conjure @Test @MainActor func actionsBackgroundKeepsWindowCoordinates() throws { _ = NSApplication.shared let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 750, height: 480), styleMask: [.borderless], backing: .buffered, defer: false) let host = try #require(window.contentView) let anchor = NSView(frame: NSRect(x: 700, y: 20, width: 30, height: 30)) host.addSubview(anchor) let actions = ApplicationActionsController() defer { actions.close(animated: false) } func descendants(_ view: NSView) -> [NSView] { [view] + view.subviews.flatMap(descendants) } for width in [750.0, 900.0] { window.setContentSize(NSSize(width: width, height: 480)) actions.showEmoji(named: "Smile", relativeTo: anchor) let background = try #require(descendants(host).compactMap { $0 as? LauncherBackground }.first) let search = try #require(descendants(actions.view).compactMap { $0 as? NSSearchField }.first) for query in ["", "Copy Emoji", "no matching action"] { search.stringValue = query actions.controlTextDidChange(Notification(name: NSControl.textDidChangeNotification, object: search)) host.layoutSubtreeIfNeeded() let rect = background.convert(background.bounds, to: host) #expect(rect == host.bounds) #expect(background.bounds.size != actions.view.bounds.size) } actions.close(animated: false) } }