native macOS codings agent orchestrator prowl.onev.cat
Something went wrong. Try again.
Swift
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122import ComposableArchitectureimport DependenciesTestSupportimport Foundationimport ProwlCLISharedimport Testing
@testable import Prowl
@MainActorstruct SettingsFeatureCLIInstallTests { @Test(.dependencies) func installShowsSuccessAlert() async { let installed = LockIsolated(false) let store = TestStore( initialState: SettingsFeature.State() ) { SettingsFeature() } withDependencies: { $0.cliInstallClient.install = { _ in installed.setValue(true) } $0.cliInstallClient.installationStatus = { _ in .installed(path: "/usr/local/bin/prowl") } }
await store.send(.installCLIButtonTapped()) await store.receive(\.cliInstallCompleted.success) { $0.alert = AlertState { TextState("Command Line Tool Installed") } actions: { ButtonState(action: .dismiss) { TextState("OK") } } message: { TextState("The prowl command is now available at /usr/local/bin/prowl.") } $0.cliInstallStatus = .installed(path: "/usr/local/bin/prowl") } await store.receive(\.delegate.cliInstallCompleted)
#expect(installed.value == true) }
@Test(.dependencies) func installShowsErrorAlertOnFailure() async { let store = TestStore( initialState: SettingsFeature.State() ) { SettingsFeature() } withDependencies: { $0.cliInstallClient.install = { _ in throw CLIInstallError(message: "Permission denied") } $0.cliInstallClient.installationStatus = { _ in .notInstalled } }
await store.send(.installCLIButtonTapped()) await store.receive(\.cliInstallCompleted.failure) { $0.alert = AlertState { TextState("Command Line Tool Error") } actions: { ButtonState(action: .dismiss) { TextState("OK") } } message: { TextState("Permission denied") } } await store.receive(\.delegate.cliInstallCompleted) }
@Test(.dependencies) func uninstallShowsSuccessAlert() async { let uninstalled = LockIsolated(false) let store = TestStore( initialState: SettingsFeature.State() ) { SettingsFeature() } withDependencies: { $0.cliInstallClient.uninstall = { _ in uninstalled.setValue(true) } $0.cliInstallClient.installationStatus = { _ in .notInstalled } }
await store.send(.uninstallCLIButtonTapped) await store.receive(\.cliInstallCompleted.success) { $0.alert = AlertState { TextState("Command Line Tool Uninstalled") } actions: { ButtonState(action: .dismiss) { TextState("OK") } } message: { TextState("The prowl command line tool has been removed.") } } await store.receive(\.delegate.cliInstallCompleted)
#expect(uninstalled.value == true) }
@Test(.dependencies) func commandPaletteInstallRoutesToSettingsAndShowsToast() async { let installed = LockIsolated(false) let store = TestStore( initialState: AppFeature.State(settings: SettingsFeature.State()) ) { AppFeature() } withDependencies: { $0.cliInstallClient.install = { _ in installed.setValue(true) } $0.cliInstallClient.installationStatus = { _ in .installed(path: "/usr/local/bin/prowl") } } store.exhaustivity = .off
await store.send(.commandPalette(.delegate(.installCLI))) await store.receive(\.settings.installCLIButtonTapped) { $0.settings.cliInstallShowAlert = false } await store.receive(\.settings.cliInstallCompleted.success) { $0.settings.cliInstallStatus = .installed(path: "/usr/local/bin/prowl") } await store.receive(\.settings.delegate.cliInstallCompleted) await store.receive(\.repositories.showToast) { $0.repositories.statusToast = .success("prowl installed at /usr/local/bin/prowl") }
#expect(installed.value == true) }}