From 88c7c19233ebde285d30bac08cf0e72f46d98923 Mon Sep 17 00:00:00 2001 From: OrcaWin <293788423+OrcaWin@users.noreply.github.com> Date: Sun, 8 Nov 2026 18:40:58 -0800 Subject: [PATCH] test: remove marginal mobile web build helper cases --- .../build-mobile-web-app-bundle.test.mjs | 36 +------ .../mobile-web-bundle-manifest.test.mjs | 50 ---------- .../mobile-web-page-routes.test.mjs | 99 ------------------- .../mobile-web-source-line-endings.test.mjs | 19 ---- 4 files changed, 1 insertion(+), 203 deletions(-) delete mode 100644 config/scripts/build/mobile-web-app/mobile-web-bundle-manifest.test.mjs delete mode 100644 config/scripts/build/mobile-web-app/mobile-web-page-routes.test.mjs delete mode 100644 config/scripts/build/mobile-web-app/mobile-web-source-line-endings.test.mjs diff --git a/config/scripts/build/mobile-web-app/build-mobile-web-app-bundle.test.mjs b/config/scripts/build/mobile-web-app/build-mobile-web-app-bundle.test.mjs index 7d97c713144..a1d27b2dbec 100644 --- a/config/scripts/build/mobile-web-app/build-mobile-web-app-bundle.test.mjs +++ b/config/scripts/build/mobile-web-app/build-mobile-web-app-bundle.test.mjs @@ -5,11 +5,7 @@ import { withScratch, copyWrittenBundle } from '../../mobile-web-app/mobile-web-app-bundle-test-fixture.mjs' -import { - bundleMobileWebApp, - renameOutputsByContent, - routeChunkNames -} from './build-mobile-web-app-bundle.mjs' +import { bundleMobileWebApp } from './build-mobile-web-app-bundle.mjs' import { MOBILE_WEB_APP_ROUTE_ROOT } from '../../mobile-web-app/mobile-web-app-route-manifest.mjs' import { verifyMobileWebAppBundle } from './verify-mobile-web-app-bundle.mjs' import { @@ -141,33 +137,3 @@ describe('the verifier', () => { 240_000 ) }) - -describe('naming an output by its bytes', () => { - it('refuses two outputs that name each other', () => { - const emitted = (text) => new TextEncoder().encode(text) - const metafile = { - outputs: { - 'dist/a.js': { imports: [{ path: 'dist/b.js', kind: 'import-statement' }] }, - 'dist/b.js': { imports: [{ path: 'dist/a.js', kind: 'import-statement' }] } - } - } - // Cycles have no final dependency names/content hash; fail if esbuild ever stops emitting a DAG. - expect(() => - renameOutputsByContent(metafile, [ - { path: 'dist/a.js', contents: emitted('import "/assets/b.js"') }, - { path: 'dist/b.js', contents: emitted('import "/assets/a.js"') } - ]) - ).toThrow(/output cycle/) - }) - - it('refuses a route it cannot find an output for', async () => { - await withScratch(async (scratch) => { - const module = join(scratch, 'index.tsx') - await writeFile(module, 'export default function Route() { return null }\n') - // Only metafile maps routes to chunks; missing output must fail before phones request undefined/404. - expect(() => - routeChunkNames({ outputs: {} }, [{ key: './index.tsx', module }], new Map()) - ).toThrow(/\.\/index\.tsx reached no output/) - }) - }) -}) diff --git a/config/scripts/build/mobile-web-app/mobile-web-bundle-manifest.test.mjs b/config/scripts/build/mobile-web-app/mobile-web-bundle-manifest.test.mjs deleted file mode 100644 index e00c3366b52..00000000000 --- a/config/scripts/build/mobile-web-app/mobile-web-bundle-manifest.test.mjs +++ /dev/null @@ -1,50 +0,0 @@ -import { existsSync } from 'node:fs' -import { mkdtemp, rm } from 'node:fs/promises' -import { tmpdir } from 'node:os' -import { join } from 'node:path' -import { describe, expect, it } from 'vitest' -import { - contentTypeForExtension, - hashedAsset, - sha256Hex, - writeMobileWebBundleTree -} from './mobile-web-bundle-manifest.mjs' - -describe('hashedAsset', () => { - it('refuses an extension with no registered content type', () => { - // Unknown content type must fail rather than leave phone guessing how to serve addressed bytes. - expect(() => hashedAsset(Buffer.from('body'), 'wasm')).toThrow(/no content type registered/) - }) -}) - -describe('writeMobileWebBundleTree', () => { - it('marks a dark build outside the manifest, so its buildId is the same tree’s', async () => { - const outDir = await mkdtemp(join(tmpdir(), 'mobile-web-bundle-manifest-')) - try { - const bytes = Buffer.from('\n', 'utf8') - const tree = (env) => - writeMobileWebBundleTree({ - outDir, - written: [ - { - path: 'index.html', - bytes, - sha256: sha256Hex(bytes), - byteLength: bytes.byteLength, - contentType: contentTypeForExtension('html') - } - ], - desktopVersion: '1.0.0', - protocolWindow: { runtimeProtocolVersion: 3, minCompatibleRuntimeProtocolVersion: 3 }, - env - }) - const dark = await tree({ ORCA_SIDEBAR_INPUTS: 'main' }) - expect(existsSync(join(outDir, 'ORCA_SIDEBAR_INPUTS_MAIN'))).toBe(true) - const off = await tree({}) - expect(existsSync(join(outDir, 'ORCA_SIDEBAR_INPUTS_MAIN'))).toBe(false) - expect(dark.manifest.buildId).toBe(off.manifest.buildId) - } finally { - await rm(outDir, { recursive: true, force: true }) - } - }) -}) diff --git a/config/scripts/build/mobile-web-app/mobile-web-page-routes.test.mjs b/config/scripts/build/mobile-web-app/mobile-web-page-routes.test.mjs deleted file mode 100644 index eb7522f2543..00000000000 --- a/config/scripts/build/mobile-web-app/mobile-web-page-routes.test.mjs +++ /dev/null @@ -1,99 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { - MOBILE_WEB_BUNDLE_MAX_ROUTE_GRANTS, - MobileWebBundleRouteSchema -} from '../../../../src/shared/mobile-web-bundle/manifest-contract.ts' -import { resolveMobileWebPageRoutes } from './build-mobile-web-app-bundle.mjs' -import { MOBILE_WEB_PAGE_ROUTES } from './mobile-web-page-routes.mjs' -import { routePathnameFromKey } from '../../mobile-web-app/mobile-web-app-route-manifest.mjs' - -// Test declared screens separately from bundle mechanics so route inventory can grow without coupling builder test size. - -describe('the page routes the manifest declares', () => { - it('turns a route key into the URL pattern expo-router gives it', () => { - expect(routePathnameFromKey('./h/[hostId]/index.tsx')).toBe('/h/[hostId]') - expect(routePathnameFromKey('./h/[hostId]/tasks.tsx')).toBe('/h/[hostId]/tasks') - expect(routePathnameFromKey('./h/[hostId]/session/[worktreeId].tsx')).toBe( - '/h/[hostId]/session/[worktreeId]' - ) - }) - - it('answers null for a layout, which is not a screen anyone navigates to', () => { - expect(routePathnameFromKey('./h/_layout.tsx')).toBeNull() - expect(routePathnameFromKey('./h/[hostId]/_layout.tsx')).toBeNull() - }) - - // Synthetic optional-grant input checks member-by-member mapping; newly declared field must survive builder map before reaching phone. - it('carries an optional grant list through, and writes no key for a route without one', () => { - expect( - resolveMobileWebPageRoutes( - ['./h/[hostId]/index.tsx', './h/[hostId]/tasks.tsx'], - [ - { - pathname: '/h/[hostId]', - grants: ['navigate'], - optionalGrants: ['externalNavigation'] - }, - { pathname: '/h/[hostId]/tasks', grants: ['navigate'], optionalGrants: [] } - ] - ) - ).toEqual([ - { pathname: '/h/[hostId]', grants: ['navigate'], optionalGrants: ['externalNavigation'] }, - { pathname: '/h/[hostId]/tasks', grants: ['navigate'] } - ]) - }) - - it('carries the host-area declaration through, and writes no key where there is none', () => { - expect( - resolveMobileWebPageRoutes( - ['./h/[hostId]/index.tsx', './h/[hostId]/tasks.tsx'], - [ - { pathname: '/h/[hostId]', grants: ['navigate'], canOwnHostArea: true }, - { pathname: '/h/[hostId]/tasks', grants: ['navigate'] } - ] - ) - ).toEqual([ - { pathname: '/h/[hostId]', grants: ['navigate'], canOwnHostArea: true }, - { pathname: '/h/[hostId]/tasks', grants: ['navigate'] } - ]) - }) - - /** - * The wide iPad's host-area session is granted every served route's list, so its in-page hops - * stay in the page. Bounded by what one route can be granted, so that grant never outgrows one route's. - */ - - // The phone refuses the whole manifest over one bad route, which takes every page down. - it('declares only routes the manifest schema accepts', () => { - for (const route of MOBILE_WEB_PAGE_ROUTES) { - expect( - MobileWebBundleRouteSchema.safeParse(route).error?.issues ?? [], - route.pathname - ).toEqual([]) - } - }) - - it('holds the optional lane to the manifest grammar and its own ceiling', () => { - // Released shells read each list against the ceiling on its own, so the writer bounds each the same way. - const withOptional = (optionalGrants, grants = []) => - MobileWebBundleRouteSchema.safeParse({ pathname: '/h/[hostId]', grants, optionalGrants }) - .success - expect(withOptional(['externalNavigation'])).toBe(true) - expect(withOptional(['native.externalNavigation'])).toBe(false) - const names = (count, prefix) => - Array.from({ length: count }, (_value, index) => `${prefix}${String(index)}`) - const cap = MOBILE_WEB_BUNDLE_MAX_ROUTE_GRANTS - expect(withOptional(names(cap, 'opt'), names(cap, 'req'))).toBe(true) - expect(withOptional(names(cap + 1, 'opt'))).toBe(false) - }) - - it('fails the build on a declaration the bundle cannot render', () => { - // Declared-but-unbundled route opens page then paints Unmatched; catch mismatch at declaration. - expect(() => - resolveMobileWebPageRoutes( - ['./h/[hostId]/index.tsx'], - [{ pathname: '/h/[hostId]/gone', grants: [] }] - ) - ).toThrow('has no module in the bundle') - }) -}) diff --git a/config/scripts/build/mobile-web-app/mobile-web-source-line-endings.test.mjs b/config/scripts/build/mobile-web-app/mobile-web-source-line-endings.test.mjs deleted file mode 100644 index e5df4594bb8..00000000000 --- a/config/scripts/build/mobile-web-app/mobile-web-source-line-endings.test.mjs +++ /dev/null @@ -1,19 +0,0 @@ -import { mkdtemp, rm, writeFile } from 'node:fs/promises' -import { tmpdir } from 'node:os' -import { join } from 'node:path' -import { describe, expect, it } from 'vitest' -import { assertNoCarriageReturnsInSource } from './mobile-web-source-line-endings.mjs' - -describe('assertNoCarriageReturnsInSource', () => { - it('rejects a CRLF source file, because CRLF changes every asset hash and the buildId', async () => { - const scratch = await mkdtemp(join(tmpdir(), 'orca-mobile-web-eol-')) - try { - await writeFile(join(scratch, 'route.tsx'), 'const a = 1\r\nconst b = 2\r\n', 'utf8') - await expect(assertNoCarriageReturnsInSource(scratch)).rejects.toThrow( - /CRLF in mobile web source/ - ) - } finally { - await rm(scratch, { recursive: true, force: true }) - } - }) -})