Unified · Split
| @@ -214,58 +214,77 @@ function resetServerConfigSnapshot(): void { · 213 unmodified lines | ||
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | vi.mock("@effect/atom-react", async (importOriginal) => { |
| 217 | − const actual = await importOriginal<typeof import("@effect/atom-react")>(); | |
| 217 | + const [actual, Exit] = await Promise.all([ | |
| 218 | + importOriginal<typeof import("@effect/atom-react")>(), | |
| 219 | + import("effect/Exit"), | |
| 220 | + ]); | |
| 221 | + const withSuccessfulExit = | |
| 222 | + <Args extends Array<unknown>, A>(run: (...args: Args) => A | Promise<A>) => | |
| 223 | + async (...args: Args) => | |
| 224 | + Exit.succeed(await run(...args)); | |
| 225 | + const refreshProviders = withSuccessfulExit(mockRefreshProviders); | |
| 226 | + const connectPairingEnvironment = withSuccessfulExit(mockConnectPairingEnvironment); | |
| 227 | + const connectDesktopSshEnvironment = withSuccessfulExit(mockConnectDesktopSshEnvironment); | |
| 228 | + const connectRelayEnvironment = withSuccessfulExit(mockConnectRelayEnvironment); | |
| 229 | + const removeEnvironment = withSuccessfulExit(mockRemoveEnvironment); | |
| 230 | + const retryEnvironment = withSuccessfulExit(mockRetryEnvironment); | |
| 231 | + const refreshRelayEnvironments = withSuccessfulExit(mockRefreshRelayEnvironments); | |
| 232 | + const updateProvider = withSuccessfulExit(mockUpdateProvider); | |
| 233 | + const signalProcess = withSuccessfulExit( | |
| 234 | + ({ input }: { readonly input: Parameters<LocalApi["server"]["signalProcess"]>[0] }) => | |
| 235 | + window.nativeApi?.server.signalProcess(input), | |
| 236 | + ); | |
| 237 | + const openInEditor = withSuccessfulExit( | |
| 238 | + ({ | |
| 239 | + input, | |
| 240 | + }: { | |
| 241 | + readonly input: { | |
| 242 | + readonly cwd: string; | |
| 243 | + readonly editor: Parameters<LocalApi["shell"]["openInEditor"]>[1]; | |
| 244 | + }; | |
| 245 | + }) => window.nativeApi?.shell.openInEditor(input.cwd, input.editor), | |
| 246 | + ); | |
| 247 | + const succeedWithNoResult = async () => Exit.succeed(undefined); | |
| 218 | 248 | |
| 219 | 249 | return { |
| 220 | 250 | ...actual, |
| 221 | 251 | useAtomSet: (atom: unknown, options: unknown) => { |
| 222 | 252 | if (atom === directAtomMocks.refreshProvidersAction) { |
| 223 | − return mockRefreshProviders; | |
| 253 | + return refreshProviders; | |
| 224 | 254 | } |
| 225 | 255 | if (atom === directAtomMocks.connectPairingAction) { |
| 226 | − return mockConnectPairingEnvironment; | |
| 256 | + return connectPairingEnvironment; | |
| 227 | 257 | } |
| 228 | 258 | if (atom === directAtomMocks.connectSshEnvironmentAction) { |
| 229 | − return mockConnectDesktopSshEnvironment; | |
| 259 | + return connectDesktopSshEnvironment; | |
| 230 | 260 | } |
| 231 | 261 | if (atom === directAtomMocks.environmentRegisterAction) { |
| 232 | − return mockConnectRelayEnvironment; | |
| 262 | + return connectRelayEnvironment; | |
| 233 | 263 | } |
| 234 | 264 | if (atom === directAtomMocks.environmentRemoveAction) { |
| 235 | − return mockRemoveEnvironment; | |
| 265 | + return removeEnvironment; | |
| 236 | 266 | } |
| 237 | 267 | if (atom === directAtomMocks.environmentRetryAction) { |
| 238 | − return mockRetryEnvironment; | |
| 268 | + return retryEnvironment; | |
| 239 | 269 | } |
| 240 | 270 | if (atom === directAtomMocks.refreshRelayEnvironmentsAction) { |
| 241 | − return mockRefreshRelayEnvironments; | |
| 271 | + return refreshRelayEnvironments; | |
| 242 | 272 | } |
| 243 | 273 | if (atom === directAtomMocks.updateProviderAction) { |
| 244 | − return mockUpdateProvider; | |
| 274 | + return updateProvider; | |
| 245 | 275 | } |
| 246 | 276 | if (atom === directAtomMocks.signalProcessAction) { |
| 247 | − return async ({ | |
| 248 | − input, | |
| 249 | − }: { | |
| 250 | − readonly input: Parameters<LocalApi["server"]["signalProcess"]>[0]; | |
| 251 | − }) => window.nativeApi?.server.signalProcess(input); | |
| 277 | + return signalProcess; | |
| 252 | 278 | } |
| 253 | 279 | if (atom === directAtomMocks.openInEditorAction) { |
| 254 | − return async ({ | |
| 255 | − input, | |
| 256 | − }: { | |
| 257 | − readonly input: { | |
| 258 | − readonly cwd: string; | |
| 259 | − readonly editor: Parameters<LocalApi["shell"]["openInEditor"]>[1]; | |
| 260 | − }; | |
| 261 | − }) => window.nativeApi?.shell.openInEditor(input.cwd, input.editor); | |
| 280 | + return openInEditor; | |
| 262 | 281 | } |
| 263 | 282 | if ( |
| 264 | 283 | atom === directAtomMocks.removeKeybindingAction || |
| 265 | 284 | atom === directAtomMocks.updateSettingsAction || |
| 266 | 285 | atom === directAtomMocks.upsertKeybindingAction |
| 267 | 286 | ) { |
| 268 | − return async () => undefined; | |
| 287 | + return succeedWithNoResult; | |
| 269 | 288 | } |
| 270 | 289 | return actual.useAtomSet(atom as never, options as never); |
| 271 | 290 | }, |