mirror of
https://github.com/stablyai/orca.git
synced 2026-09-26 00:02:34 +00:00
* refactor(tests): split oversized test files off the max-lines suppression list Every `*.test.ts`/`*.spec.ts` that carried an `eslint/oxlint-disable max-lines` directive is now split into focused, behavior-scoped suites that fit the 800-line test budget, with shared setup extracted into co-located `*-test-harness.ts` / `*-test-fixtures.ts` modules (300-line budget). 83 files became ~930; the largest output is 797 effective lines. `orca-runtime.test.ts` is intentionally untouched. Test bodies were moved by scripted line-range slicing rather than retyped, so assertions are byte-identical. The only permitted body edits were mechanical rebinding where a shared value moved into a harness (e.g. `tmpHome` -> `homes.tmpHome`). Registries that enumerate test files were updated in lockstep: - config/max-lines-baseline.txt: pruned 341 -> 258 entries (all 83 removed). - config/reliability-gates.jsonc: 33 gates repointed at the split files, with assertionRefs split per file where a gate's coverage now spans several. - .github/workflows/pr.yml: the real-zsh lane now lists the 4 split files that actually exercise zsh, so they keep running in the dedicated shell lane. Also renamed agent-hooks `server-test-fixtures.ts` to `server.test-fixtures.ts` so the global-fetch call-site audit keeps skipping it, and added `.js` extensions to the CLI suites' dynamic harness imports (node16 resolution) to unbreak `build:cli`. Verification: full suite 52,449 passing vs 52,448 at baseline with zero assertions lost; `pnpm lint`, `pnpm typecheck`, and `pnpm build:cli` all exit 0; the terminal-pane e2e spec runs 31/31 headless. * refactor(tests): split hook-idle arbitration suite that oxfmt pushed over budget The pre-commit oxfmt pass reflowed pty-connection-hook-idle-arbitration.test.ts to 811 effective lines, 11 over the test budget. Split the hook-completion side effect and replacement-agent veto cases into their own suite; both files now sit well under the cap and the 15 tests are unchanged. * test: port upstream test changes into the split files after rebase Rebasing onto main surfaced 27 tests that main had added to files this branch deleted, plus edits to tests that had already moved. Taking the deletion side of those modify/delete conflicts would have dropped that coverage silently, so each upstream change is ported into the split file that now owns the behavior — for example main's six orchestration mailbox tests land across orchestration-runs, -send, and -check. Also repoints `orchestration.notification-mailbox-consistency`, a gate main added after this branch's gate remap, at those same three split files, and re-prunes the max-lines baseline against main's (257 entries). Verified: all 27 upstream test titles present; full suite 52,761 passing with the only diff vs baseline being 12 tests main itself removed and 3 that moved from skipped to passing; lint and typecheck exit 0. * fix(test): flush pending continuations before tearing down terminal test globals CI shard 5/16 failed on both Node 24 and 26 with `ReferenceError: window is not defined` from pty-connection.ts, surfacing through pty-connection-daemon-snapshot-replay.test.ts. The reattach/settle chains `await` a real promise and then touch `window.api`. Under fake timers those continuations cannot run, so they only become schedulable once restoreTerminalTestGlobals() switches back to real timers — which previously happened immediately before `delete globalThis.window`, so a late continuation threw and failed the whole file. Flush async ticks in that window instead. This is latent in the source rather than new: the pre-split 25k-line file kept running other tests after these, which gave the chains time to settle before teardown. Splitting the file moved teardown directly behind them. * fix(test): keep an inert window after terminal test teardown instead of deleting it The async-tick flush was not enough: the reattach/settle chain can resolve after teardown regardless of how long we drain, so CI shard 5/16 still failed with `ReferenceError: window is not defined` from pty-connection.ts. A real renderer never loses `window`, so deleting it was the artificial part. Swap in an inert proxy whose properties resolve to callables and whose calls resolve to undefined, making a late `window.api.pty.*` call a harmless no-op. The next test replaces it wholesale via installTerminalTestGlobals(), and no test asserts that `window` is absent.
345 lines
10 KiB
TypeScript
345 lines
10 KiB
TypeScript
// Matching across non-QWERTY, non-Latin, JIS, AltGr, and composed layouts.
|
||
import { describe, expect, it } from 'vitest'
|
||
import {
|
||
getEffectiveKeybindingsForAction,
|
||
keybindingFromInput,
|
||
keybindingMatchesAction,
|
||
keybindingMatchesInput
|
||
} from './keybindings'
|
||
|
||
describe('keybindings', () => {
|
||
it('matches the default file explorer delete shortcut', () => {
|
||
expect(getEffectiveKeybindingsForAction('fileExplorer.delete', 'darwin')).toEqual([
|
||
'Mod+Backspace',
|
||
'Delete'
|
||
])
|
||
expect(
|
||
keybindingMatchesAction(
|
||
'fileExplorer.delete',
|
||
{ key: 'Delete', code: 'Delete', control: false, meta: false, alt: false, shift: false },
|
||
'linux'
|
||
)
|
||
).toBe(true)
|
||
})
|
||
|
||
it('matches file explorer undo and redo by produced logical key', () => {
|
||
expect(getEffectiveKeybindingsForAction('fileExplorer.undo', 'darwin')).toEqual(['Mod+Z'])
|
||
expect(getEffectiveKeybindingsForAction('fileExplorer.redo', 'darwin')).toEqual(['Mod+Shift+Z'])
|
||
expect(getEffectiveKeybindingsForAction('fileExplorer.redo', 'linux')).toEqual([
|
||
'Mod+Shift+Z',
|
||
'Ctrl+Y'
|
||
])
|
||
|
||
expect(
|
||
keybindingMatchesAction(
|
||
'fileExplorer.undo',
|
||
{ key: 'z', code: 'Semicolon', control: false, meta: true, alt: false, shift: false },
|
||
'darwin'
|
||
)
|
||
).toBe(true)
|
||
expect(
|
||
keybindingMatchesAction(
|
||
'fileExplorer.undo',
|
||
{ key: ';', code: 'KeyZ', control: false, meta: true, alt: false, shift: false },
|
||
'darwin'
|
||
)
|
||
).toBe(false)
|
||
expect(
|
||
keybindingMatchesAction(
|
||
'fileExplorer.redo',
|
||
{ key: 'Z', code: 'Semicolon', control: false, meta: true, alt: false, shift: true },
|
||
'darwin'
|
||
)
|
||
).toBe(true)
|
||
expect(
|
||
keybindingMatchesAction(
|
||
'fileExplorer.redo',
|
||
{ key: 'y', code: 'KeyF', control: true, meta: false, alt: false, shift: false },
|
||
'linux'
|
||
)
|
||
).toBe(true)
|
||
expect(
|
||
keybindingMatchesAction(
|
||
'fileExplorer.redo',
|
||
{ key: 'f', code: 'KeyY', control: true, meta: false, alt: false, shift: false },
|
||
'linux'
|
||
)
|
||
).toBe(false)
|
||
})
|
||
|
||
it('matches non-QWERTY shortcuts by the produced logical key', () => {
|
||
const dvorakPhysicalW = {
|
||
key: ',',
|
||
code: 'KeyW',
|
||
control: false,
|
||
meta: true,
|
||
alt: false,
|
||
shift: false
|
||
}
|
||
const dvorakPhysicalComma = {
|
||
key: 'w',
|
||
code: 'Comma',
|
||
control: false,
|
||
meta: true,
|
||
alt: false,
|
||
shift: false
|
||
}
|
||
|
||
expect(keybindingMatchesAction('app.settings', dvorakPhysicalW, 'darwin')).toBe(true)
|
||
expect(keybindingMatchesAction('tab.close', dvorakPhysicalW, 'darwin')).toBe(false)
|
||
expect(keybindingMatchesAction('tab.close', dvorakPhysicalComma, 'darwin')).toBe(true)
|
||
expect(keybindingMatchesAction('app.settings', dvorakPhysicalComma, 'darwin')).toBe(false)
|
||
expect(keybindingFromInput(dvorakPhysicalW, 'darwin')).toEqual({
|
||
ok: true,
|
||
value: 'Mod+Comma'
|
||
})
|
||
expect(keybindingFromInput(dvorakPhysicalComma, 'darwin')).toEqual({
|
||
ok: true,
|
||
value: 'Mod+W'
|
||
})
|
||
})
|
||
|
||
it('matches letter shortcuts on non-Latin layouts via the physical code (issue #6274)', () => {
|
||
// Cyrillic ЙЦУКЕН: physical C produces the logical key 'с' (Cyrillic es,
|
||
// U+0441) while code stays 'KeyC'. The produced character is not a Latin
|
||
// shortcut letter, so the chord must still match through the physical code.
|
||
const cyrillicCtrlC = {
|
||
key: 'с',
|
||
code: 'KeyC',
|
||
control: true,
|
||
meta: false,
|
||
alt: false,
|
||
shift: false
|
||
}
|
||
expect(keybindingMatchesAction('browser.grabElement', cyrillicCtrlC, 'win32')).toBe(true)
|
||
expect(keybindingMatchesAction('browser.grabElement', cyrillicCtrlC, 'linux')).toBe(true)
|
||
|
||
// Ctrl+Shift+C on the same layout (terminal copy) must match too.
|
||
expect(
|
||
keybindingMatchesAction('terminal.copySelection', { ...cyrillicCtrlC, shift: true }, 'win32')
|
||
).toBe(true)
|
||
|
||
// Greek layout: physical P produces 'π' (U+03C0); Ctrl+P must still match.
|
||
expect(
|
||
keybindingMatchesAction(
|
||
'worktree.quickOpen',
|
||
{ key: 'π', code: 'KeyP', control: true, meta: false, alt: false, shift: false },
|
||
'win32'
|
||
)
|
||
).toBe(true)
|
||
|
||
// The fallback must not steal a different physical key: Ctrl+V (physical V,
|
||
// Cyrillic 'м') is not Ctrl+C, so grabElement must stay unmatched.
|
||
expect(
|
||
keybindingMatchesAction(
|
||
'browser.grabElement',
|
||
{ key: 'м', code: 'KeyV', control: true, meta: false, alt: false, shift: false },
|
||
'win32'
|
||
)
|
||
).toBe(false)
|
||
})
|
||
|
||
it('does not let non-Latin physical fallback hijack AltGr text input (issue #6274)', () => {
|
||
// Windows/Linux AltGr arrives as Ctrl+Alt. A composed character typed via
|
||
// AltGr (e.g. AltGr+C) must remain text input, never an app shortcut.
|
||
// editor.copyContext is Mod+Alt+C, so the modifier state otherwise matches —
|
||
// only the AltGr key gating may keep this from firing.
|
||
expect(
|
||
keybindingMatchesAction(
|
||
'editor.copyContext',
|
||
{
|
||
key: '¢',
|
||
code: 'KeyC',
|
||
control: true,
|
||
meta: false,
|
||
alt: true,
|
||
shift: false
|
||
},
|
||
'win32'
|
||
)
|
||
).toBe(false)
|
||
})
|
||
|
||
it('uses shifted punctuation aliases only while Shift is pressed', () => {
|
||
const shiftedComma = {
|
||
key: '<',
|
||
code: 'Comma',
|
||
control: false,
|
||
meta: true,
|
||
alt: false,
|
||
shift: true
|
||
}
|
||
|
||
expect(keybindingMatchesInput('Mod+Shift+Comma', shiftedComma, 'darwin')).toBe(true)
|
||
expect(keybindingFromInput(shiftedComma, 'darwin')).toEqual({
|
||
ok: true,
|
||
value: 'Mod+Shift+Comma'
|
||
})
|
||
expect(
|
||
keybindingMatchesInput(
|
||
'Mod+Comma',
|
||
{ ...shiftedComma, code: 'IntlBackslash', shift: false },
|
||
'darwin'
|
||
)
|
||
).toBe(false)
|
||
})
|
||
|
||
it('matches logical bracket shortcuts on JIS keyboards without changing code fallback', () => {
|
||
const jisLeftBracket = {
|
||
key: '[',
|
||
code: 'BracketRight',
|
||
control: false,
|
||
meta: true,
|
||
alt: false,
|
||
shift: false
|
||
}
|
||
const jisRightBracket = {
|
||
key: ']',
|
||
code: 'Backslash',
|
||
control: false,
|
||
meta: true,
|
||
alt: false,
|
||
shift: false
|
||
}
|
||
const jisLeftBracketShifted = { ...jisLeftBracket, key: '{', shift: true }
|
||
const jisRightBracketShifted = { ...jisRightBracket, key: '}', shift: true }
|
||
|
||
expect(
|
||
keybindingMatchesAction('tab.previousSameType', jisLeftBracketShifted, 'darwin', {
|
||
'tab.previousSameType': ['Mod+Shift+BracketLeft']
|
||
})
|
||
).toBe(true)
|
||
expect(
|
||
keybindingMatchesAction('tab.previousSameType', jisRightBracketShifted, 'darwin', {
|
||
'tab.previousSameType': ['Mod+Shift+BracketLeft']
|
||
})
|
||
).toBe(false)
|
||
expect(
|
||
keybindingMatchesAction('tab.nextSameType', jisRightBracketShifted, 'darwin', {
|
||
'tab.nextSameType': ['Mod+Shift+BracketRight']
|
||
})
|
||
).toBe(true)
|
||
expect(
|
||
keybindingMatchesAction('tab.nextSameType', jisLeftBracketShifted, 'darwin', {
|
||
'tab.nextSameType': ['Mod+Shift+BracketRight']
|
||
})
|
||
).toBe(false)
|
||
|
||
expect(keybindingMatchesAction('terminal.focusPreviousPane', jisLeftBracket, 'darwin')).toBe(
|
||
true
|
||
)
|
||
expect(keybindingMatchesAction('terminal.focusNextPane', jisLeftBracket, 'darwin')).toBe(false)
|
||
expect(keybindingMatchesAction('terminal.focusNextPane', jisRightBracket, 'darwin')).toBe(true)
|
||
|
||
// Alt+bracket is the fresh-install same-type default after the convention swap.
|
||
expect(
|
||
keybindingMatchesAction('tab.previousSameType', { ...jisLeftBracket, alt: true }, 'darwin')
|
||
).toBe(true)
|
||
expect(
|
||
keybindingMatchesAction('tab.nextSameType', { ...jisRightBracket, alt: true }, 'darwin')
|
||
).toBe(true)
|
||
expect(
|
||
keybindingMatchesAction(
|
||
'tab.previousSameType',
|
||
{ ...jisLeftBracket, control: true, meta: false, alt: true },
|
||
'linux'
|
||
)
|
||
).toBe(true)
|
||
expect(
|
||
keybindingMatchesAction(
|
||
'tab.nextSameType',
|
||
{ ...jisLeftBracket, control: true, meta: false, alt: true },
|
||
'linux'
|
||
)
|
||
).toBe(false)
|
||
expect(
|
||
keybindingMatchesAction(
|
||
'tab.nextSameType',
|
||
{ ...jisRightBracket, control: true, meta: false, alt: true },
|
||
'linux'
|
||
)
|
||
).toBe(true)
|
||
|
||
expect(
|
||
keybindingMatchesAction('terminal.splitRight', jisRightBracketShifted, 'darwin', {
|
||
'terminal.splitRight': ['Mod+Shift+Backslash']
|
||
})
|
||
).toBe(false)
|
||
|
||
expect(
|
||
keybindingMatchesAction(
|
||
'tab.nextSameType',
|
||
{
|
||
key: 'Dead',
|
||
code: 'BracketRight',
|
||
control: false,
|
||
meta: true,
|
||
alt: false,
|
||
shift: true
|
||
},
|
||
'darwin',
|
||
{ 'tab.nextSameType': ['Mod+Shift+BracketRight'] }
|
||
)
|
||
).toBe(true)
|
||
|
||
expect(
|
||
keybindingMatchesAction(
|
||
'tab.previousSameType',
|
||
{
|
||
key: '[',
|
||
code: 'Digit8',
|
||
control: true,
|
||
meta: false,
|
||
alt: true,
|
||
shift: false
|
||
},
|
||
'linux'
|
||
)
|
||
).toBe(false)
|
||
expect(
|
||
keybindingMatchesAction(
|
||
'tab.previousSameType',
|
||
{
|
||
key: 'Dead',
|
||
code: 'BracketLeft',
|
||
control: true,
|
||
meta: false,
|
||
alt: true,
|
||
shift: false
|
||
},
|
||
'linux'
|
||
)
|
||
).toBe(true)
|
||
})
|
||
|
||
it('matches macOS Option-composed bracket shortcuts for same-type tab switching', () => {
|
||
// Cmd+Alt+bracket is the fresh-install same-type default after the swap, so
|
||
// Option-composed dead keys (\u2325[ -> "\u201c") must still resolve to that action.
|
||
const macOptionLeftBracket = {
|
||
key: '\u201c',
|
||
code: 'BracketLeft',
|
||
control: false,
|
||
meta: true,
|
||
alt: true,
|
||
shift: false
|
||
}
|
||
const macOptionRightBracket = {
|
||
key: '\u2018',
|
||
code: 'BracketRight',
|
||
control: false,
|
||
meta: true,
|
||
alt: true,
|
||
shift: false
|
||
}
|
||
|
||
expect(keybindingMatchesAction('tab.previousSameType', macOptionLeftBracket, 'darwin')).toBe(
|
||
true
|
||
)
|
||
expect(keybindingMatchesAction('tab.nextSameType', macOptionLeftBracket, 'darwin')).toBe(false)
|
||
expect(keybindingMatchesAction('tab.nextSameType', macOptionRightBracket, 'darwin')).toBe(true)
|
||
expect(keybindingMatchesAction('tab.previousSameType', macOptionRightBracket, 'darwin')).toBe(
|
||
false
|
||
)
|
||
})
|
||
})
|