test: remove low-value plugin policy and graph GC suites (#41675)

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
OrcaWin
2026-11-12 14:07:58 -08:00
committed by GitHub
co-authored by OrcaWin
parent 3265616c56
commit e388a69394
8 changed files with 2 additions and 335 deletions
@@ -6592,7 +6592,6 @@
"src/shared/plugins/contributions/plugin-command-replaces.test.ts": 230,
"src/shared/plugins/contributions/plugin-content-pack-contributions.test.ts": 227,
"src/shared/plugins/contributions/plugin-custom-editor-contribution.test.ts": 238,
"src/shared/plugins/contributions/plugin-panel-contribution.test.ts": 240,
"src/shared/plugins/declarative/plugin-declarative-catalog-rich.test.ts": 147,
"src/shared/plugins/declarative/plugin-declarative-example.test.ts": 198,
"src/shared/plugins/declarative/plugin-declarative-tree.test.ts": 168,
@@ -6616,7 +6615,6 @@
"src/shared/plugins/images/plugin-image-format.test.ts": 104,
"src/shared/plugins/images/plugin-image-url.test.ts": 42,
"src/shared/plugins/installation/plugin-file-validation.test.ts": 363,
"src/shared/plugins/installation/plugin-path-safety.test.ts": 221,
"src/shared/plugins/manifest/plugin-display-text.test.ts": 285,
"src/shared/plugins/manifest/plugin-manifest-source-module-floor.test.ts": 212,
"src/shared/plugins/manifest/plugin-manifest-v2-rules.test.ts": 239,
@@ -1,214 +0,0 @@
import { workspaceId, local, repo } from './git-graph-workspace.test-fixtures'
// @vitest-environment happy-dom
import { useAppStore } from '@/store'
import { gitGraphHistoryForTab, disposeGitGraphHistory } from './git-graph-tab-controllers'
import { act } from 'react'
import { createRoot } from 'react-dom/client'
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
import { TooltipProvider } from '@/components/ui/tooltip'
import { GitGraphTab } from './git-graph-tab'
import * as graphSvg from '@/components/right-sidebar/source-control/sync/git-history-graph-svg'
import type { GitHistoryResult } from '../../../../../shared/git/history/git-history-types'
const { getHistory, getRefs, viewport } = vi.hoisted(() => ({
getHistory: vi.fn(),
getRefs: vi.fn(),
viewport: { rows: 20 }
}))
vi.mock('@/runtime/source-control/git/runtime-git-status-client', async (original) => ({
...(await original<object>()),
getRuntimeGitHistory: getHistory,
getRuntimeGitRefs: getRefs
}))
vi.mock('@/runtime/source-control/git/runtime-git-diff-client', async (original) => ({
...(await original<object>()),
getRuntimeGitCommitCompare: vi.fn(async () => ({ summary: { status: 'ready' }, entries: [] }))
}))
const container = document.createElement('div')
document.body.appendChild(container)
let root = createRoot(container)
let resize: (() => void) | undefined
const initialState = useAppStore.getState()
beforeEach(() => {
vi.spyOn(HTMLElement.prototype, 'clientHeight', 'get').mockImplementation(
() => viewport.rows * 24
)
vi.spyOn(HTMLElement.prototype, 'scrollHeight', 'get').mockImplementation(function (
this: HTMLElement
) {
return (
Number.parseFloat(
this.firstElementChild?.getAttribute('style')?.match(/height: ([\d.]+)px/)?.[1] ?? '0'
) + 48
)
})
vi.stubGlobal(
'ResizeObserver',
class {
constructor(private readonly callback: () => void) {
resize = callback
}
observe() {}
disconnect() {
if (resize === this.callback) {
resize = undefined
}
}
unobserve() {}
}
)
useAppStore.setState({
repos: [repo],
worktreesByRepo: { r: [local] },
activeWorktreeId: workspaceId,
activeWorkspaceExecutionHostId: 'local',
gitGraphFiltersByWorktree: {}
})
})
afterEach(async () => {
await act(async () => root.unmount())
root = createRoot(container)
viewport.rows = 20
disposeGitGraphHistory(`${workspaceId}::git-graph`)
useAppStore.setState(initialState, true)
vi.restoreAllMocks()
})
const result: GitHistoryResult = {
items: [{ id: 'a', subject: 'subject', message: 'subject', parentIds: [] }],
hasMore: false,
hasIncomingChanges: false,
hasOutgoingChanges: false,
limit: 50
}
const renderTab = () =>
act(async () =>
root.render(
<TooltipProvider>
<GitGraphTab worktreeId={workspaceId} />
</TooltipProvider>
)
)
const loadedCount = () => gitGraphHistoryForTab(workspaceId).view.getState().result?.items.length
it('releases replaced history while the pane stays mounted', async () => {
const count = 500_000
viewport.rows = 40
const renderedGraph = vi.spyOn(graphSvg, 'GitHistoryGraphSvg')
getHistory
.mockReset()
.mockImplementationOnce(async () => ({
...result,
refs: 'all',
hasMore: true,
items: Array.from({ length: count }, (_, index) => ({
id: `old-${index}`,
subject: `Old ${index}`,
message: `Old ${index}`,
parentIds: []
}))
}))
.mockRejectedValueOnce(new Error('network down'))
.mockResolvedValue({ ...result, refs: 'head' })
await renderTab()
await act(async () => {
const scroll = container.querySelector<HTMLDivElement>('div.overflow-y-auto')!
scroll.scrollTop = (count - 40) * 24
scroll.dispatchEvent(new Event('scroll'))
})
expect(getHistory).toHaveBeenCalledTimes(2)
expect(container.textContent).toContain('network down')
const replaced = (() => {
const loaded = gitGraphHistoryForTab(workspaceId).view.getState().result!
expect(loaded.items).toHaveLength(count)
return [
new WeakRef(renderedGraph.mock.calls[0]![0].viewModel),
new WeakRef(loaded),
new WeakRef(loaded.items),
new WeakRef(loaded.items[count - 1]!)
]
})()
await act(async () =>
useAppStore.setState({ gitGraphFiltersByWorktree: { [workspaceId]: 'head' } })
)
await act(async () => {
await gitGraphHistoryForTab(workspaceId).settledResult()
})
expect(loadedCount()).toBe(1)
getHistory.mockReset()
renderedGraph.mockClear()
await expectReleased(replaced)
let controller = gitGraphHistoryForTab(workspaceId)
const loadDisposable = async () => {
getHistory.mockImplementationOnce(async () => ({
...result,
items: [{ id: 'disposable', subject: 'Disposable', message: 'Body', parentIds: [] }]
}))
await act(async () => {
await controller.refresh()
})
const payload = controller.view.getState().result!.items[0]!
const row = renderedGraph.mock.calls.find(
([props]) => props.viewModel.historyItem.id === 'disposable'
)![0].viewModel
const weak = [new WeakRef(payload), new WeakRef(row)]
getHistory.mockReset()
renderedGraph.mockClear()
return weak
}
const empty = await loadDisposable()
getHistory.mockResolvedValueOnce({ ...result, items: [] })
await act(async () => {
await controller.refresh()
})
// A normal refresh commits past React's previous-render snapshot.
getHistory.mockRejectedValueOnce(new Error('Empty refresh failed'))
await act(async () => {
await controller.refresh()
})
expect(container.textContent).toContain('Empty refresh failed')
expect(loadedCount()).toBe(0)
getHistory.mockReset()
renderedGraph.mockClear()
await expectReleased(empty)
const missing = await loadDisposable()
getHistory.mockRejectedValueOnce(new Error('failed filter'))
await act(async () =>
useAppStore.setState({ gitGraphFiltersByWorktree: { [workspaceId]: 'all' } })
)
await act(async () => {
await controller.settledResult()
})
expect(loadedCount()).toBeUndefined()
getHistory.mockRejectedValueOnce(new Error('Missing refresh failed'))
await act(async () => {
await controller.refresh()
})
expect(container.textContent).toContain('Missing refresh failed')
expect(loadedCount()).toBeUndefined()
getHistory.mockReset()
renderedGraph.mockClear()
await expectReleased(missing)
const unmounted = await loadDisposable()
await act(async () => {
disposeGitGraphHistory(`${workspaceId}::git-graph`)
root.unmount()
})
root = createRoot(container)
controller = gitGraphHistoryForTab(workspaceId)
await expectReleased(unmounted)
})
async function expectReleased(obsolete: WeakRef<object>[]) {
if (typeof globalThis.gc !== 'function') {
throw new Error('Run with the repository Vitest --expose-gc config')
}
for (let round = 0; round < 3; round++) {
await new Promise<void>((resolve) => setImmediate(resolve))
globalThis.gc()
}
for (const value of obsolete) {
expect(value.deref()).toBeUndefined()
}
}
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { pluginListingRepositoryUrl, pluginRepositoryPageUrl } from './plugin-repository-link'
import { pluginRepositoryPageUrl } from './plugin-repository-link'
describe('pluginRepositoryPageUrl', () => {
it('drops credentials, ports, queries and fragments from the URL it was given', () => {
@@ -8,24 +8,3 @@ describe('pluginRepositoryPageUrl', () => {
)
})
})
describe('pluginListingRepositoryUrl', () => {
const mirror = { url: 'https://github.com/stablyai/orca-community-mirror.git' }
it("never links a recorded repository outside the publisher's namespace or linkable hosts", () => {
for (const repository of [
'https://github.com/someone-else/notes',
'https://evil.example/acme/notes',
'https://github.com/acme/%2e%2e'
]) {
expect(
pluginListingRepositoryUrl({
pluginKey: 'acme.notes',
source: mirror,
release: { repository }
})
).toBe(mirror.url)
}
expect(pluginListingRepositoryUrl({ pluginKey: 'acme.notes', source: mirror })).toBe(mirror.url)
})
})
@@ -1,29 +0,0 @@
import { describe, expect, it } from 'vitest'
import { parsePluginManifest } from '../manifest/plugin-manifest'
const panel = { id: 'board', title: 'Board' }
function manifest(engine: string, panelFields: Record<string, unknown>) {
return {
manifestVersion: 2,
execution: 'sandboxed-ui',
id: 'board',
publisher: 'acme',
name: 'Board',
version: '1.0.0',
engines: { orca: engine },
pluginApi: 1,
contributes: { panels: [{ ...panel, entry: 'panel.js', ...panelFields }] }
}
}
describe('panel ui', () => {
it('makes authors declare the release that reads ui and the newer icons', () => {
expect(parsePluginManifest(manifest('>=1.4.245', { ui: 'components' })).ok).toBe(false)
expect(parsePluginManifest(manifest('>=1.4.245', { icon: 'add' })).ok).toBe(false)
expect(parsePluginManifest(manifest('>=1.4.245', { icon: 'rocket' })).ok).toBe(true)
expect(parsePluginManifest(manifest('>=1.4.246', { ui: 'components', icon: 'add' })).ok).toBe(
true
)
})
})
@@ -107,14 +107,4 @@ describe('readPluginImageHeader', () => {
height: 800
})
})
it('refuses animation, other formats and oversized frames', () => {
expect(readPluginImageHeader(pngBytes(512, 512, true))).toBe('animated images are not allowed')
expect(readPluginImageHeader(webpVp8x(512, 512, 0x02))).toBe('animated images are not allowed')
expect(readPluginImageHeader(Buffer.from('<svg xmlns="http://www.w3.org/2000/svg"/>'))).toBe(
'must be a PNG, JPEG or WebP image'
)
expect(readPluginImageHeader(Buffer.from('GIF89a'))).toBe('must be a PNG, JPEG or WebP image')
expect(readPluginImageHeader(pngBytes(5000, 100))).toBe('image is larger than 4096×4096')
})
})
@@ -1,30 +0,0 @@
import { describe, expect, it } from 'vitest'
import { parsePluginManifest } from '../manifest/plugin-manifest'
describe('plugin path portability', () => {
it('applies portable path validation to every declared artifact kind', () => {
const base = {
manifestVersion: 1,
id: 'demo',
publisher: 'samples',
name: 'Demo',
version: '1.0.0',
engines: { orca: '>=1.0.0' },
pluginApi: 1,
contributes: { panels: [], commands: [], events: [] },
capabilities: []
}
expect(parsePluginManifest({ ...base, icon: 'assets/NUL.svg' }).ok).toBe(false)
expect(parsePluginManifest({ ...base, main: 'dist/worker.js.' }).ok).toBe(false)
expect(
parsePluginManifest({
...base,
contributes: {
...base.contributes,
panels: [{ id: 'panel', title: 'Panel', entry: 'dist/panel.html:ads' }]
}
}).ok
).toBe(false)
})
})
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest'
import { validatePluginFile } from '../installation/plugin-file-validation'
import { pluginCatalogEntrySchema } from '../catalog/plugin-catalog'
import { parseHostPluginManifest, parsePluginManifest } from './plugin-manifest'
import { parseHostPluginManifest } from './plugin-manifest'
import {
catalogEntryFixture,
catalogFixture,
@@ -27,18 +27,6 @@ describe('plugin display text', () => {
})
})
it('refuses unsafe characters in validate:plugin instead of stripping them', () => {
expect(parsePluginManifest(themed(SPOOFED_NAME, 'Dusk'))).toEqual({
ok: false,
error: expect.stringContaining(
'name: must be one line without control, bidirectional or zero-width characters;'
)
})
expect(validatePluginFile('orca-plugin.json', themed('Dusk', 'Dusk\u2066'))).toEqual([
'description: must be one line without control, bidirectional or zero-width characters; contributes.themes[0].title: must be one line without control, bidirectional or zero-width characters'
])
})
it('strips catalog listing text at runtime and refuses it in catalog CI', () => {
const entry = catalogEntryFixture({ description: 'Gleam\u202e' }, { name: 'Gleam\u200b' })
expect(pluginCatalogEntrySchema.parse(entry)).toMatchObject({
@@ -99,21 +99,6 @@ describe('readPluginVideoHeader', () => {
})
})
it('refuses images, audio, extra tracks and missing or negative lengths', () => {
const oneTrack = 'video must have exactly one track, a video track with no audio'
expect(readPluginVideoHeader(Buffer.from('\x89PNG\r\n\x1a\n'))).toBe(
'must be an MP4 or WebM video'
)
const video = mp4Track('vide', 'avc1', 960, 540)
const audio = mp4Track('soun', 'mp4a', 0, 0)
expect(readPluginVideoHeader(mp4([audio]))).toBe(oneTrack)
expect(readPluginVideoHeader(mp4([audio, video]))).toBe(oneTrack)
expect(readPluginVideoHeader(mp4([video, video]))).toBe(oneTrack)
expect(readPluginVideoHeader(webm('V_VP9', 960, 540, 1000, true))).toBe(oneTrack)
expect(readPluginVideoHeader(webm('V_VP9', 960, 540))).toBe('video has no duration')
expect(readPluginVideoHeader(webm('V_VP9', 960, 540, -5000))).toBe('video has no duration')
})
it('stops on hostile structure instead of recursing or reading past the end', () => {
let nested = box('mdia')
for (let depth = 0; depth < 5000; depth++) {