Files
openchamber/packages/vscode/src/bridge-localfs-proxy-runtime.test.js
T
Bohdan Triapitsyn a45376d585 perf: migrate chat rendering to virtua (#1651)
* refactor: migrate chat history virtualization to virtua

* refactor: render loaded chat history directly

* refactor: finish virtua migration

* perf: defer tool body rendering

* perf: queue deferred tool body mounts

* perf: quiet and defer markdown file probes

* perf: defer markdown code highlighting

* perf: stabilize markdown plugin lists

* perf: defer mermaid markdown rendering

* perf: delay markdown file reference annotation

* perf: attach markdown table listeners on demand

* perf: trim markdown render overhead
2026-06-15 03:29:40 +03:00

60 lines
1.5 KiB
JavaScript

import { describe, expect, it, mock } from 'bun:test';
mock.module('fs', () => ({
promises: {
realpath: mock(async () => {
const error = new Error('missing');
error.code = 'ENOENT';
throw error;
}),
stat: mock(async () => {
const error = new Error('missing');
error.code = 'ENOENT';
throw error;
}),
},
default: {
promises: {
realpath: mock(async () => {
const error = new Error('missing');
error.code = 'ENOENT';
throw error;
}),
stat: mock(async () => {
const error = new Error('missing');
error.code = 'ENOENT';
throw error;
}),
},
},
}));
mock.module('vscode', () => ({
Uri: {
file: (fsPath) => ({ fsPath }),
},
workspace: {
workspaceFolders: [{ uri: { fsPath: '/workspace' } }],
},
}));
const { tryHandleLocalFsProxy } = await import('./bridge-localfs-proxy-runtime');
describe('bridge local fs proxy', () => {
it('returns a quiet optional stat miss for missing files', async () => {
const response = await tryHandleLocalFsProxy('GET', '/api/fs/stat?path=%2Fmissing.ts&optional=true');
expect(response?.status).toBe(200);
expect(JSON.parse(Buffer.from(response?.bodyBase64 ?? '', 'base64').toString('utf8'))).toEqual({
path: '/missing.ts',
exists: false,
});
});
it('keeps regular stat miss behavior without optional flag', async () => {
const response = await tryHandleLocalFsProxy('GET', '/api/fs/stat?path=%2Fmissing.ts');
expect(response?.status).toBe(404);
});
});