test: remove plugin syntax limits and contribution inventories

This commit is contained in:
OrcaWin
2026-11-12 13:41:16 -08:00
parent a3bf245d42
commit 56541f0477
4 changed files with 1 additions and 131 deletions
@@ -6603,7 +6603,6 @@
"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/contributions/plugin-status-bar-item-contribution.test.ts": 232,
"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,
@@ -11,18 +11,6 @@ function grammar(scopeName: string, body: Record<string, unknown> = {}): string
}
describe('plugin syntax artifacts', () => {
it('refuses oversized and deeply nested grammars', () => {
const huge = grammar('source.demo', { comment: 'x'.repeat(1024 * 1024) })
expect(() => parsePluginGrammarArtifact(huge, 'source.demo')).toThrow('exceeds')
let nested: Record<string, unknown> = { match: 'a' }
for (let depth = 0; depth < 80; depth += 1) {
nested = { patterns: [nested] }
}
expect(() =>
parsePluginGrammarArtifact(grammar('source.demo', { patterns: [nested] }), 'source.demo')
).toThrow('nested too deeply')
})
it('requires includes inside the plugin to resolve and lets outside scopes degrade', () => {
const main = parsePluginGrammarArtifact(
grammar('source.demo', {
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { parsePluginManifest, pluginManifestSchema } from '../manifest/plugin-manifest'
import { pluginManifestSchema } from '../manifest/plugin-manifest'
function manifest(contributes: Record<string, unknown>): Record<string, unknown> {
return {
@@ -16,75 +16,6 @@ function manifest(contributes: Record<string, unknown>): Record<string, unknown>
}
describe('content-pack manifest contributions', () => {
it('still requires a worker entry for non-alias commands', () => {
expect(
parsePluginManifest(
manifest({ commands: [{ id: 'content-pack.run', title: 'Run content pack' }] })
)
).toMatchObject({ ok: false, error: expect.stringContaining('worker command') })
})
it.each([
[
'unknown alias target',
{
commands: [{ id: 'open', title: 'Open', action: 'missing.action' }]
},
'unknown built-in action'
],
[
'unknown command reference',
{ keybindings: [{ command: 'missing', key: 'Mod+K' }] },
'unknown contributed command'
],
[
'invalid chord',
{
commands: [{ id: 'open', title: 'Open', action: 'view.tasks' }],
keybindings: [{ command: 'open', key: 'Mod+NotAKey' }]
},
'key'
],
[
'global binding for a worktree command',
{
commands: [{ id: 'open', title: 'Open', context: 'workspace', action: 'view.tasks' }],
keybindings: [{ command: 'open', key: 'Mod+K', when: 'global' }]
},
"command's when"
],
[
'platform-equivalent duplicate chords',
{
commands: [
{ id: 'first', title: 'First', action: 'view.tasks' },
{ id: 'second', title: 'Second', action: 'sidebar.left.toggle' }
],
keybindings: [
{ command: 'first', key: 'Mod+K' },
{ command: 'second', key: 'Ctrl+K' }
]
},
'duplicate keybinding'
]
])('rejects %s', (_label, contributes, error) => {
expect(parsePluginManifest(manifest(contributes))).toMatchObject({
ok: false,
error: expect.stringContaining(error)
})
})
it.each([
['language pack', { languagePacks: [{ locale: 'en_US', path: 'locale.json' }] }],
// Shape-legal but ill-formed: the regex alone let these load with dates falling back to English.
['duplicate region', { languagePacks: [{ locale: 'en-US-US', path: 'locale.json' }] }],
['unknown subtag', { languagePacks: [{ locale: 'en-aaa', path: 'locale.json' }] }],
['language pack path', { languagePacks: [{ locale: 'pt-BR', path: '../outside.json' }] }],
['VM recipe', { vmRecipes: [{ path: '\\\\server\\recipe.json' }] }]
])('rejects unsafe or malformed %s contributions', (_label, contributes) => {
expect(parsePluginManifest(manifest(contributes)).ok).toBe(false)
})
it('rejects duplicate ids, locales, paths, and bindings', () => {
const parsed = pluginManifestSchema.safeParse(
manifest({
@@ -1,48 +0,0 @@
import { describe, expect, it } from 'vitest'
import { parsePluginManifest } from '../manifest/plugin-manifest'
import {
buildPluginApprovalRequest,
formatPluginApprovalMessage
} from '../approval/plugin-cli-approval'
function manifest(statusBarItems: unknown[], engines = '>=1.4.248') {
return {
manifestVersion: 2,
execution: 'declarative',
id: 'status-demo',
name: 'Status demo',
version: '1.0.0',
engines: { orca: engines },
contributes: {
commands: [{ id: 'demo.tasks', title: 'Open tasks', action: 'view.tasks' }],
statusBarItems
}
}
}
describe('contributes.statusBarItems', () => {
it('lists items in the dev-load and inspect approval, and binds the fingerprint to them', () => {
const subject = (items: unknown[]) => {
const parsed = parsePluginManifest(manifest(items))
if (!parsed.ok) {
throw new Error(parsed.error)
}
return {
pluginKey: 'dev:status-demo',
manifest: parsed.manifest,
consentFingerprint: 'c',
contentIdentity: 'h',
isDev: true
}
}
const request = buildPluginApprovalRequest(
subject([{ id: 'tasks', text: '3 open' }]),
'dev-load'
)
expect(formatPluginApprovalMessage(request)).toContain('statusBarItems "3 open"')
expect(
buildPluginApprovalRequest(subject([{ id: 'tasks', text: '4 open' }]), 'dev-load')
.approvalFingerprint
).not.toBe(request.approvalFingerprint)
})
})