From 23bf9c35bb4bd579e4629085ed4082b2a42a85a5 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Mon, 27 Jul 2026 16:43:15 -0700 Subject: [PATCH] test(editor): cover the Ctrl chord for rich markdown link routing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This file is the only test of handleRichMarkdownEditorClick, and it exercised metaKey alone, so the isMac branch of modKey had no coverage off macOS. Also stop claiming the source-owner case proves SSH links stay out of Orca — it proves the owner survives the hop; http-link-routing.test.ts enforces the rest. --- ...rich-markdown-editor-click-routing.test.ts | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/renderer/src/components/editor/rich-markdown-editor-click-routing.test.ts b/src/renderer/src/components/editor/rich-markdown-editor-click-routing.test.ts index 1ac526c460d..abd447bf485 100644 --- a/src/renderer/src/components/editor/rich-markdown-editor-click-routing.test.ts +++ b/src/renderer/src/components/editor/rich-markdown-editor-click-routing.test.ts @@ -14,9 +14,10 @@ beforeEach(() => { openHttpLinkMock.mockReset() }) -// Why: the rich editor and the markdown preview render the same file, so a link -// clicked in either must reach the same destination. -function clickExternalLinkWithShift(sourceOwner: HttpLinkSourceOwner): boolean { +// Why: the preview half of this same decision is pinned with an identical options +// shape in markdown-preview-links.test.ts — the two together keep the editor and +// preview of one file from routing a link two different ways. +function clickExternalLinkWithShift(sourceOwner: HttpLinkSourceOwner, isMac = true): boolean { const href = 'https://example.com/docs' const view = { state: { @@ -32,9 +33,9 @@ function clickExternalLinkWithShift(sourceOwner: HttpLinkSourceOwner): boolean { return handleRichMarkdownEditorClick({ activateMarkdownLink: vi.fn(), editorRef: { current: {} } as unknown as MutableRefObject, - event: { metaKey: true, ctrlKey: false, shiftKey: true } as MouseEvent, + event: { metaKey: isMac, ctrlKey: !isMac, shiftKey: true } as MouseEvent, filePath: '/repo/docs/README.md', - isMac: true, + isMac, htmlSuperscriptLinkContext: { getSnapshot: () => ({ sourceOwner }) }, @@ -61,9 +62,20 @@ describe('rich markdown editor Shift+modifier click on external links', () => { }) }) - // Why: openHttpLink refuses to route a non-local source into Orca, so the owner - // has to survive the hop or an SSH file's links could land in the wrong browser. - it('preserves a non-local source owner so remote files stay out of Orca', () => { + // Why: AGENTS.md — Shift+Ctrl is the chord off macOS, and modKey reads a + // different event field there. + it('uses the Ctrl chord off macOS', () => { + expect(clickExternalLinkWithShift({ kind: 'local' }, false)).toBe(true) + expect(openHttpLinkMock).toHaveBeenCalledWith('https://example.com/docs', { + worktreeId: 'wt-1', + modifierHeld: true, + sourceOwner: { kind: 'local' } + }) + }) + + // Why: the owner has to survive the hop; openHttpLink is what then refuses to put + // a non-local source in Orca (enforced in http-link-routing.test.ts, not here). + it('forwards a non-local source owner untouched', () => { const sourceOwner = { kind: 'ssh', connectionId: 'conn-1' } as HttpLinkSourceOwner expect(clickExternalLinkWithShift(sourceOwner)).toBe(true)