2026-02-21 23:52:38 +01:00
|
|
|
import Foundation
|
2026-01-30 03:15:10 +01:00
|
|
|
import OpenClawDiscovery
|
2025-12-14 04:30:45 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
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 OnboardingViewSmokeTests {
|
|
|
|
|
@Test func onboardingViewBuildsBody() {
|
|
|
|
|
let state = AppState(preview: true)
|
|
|
|
|
let view = OnboardingView(
|
|
|
|
|
state: state,
|
|
|
|
|
permissionMonitor: PermissionMonitor.shared,
|
2026-01-10 23:39:14 +01:00
|
|
|
discoveryModel: GatewayDiscoveryModel(localDisplayName: InstanceIdentity.displayName))
|
2025-12-14 04:30:45 +00:00
|
|
|
_ = view.body
|
|
|
|
|
}
|
2025-12-20 15:20:31 +00:00
|
|
|
|
2025-12-20 15:48:49 +00:00
|
|
|
@Test func pageOrderOmitsWorkspaceAndIdentitySteps() {
|
2026-01-16 07:58:30 +00:00
|
|
|
let order = OnboardingView.pageOrder(for: .local, showOnboardingChat: false)
|
2025-12-20 15:20:31 +00:00
|
|
|
#expect(!order.contains(7))
|
2026-01-03 16:04:19 +01:00
|
|
|
#expect(order.contains(3))
|
2025-12-20 15:20:31 +00:00
|
|
|
}
|
2025-12-20 16:51:33 +00:00
|
|
|
|
|
|
|
|
@Test func pageOrderOmitsOnboardingChatWhenIdentityKnown() {
|
2026-01-16 07:58:30 +00:00
|
|
|
let order = OnboardingView.pageOrder(for: .local, showOnboardingChat: false)
|
2025-12-20 16:51:33 +00:00
|
|
|
#expect(!order.contains(8))
|
|
|
|
|
}
|
2026-02-21 23:52:38 +01:00
|
|
|
|
|
|
|
|
@Test func selectRemoteGatewayClearsStaleSshTargetWhenEndpointUnresolved() async {
|
|
|
|
|
let override = FileManager().temporaryDirectory
|
|
|
|
|
.appendingPathComponent("openclaw-config-\(UUID().uuidString)")
|
|
|
|
|
.appendingPathComponent("openclaw.json")
|
|
|
|
|
.path
|
|
|
|
|
|
|
|
|
|
await TestIsolation.withEnvValues(["OPENCLAW_CONFIG_PATH": override]) {
|
|
|
|
|
let state = AppState(preview: true)
|
|
|
|
|
state.remoteTransport = .ssh
|
|
|
|
|
state.remoteTarget = "user@old-host:2222"
|
|
|
|
|
let view = OnboardingView(
|
|
|
|
|
state: state,
|
|
|
|
|
permissionMonitor: PermissionMonitor.shared,
|
|
|
|
|
discoveryModel: GatewayDiscoveryModel(localDisplayName: InstanceIdentity.displayName))
|
|
|
|
|
let gateway = GatewayDiscoveryModel.DiscoveredGateway(
|
|
|
|
|
displayName: "Unresolved",
|
|
|
|
|
serviceHost: nil,
|
|
|
|
|
servicePort: nil,
|
|
|
|
|
lanHost: "txt-host.local",
|
|
|
|
|
tailnetDns: "txt-host.ts.net",
|
|
|
|
|
sshPort: 22,
|
|
|
|
|
gatewayPort: 18789,
|
|
|
|
|
cliPath: "/tmp/openclaw",
|
|
|
|
|
stableID: UUID().uuidString,
|
|
|
|
|
debugID: UUID().uuidString,
|
|
|
|
|
isLocal: false)
|
|
|
|
|
|
|
|
|
|
view.selectRemoteGateway(gateway)
|
|
|
|
|
#expect(state.remoteTarget.isEmpty)
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-12-14 04:30:45 +00:00
|
|
|
}
|