d3ro-voice/apps/desktop/tests/main/windows/popup-window-options.test.ts
Yun Chan 03cd8bf890 feat(desktop): screen text capture (OCR) overlay with selectable text
A rebindable screen-ocr action (default Ctrl+Alt+O) freezes the monitor under the cursor and
covers it with a focusable overlay. Text is selected by flow drag, rectangle drag, double/triple
click, Shift+click or Ctrl+A, then copied, saved as PNG or searchable PDF, translated,
summarized, read aloud, opened as a link or searched.

- Selection, text assembly and the PDF document are pure functions in @d3ro/core/screen-ocr,
  shared by the main process and the overlay.
- Recognition uses Windows.Media.Ocr through powershell.exe -EncodedCommand with 2x upscaling;
  the capture reaches disk only as a temp PNG that is removed right after recognition.
- Capture uses GDI BitBlt for the target monitor (39 ms) because desktopCapturer captured all
  three monitors and took 2.9 s when DXGI duplication timed out.
- The accelerator is reserved only where the feature is available, so macOS does not swallow
  the key for a feature it cannot run (fails closed with a message).

Map: CAP-17 [~], GAP-OCR-01 (live hotkey journey not yet driven in the running app),
GAP-OCR-02 (macOS engine, mixed-language accuracy).
2026-11-20 15:16:37 +09:00

45 lines
1.6 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest'
vi.mock('electron', () => ({
BrowserWindow: class {},
nativeTheme: { shouldUseDarkColors: true },
shell: { openExternal: vi.fn() },
app: { getPath: () => '', isPackaged: false }
}))
vi.mock('@electron-toolkit/utils', () => ({ is: { dev: false } }))
import { buildPopupWindowOptions } from '../../../src/main/windows/popup-window-factory'
const spec = { name: 'history-popup', bounds: { width: 380, height: 200 }, onClosed: () => undefined }
describe('buildPopupWindowOptions', () => {
it('팝업창옵션_기본팝업_포커스를빼앗지않는투명창이다', () => {
const options = buildPopupWindowOptions(spec, '/preload/popup.js')
expect(options).toMatchObject({
width: 380,
height: 200,
show: false,
frame: false,
transparent: true,
focusable: false,
alwaysOnTop: true,
skipTaskbar: true
})
expect(options.webPreferences).toMatchObject({
preload: '/preload/popup.js',
contextIsolation: true,
nodeIntegration: false,
backgroundThrottling: false
})
})
it('팝업창옵션_화면OCR오버레이_키를받는불투명창이되고보안설정은그대로다', () => {
const options = buildPopupWindowOptions(
{ ...spec, name: 'screen-ocr', focusable: true, transparent: false },
'/preload/popup.js'
)
expect(options).toMatchObject({ focusable: true, transparent: false, frame: false, alwaysOnTop: true })
expect(options.webPreferences).toMatchObject({ contextIsolation: true, nodeIntegration: false })
})
})