Skip to content

Strip project scope prefix from IDs copied by "Copy test ID" - #26153

Merged
Eduardo Villalpando Mello (edvilme) merged 4 commits into
mainfrom
copilot/fix-copy-test-id-issue-26092
Sep 21, 2026
Merged

Eduardo Villalpando Mello (edvilme) merged 4 commits into
mainfrom
copilot/fix-copy-test-id-issue-26092

Conversation

Copilot AI commented Sep 16, 2026 •

Copy link
Copy Markdown

Fixes #26092

"Copy test ID" copied the raw TestItem.id, which since project scoping is {projectId}@@vsc@@{testId}, so users pasted file:///path/to/workspace@@vsc@@/path/to/workspace/tests/unit/test_foo.py::test_bar instead of the test ID.

Changes

  • src/client/testing/utils.ts: writeTestIdToClipboard now normalizes the ID with the existing parseVsId helper before unittest detection/conversion, the pytest clipboard write, and logging.
    • TestItem.id is not mutated and discovery/execution scoping is untouched — only the clipboard-facing value is normalized.
    • parseVsId returns [undefined, vsId] for unscoped IDs, so legacy behavior and the module.class.method unittest formatting are preserved.
-        if (testItem.id.includes('\\') && testItem.id.indexOf('::') === -1) {
+        const [, testId] = parseVsId(testItem.id);
+        if (testId.includes('\\') && testId.indexOf('::') === -1) {
  • src/test/testing/utils.unit.test.ts: this file was a top-level IIFE with try/catch-swallowed assertions that mocha never registered as tests (and its idToModuleClassMethod inputs had lost their backslash separators). Converted to a suite/test file asserting the real clipboard contents via the MockClipboard from src/test/vscode-mock.ts, with cases for project-scoped pytest IDs, parameterized IDs (test_pipe_single[False] preserved verbatim), Windows-style paths, legacy unscoped IDs, and project-scoped unittest IDs.

Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix copy test ID to remove 'file://' prefix Strip project scope prefix from IDs copied by "Copy test ID" Sep 16, 2026
@edvilme
Eduardo Villalpando Mello (edvilme) marked this pull request as ready for review September 17, 2026 16:39
@bschnurr

Bill Schnurr (bschnurr) commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

🔒 Automated review in progress — Bill Schnurr (@bschnurr) is auto-reviewing this PR.

Comment thread src/client/testing/utils.ts Outdated

@bschnurr Bill Schnurr (bschnurr) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

@edvilme Eduardo Villalpando Mello (edvilme) added the bug Issue identified by VS Code Team member as probable bug label Sep 18, 2026
Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
@bschnurr

Copy link
Copy Markdown
Member

Result: ⚠️ partially-verified

Verification details

Verification: Isolated verification observed failures that were not classified as caused by this PR: Dependency and test discovery. The relevant tests could not be fully run in the isolated environment; this review is not fully verified.

Summary: The targeted utils unit suite compiled and passed all 13 tests, including scoped pytest, parameterized, Windows, legacy, and unittest IDs. TypeScript compilation and ESLint also passed. An initial combined run and git-based discovery were blocked by sandbox infrastructure, so the verdict is partially verified despite the successful targeted run.

Test runs: 3 passed, 1 failed, 1 not run

  • ⚠️ Not run | Combined compile and utils unit tests | node ./node_modules/typescript/bin/tsc -p ./ && node ./node_modules/mocha/bin/mocha.js --require out/test/unittests.js --ui tdd --timeout 180000 --reporter spec out/test/testing/utils.unit.test.js
  • ❌ Failed | unrelated to this PR | Dependency and test discovery | printf '%s\n' '=== sandbox profile ==='; printf '%s\n' "${AUTOMATION_SANDBOX_PROFILE:-<unset>}"; printf '%s\n' '=== changed files ==='; git diff --name-status HEAD^...HEAD; printf '%s\n' '=== relevant diff ==='; git diff --unified=20 HEAD^...HEAD -- src/client/testing/utils.ts src/test/testing/utils.unit.test.ts; printf '%s\n' '=== package scripts ==='; node -e "const p=require('./package.json'); console.log(JSON.stringify({scripts:p.scripts,packageManager:p.packageManager},null,2))"; printf '%s\n' '=== dependency state ==='; test -d node_modules && echo node_modules-present || echo node_modules-missing; test -x node_modules/.bin/mocha && echo mocha-present || echo mocha-missing; test -f package-lock.json && echo package-lock-present; test -f pnpm-lock.yaml && echo pnpm-lock-present
  • ✅ Passed | Testing - utils unit tests | node ./node_modules/mocha/bin/mocha.js --require out/test/unittests.js --ui tdd --timeout 180000 --reporter spec out/test/testing/utils.unit.test.js
  • ✅ Passed | Changed-file ESLint check | node ./node_modules/eslint/bin/eslint.js src/client/testing/utils.ts src/test/testing/utils.unit.test.ts
  • ✅ Passed | TypeScript compilation | node ./node_modules/typescript/bin/tsc -p ./
⚠️ Combined compile and utils unit tests diagnostic output
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\Users\bschnurr\AppData\Local\Temp\automation-job-ready-c9wl6bgb'
❌ Dependency and test discovery diagnostic output
AUTOMATION_SANDBOX_PROFILE=typescript
git: Not a git repository
node_modules-missing
mocha-missing
package-lock-present

@edvilme
Eduardo Villalpando Mello (edvilme) merged commit cd425b7 into main Sep 21, 2026
90 checks passed
@edvilme
Eduardo Villalpando Mello (edvilme) deleted the copilot/fix-copy-test-id-issue-26092 branch September 21, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug review-auto:approved Automated review: no blocking findings (approval posted).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Copy test ID" includes file:// gunk

4 participants