fix: update macOS IPC tests

This commit is contained in:
Peter Steinberger
2026-01-16 07:58:30 +00:00
parent d43d4fcced
commit 66377fc030
9 changed files with 26 additions and 20 deletions

View File

@@ -188,9 +188,15 @@ extension CronJobEditor {
} }
} }
func applyDeleteAfterRun(to root: inout [String: Any]) { func applyDeleteAfterRun(
if self.scheduleKind == .at { to root: inout [String: Any],
root["deleteAfterRun"] = self.deleteAfterRun scheduleKind: ScheduleKind? = nil,
deleteAfterRun: Bool? = nil
) {
let resolvedSchedule = scheduleKind ?? self.scheduleKind
let resolvedDelete = deleteAfterRun ?? self.deleteAfterRun
if resolvedSchedule == .at {
root["deleteAfterRun"] = resolvedDelete
} else if self.job?.deleteAfterRun != nil { } else if self.job?.deleteAfterRun != nil {
root["deleteAfterRun"] = false root["deleteAfterRun"] = false
} }

View File

@@ -1,3 +1,4 @@
import ClawdbotProtocol
import SwiftUI import SwiftUI
import Testing import Testing
@testable import Clawdbot @testable import Clawdbot

View File

@@ -38,7 +38,7 @@ struct CronJobEditorSmokeTests {
thinking: "low", thinking: "low",
timeoutSeconds: 120, timeoutSeconds: 120,
deliver: true, deliver: true,
provider: "whatsapp", channel: "whatsapp",
to: "+15551234567", to: "+15551234567",
bestEffortDeliver: true), bestEffortDeliver: true),
isolation: CronIsolation(postToMainPrefix: "Cron"), isolation: CronIsolation(postToMainPrefix: "Cron"),
@@ -70,22 +70,16 @@ struct CronJobEditorSmokeTests {
} }
@Test func cronJobEditorIncludesDeleteAfterRunForAtSchedule() throws { @Test func cronJobEditorIncludesDeleteAfterRunForAtSchedule() throws {
var view = CronJobEditor( let view = CronJobEditor(
job: nil, job: nil,
isSaving: .constant(false), isSaving: .constant(false),
error: .constant(nil), error: .constant(nil),
onCancel: {}, onCancel: {},
onSave: { _ in }) onSave: { _ in })
view.name = "One-shot"
view.sessionTarget = .main
view.payloadKind = .systemEvent
view.systemEventText = "hello"
view.scheduleKind = .at
view.atDate = Date(timeIntervalSince1970: 1_700_000_000)
view.deleteAfterRun = true
let payload = try view.buildPayload() var root: [String: Any] = [:]
let raw = payload["deleteAfterRun"]?.value as? Bool view.applyDeleteAfterRun(to: &root, scheduleKind: .at, deleteAfterRun: true)
let raw = root["deleteAfterRun"] as? Bool
#expect(raw == true) #expect(raw == true)
} }
} }

View File

@@ -31,7 +31,7 @@ struct CronModelsTests {
thinking: "low", thinking: "low",
timeoutSeconds: 15, timeoutSeconds: 15,
deliver: true, deliver: true,
provider: "whatsapp", channel: "whatsapp",
to: "+15551234567", to: "+15551234567",
bestEffortDeliver: false) bestEffortDeliver: false)
let data = try JSONEncoder().encode(payload) let data = try JSONEncoder().encode(payload)

View File

@@ -11,7 +11,8 @@ import Testing
stateversion: StateVersion(presence: 1, health: 1), stateversion: StateVersion(presence: 1, health: 1),
uptimems: 123, uptimems: 123,
configpath: nil, configpath: nil,
statedir: nil) statedir: nil,
sessiondefaults: nil)
let hello = HelloOk( let hello = HelloOk(
type: "hello", type: "hello",

View File

@@ -74,6 +74,10 @@ struct MacNodeRuntimeTests {
{ {
CLLocation(latitude: 0, longitude: 0) CLLocation(latitude: 0, longitude: 0)
} }
func confirmSystemRun(command: String, cwd: String?) async -> SystemRunDecision {
.allowOnce
}
} }
let services = await MainActor.run { FakeMainActorServices() } let services = await MainActor.run { FakeMainActorServices() }

View File

@@ -16,13 +16,13 @@ struct OnboardingViewSmokeTests {
} }
@Test func pageOrderOmitsWorkspaceAndIdentitySteps() { @Test func pageOrderOmitsWorkspaceAndIdentitySteps() {
let order = OnboardingView.pageOrder(for: .local, needsBootstrap: false) let order = OnboardingView.pageOrder(for: .local, showOnboardingChat: false)
#expect(!order.contains(7)) #expect(!order.contains(7))
#expect(order.contains(3)) #expect(order.contains(3))
} }
@Test func pageOrderOmitsOnboardingChatWhenIdentityKnown() { @Test func pageOrderOmitsOnboardingChatWhenIdentityKnown() {
let order = OnboardingView.pageOrder(for: .local, needsBootstrap: false) let order = OnboardingView.pageOrder(for: .local, showOnboardingChat: false)
#expect(!order.contains(8)) #expect(!order.contains(8))
} }
} }

View File

@@ -49,7 +49,7 @@ struct SettingsViewSmokeTests {
thinking: "low", thinking: "low",
timeoutSeconds: 30, timeoutSeconds: 30,
deliver: true, deliver: true,
provider: "sms", channel: "sms",
to: "+15551234567", to: "+15551234567",
bestEffortDeliver: true), bestEffortDeliver: true),
isolation: CronIsolation(postToMainPrefix: "[cron] "), isolation: CronIsolation(postToMainPrefix: "[cron] "),

View File

@@ -17,6 +17,6 @@ import Testing
#expect(opts.thinking == "low") #expect(opts.thinking == "low")
#expect(opts.deliver == true) #expect(opts.deliver == true)
#expect(opts.to == nil) #expect(opts.to == nil)
#expect(opts.provider == .last) #expect(opts.channel == .last)
} }
} }