Files
openclaw/apps/macos/Sources/OpenClaw/OnboardingView+Testing.swift

88 lines
3.0 KiB
Swift
Raw Normal View History

2026-01-30 03:15:10 +01:00
import OpenClawDiscovery
2025-12-24 19:29:27 +01:00
import SwiftUI
#if DEBUG
@MainActor
extension OnboardingView {
static func exerciseForTesting() {
let state = AppState(preview: true)
let discovery = GatewayDiscoveryModel(localDisplayName: InstanceIdentity.displayName)
2025-12-24 19:29:27 +01:00
discovery.statusText = "Searching..."
let gateway = GatewayDiscoveryModel.DiscoveredGateway(
2026-01-19 04:50:07 +00:00
displayName: "Test Gateway",
lanHost: "gateway.local",
tailnetDns: "gateway.ts.net",
2025-12-24 19:29:27 +01:00
sshPort: 2222,
gatewayPort: 18789,
2026-01-30 03:15:10 +01:00
cliPath: "/usr/local/bin/openclaw",
2026-01-19 04:50:07 +00:00
stableID: "gateway-1",
debugID: "gateway-1",
2025-12-24 19:29:27 +01:00
isLocal: false)
discovery.gateways = [gateway]
2025-12-25 03:23:31 +01:00
let view = OnboardingView(
2025-12-24 19:29:27 +01:00
state: state,
permissionMonitor: PermissionMonitor.shared,
discoveryModel: discovery)
view.needsBootstrap = true
view.localGatewayProbe = LocalGatewayProbe(
port: GatewayEnvironment.gatewayPort(),
2025-12-24 19:29:27 +01:00
pid: 123,
2026-01-30 03:15:10 +01:00
command: "openclaw-gateway",
2025-12-24 19:29:27 +01:00
expected: true)
view.showAdvancedConnection = true
view.preferredGatewayID = gateway.stableID
view.cliInstalled = true
2026-01-30 03:15:10 +01:00
view.cliInstallLocation = "/usr/local/bin/openclaw"
2025-12-24 19:29:27 +01:00
view.cliStatus = "Installed"
2026-01-30 03:15:10 +01:00
view.workspacePath = "/tmp/openclaw"
2025-12-24 19:29:27 +01:00
view.workspaceStatus = "Saved workspace"
view.anthropicAuthPKCE = AnthropicOAuth.PKCE(verifier: "verifier", challenge: "challenge")
view.anthropicAuthCode = "code#state"
view.anthropicAuthStatus = "Connected"
view.anthropicAuthDetectedStatus = .connected(expiresAtMs: 1_700_000_000_000)
view.anthropicAuthConnected = true
view.anthropicAuthAutoDetectClipboard = false
view.anthropicAuthAutoConnectClipboard = false
view.state.connectionMode = .local
_ = view.welcomePage()
_ = view.connectionPage()
_ = view.anthropicAuthPage()
2026-01-03 16:04:19 +01:00
_ = view.wizardPage()
2025-12-24 19:29:27 +01:00
_ = view.permissionsPage()
_ = view.cliPage()
_ = view.workspacePage()
_ = view.onboardingChatPage()
_ = view.readyPage()
view.selectLocalGateway()
view.selectRemoteGateway(gateway)
view.selectUnconfiguredGateway()
view.state.connectionMode = .remote
_ = view.connectionPage()
_ = view.workspacePage()
view.state.connectionMode = .unconfigured
_ = view.connectionPage()
view.currentPage = 0
view.handleNext()
view.handleBack()
_ = view.onboardingPage { Text("Test") }
_ = view.onboardingCard { Text("Card") }
_ = view.featureRow(title: "Feature", subtitle: "Subtitle", systemImage: "sparkles")
_ = view.featureActionRow(
title: "Action",
subtitle: "Action subtitle",
systemImage: "gearshape",
2026-01-19 00:19:42 +00:00
buttonTitle: "Action",
2025-12-24 19:29:27 +01:00
action: {})
_ = view.gatewaySubtitle(for: gateway)
_ = view.isSelectedGateway(gateway)
}
}
#endif