fix(agent-browser): restore bounded presentation lifecycle
This commit is contained in:
@@ -17,6 +17,36 @@ afterEach(async () => {
|
||||
});
|
||||
|
||||
describe('coding composition background sleep', () => {
|
||||
it('closes the shared browser before an idle background runtime sleeps', async () => {
|
||||
const projectPath = await mkdtemp(path.join(tmpdir(), 'makelore-sleep-browser-project-'));
|
||||
const userDataDir = await mkdtemp(path.join(tmpdir(), 'makelore-sleep-browser-user-'));
|
||||
roots.push(projectPath, userDataDir);
|
||||
const close = vi.fn(async () => undefined);
|
||||
const composition = createCodingComposition({
|
||||
storage: createMemoryCodingProjectStorage(),
|
||||
browser: { close } as unknown as AgentBrowserModule,
|
||||
paths: {
|
||||
executablePath: process.execPath,
|
||||
cliPath: path.join(projectPath, 'unused-cli.js'),
|
||||
serverPath: path.join(projectPath, 'unused-server.mjs'),
|
||||
userDataDir,
|
||||
bundledSkillsDir: path.resolve('resources/coding-skills'),
|
||||
},
|
||||
});
|
||||
const stopAgentServer = vi.spyOn(PiAgentServerProcess.prototype, 'stop')
|
||||
.mockResolvedValue(undefined);
|
||||
|
||||
try {
|
||||
await composition.sleep('background_sleep');
|
||||
|
||||
expect(close).toHaveBeenCalledTimes(1);
|
||||
expect(stopAgentServer).toHaveBeenCalledTimes(1);
|
||||
} finally {
|
||||
stopAgentServer.mockRestore();
|
||||
await composition.shutdown();
|
||||
}
|
||||
});
|
||||
|
||||
it('does not stop the shared Agent Server when work starts during worker cleanup', async () => {
|
||||
const projectPath = await mkdtemp(path.join(tmpdir(), 'makelore-sleep-race-project-'));
|
||||
const userDataDir = await mkdtemp(path.join(tmpdir(), 'makelore-sleep-race-user-'));
|
||||
|
||||
Reference in New Issue
Block a user