|
| 1 | +import XCTest |
| 2 | + |
| 3 | +@MainActor |
| 4 | +final class OpenClawSnapshotUITests: XCTestCase { |
| 5 | +private struct ScreenshotTarget { |
| 6 | +let initialTab: String |
| 7 | +let initialDestination: String |
| 8 | +let name: String |
| 9 | +} |
| 10 | + |
| 11 | +private static let screenshotTargets = [ |
| 12 | +ScreenshotTarget(initialTab: "control", initialDestination: "overview", name: "01-control-connected"), |
| 13 | +ScreenshotTarget(initialTab: "chat", initialDestination: "chat", name: "02-chat-connected"), |
| 14 | +ScreenshotTarget(initialTab: "talk", initialDestination: "talk", name: "03-talk-connected"), |
| 15 | +ScreenshotTarget(initialTab: "agent", initialDestination: "agents", name: "04-agent-connected"), |
| 16 | +ScreenshotTarget(initialTab: "settings", initialDestination: "settings", name: "05-settings-connected"), |
| 17 | +] |
| 18 | + |
| 19 | +private var app: XCUIApplication? |
| 20 | + |
| 21 | +override func setUpWithError() throws { |
| 22 | +try super.setUpWithError() |
| 23 | +self.continueAfterFailure = false |
| 24 | +} |
| 25 | + |
| 26 | +override func tearDownWithError() throws { |
| 27 | +self.app?.terminate() |
| 28 | +self.app = nil |
| 29 | +try super.tearDownWithError() |
| 30 | +} |
| 31 | + |
| 32 | +func testConnectedGatewayTabs() { |
| 33 | +for target in Self.screenshotTargets { |
| 34 | +self.launchApp(for: target) |
| 35 | +snapshot(target.name, timeWaitingForIdle: 5) |
| 36 | +} |
| 37 | +} |
| 38 | + |
| 39 | +private func launchApp(for target: ScreenshotTarget) { |
| 40 | +self.app?.terminate() |
| 41 | + |
| 42 | +let app = XCUIApplication() |
| 43 | +setupSnapshot(app, waitForAnimations: false) |
| 44 | + app.launchArguments += [ |
| 45 | +"--openclaw-screenshot-mode", |
| 46 | +"--openclaw-initial-tab", |
| 47 | + target.initialTab, |
| 48 | +"--openclaw-initial-destination", |
| 49 | + target.initialDestination, |
| 50 | +"--openclaw-sidebar-visibility", |
| 51 | +"hidden", |
| 52 | +] |
| 53 | + app.launch() |
| 54 | +self.app = app |
| 55 | + |
| 56 | +XCTAssertTrue(app.wait(for: .runningForeground, timeout: 8)) |
| 57 | +} |
| 58 | +} |