refactor(scanner): type the worker path and align app-test results

Move the worker scanner surface into TypeScript, add a direct worker regression, and make the version=2 app-test path populate the same visible result data and final status as the legacy scanner. This keeps the refactor bounded while making the worker route safe to exercise.

Constraint: Must preserve the existing Apple Silicon app-test behavior while changing the worker internals
Rejected: Flip production to the worker path immediately | still needs the normal deploy path and broader production soak
Confidence: medium
Scope-risk: moderate
Reversibility: clean
Directive: Keep the version=2 adapter using the shared finishFileScan path until the legacy scanner can be removed entirely
Tested: pnpm run typecheck; pnpm exec vitest run test/scanner/client.test.ts; pnpm run test:browser (original workspace); netlify build --context deploy-preview (original workspace)
Not-tested: Browser suite from the clean clone environment (local Astro dev server startup timed out there)
This commit is contained in:
ThatGuySam 2026-04-04 14:58:25 -05:00
parent 0480c47bbb
commit 689fc0d13d
10 changed files with 869 additions and 657 deletions

View file

@ -15,7 +15,7 @@ import glob from 'fast-glob'
import { LocalFileData } from 'get-file-object-from-local-path'
import { Zip } from 'zip-lib'
import { runScanWorker } from '~/helpers/scanner/client.mjs'
import { runScanWorker } from '~/helpers/scanner/client'
const appGlobOptions = {
@ -142,4 +142,3 @@ describe.concurrent('Apps', async () => {
})

View file

@ -58,11 +58,10 @@ export async function createNativeAppArchive ( appName = 'Playwright Native App'
const archiveBuffer = await readFile( archivePath )
const archiveArrayBuffer = new Uint8Array( archiveBuffer ).slice().buffer
return {
arrayBuffer: archiveBuffer.buffer.slice(
archiveBuffer.byteOffset,
archiveBuffer.byteOffset + archiveBuffer.byteLength
),
arrayBuffer: archiveArrayBuffer,
buffer: archiveBuffer,
mimeType: 'application/zip',
name: `${ appName }.app.zip`,

View file

@ -0,0 +1,48 @@
import {
describe,
expect,
it
} from 'vitest'
import '@vitest/web-worker'
import { runScanWorker } from '~/helpers/scanner/client'
import { createNativeAppArchive } from '../playwright/support/app-archive-fixture'
describe( 'scanner worker client', () => {
it( 'extracts app metadata from a zipped native app fixture', async () => {
const progressMessages: string[] = []
const archiveFile = await createNativeAppArchive()
const { scan } = await runScanWorker( archiveFile, details => {
if ( typeof details.message === 'string' ) {
progressMessages.push( details.message )
}
} )
expect( progressMessages ).toContain( ' Found Info.plist' )
expect( scan.status ).toBe( 'finished' )
expect( scan.displayName ).toBe( 'Playwright Native App' )
expect( scan.appVersion ).toBe( '1.0.0' )
expect( scan.binarySupportsNative ).toBe( true )
expect( scan.displayBinarySize.length ).toBeGreaterThan( 0 )
expect( scan.details ).toEqual( expect.arrayContaining( [
expect.objectContaining({
label: 'Bundle Identifier',
value: 'com.doesitarm.playwright-native-app'
}),
expect.objectContaining({
label: 'Version',
value: '1.0.0'
})
] ) )
expect( scan.info.filename ).toBe( 'Playwright Native App.app.zip' )
expect( scan.info.result ).toBe( '✅' )
expect( scan.info.infoPlist.CFBundleIdentifier ).toBe( 'com.doesitarm.playwright-native-app' )
expect( scan.info.machoMeta.architectures ).toEqual( expect.arrayContaining( [
expect.objectContaining({
processorType: 'ARM64'
})
] ) )
} )
} )