Files
openclaw/apps/shared/OpenClawKit/Tests/OpenClawKitTests/DashboardRouteMapTests.swift
Peter Steinberger 76cb418b6f fix(macos): reopen AI choice, fix daemon error text, hand onboarding off to the dashboard custodian (#117921)
* fix(macos): let onboarding replace an auto-connected AI

The AI page auto-tests the best detected candidate and connects without
asking, then hides every alternative route. Add 'Choose a different AI'
to the connected banner: a re-detect pass with auto-activation
suppressed that ends at the picker (candidates, provider sign-in, API
keys). Also disable the manual key Connect button while another test
runs (submitManualKey silently dropped the tap), and isolate a test
that read the machine's real resume store.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(macos): surface real daemon errors past the Node banner

Gateway daemon failures summarized as 'Node.js v26.5.1' because the
summary takes the last non-empty line and Node fatal errors end with a
version banner. Drop trailing banner lines and prefer the last
error-shaped line above them; all other output keeps its last line.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(macos): hand onboarding off to the dashboard custodian

Native onboarding now ends once inference verifies: welcome, connection,
install (when needed), AI setup. Finish opens the dashboard at
/custodian?onboarding=1, where the custodian onboarding owns memory
import, channels, app recommendations, and the hatch (browser-first per
the onboarding redesign). The native memory-import and permissions
pages leave the first-run flow; 'Set up later' keeps the native ready
page. The native navigation bridge gains a validated optional search
field so the handoff can request onboarding chrome; the URL fallback
carries the query alongside the token fragment.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor(macos): delete the unreachable native memory-import module

The dashboard handoff removed the memory-import page from every flow,
leaving the module reachable only from tests. CI's dead-code scan
rightly flagged the first orphans; remove the whole path (model, page,
mascot wiring, tests) instead of trimming symbol by symbol. The
dashboard's own memory-import surface owns the feature.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Peter Steinberger <steipete@mac-studio-sf2.local>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-02 02:57:25 -07:00

63 lines
2.7 KiB
Swift

import Foundation
import OpenClawKit
import Testing
struct DashboardRouteMapTests {
@Test func `route constants match Control UI paths`() {
#expect(DashboardRouteMap.channelsSettingsPath == "/settings/channels")
#expect(DashboardRouteMap.skillsPagePath == "/skills")
#expect(DashboardRouteMap.cronJobsPagePath == "/cron")
#expect(DashboardRouteMap.sessionsPagePath == "/sessions")
#expect(DashboardRouteMap.devicesSettingsPath == "/settings/devices")
}
@Test(arguments: ["/settings/channels", "/skills", "/cron"])
func `same-app path validation accepts rooted paths`(_ path: String) {
#expect(DashboardRouteMap.isValidSameAppPath(path))
}
@Test(arguments: [
"",
"settings/channels",
"//example.com/settings/channels",
"https://example.com/settings/channels",
"/settings/channels?section=telegram",
"/settings/channels#telegram",
])
func `same-app path validation rejects external or compound locations`(_ path: String) {
#expect(!DashboardRouteMap.isValidSameAppPath(path))
}
@Test func `Dashboard URL appends route and preserves token fragment`() throws {
let baseURL = try #require(URL(string: "http://127.0.0.1:18789/control/#token=test-token"))
let url = try #require(DashboardRouteMap.dashboardURL(
byAppendingSameAppPath: DashboardRouteMap.channelsSettingsPath,
to: baseURL))
#expect(url.absoluteString == "http://127.0.0.1:18789/control/settings/channels#token=test-token")
}
@Test func `Dashboard URL carries a same-app search alongside the token fragment`() throws {
let baseURL = try #require(URL(string: "http://127.0.0.1:18789/control/#token=test-token"))
let url = try #require(DashboardRouteMap.dashboardURL(
byAppendingSameAppPath: DashboardRouteMap.custodianPagePath,
search: DashboardRouteMap.custodianOnboardingSearch,
to: baseURL))
#expect(url.absoluteString == "http://127.0.0.1:18789/control/custodian?onboarding=1#token=test-token")
}
@Test(arguments: ["", "onboarding=1", "?onboarding=1#x", "?a=b#frag"])
func `same-app search validation rejects non-query input`(_ search: String) throws {
#expect(!DashboardRouteMap.isValidSameAppSearch(search))
#expect(try DashboardRouteMap.dashboardURL(
byAppendingSameAppPath: DashboardRouteMap.custodianPagePath,
search: search,
to: #require(URL(string: "http://127.0.0.1:18789/control/"))) == nil)
}
@Test func `same-app search validation accepts a plain query`() {
#expect(DashboardRouteMap.isValidSameAppSearch("?onboarding=1"))
}
}