Files
orca/config/scripts/test-runtime/module-cache/vitest-module-cache-resolution-key.test.ts
T
Neil 9bd6272fdf refactor(tooling): organize build, CI, and test owners (#38130)
* refactor(tooling): organize test runtime and maintenance owners

* test(tooling): preserve relocated runtime fixture dependency edges

* refactor(tooling): preserve xterm routing owner checks

* ci(tooling): include routing owner in sparse checkout

* test(tooling): preserve copied workflow dependency closures

* fix(tooling): normalize hashed JSON assets in release parity

* fix(tooling): distinguish asset aliases from literal references

* fix(tooling): frame normalized asset reference payloads

* fix(tooling): normalize decoded JSON asset references

* refactor(tooling): organize build, CI and release owners

* fix(tooling): align moved generator and workflow path contracts

* fix(tooling): update generated plugin bundle owner banners

* test(tooling): create relocated mobile verifier fixture directories

* test(tooling): copy headless detector dependency closure

* test(tooling): align native batch policy fixtures with owner path

* fix(tooling): link moved reliability command to historical evidence

* fix(tooling): preserve nested sandbox owners and canonical guide source

* fix(tooling): target release version owners in checkout fixture
2026-11-04 21:08:19 -08:00

37 lines
1.4 KiB
TypeScript

import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, expect, it } from 'vitest'
import { createResolutionFingerprint } from './vitest-module-cache-resolution-key'
const roots: string[] = []
afterEach(() => {
for (const root of roots.splice(0)) {
rmSync(root, { recursive: true, force: true })
}
})
function fixture(): string {
const root = mkdtempSync(join(tmpdir(), 'orca-resolution-key-'))
roots.push(root)
mkdirSync(join(root, 'src/lib/foo'), { recursive: true })
writeFileSync(join(root, 'src/lib/foo/index.ts'), '')
return root
}
const source = "import a from './lib/foo'\nimport b from '@/lib/foo?raw'"
const aliases = (root: string) => [{ find: '@', replacement: join(root, 'src') }]
it.each([
['a same-stem sibling shadows a directory index', 'src/lib/foo.ts'],
['a higher-precedence extension appears', 'src/lib/foo.mts'],
['another index candidate appears', 'src/lib/foo/index.mts'],
['the directory gains a package.json', 'src/lib/foo/package.json']
])('changes the key when %s', (_, added) => {
const root = fixture()
const before = createResolutionFingerprint(root, aliases(root))(join(root, 'src/a.ts'), source)
writeFileSync(join(root, added), '{}')
const after = createResolutionFingerprint(root, aliases(root))(join(root, 'src/a.ts'), source)
expect(after).not.toBe(before)
})