mirror of
https://github.com/stablyai/orca.git
synced 2026-11-01 17:47:40 +00:00
* test: remove redundant cases and repair behavioral assertions * docs: reconcile audit records with current main * fix(deps): apply security updates from #32101 Apply the six-file DOMPurify 3.4.17 and Next.js 16.4.1 patch from PR #32101 to resolve the dependency security gate for this test audit. Original patch by Brennan Benson. * test: satisfy changed-line quality gates Add required braces and replace filter indexing with find. Rerun both CI quality gates and the 27 affected relay tests; refresh audit hashes and record the corrections. --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
import type { platformApi } from './platform-bridge'
|
|
|
|
const mocks = vi.hoisted(() => ({ getLinuxDisplayServer: vi.fn(() => null) }))
|
|
|
|
vi.mock('../preload-runtime-support', () => ({
|
|
getLinuxDisplayServer: mocks.getLinuxDisplayServer
|
|
}))
|
|
|
|
// Electron declares getSystemVersion as required on NodeJS.Process; Node does not have it.
|
|
const mutableProcess = process as unknown as { getSystemVersion?: () => string }
|
|
|
|
async function loadPlatformApi(): Promise<typeof platformApi> {
|
|
vi.resetModules()
|
|
return (await import('./platform-bridge')).platformApi
|
|
}
|
|
|
|
describe('platformApi.get', () => {
|
|
beforeEach(() => {
|
|
mocks.getLinuxDisplayServer.mockClear()
|
|
})
|
|
|
|
afterEach(() => {
|
|
delete mutableProcess.getSystemVersion
|
|
})
|
|
|
|
it('resolves the immutable payload once and returns the identical object', async () => {
|
|
const platformApi = await loadPlatformApi()
|
|
const getSystemVersion = vi.fn(() => '25.3.0')
|
|
mutableProcess.getSystemVersion = getSystemVersion
|
|
|
|
const first = platformApi.get()
|
|
expect(platformApi.get()).toBe(first)
|
|
expect(Object.isFrozen(first)).toBe(true)
|
|
|
|
expect(getSystemVersion).toHaveBeenCalledTimes(1)
|
|
expect(mocks.getLinuxDisplayServer).toHaveBeenCalledTimes(1)
|
|
expect(first.platform).toBe(process.platform)
|
|
expect(first.arch).toBe(process.arch)
|
|
expect(first.osRelease).toBe('25.3.0')
|
|
})
|
|
|
|
it('resolves nothing before the first get, keeping preload startup free', async () => {
|
|
await loadPlatformApi()
|
|
|
|
expect(mocks.getLinuxDisplayServer).not.toHaveBeenCalled()
|
|
})
|
|
})
|