test: remove 16 low-value audience, notice and export cases (#35128)

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
OrcaWin
2026-10-28 14:12:18 -07:00
committed by GitHub
co-authored by OrcaWin
parent f7a114af29
commit 88e23db6b5
7 changed files with 2 additions and 203 deletions
-1
View File
@@ -12508,7 +12508,6 @@
"src/shared/native-chat-turn-membership.test.ts": 174,
"src/shared/native-chat-turn-status.test.ts": 52,
"src/shared/native-chat-unverifiable-turn-status.test.ts": 111,
"src/shared/native-chat/native-chat-upgrade-tip-audience.test.ts": 41,
"src/shared/native-chat/native-chat-visual-directive.test.ts": 45,
"src/shared/native-chat/native-chat-visual-height-governor.test.ts": 141,
"src/shared/native-chat/native-chat-visual-shell.reader-scroll.test.ts": 188,
@@ -1,27 +1,7 @@
import { describe, expect, it } from 'vitest'
import {
GpuCrashFallbackTracker,
isGpuChildProcessType,
isGpuFallbackCrashCandidate
} from './gpu-crash-fallback-decision'
import { GpuCrashFallbackTracker, isGpuFallbackCrashCandidate } from './gpu-crash-fallback-decision'
describe('GpuCrashFallbackTracker', () => {
it('engages fallback once GPU crashes hit the threshold inside the window', () => {
const tracker = new GpuCrashFallbackTracker({ windowMs: 30_000, threshold: 3 })
expect(tracker.recordGpuCrash(500)).toEqual({
shouldEngageFallback: false,
crashesInWindow: 1
})
expect(tracker.recordGpuCrash(8_000)).toEqual({
shouldEngageFallback: false,
crashesInWindow: 2
})
expect(tracker.recordGpuCrash(16_000)).toEqual({
shouldEngageFallback: true,
crashesInWindow: 3
})
})
it('engages at most once so the relaunch cannot loop', () => {
const tracker = new GpuCrashFallbackTracker({ windowMs: 30_000, threshold: 2 })
tracker.recordGpuCrash(100)
@@ -44,18 +24,6 @@ describe('GpuCrashFallbackTracker', () => {
expect(tracker.hasEngaged()).toBe(false)
})
it('engages on a burst that starts long after launch (session 12e6ee64)', () => {
const tracker = new GpuCrashFallbackTracker({ windowMs: 30_000, threshold: 3 })
// Field timings reproduce a burst long after launch.
expect(tracker.recordGpuCrash(242_137).shouldEngageFallback).toBe(false)
expect(tracker.recordGpuCrash(920_110).shouldEngageFallback).toBe(false)
expect(tracker.recordGpuCrash(926_462).shouldEngageFallback).toBe(false)
expect(tracker.recordGpuCrash(946_115)).toEqual({
shouldEngageFallback: true,
crashesInWindow: 3
})
})
it('treats a span of exactly windowMs as inside the window', () => {
const tracker = new GpuCrashFallbackTracker({ windowMs: 30_000, threshold: 3 })
tracker.recordGpuCrash(0)
@@ -75,38 +43,12 @@ describe('GpuCrashFallbackTracker', () => {
expect(tracker.hasEngaged()).toBe(false)
})
it('ignores a slow drip that never fills the window', () => {
const tracker = new GpuCrashFallbackTracker({ windowMs: 30_000, threshold: 3 })
for (const at of [0, 20_000, 40_000, 60_000, 80_000, 100_000]) {
expect(tracker.recordGpuCrash(at).shouldEngageFallback).toBe(false)
}
expect(tracker.hasEngaged()).toBe(false)
})
it('never retains a crash older than the window, even on a backwards clock jump', () => {
const tracker = new GpuCrashFallbackTracker({ windowMs: 30_000, threshold: 3 })
tracker.recordGpuCrash(100_000)
tracker.recordGpuCrash(1_000)
// Assert sorted pruning directly; the crash count alone can hide out-of-order retention.
const window = tracker.windowSnapshot()
const newest = window.at(-1) ?? 0
expect(window.every((at) => newest - at <= 30_000)).toBe(true)
expect([...window]).toEqual([...window].sort((left, right) => left - right))
})
it('ignores impossible timestamps', () => {
const tracker = new GpuCrashFallbackTracker({ windowMs: 30_000, threshold: 1 })
expect(tracker.recordGpuCrash(-1).shouldEngageFallback).toBe(false)
expect(tracker.recordGpuCrash(Number.NaN).shouldEngageFallback).toBe(false)
expect(tracker.hasEngaged()).toBe(false)
})
it('classifies GPU child process types case-insensitively', () => {
expect(isGpuChildProcessType('GPU')).toBe(true)
expect(isGpuChildProcessType('gpu')).toBe(true)
expect(isGpuChildProcessType('Utility')).toBe(false)
expect(isGpuChildProcessType(undefined)).toBe(false)
})
})
describe('isGpuFallbackCrashCandidate', () => {
@@ -107,31 +107,6 @@ describe('OpenCode status plugin module contract', () => {
expect(module.default).toBe(module.OrcaOpenCodeStatusPlugin)
})
it('exposes a default export carrying a string id and a callable server()', async () => {
const module = await loadPluginModule()
expect(module.default).toBeTypeOf('object')
expect(typeof module.default?.id).toBe('string')
expect(module.default?.id).toBe('orca-opencode-status')
expect(module.default?.server).toBeTypeOf('function')
})
it('keeps the named factory export so the factory-based loader still resolves', async () => {
const module = await loadPluginModule()
expect(module.OrcaOpenCodeStatusPlugin).toBeTypeOf('function')
})
it('returns an event handler from the default export server(), like the named factory', async () => {
const module = await loadPluginModule()
const fromDefault = await module.default?.server?.({})
const fromNamed = await module.OrcaOpenCodeStatusPlugin?.({})
expect(fromDefault?.event).toBeTypeOf('function')
expect(fromNamed?.event).toBeTypeOf('function')
})
it('reports a session lifecycle event through the hook endpoint when driven via the default export', async () => {
process.env.ORCA_PANE_KEY = 'tab-1:leaf-1'
const posts = captureHookPosts()
@@ -1,43 +0,0 @@
// @vitest-environment happy-dom
import { cleanup, renderHook } from '@testing-library/react'
import { afterEach, expect, it, vi } from 'vitest'
const state = vi.hoisted(() => ({
browserSessionImportState: {
status: 'success',
summary: {
totalCookies: 2,
importedCookies: 1,
skippedCookies: 1,
domains: ['good.example']
}
},
clearBrowserSessionImportState: vi.fn()
}))
vi.mock('@/store', () => ({
useAppStore: (select: (value: typeof state) => unknown) => select(state)
}))
import { useBrowserPageResourceNotices } from './use-browser-page-resource-notices'
afterEach(cleanup)
it('names only the successful summary domains in the import notice', () => {
Object.defineProperty(window, 'api', {
configurable: true,
value: {
browser: {
onPermissionDenied: () => () => {},
onPopup: () => () => {}
}
}
})
const { result } = renderHook(() => useBrowserPageResourceNotices('browser-1'))
expect(result.current.resourceNotice).toBe(
'Imported 1 cookies for good.example. Reload the page to use them.'
)
expect(state.clearBrowserSessionImportState).toHaveBeenCalledOnce()
})
@@ -1,8 +1,5 @@
import { describe, expect, it } from 'vitest'
import {
deriveNativeChatContextUsage,
isNativeChatCompactionBoundary
} from './native-chat-context-usage'
import { deriveNativeChatContextUsage } from './native-chat-context-usage'
import type { AgentSessionTokenUsage } from '../agent-session-context-usage'
import type { NativeChatMessage } from '../native-chat-types'
@@ -91,15 +88,3 @@ describe('deriveNativeChatContextUsage', () => {
expect(deriveNativeChatContextUsage([assistant('zero', usage(0))], noWindow)).toBeNull()
})
})
describe('isNativeChatCompactionBoundary', () => {
it('matches only the compaction presentation', () => {
expect(isNativeChatCompactionBoundary(compaction)).toBe(true)
expect(
isNativeChatCompactionBoundary({
...compaction,
blocks: [{ type: 'text', text: 'Context compacted' }]
})
).toBe(false)
})
})
@@ -1,32 +0,0 @@
import { describe, expect, it } from 'vitest'
import {
isInNativeChatUpgradeTipAudience,
nativeChatUpgradeTipVariant
} from './native-chat-upgrade-tip-audience'
describe('nativeChatUpgradeTipVariant', () => {
it.each([
['eligible', 'chat-ui-on', 'standard'],
['eligible', 'chat-ui-on-terminal-default', 'keep-terminal'],
['excluded', 'chat-ui-on-terminal-default', 'none'],
['excluded', 'chat-ui-off', 'none'],
['excluded', 'new-profile', 'none']
] as const)('gives %s/%s the %s tip', (membership, basis, variant) => {
expect(nativeChatUpgradeTipVariant({ version: 1, membership, basis })).toBe(variant)
})
it('shows no tip without a readable record', () => {
expect(nativeChatUpgradeTipVariant(null)).toBe('none')
})
})
describe('isInNativeChatUpgradeTipAudience', () => {
it.each([
[null, null],
['none', false],
['standard', true],
['keep-terminal', true]
] as const)('reads variant %s as %s', (variant, inAudience) => {
expect(isInNativeChatUpgradeTipAudience(variant)).toBe(inAudience)
})
})
@@ -2,19 +2,14 @@ import { describe, expect, it } from 'vitest'
import {
NATIVE_CHAT_VISUAL_CSP,
NATIVE_CHAT_VISUAL_HOST_CSP,
NATIVE_CHAT_VISUAL_MAX_HEIGHT,
NATIVE_CHAT_VISUAL_MIN_HEIGHT,
NATIVE_CHAT_VISUAL_OPEN_LINK_TYPE,
NATIVE_CHAT_VISUAL_PING_TYPE,
NATIVE_CHAT_VISUAL_PONG_TYPE,
NATIVE_CHAT_VISUAL_READER_SCROLL_TYPE,
NATIVE_CHAT_VISUAL_SIZE_TYPE,
NATIVE_CHAT_VISUAL_THEME_TYPE,
buildNativeChatVisualDocument,
clampNativeChatVisualHeight,
nativeChatVisualPingMessage,
nativeChatVisualThemeCss,
nativeChatVisualThemeMessage,
readNativeChatVisualFrameMessage,
readNativeChatVisualPong
} from './native-chat-visual-shell'
@@ -89,12 +84,6 @@ describe('buildNativeChatVisualDocument', () => {
expect(document.endsWith(html)).toBe(true)
})
it('paints the theme before the visual and carries the channel in the bootstrap', () => {
expect(document).toContain('<html class="dark">')
expect(document).toContain('--background:oklch(0.2 0 0)')
expect(document).toContain('"channel":"abc123"')
})
it('resolves in-page links against the visual itself, ahead of the policy that bars any other base', () => {
const baseAt = document.indexOf('<base href="about:srcdoc">')
expect(baseAt).toBeGreaterThan(0)
@@ -121,14 +110,6 @@ describe('nativeChatVisualThemeCss', () => {
expect(css).not.toContain('--Upper')
expect(css.startsWith(':root{color-scheme:light')).toBe(true)
})
it('builds the live theme message on the same channel', () => {
expect(nativeChatVisualThemeMessage(theme, 'abc')).toMatchObject({
type: NATIVE_CHAT_VISUAL_THEME_TYPE,
channel: 'abc',
colorScheme: 'dark'
})
})
})
describe('readNativeChatVisualFrameMessage', () => {
@@ -229,11 +210,3 @@ describe('readNativeChatVisualPong', () => {
expect(readNativeChatVisualPong(data, 'c')).toBeNull()
})
})
describe('clampNativeChatVisualHeight', () => {
it('keeps heights in range', () => {
expect(clampNativeChatVisualHeight(1)).toBe(NATIVE_CHAT_VISUAL_MIN_HEIGHT)
expect(clampNativeChatVisualHeight(99_999)).toBe(NATIVE_CHAT_VISUAL_MAX_HEIGHT)
expect(clampNativeChatVisualHeight(300.4)).toBe(300)
})
})