test: repair benchmark runners and strengthen policy boundaries (#33183)

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
OrcaWin
2026-10-24 08:43:22 -07:00
committed by GitHub
co-authored by OrcaWin
parent df6bb97c14
commit 6f0834212e
8 changed files with 66 additions and 16 deletions
@@ -25,7 +25,10 @@ async function load(contents) {
}))
bundler.onLoad({ filter: /.*/, namespace: 'bench' }, (args) => ({
contents: args.path.endsWith('markdown-round-trip')
? 'export const getRichMarkdownRoundTripOutput = (content) => content'
? `export const getRichMarkdownRoundTripOutput = (content) => content
export const getRichMarkdownPassthroughOutput = () => {
throw new Error("unexpected editor passthrough")
}`
: 'export const translate = (_key, fallback) => fallback',
loader: 'js'
}))
@@ -25,7 +25,10 @@ async function load(contents) {
}))
bundler.onLoad({ filter: /.*/, namespace: 'bench' }, (args) => ({
contents: args.path.endsWith('markdown-round-trip')
? 'export const getRichMarkdownRoundTripOutput = () => { throw new Error("unexpected editor round trip") }'
? `export const getRichMarkdownRoundTripOutput = () => { throw new Error("unexpected editor round trip") }
export const getRichMarkdownPassthroughOutput = () => {
throw new Error("unexpected editor passthrough")
}`
: 'export const translate = (_key, fallback) => fallback',
loader: 'js'
}))
@@ -11,7 +11,7 @@ import type { RpcResponse } from './types'
// changed only where the refusal is raised.
function success(result: unknown): RpcResponse {
return { ok: true, result }
return { id: 'reply-1', ok: true, result }
}
const installed = {
@@ -62,7 +62,11 @@ describe('the endpoints reader is the endpoints contract', () => {
})
it('still raises the host code and message on a refusal, ahead of the reader', () => {
const refusal: RpcResponse = { ok: false, error: { code: 'forbidden', message: 'no' } }
const refusal: RpcResponse = {
id: 'reply-1',
ok: false,
error: { code: 'forbidden', message: 'no' }
}
expect(() => relayPairingEndpointsRead.interpret(refusal)).toThrow('forbidden: no')
})
})
@@ -78,7 +78,9 @@ describe('decoding a bundle range', () => {
vector.outputLimit - 1
)
).toString('hex')
} catch {
} catch (error) {
expect(error, vector.name).toBeInstanceOf(MobileWebBundleFetchError)
expect(error, vector.name).toMatchObject({ refusal: 'range-undecodable' })
actual = null
}
expect(actual, vector.name).toBe(vector.js)
@@ -1,9 +1,46 @@
import { describe, expect, it } from 'vitest'
import { MOBILE_WEB_PAGE_VERSION } from '../../../src/shared/mobile-web-bundle/manifest-contract'
import { MOBILE_WEB_PAGE_VERSION_FLOOR } from './mobile-web-bundle-compat'
import {
MOBILE_WEB_BUNDLE_SCHEMA_VERSION,
MOBILE_WEB_PAGE_VERSION
} from '../../../src/shared/mobile-web-bundle/manifest-contract'
import { MOBILE_WEB_BUNDLE_CAPABILITY } from '../../../src/shared/mobile-web-bundle/mobile-web-bundle-capability'
import {
MIN_COMPATIBLE_RUNTIME_CLIENT_VERSION,
MIN_COMPATIBLE_RUNTIME_SERVER_VERSION,
RUNTIME_PROTOCOL_VERSION
} from '../../../src/shared/protocol-version'
import {
evaluateMobileWebBundleCompat,
MOBILE_WEB_PAGE_VERSION_FLOOR
} from './mobile-web-bundle-compat'
describe("the shell's page floor", () => {
it('never requires a page newer than the one built beside this shell', () => {
expect(MOBILE_WEB_PAGE_VERSION_FLOOR).toBeLessThanOrEqual(MOBILE_WEB_PAGE_VERSION)
it('accepts the page built beside this shell and refuses a page below its floor', () => {
const input = {
hostCapabilities: [MOBILE_WEB_BUNDLE_CAPABILITY],
hostStatus: {
protocolVersion: RUNTIME_PROTOCOL_VERSION,
minCompatibleMobileVersion: MIN_COMPATIBLE_RUNTIME_CLIENT_VERSION
},
manifest: {
schemaVersion: MOBILE_WEB_BUNDLE_SCHEMA_VERSION,
runtimeProtocolVersion: RUNTIME_PROTOCOL_VERSION,
minCompatibleRuntimeProtocolVersion: MIN_COMPATIBLE_RUNTIME_SERVER_VERSION,
pageVersion: MOBILE_WEB_PAGE_VERSION
}
}
expect(evaluateMobileWebBundleCompat(input)).toEqual({ kind: 'ok', manifestChecked: true })
expect(
evaluateMobileWebBundleCompat({
...input,
manifest: { ...input.manifest, pageVersion: MOBILE_WEB_PAGE_VERSION_FLOOR - 1 }
})
).toEqual({
kind: 'blocked',
reason: 'bundle-incompatible',
side: 'desktop',
pageVersion: MOBILE_WEB_PAGE_VERSION_FLOOR - 1,
requiredPageVersion: MOBILE_WEB_PAGE_VERSION_FLOOR
})
})
})
-1
View File
@@ -94,7 +94,6 @@ src/transport/mobile-relay-background-lifecycle.test.ts
src/transport/mobile-relay-direct-upgrade.test.ts
src/transport/mobile-relay-e2ee-link.test.ts
src/transport/mobile-relay-pairing-recovery.test.ts
src/transport/mobile-relay-pairing-reply.test.ts
src/transport/mobile-relay-physical-client.test.ts
src/transport/mobile-relay-reconnect-controller.test.ts
src/transport/mobile-relay-resume-director.test.ts
@@ -123,14 +123,16 @@ describe('ensureOrcaCliAvailableForAgentSkillTerminal', () => {
})
const pending = ensureOrcaCliAvailableForAgentSkillTerminal({ registrationPromptDelayMs: 700 })
await vi.waitFor(() => {
expect(toast.message).toHaveBeenCalledWith(CLI_PREREQUISITE_REGISTRATION_TOAST, {
description: CLI_PREREQUISITE_REGISTRATION_TOAST_DESCRIPTION
})
await Promise.resolve()
expect(toast.message).toHaveBeenCalledWith(CLI_PREREQUISITE_REGISTRATION_TOAST, {
description: CLI_PREREQUISITE_REGISTRATION_TOAST_DESCRIPTION
})
expect(install).not.toHaveBeenCalled()
await vi.advanceTimersByTimeAsync(700)
await vi.advanceTimersByTimeAsync(699)
expect(install).not.toHaveBeenCalled()
await vi.advanceTimersByTimeAsync(1)
await expect(pending).resolves.toBe(installed)
expect(install).toHaveBeenCalledTimes(1)
})
@@ -13,7 +13,7 @@ describe('agentVerdictStatusLine', () => {
...FAILED,
agentType: 'rsync',
lastAssistantMessage: 'rsync failed',
programStatus: { state: 'error', message: 'rsync failed', observedAt: 1 }
programStatus: { state: 'error', message: 'Transfer interrupted', observedAt: 1 }
})
).toBe('Failed: rsync failed')
})