From f25ea81f8679be80e84d8a9e217b6b1b071c1ded Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Sun, 5 Apr 2026 08:19:47 -0300 Subject: [PATCH] test: verify dragged paths with an `@` segment are preserved MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a fixture under a scoped-package-style subdir (`@types/index.d.ts`) so we exercise the realistic `node_modules/@types/...` drag case and lock in that `extractDraggedFilePaths` returns the raw path unchanged — the `@` inside the path must not collide with the mention prefix the caller prepends downstream. --- src/utils/dragDropPaths.test.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/utils/dragDropPaths.test.ts b/src/utils/dragDropPaths.test.ts index 0c3aad4a..5a4e3cc0 100644 --- a/src/utils/dragDropPaths.test.ts +++ b/src/utils/dragDropPaths.test.ts @@ -1,5 +1,5 @@ import { afterAll, beforeAll, describe, expect, test } from 'bun:test' -import { mkdtempSync, rmSync, writeFileSync } from 'fs' +import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'fs' import { tmpdir } from 'os' import { join } from 'path' import { extractDraggedFilePaths } from './dragDropPaths.js' @@ -10,13 +10,19 @@ describe('extractDraggedFilePaths', () => { const packageJson = `${process.cwd()}/package.json` // Temp dir with a file whose name contains a space, for Finder-drag - // backslash-escape tests. + // backslash-escape tests, and a scoped-package-style subdir so we can + // exercise paths that embed `@` (e.g. `node_modules/@types/...`). let tmpDir: string let spacedFile: string + let atSignFile: string beforeAll(() => { tmpDir = mkdtempSync(join(tmpdir(), 'dragdrop-test-')) spacedFile = join(tmpDir, 'my file.txt') writeFileSync(spacedFile, 'test') + const scopedDir = join(tmpDir, '@types') + mkdirSync(scopedDir) + atSignFile = join(scopedDir, 'index.d.ts') + writeFileSync(atSignFile, 'test') }) afterAll(() => { rmSync(tmpDir, { recursive: true, force: true }) @@ -128,4 +134,12 @@ describe('extractDraggedFilePaths', () => { test('trims surrounding whitespace from the whole paste', () => { expect(extractDraggedFilePaths(` ${thisFile} `)).toEqual([thisFile]) }) + + test('resolves a path that embeds an `@` segment', () => { + // Realistic case: dragging something under `node_modules/@types/...`. + // The `@` inside the path must not be confused with the mention prefix + // that the caller prepends downstream — `extractDraggedFilePaths` + // returns raw paths and leaves mention formatting to PromptInput. + expect(extractDraggedFilePaths(atSignFile)).toEqual([atSignFile]) + }) })