2025-12-14 04:30:45 +00:00
|
|
|
|
import AppKit
|
2026-01-30 03:15:10 +01:00
|
|
|
|
import OpenClawIPC
|
2025-12-14 04:30:45 +00:00
|
|
|
|
import Foundation
|
|
|
|
|
|
import Testing
|
2026-01-30 03:15:10 +01:00
|
|
|
|
@testable import OpenClaw
|
2025-12-14 04:30:45 +00:00
|
|
|
|
|
|
|
|
|
|
@Suite(.serialized)
|
|
|
|
|
|
@MainActor
|
|
|
|
|
|
struct CanvasWindowSmokeTests {
|
|
|
|
|
|
@Test func panelControllerShowsAndHides() async throws {
|
2026-01-18 20:00:26 +01:00
|
|
|
|
let root = FileManager().temporaryDirectory
|
2026-01-30 03:15:10 +01:00
|
|
|
|
.appendingPathComponent("openclaw-canvas-test-\(UUID().uuidString)")
|
2026-01-18 20:00:26 +01:00
|
|
|
|
try FileManager().createDirectory(at: root, withIntermediateDirectories: true)
|
|
|
|
|
|
defer { try? FileManager().removeItem(at: root) }
|
2025-12-14 04:30:45 +00:00
|
|
|
|
|
|
|
|
|
|
let anchor = { NSRect(x: 200, y: 400, width: 40, height: 40) }
|
|
|
|
|
|
let controller = try CanvasWindowController(
|
|
|
|
|
|
sessionKey: " main/invalid⚡️ ",
|
|
|
|
|
|
root: root,
|
|
|
|
|
|
presentation: .panel(anchorProvider: anchor))
|
|
|
|
|
|
|
|
|
|
|
|
#expect(controller.directoryPath.contains("main_invalid__") == true)
|
|
|
|
|
|
|
|
|
|
|
|
controller.applyPreferredPlacement(CanvasPlacement(x: 120, y: 200, width: 520, height: 680))
|
|
|
|
|
|
controller.showCanvas(path: "/")
|
2025-12-17 19:14:54 +00:00
|
|
|
|
_ = try await controller.eval(javaScript: "1 + 1")
|
2025-12-14 04:30:45 +00:00
|
|
|
|
controller.windowDidMove(Notification(name: NSWindow.didMoveNotification))
|
|
|
|
|
|
controller.windowDidEndLiveResize(Notification(name: NSWindow.didEndLiveResizeNotification))
|
|
|
|
|
|
controller.hideCanvas()
|
|
|
|
|
|
controller.close()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test func windowControllerShowsAndCloses() async throws {
|
2026-01-18 20:00:26 +01:00
|
|
|
|
let root = FileManager().temporaryDirectory
|
2026-01-30 03:15:10 +01:00
|
|
|
|
.appendingPathComponent("openclaw-canvas-test-\(UUID().uuidString)")
|
2026-01-18 20:00:26 +01:00
|
|
|
|
try FileManager().createDirectory(at: root, withIntermediateDirectories: true)
|
|
|
|
|
|
defer { try? FileManager().removeItem(at: root) }
|
2025-12-14 04:30:45 +00:00
|
|
|
|
|
|
|
|
|
|
let controller = try CanvasWindowController(
|
|
|
|
|
|
sessionKey: "main",
|
|
|
|
|
|
root: root,
|
|
|
|
|
|
presentation: .window)
|
|
|
|
|
|
|
|
|
|
|
|
controller.showCanvas(path: "/")
|
|
|
|
|
|
controller.windowWillClose(Notification(name: NSWindow.willCloseNotification))
|
|
|
|
|
|
controller.hideCanvas()
|
|
|
|
|
|
controller.close()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|