Files
orca/src/shared/runtime-workspace-file-owner.test.ts
T
Jihwan KimandOrcaWin 5bd2f59d29 fix(runtime): open files from sibling workspaces (#11369)
* feat(runtime): match files to workspace owners

* fix(runtime): resolve terminal paths through sibling workspaces

* fix(editor): route restored sibling workspace files

* fix remote sibling file ownership routing

* fix(editor): migrate restored sibling file owners

* fix(editor): revalidate restored owner activation

* docs(review): record PR 11369 correction evidence

* fix(editor): reject collision before activation prep

* docs(review): record PR 11369 final correction

* fix(editor): retain projected reconciliation narrowing

* chore(review): keep verification artifacts out of PR

* fix(editor): harden restored owner migration

* fix(runtime): resolve workspace root terminal paths

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-08-03 21:41:58 -07:00

75 lines
2.2 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { findRuntimeWorkspaceFileOwner } from './runtime-workspace-file-owner'
describe('findRuntimeWorkspaceFileOwner', () => {
const roots = [
{ workspaceId: 'repo-a', rootPath: '/srv/repo-a', executionHostId: 'runtime:host-a' as const },
{ workspaceId: 'repo-b', rootPath: '/srv/repo-b', executionHostId: 'runtime:host-a' as const },
{
workspaceId: 'repo-b-docs',
rootPath: '/srv/repo-b/docs',
executionHostId: 'runtime:host-a' as const
},
{
workspaceId: 'other-host',
rootPath: '/srv/repo-b',
executionHostId: 'runtime:host-b' as const
}
]
it('finds a sibling workspace on the same execution host', () => {
expect(
findRuntimeWorkspaceFileOwner(roots, '/srv/repo-b/src/index.ts', 'runtime:host-a')
).toMatchObject({
workspaceId: 'repo-b',
relativePath: 'src/index.ts'
})
})
it('uses the most specific nested workspace root', () => {
expect(
findRuntimeWorkspaceFileOwner(roots, '/srv/repo-b/docs/guide.md', 'runtime:host-a')
).toMatchObject({
workspaceId: 'repo-b-docs',
relativePath: 'guide.md'
})
})
it('uses an exact nested workspace root instead of its parent', () => {
expect(
findRuntimeWorkspaceFileOwner(roots, '/srv/repo-b/docs', 'runtime:host-a')
).toMatchObject({
workspaceId: 'repo-b-docs',
relativePath: ''
})
})
it('does not cross execution-host boundaries', () => {
expect(
findRuntimeWorkspaceFileOwner(roots, '/srv/repo-b/src/index.ts', 'runtime:host-b')
).toMatchObject({
workspaceId: 'other-host'
})
expect(findRuntimeWorkspaceFileOwner(roots, '/srv/repo-a/file.ts', 'runtime:host-b')).toBeNull()
})
it('matches Windows roots without case-sensitive drive assumptions', () => {
expect(
findRuntimeWorkspaceFileOwner(
[
{
workspaceId: 'windows-repo',
rootPath: 'C:\\Work\\Repo',
executionHostId: 'runtime:windows'
}
],
'c:\\work\\repo\\src\\index.ts',
'runtime:windows'
)
).toMatchObject({
workspaceId: 'windows-repo',
relativePath: 'src/index.ts'
})
})
})