Merge pull request #1180 from manaflow-ai/task-fix-drag-config-tests

Fix drag configuration test compatibility on macOS 15
This commit is contained in:
Lawrence Chen 2026-03-10 22:31:03 -07:00 committed by GitHub
commit 0cdeb451e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9511,6 +9511,41 @@ final class CmuxWebViewDragRoutingTests: XCTestCase {
}
#if compiler(>=6.2)
@available(macOS 26.0, *)
private struct DragConfigurationOperationsSnapshot: Equatable {
let allowCopy: Bool
let allowMove: Bool
let allowDelete: Bool
let allowAlias: Bool
}
@available(macOS 26.0, *)
private enum DragConfigurationSnapshotError: Error {
case missingBoolField(primary: String, fallback: String?)
}
@available(macOS 26.0, *)
private func dragConfigurationOperationsSnapshot<T>(from operations: T) throws -> DragConfigurationOperationsSnapshot {
let mirror = Mirror(reflecting: operations)
func readBool(_ primary: String, fallback: String? = nil) throws -> Bool {
if let value = mirror.descendant(primary) as? Bool {
return value
}
if let fallback, let value = mirror.descendant(fallback) as? Bool {
return value
}
throw DragConfigurationSnapshotError.missingBoolField(primary: primary, fallback: fallback)
}
return try DragConfigurationOperationsSnapshot(
allowCopy: readBool("allowCopy", fallback: "_allowCopy"),
allowMove: readBool("allowMove", fallback: "_allowMove"),
allowDelete: readBool("allowDelete", fallback: "_allowDelete"),
allowAlias: readBool("allowAlias", fallback: "_allowAlias")
)
}
@MainActor
final class InternalTabDragConfigurationTests: XCTestCase {
func testDisablesExternalOperationsForInternalTabDrags() throws {
@ -9519,16 +9554,28 @@ final class InternalTabDragConfigurationTests: XCTestCase {
}
let configuration = InternalTabDragConfigurationProvider.value
let withinApp = try dragConfigurationOperationsSnapshot(from: configuration.operationsWithinApp)
let outsideApp = try dragConfigurationOperationsSnapshot(from: configuration.operationsOutsideApp)
XCTAssertFalse(configuration.operationsWithinApp.allowCopy)
XCTAssertTrue(configuration.operationsWithinApp.allowMove)
XCTAssertFalse(configuration.operationsWithinApp.allowDelete)
XCTAssertFalse(configuration.operationsWithinApp.allowAlias)
XCTAssertEqual(
withinApp,
DragConfigurationOperationsSnapshot(
allowCopy: false,
allowMove: true,
allowDelete: false,
allowAlias: false
)
)
XCTAssertFalse(configuration.operationsOutsideApp.allowCopy)
XCTAssertFalse(configuration.operationsOutsideApp.allowMove)
XCTAssertFalse(configuration.operationsOutsideApp.allowDelete)
XCTAssertFalse(configuration.operationsOutsideApp.allowAlias)
XCTAssertEqual(
outsideApp,
DragConfigurationOperationsSnapshot(
allowCopy: false,
allowMove: false,
allowDelete: false,
allowAlias: false
)
)
}
}
#endif