test: decouple remote background test from shell service

This commit is contained in:
Adam Weidman
2026-03-09 00:18:38 -04:00
parent 020fcc9674
commit bc76cbeb50
@@ -22,7 +22,7 @@ import type { RemoteAgentDefinition } from './types.js';
import { createMockMessageBus } from '../test-utils/mock-message-bus.js'; import { createMockMessageBus } from '../test-utils/mock-message-bus.js';
import { A2AAuthProviderFactory } from './auth-provider/factory.js'; import { A2AAuthProviderFactory } from './auth-provider/factory.js';
import type { A2AAuthProvider } from './auth-provider/types.js'; import type { A2AAuthProvider } from './auth-provider/types.js';
import { ShellExecutionService } from '../services/shellExecutionService.js'; import { ExecutionLifecycleService } from '../services/executionLifecycleService.js';
// Mock A2AClientManager // Mock A2AClientManager
vi.mock('./a2a-client-manager.js', () => ({ vi.mock('./a2a-client-manager.js', () => ({
@@ -59,6 +59,7 @@ describe('RemoteAgentInvocation', () => {
beforeEach(() => { beforeEach(() => {
vi.clearAllMocks(); vi.clearAllMocks();
ExecutionLifecycleService.resetForTest();
(A2AClientManager.getInstance as Mock).mockReturnValue(mockClientManager); (A2AClientManager.getInstance as Mock).mockReturnValue(mockClientManager);
( (
RemoteAgentInvocation as unknown as { RemoteAgentInvocation as unknown as {
@@ -619,8 +620,8 @@ describe('RemoteAgentInvocation', () => {
const updateOutput = vi.fn((output: unknown) => { const updateOutput = vi.fn((output: unknown) => {
if (output === 'Chunk 1' && executionId !== undefined) { if (output === 'Chunk 1' && executionId !== undefined) {
ShellExecutionService.background(executionId); ExecutionLifecycleService.background(executionId);
unsubscribeStream = ShellExecutionService.subscribe( unsubscribeStream = ExecutionLifecycleService.subscribe(
executionId, executionId,
(event) => { (event) => {
if (event.type === 'data' && typeof event.chunk === 'string') { if (event.type === 'data' && typeof event.chunk === 'string') {
@@ -643,7 +644,7 @@ describe('RemoteAgentInvocation', () => {
undefined, undefined,
(newExecutionId) => { (newExecutionId) => {
executionId = newExecutionId; executionId = newExecutionId;
unsubscribeOnExit = ShellExecutionService.onExit( unsubscribeOnExit = ExecutionLifecycleService.onExit(
newExecutionId, newExecutionId,
onExit, onExit,
); );