Files
orca/src/shared/notebook-venv-location.test.ts
T
Jinwoo Hong 5610b11703 feat(ipynb): create a .venv when pip is locked out, and show ipykernel setup progress (#22710)
* feat(ipynb): set up ipykernel in a new .venv when pip is locked out, and show install progress in the dialog

* fix(ipynb): drop the retired installFailed string from translated catalogs

* refactor(ipynb): drive the setup dialog from one setup state; fix review findings

- Kernel status now only describes the kernel; a single `setup` object (base, offer, phase, error) drives the dialog, replacing the extra statuses and the externallyManaged/setupError fields.
- The picker's 'Create virtual environment…' opens the same dialog; success switches through selectEnvironment, so a running kernel is only replaced once the venv exists.
- Async setup results are dropped when the dialog they belong to is gone (tab closed/reopened).
- main verifies ipykernel imports after pip, reuses an existing .venv instead of re-running venv over it, and explains failures that printed nothing.
- Windows copy command guards the install with if ($?); notebooks at a filesystem root get a correct .venv parent; 'Try again' shows for both retry paths.

* fix(ipynb): close the setup prompt when another Python is picked
2026-09-24 16:22:34 -04:00

18 lines
852 B
TypeScript

import { describe, expect, it } from 'vitest'
import { notebookVenvParent } from './notebook-venv-location'
describe('notebookVenvParent', () => {
it('uses the workspace root for a notebook inside it, else the notebook folder', () => {
expect(notebookVenvParent('/repo/analysis/nb.ipynb', '/repo')).toBe('/repo')
expect(notebookVenvParent('/elsewhere/nb.ipynb', '/repo')).toBe('/elsewhere')
expect(notebookVenvParent('/repo-2/nb.ipynb', '/repo')).toBe('/repo-2')
expect(notebookVenvParent('/repo/nb.ipynb', null)).toBe('/repo')
expect(notebookVenvParent('C:\\repo\\a\\nb.ipynb', 'c:\\Repo')).toBe('c:\\Repo')
})
it('keeps the root separator for a notebook at a filesystem root', () => {
expect(notebookVenvParent('/nb.ipynb', '/repo')).toBe('/')
expect(notebookVenvParent('C:\\nb.ipynb', null)).toBe('C:\\')
})
})