From 1172ef56f818d977fb617a24a2c5ab6ea0fac0eb Mon Sep 17 00:00:00 2001 From: Codeman maintainer Date: Tue, 13 Oct 2026 18:56:58 +0200 Subject: [PATCH] test(file-preview): every link form routes .md and .html to the preview (#547/#604 integration) Pins the merge resolution: `~/`, relative (`./`, bare) and hard-wrapped links to .md/.markdown and .html/.htm open the file preview (rendered markdown, HTML page) exactly like rooted ones, while other text such as a relative .json keeps the log viewer. Fails if the terminal's activate path drops rendersAsPage(). Co-Authored-By: Claude Opus 5.5 (1M context) --- test/file-path-link-forms.test.ts | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/test/file-path-link-forms.test.ts b/test/file-path-link-forms.test.ts index 3e6f23a5..e601bc9e 100644 --- a/test/file-path-link-forms.test.ts +++ b/test/file-path-link-forms.test.ts @@ -284,6 +284,44 @@ describe('terminal link provider', () => { expect(app.openLogViewerWindow).toHaveBeenCalledWith('/mnt/build/neon_getaway-mgr-hebel/logs/run.log', 's1'); }); + it('routes .md/.markdown and .html/.htm in every link form to the preview, other text to the log viewer', () => { + // The rendered markdown viewer and the HTML page view (rendersAsPage) apply to + // `~/`, relative and hard-wrapped links exactly as to rooted ones. + const WS = '/mnt/build/neon_getaway-mgr-hebel'; + const cases: Array<[string[], number, string, 'preview' | 'log']> = [ + [['wrote ~/notes/plan.md'], 1, '~/notes/plan.md', 'preview'], + [['wrote ~/site/index.html'], 1, '~/site/index.html', 'preview'], + [['wrote docs/README.markdown'], 1, `${WS}/docs/README.markdown`, 'preview'], + [['wrote report/index.htm'], 1, `${WS}/report/index.htm`, 'preview'], + [['wrote ./notes/plan.md'], 1, `${WS}/notes/plan.md`, 'preview'], + [['wrote out/data.json'], 1, `${WS}/out/data.json`, 'log'], + [ + [' ⎿ WROTE /mnt/build/neon_getaway-mgr-hebel/builds/reports/2', ' 026-10-10/summary.md done', ''], + 2, + `${WS}/builds/reports/2026-10-10/summary.md`, + 'preview', + ], + [ + [' ⎿ WROTE /mnt/build/neon_getaway-mgr-hebel/builds/reports/2', ' 026-10-10/page.html done', ''], + 2, + `${WS}/builds/reports/2026-10-10/page.html`, + 'preview', + ], + ]; + for (const [lines, row, expected, where] of cases) { + const { app, links } = linksOn(lines, row); + expect(links.length, expected).toBe(1); + links[0].activate({}, links[0].text); + if (where === 'preview') { + expect(app.openFilePreview, expected).toHaveBeenCalledWith(expected, 's1'); + expect(app.openLogViewerWindow, expected).not.toHaveBeenCalled(); + } else { + expect(app.openLogViewerWindow, expected).toHaveBeenCalledWith(expected, 's1'); + expect(app.openFilePreview, expected).not.toHaveBeenCalled(); + } + } + }); + it('never adds a path link overlapping a URL link', () => { const { links } = linksOn(['see https://x.io/view?img=shots/a.png now'], 1); expect(links.map((l) => l.text)).toEqual(['https://x.io/view?img=shots/a.png']);