Post-merge follow-ups for #2740 #2735 #2734 #2690 #2676 #2738 #2684 #2689 #2733 #2739 #2462 #2687 #2736 #2618 #2697, plus three regressions found while reviewing them: - ctrl/cmd+digit while typing no longer switches session tabs (#2503 was still open in practice: the guard only covered the mod+alt surface binding) - Shiki template-call sanitizer now covers every bundled grammar, including the js/ts aliases and embedding grammars; timed-out highlight requests are memoized and no longer cancel unrelated in-flight requests - settings flush on suspend uses keepalive and also fires on Capacitor appStateChange; keeps the selected model persisted across mode switches - remote-only branches fetch before checkout; range helpers fail clearly - git status invalidation now fires for runtime adapters too - settings number inputs and select triggers size in ch so they scale with the interface font - recent-activity timestamps tick from one list-level ticker - Markdown preview find goes through the shared find_in_file keybind with containment, no longer counts its own bar, and debounces observer runs - #2676 reverted; #2524 fixed by fading the sticky header's own background instead of overlaying the content below it - sticky group headers in the model picker and sidebar render again (oc-sticky-fade-scroller class restored after9b9d7069c) - project switcher names are left-aligned again (wrapper lost in26dbc2f30) - tool card quick-open icon is always visible and opens the same line as the expanded card's button - tautological tests replaced or removed; new oxlint findings fixed
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
import { afterEach, describe, expect, test } from 'bun:test';
|
|
import { getVSCodeBootstrapConfig, isVSCodeBootstrapPresent } from './vscodeBootstrap';
|
|
|
|
interface TestWindow {
|
|
__VSCODE_CONFIG__?: { workspaceFolder: string; workspaceFolders: { name: string; path: string }[] };
|
|
}
|
|
|
|
/**
|
|
* bun test runs without a DOM, so `globalThis` has no `window` binding to
|
|
* assign through. Defining the property directly installs the stub without
|
|
* asserting that it is a real `Window`.
|
|
*/
|
|
const setTestWindow = (value: TestWindow | undefined): void => {
|
|
if (value === undefined) {
|
|
Reflect.deleteProperty(globalThis, 'window');
|
|
return;
|
|
}
|
|
Object.defineProperty(globalThis, 'window', { value, configurable: true, writable: true });
|
|
};
|
|
|
|
describe('VS Code bootstrap config', () => {
|
|
afterEach(() => {
|
|
setTestWindow(undefined);
|
|
});
|
|
|
|
test('reads extension-host __VSCODE_CONFIG__ before RuntimeAPIs exist', () => {
|
|
setTestWindow({
|
|
__VSCODE_CONFIG__: {
|
|
workspaceFolder: '/workspace/project-one',
|
|
workspaceFolders: [{ name: 'project-one', path: '/workspace/project-one' }],
|
|
},
|
|
});
|
|
|
|
expect(getVSCodeBootstrapConfig()).toEqual({
|
|
workspaceFolder: '/workspace/project-one',
|
|
workspaceFolders: [{ name: 'project-one', path: '/workspace/project-one' }],
|
|
});
|
|
expect(isVSCodeBootstrapPresent()).toBe(true);
|
|
});
|
|
|
|
test('treats missing window/bootstrap as not VS Code', () => {
|
|
expect(getVSCodeBootstrapConfig()).toBeNull();
|
|
expect(isVSCodeBootstrapPresent()).toBe(false);
|
|
expect(isVSCodeBootstrapPresent(null)).toBe(false);
|
|
});
|
|
});
|