mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-15 06:35:20 -07:00
Replace all in-scope axios callsites with a new helpers/http.js wrapper over native fetch, including JSON/text GET, JSON POST, HEAD checks, and transient 5xx retry behavior; update all browser, build, script, and proxy API clients to use it; add focused unit tests; and remove axios from package dependencies. Constraint: Preserve API/build and deployment behavior while lowering transport surface area. Rejected: inline fetch replacements at each callsite | rejected to avoid inconsistent error/retry semantics. Confidence: high Scope-risk: moderate Directive: Keep helper in place as the transport boundary and update tests when changing request semantics. Tested: pnpm run -s typecheck, pnpm -s run test-prebuild, pnpm -s run test, pnpm -s run test:browser, pnpm -s run netlify-build, smoke GETs on /apple-silicon-app-test and /apple-silicon-app-test/?version=2 Not-tested: branch/netlify deployment health in CI pipeline after merge
53 lines
1.6 KiB
TypeScript
53 lines
1.6 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)
|
|
})
|
|
})
|