test: remove notification, icon and native policy inventories (#41375)

* test: remove notification and native policy inventories

* test: remove icon projection samples and tray suite

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
OrcaWin
2026-11-11 20:54:07 -08:00
committed by GitHub
co-authored by OrcaWin
parent f4f332e7d5
commit bbe22681c2
13 changed files with 20 additions and 428 deletions
@@ -200,19 +200,6 @@ test('refuses to release a lease another run now holds', async () => {
assert.equal(storage.state.object.generation, '1500')
})
test('fails closed when the bucket answers 5xx', async () => {
const storage = fakeStorage({
faults: [{ when: (request) => request.method === 'GET', status: 503 }]
})
const error = await leaseFor(storage)
.acquire(HOLDER)
.catch((thrown) => thrown)
assert.match(error.message, /lease inspection failed: 503/)
assert.equal(storage.state.requests.filter((request) => request.method !== 'GET').length, 0)
})
test('treats an unreadable record as held, not free', async () => {
const storage = fakeStorage({
object: { generation: '1500', body: { holder_key: 'stablyai/orca/9001' } }
@@ -239,17 +226,3 @@ test('renewal rewrites only expires_at on the observed generation', async () =>
assert.equal(storage.state.object.body.acquired_at, NOW)
assert.equal(storage.state.object.body.holder_key, HOLDER.holderKey)
})
test('renewal stops once the object belongs to someone else', async () => {
const storage = fakeStorage({
object: {
generation: '1500',
body: storedRecord({ holderKey: 'stablyai/orca/9001', expiresAt: NOW + 60_000 })
}
})
assert.deepEqual(await leaseFor(storage).renew(HOLDER.holderKey), {
renewed: false,
reason: 'foreign'
})
})
File diff suppressed because one or more lines are too long
@@ -2065,7 +2065,6 @@
"src/main/ipc/markdown-documents-ripgrep.test.ts": 289,
"src/main/ipc/mobile.test.ts": 1861,
"src/main/ipc/notebook-project-link.test.ts": 548,
"src/main/ipc/notifications-custom-sound.test.ts": 289,
"src/main/ipc/notifications-message-formatting.test.ts": 229,
"src/main/ipc/notifications-subject-retirement.test.ts": 304,
"src/main/ipc/profiles/orca-profiles-switch-persistence.test.ts": 2761,
@@ -4026,7 +4025,6 @@
"src/main/text-generation/source-control-wsl-launch.test.ts": 482,
"src/main/text-generation/source-control-wsl-prompt.test.ts": 2440,
"src/main/tray/system-tray.test.ts": 556,
"src/main/tray/tray-attention-icon.test.ts": 52,
"src/main/tray/tray-dev-badge.test.ts": 51,
"src/main/updater/updater-events.test.ts": 280,
"src/main/updater/updater-linux-package-recovery-actions.test.ts": 2294,
@@ -17,7 +17,5 @@ android {
dependencies {
// react-native-webview already ships this exact version; no new APK artifact.
implementation 'androidx.webkit:webkit:1.14.0'
// JVM android.jar stubs org.json; manifest checks need the real parser.
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.json:json:20240303'
}
@@ -1,67 +0,0 @@
package expo.modules.orcamobilewebshell
import java.io.File
import org.json.JSONArray
import org.json.JSONObject
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Test
private val DIRECTORY = File("/tmp/generation")
private fun asset(path: Any, contentType: Any): JSONObject =
JSONObject().put("path", path).put("contentType", contentType)
private fun manifest(
schemaVersion: Any = 1,
entrypoint: Any = "index.html",
assets: List<JSONObject> = listOf(
asset("index.html", "text/html; charset=utf-8"),
asset("assets/aa.js", "text/javascript; charset=utf-8"),
asset("assets/bb.png", "image/png")
)
): String = JSONObject()
.put("schemaVersion", schemaVersion)
.put("entrypoint", entrypoint)
.put("assets", JSONArray(assets))
.toString()
private fun make(json: String) = MobileWebShellGeneration.make(json, DIRECTORY)
class MobileWebShellGenerationTest {
@Test
fun `refuses a manifest whose shape it does not recognise`() {
assertNull(make("not json"))
assertNull(make("[]"))
assertNull(make(manifest(schemaVersion = 2)))
assertNull(make(manifest(schemaVersion = "1")))
assertNull(make(manifest(entrypoint = "start.html")))
assertNull(make(manifest(assets = emptyList())))
// Without the entrypoint among the assets, "/" would map to a file nobody declared.
assertNull(make(manifest(assets = listOf(asset("assets/aa.js", "text/javascript")))))
assertNull(make(manifest(assets = (0..256).map { asset("assets/a$it.js", "text/javascript") })))
assertNotNull(make(manifest(assets = listOf(asset("index.html", "text/html")) +
(0..254).map { asset("assets/a$it.js", "text/javascript") })))
}
@Test
fun `refuses a manifest that declares a path or a content type it will not serve`() {
assertNull(make(manifest(assets = listOf(
asset("index.html", "text/html"),
asset("../escape.js", "text/javascript")
))))
assertNull(make(manifest(assets = listOf(
asset("index.html", "text/html"),
asset("assets/aa.js", "text/javascript\r\nX-Injected: 1")
))))
assertNull(make(manifest(assets = listOf(
asset("index.html", "text/html"),
asset(7, "text/javascript")
))))
assertNull(make(manifest(assets = listOf(
asset("index.html", "text/html"),
asset("assets/aa.js", 7)
))))
}
}
@@ -1,57 +0,0 @@
package expo.modules.orcamobilewebshell
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test
private const val SESSION = "sess-01JN_aZ9"
private fun parts(
path: String?,
method: String = "GET",
hasRangeHeader: Boolean = false,
scheme: String? = "https",
host: String? = mobileWebShellOriginHost(SESSION),
port: Int = -1,
userInfo: String? = null,
query: String? = null,
fragment: String? = null,
urlLength: Int = 64
) = MobileWebShellRequestParts(
method = method,
hasRangeHeader = hasRangeHeader,
scheme = scheme,
host = host,
port = port,
userInfo = userInfo,
query = query,
fragment = fragment,
encodedPath = path,
urlLength = urlLength
)
private fun resolve(request: MobileWebShellRequestParts): String? =
resolveMobileWebShellRequestPath(request, mobileWebShellOriginHost(SESSION)!!)
class MobileWebShellOriginTest {
@Test
fun `refuses everything outside a plain GET on this origin`() {
assertNull(resolve(parts("/", method = "POST")))
assertNull(resolve(parts("/", method = "HEAD")))
assertNull(resolve(parts("/", hasRangeHeader = true)))
assertNull(resolve(parts("/", scheme = "http")))
assertNull(resolve(parts("/", scheme = null)))
assertNull(resolve(parts("/", host = "other.orca-mobile-web.invalid")))
assertNull(resolve(parts("/", host = null)))
assertNull(resolve(parts("/", port = 443)))
assertNull(resolve(parts("/", userInfo = "someone")))
assertNull(resolve(parts("/", query = "v=1")))
assertNull(resolve(parts("/", fragment = "frag")))
assertNull(resolve(parts("/assets/%2e%2e/etc")))
assertNull(resolve(parts("assets/aa.js")))
assertNull(resolve(parts(null)))
assertEquals("/", resolve(parts("/", urlLength = 8 * 1024)))
assertNull(resolve(parts("/", urlLength = 8 * 1024 + 1)))
}
}
@@ -84,7 +84,6 @@ function New-OrcaSnapshot { [pscustomobject]@{} }
foreach ($case in @(
@{ tool = "click"; x = 5; y = 6 },
@{ tool = "click"; x = 5; y = 6; modifiers = "ctrl" },
@{ tool = "scroll"; x = 5; y = 6; direction = "down"; pages = 1 },
@{ tool = "drag"; from_x = 5; from_y = 6; to_x = 25; to_y = 26 }
)) {
@@ -1,61 +0,0 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { getLoadSoundHandler, resetNotificationDispatchMocks } from './notifications-test-harness'
vi.mock('electron', async () =>
(await import('./notifications-test-harness')).createElectronModuleMock()
)
vi.mock('./notification-authorization-status', async () =>
(await import('./notifications-test-harness')).createNotificationAuthorizationModuleMock()
)
vi.mock('./ui', async () =>
(await import('./notifications-test-harness')).createTrustedUIRendererModuleMock()
)
vi.mock('../tray/system-tray', async () =>
(await import('./notifications-test-harness')).createSystemTrayModuleMock()
)
import { registerNotificationHandlers } from './notifications'
describe('registerNotificationHandlers', () => {
let tempDir: string
beforeEach(() => {
vi.useFakeTimers()
vi.setSystemTime(new Date('2026-03-28T16:00:00Z'))
tempDir = mkdtempSync(join(tmpdir(), 'orca-notification-test-'))
resetNotificationDispatchMocks()
})
afterEach(() => {
rmSync(tempDir, { recursive: true, force: true })
})
it('loads allowed custom sound files for preload playback', async () => {
const soundPath = join(tempDir, 'sound.ogg')
writeFileSync(soundPath, Buffer.from([1, 2, 3]))
registerNotificationHandlers({
getSettings: () => ({
notifications: {
enabled: true,
agentTaskComplete: true,
terminalBell: true,
suppressWhenFocused: false,
customSoundPath: soundPath
}
})
} as never)
const handler = getLoadSoundHandler()
await expect(handler({})).resolves.toMatchObject({
ok: true,
data: new Uint8Array([1, 2, 3]),
mimeType: 'audio/ogg'
})
})
})
@@ -65,46 +65,4 @@ describe('registerNotificationHandlers', () => {
body: 'Claude finished.'
})
})
it('normalizes custom agent labels and re-bounds multiline assistant previews', async () => {
registerNotificationHandlers({
getSettings: () => ({
notifications: {
enabled: true,
agentTaskComplete: true,
terminalBell: false,
suppressWhenFocused: false
}
})
} as never)
const longAssistantMessage = `Line one\n\n${'x'.repeat(400)}`
const handler = getDispatchHandler()
expect(
await handler(
{},
{
source: 'agent-task-complete',
worktreeId: 'repo::wt1',
worktreeLabel: 'feat/notis',
agentType: 'builder\nagent',
agentState: 'done',
agentLastAssistantMessage: longAssistantMessage
}
)
).toEqual({ delivered: true })
const options = (
notificationCtorMock.mock.calls as unknown as [{ title: string; body: string }][]
)[0]?.[0]
if (!options) {
throw new Error('Expected notification options')
}
expect(options).toMatchObject({
title: 'feat/notis - builder agent finished'
})
expect(options.body).toMatch(/^Line one x+/)
expect(options.body).not.toContain('\n')
expect(options.body.length).toBeLessThanOrEqual(180)
})
})
@@ -131,10 +131,6 @@ export function getOpenSystemSettingsHandler(): (event: unknown) => unknown {
return findRegisteredHandler('notifications:openSystemSettings') as (event: unknown) => unknown
}
export function getLoadSoundHandler(): (event: unknown) => Promise<unknown> {
return findRegisteredHandler('notifications:loadSound') as (event: unknown) => Promise<unknown>
}
export function getResolveSoundPathHandler(): (event: unknown) => unknown {
return findRegisteredHandler('notifications:resolveSoundPath') as (event: unknown) => unknown
}
@@ -46,62 +46,7 @@ function setup(
const ENCODED = new Uint8Array([1, 2, 3])
const ENCODED_URL = 'data:image/png;base64,AQID'
describe('RepoIconDataUrls without an encoder (orcad)', () => {
it('passes a small fetched image through as a data URL', async () => {
const bytes = pngHeader(64, 64)
const { icons } = setup([repo('a', AVATAR)])
const id = repoIconId(AVATAR)!
expect(await icons.read([id])).toEqual({
icons: [{ id, dataUrl: `data:image/png;base64,${Buffer.from(bytes).toString('base64')}` }]
})
})
it('falls back for an upload too large to pass through', async () => {
const icon = upload(pngHeader(64, 64, MAX_REPO_ICON_DATA_URL_BYTES))
const { icons } = setup([repo('a', icon)])
expect((await icons.read([repoIconId(icon)!])).icons[0].dataUrl).toBeNull()
})
it('answers null for an id no repo shows, in request order', async () => {
const { icons, fetch } = setup([repo('a', AVATAR)])
const id = repoIconId(AVATAR)!
const reply = await icons.read(['missing', id])
expect(reply.icons.map((icon) => [icon.id, icon.dataUrl === null])).toEqual([
['missing', true],
[id, false]
])
expect(fetch).toHaveBeenCalledTimes(1)
})
})
describe('RepoIconDataUrls.idsByRepo', () => {
it('names each repo’s image by host and repo, the ids a read answers', async () => {
const remote = { ...repo('a', AVATAR), connectionId: 'box' }
const { icons } = setup([
repo('a', AVATAR),
remote,
repo('glyph', { type: 'emoji', emoji: 'x' }),
repo('none', null)
])
const id = repoIconId(AVATAR)!
expect(icons.idsByRepo()).toEqual({ 'local|a': id, 'ssh:box|a': id })
expect((await icons.read([id])).icons[0].dataUrl).not.toBeNull()
})
})
describe('RepoIconDataUrls with an encoder (desktop)', () => {
it('re-encodes a large upload rather than dropping it', async () => {
const icon = upload(pngHeader(1024, 1024, 300 * 1024))
const { icons } = setup([repo('a', icon)], { encoder: () => ENCODED })
expect((await icons.read([repoIconId(icon)!])).icons[0].dataUrl).toBe(ENCODED_URL)
})
it('steps down to 32 px when the 64 px PNG is over the cap', async () => {
const huge = new Uint8Array(MAX_REPO_ICON_DATA_URL_BYTES)
const encoder = vi.fn<RepoIconPngEncoder>((_bytes, edge) => (edge === 64 ? huge : ENCODED))
@@ -111,13 +56,6 @@ describe('RepoIconDataUrls with an encoder (desktop)', () => {
expect(encoder.mock.calls.map(([, edge]) => edge)).toEqual([64, 32])
})
it('passes a small image the decoder cannot read through, as orcad would', async () => {
const { icons } = setup([repo('a', AVATAR)], { encoder: () => null })
expect((await icons.read([repoIconId(AVATAR)!])).icons[0].dataUrl).toMatch(
/^data:image\/png;base64,/
)
})
it('falls back when neither encoding nor passthrough fits the cap', async () => {
const icon = upload(pngHeader(64, 64, MAX_REPO_ICON_DATA_URL_BYTES))
const huge = new Uint8Array(MAX_REPO_ICON_DATA_URL_BYTES)
@@ -79,13 +79,6 @@ describe('fetchRemoteRepoIcon', () => {
expect(pulls).toBeLessThan(10)
})
it('refuses a reply that is not a raster image', async () => {
const svg = new Response('<svg/>', { headers: { 'content-type': 'image/svg+xml' } })
expect(await fetchRemoteRepoIcon(AVATAR, async () => svg)).toBeNull()
const missing = new Response('nope', { status: 404, headers: { 'content-type': 'image/png' } })
expect(await fetchRemoteRepoIcon(AVATAR, async () => missing)).toBeNull()
})
it('refuses non-https and credentialed sources', async () => {
const fetch = vi.fn<RepoIconFetch>()
expect(await fetchRemoteRepoIcon('http://github.com/a.png', fetch)).toBeNull()
-84
View File
@@ -1,84 +0,0 @@
import { describe, expect, it, vi } from 'vitest'
const createFromBitmapMock = vi.hoisted(() =>
vi.fn((buffer: Buffer, options: { width: number; height: number }) => ({
__image: true,
buffer,
...options
}))
)
vi.mock('electron', () => ({
nativeImage: { createFromBitmap: createFromBitmapMock }
}))
import { composeTrayAttentionIcon, tintTrayTemplateForAttention } from './tray-attention-icon'
type FakeImage = {
getSize: () => { width: number; height: number }
toBitmap: () => Buffer
}
function fakeBase(width: number, height: number): FakeImage {
// Transparent base isolates pixels contributed by the attention dot/ring.
return {
getSize: () => ({ width, height }),
toBitmap: () => Buffer.alloc(width * height * 4, 0)
}
}
// Electron bitmaps use BGRA; renderer attention token is amber-500 (#f59e0b).
const AMBER = { b: 0x0b, g: 0x9e, r: 0xf5 }
describe('composeTrayAttentionIcon', () => {
it('paints an amber dot in the top-right corner and leaves the rest untouched', () => {
createFromBitmapMock.mockClear()
const width = 16
const height = 16
composeTrayAttentionIcon(fakeBase(width, height) as never)
const bitmap = createFromBitmapMock.mock.calls[0][0]
const pixel = (x: number, y: number): [number, number, number, number] => {
const o = (y * width + x) * 4
return [bitmap[o], bitmap[o + 1], bitmap[o + 2], bitmap[o + 3]]
}
let amberCount = 0
let sumX = 0
let sumY = 0
let paintedInBottomLeft = 0
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
const [b, g, r, a] = pixel(x, y)
if (b === AMBER.b && g === AMBER.g && r === AMBER.r && a === 0xff) {
amberCount++
sumX += x
sumY += y
}
if (a !== 0 && x < width / 2 && y >= height / 2) {
paintedInBottomLeft++
}
}
}
expect(amberCount).toBeGreaterThan(0)
expect(sumX / amberCount).toBeGreaterThan(width / 2)
expect(sumY / amberCount).toBeLessThan(height / 2)
expect(paintedInBottomLeft).toBe(0)
})
})
describe('tintTrayTemplateForAttention', () => {
it('keeps white edge pixels premultiplied-valid at partial alpha', () => {
createFromBitmapMock.mockClear()
const base = {
getSize: () => ({ width: 1, height: 1 }),
toBitmap: () => Buffer.from([0x00, 0x00, 0x00, 0x80])
}
tintTrayTemplateForAttention(base as never, true)
// Premultiplied alpha requires 0x80 channels for half-covered white, not 0xff.
expect(createFromBitmapMock.mock.calls[0][0]).toEqual(Buffer.from([0x80, 0x80, 0x80, 0x80]))
})
})