doesitarm/test/scanner/plist.test.ts
ThatGuySam d026a5420b
Some checks failed
Deploy to Cloudflare Workers with Wrangler / Deploy (push) Has been cancelled
Run Node 24 Checks / build (24.x) (push) Has been cancelled
fix(scanner): rename plist parser module to avoid CI cycle false positive
Madge treated the local plist parser module name as a circular dependency during the Netlify build lane after the TypeScript refactor. Rename the local module to plist-parser so the internal file no longer collides with the external plist package name, while keeping parser behavior unchanged.

Constraint: Must restore the deploy gate without changing parser semantics
Rejected: Disable the circular-dependency check | would hide a useful guard instead of fixing the naming conflict that triggered it
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Avoid naming local modules after direct external package imports when the repo relies on static dependency graph tooling
Tested: pnpm run typecheck; pnpm exec vitest run test/scanner/plist.test.ts test/scanner/file-api.test.ts test/scanner/client.test.ts test/prebuild/load-sitemap-endpoints.test.ts; pnpm run test-prebuild
Not-tested: Full production deploy completion before push
2026-04-04 18:31:46 -05:00

52 lines
1.7 KiB
TypeScript

import { Buffer } from 'buffer'
import {
describe,
expect,
it,
vi
} from 'vitest'
import {
parseFileSync,
parsePlistBuffer
} from '~/helpers/scanner/parsers/plist-parser'
type ParsedPlist = Record<string, string>
const xmlPlist = Buffer.from( [
'<?xml version="1.0" encoding="UTF-8"?>',
'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">',
'<plist version="1.0">',
'<dict>',
' <key>CFBundleExecutable</key>',
' <string>Playwright Native App</string>',
' <key>CFBundleIdentifier</key>',
' <string>com.doesitarm.playwright-native-app</string>',
'</dict>',
'</plist>'
].join( '\n' ), 'utf8' )
describe( 'plist parser', () => {
it( 'parses xml plist buffers asynchronously', async () => {
const callback = vi.fn()
const plist = await parsePlistBuffer( xmlPlist as any, callback ) as ParsedPlist
expect( plist.CFBundleExecutable ).toBe( 'Playwright Native App' )
expect( plist.CFBundleIdentifier ).toBe( 'com.doesitarm.playwright-native-app' )
expect( callback ).toHaveBeenCalledWith( null, plist )
} )
it( 'parses xml plist buffers synchronously', () => {
const plist = parseFileSync( xmlPlist as any ) as ParsedPlist
expect( plist.CFBundleExecutable ).toBe( 'Playwright Native App' )
expect( plist.CFBundleIdentifier ).toBe( 'com.doesitarm.playwright-native-app' )
} )
it( 'rejects invalid plist data', async () => {
await expect( parsePlistBuffer( Buffer.from( 'not-a-plist', 'utf8' ) as any ) )
.rejects
.toThrow( /Invalid binary plist/i )
} )
} )