// test/codex-file-previews-setting.test.ts // Port: none (static analysis plus vm-loaded modules, runs in CI, no browser/server). // // `codexFilePreviewsEnabled` (App Settings > Header & Panels > Codex files) gates four // behaviours together, per device, default OFF: // 1. the Response files header button (never on phones, even when on), // 2. taking a click on a file tab in Codex's own sidebar (and suppressing the // ordinary linkifier on those rows), // 3. the Dock control on file previews, // 4. taking a click on a file name Codex underlined in the pane (owner decision for 1.52.1). // With it off none of the four exists. Each surface's off-state behaviour is also // pinned next to its own tests (response-viewer-file-links, terminal-link-provider-target, // file-preview-window); this file pins the setting's own wiring and the off-state of all // three through the real reader. import { describe, it, expect, vi } from 'vitest'; import { readFileSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; import { join } from 'node:path'; import vm from 'node:vm'; import { JSDOM } from 'jsdom'; import { performance } from 'node:perf_hooks'; const HERE = fileURLToPath(new URL('.', import.meta.url)); const PUBLIC = join(HERE, '../src/web/public'); const read = (file: string) => readFileSync(join(PUBLIC, file), 'utf8'); describe('codexFilePreviewsEnabled stays per-device: display key, stripped from the PUT, absent from the schema', () => { const settingsUi = read('settings-ui.js'); const schemas = readFileSync(join(HERE, '../src/web/schemas.ts'), 'utf8'); it('is in the client-side displayKeys merge policy', () => { const start = settingsUi.indexOf('const displayKeys = new Set(['); const displayKeys = settingsUi.slice(start, settingsUi.indexOf('])', start)); expect(displayKeys).toContain("'codexFilePreviewsEnabled'"); }); it('is stripped out of the object saveAppSettings() PUTs and never declared in the .strict() schema', () => { expect(settingsUi).toContain('codexFilePreviewsEnabled: _cfp,'); expect(schemas).not.toContain('codexFilePreviewsEnabled'); }); it('is loaded into and saved from its App Settings chip, default OFF', () => { const index = read('index.html'); expect(index).toMatch( /