Files
orca/config/scripts/mobile-web-app-module-closure-entrypoints.test.mjs
T
Neil 7a47f465a3 ci: trim redundant tests and consolidate suite startup (#29156)
* ci: trim redundant tests and consolidate suite startup

* ci: repair consolidated suite names and gate references
2026-10-15 07:11:58 -07:00

40 lines
1.7 KiB
JavaScript

import { mkdtemp, mkdir, rm, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { expect, it } from 'vitest'
import { mobileWebAppModuleClosure } from './build-mobile-web-app-bundle.mjs'
it('resolves local entry paths against the requested tree and selects browser siblings', async () => {
const root = await mkdtemp(join(tmpdir(), 'orca-route-entrypoints-'))
const modules = ['app/_layout', 'app/h/_layout', 'app/h/[hostId]/index']
const expected = [
'app/_layout.web.tsx',
'app/h/_layout.tsx',
'app/h/[hostId]/browser-dependency.ts',
'app/h/[hostId]/index.web.tsx'
].sort()
try {
await mkdir(join(root, 'app/h/[hostId]'), { recursive: true })
await writeFile(join(root, 'app/_layout.tsx'), "import 'native-only-layout'")
await writeFile(join(root, 'app/_layout.web.tsx'), 'export const layout = true')
await writeFile(join(root, 'app/h/_layout.tsx'), 'export const nestedLayout = true')
await writeFile(join(root, 'app/h/[hostId]/index.tsx'), "import 'native-only-package'")
await writeFile(join(root, 'app/h/[hostId]/index.web.tsx'), "import './browser-dependency'")
await writeFile(
join(root, 'app/h/[hostId]/browser-dependency.ts'),
'export const browser = true'
)
for (const entries of [
modules,
modules.map((entry) => `${entry}.tsx`),
modules.map((entry) => `./${entry}.tsx`),
modules.map((entry) => join(root, `${entry}.tsx`))
]) {
const { local } = await mobileWebAppModuleClosure(entries, { absWorkingDir: root })
expect(local.map((file) => file.replaceAll('\\', '/')).sort()).toEqual(expected)
}
} finally {
await rm(root, { recursive: true, force: true })
}
})