test(tabs): stub process.cwd instead of changing directory in the no-workingDir case

Merge-time fix for #676. The test for nit 7 changed the worker's real cwd,
which also throws under a threads pool; a process.cwd spy gives the route the
same case-folder cwd with nothing to restore by hand. It still fails without
the workingDir gate.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer committed 2026-10-22 19:37:36 +02:00
1 parent 0c1578581f
commit dda16d3e2a
1 file changed
+11 -15
+11 -15
View File
@@ -157,21 +157,17 @@ describe('case default group: create routes', () => {
});
it('POST /api/sessions without a workingDir infers no case from the server cwd', async () => {
const cwd = process.cwd();
process.chdir(caseDir); // the server's own cwd happens to be a case folder
try {
const res = await harness.app.inject({
method: 'POST',
url: '/api/sessions',
payload: { name: 'w1-nowd', mode: 'shell' },
});
expect(res.statusCode).toBe(200);
const data = unwrap(res.body);
expect(Object.keys(data)).toEqual(['session']);
expect(groupOf(world.layouts[OWNER], data.session.id)).toBeNull();
} finally {
process.chdir(cwd);
}
vi.spyOn(process, 'cwd').mockReturnValue(caseDir); // the server's own cwd happens to be a case folder
const res = await harness.app.inject({
method: 'POST',
url: '/api/sessions',
payload: { name: 'w1-nowd', mode: 'shell' },
});
expect(res.statusCode).toBe(200);
const data = unwrap(res.body);
expect(data.session.workingDir).toBe(caseDir);
expect(Object.keys(data)).toEqual(['session']);
expect(groupOf(world.layouts[OWNER], data.session.id)).toBeNull();
});
it('POST /api/sessions outside any case gets no case default and keeps its response shape', async () => {