mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 19:34:29 +00:00
test: remove 321 low-value main and shared tests (#39429)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
checkPluginLanguagePackForAuthoring,
|
||||
parsePluginLanguagePackArtifact,
|
||||
PLUGIN_LANGUAGE_CATALOG_MAX_DEPTH,
|
||||
PLUGIN_LANGUAGE_CATALOG_MAX_ENTRIES,
|
||||
validatePluginLanguagePackCatalog,
|
||||
pluginLanguageResourceId
|
||||
} from './plugin-language-pack-artifact'
|
||||
import { englishSourceLookup } from '../languages/plugin-translation-string-policy'
|
||||
@@ -21,24 +17,6 @@ describe('plugin language-pack artifacts', () => {
|
||||
expect(first).not.toBe(second)
|
||||
})
|
||||
|
||||
it('accepts nested string catalogs and reports their bounded entry count', () => {
|
||||
expect(
|
||||
parsePluginLanguagePackArtifact(
|
||||
JSON.stringify({
|
||||
settings: { appearance: { title: 'Aparência' } },
|
||||
common: { save: 'Salvar' }
|
||||
})
|
||||
)
|
||||
).toEqual({
|
||||
ok: true,
|
||||
catalog: {
|
||||
settings: { appearance: { title: 'Aparência' } },
|
||||
common: { save: 'Salvar' }
|
||||
},
|
||||
entries: 5
|
||||
})
|
||||
})
|
||||
|
||||
it('drops protected copy instead of rejecting the pack when loading tolerantly', () => {
|
||||
const raw = JSON.stringify({
|
||||
common: { save: 'Sávé' },
|
||||
@@ -52,40 +30,6 @@ describe('plugin language-pack artifacts', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('counts protected copy for authors instead of rejecting, still rejecting other problems', () => {
|
||||
expect(
|
||||
checkPluginLanguagePackForAuthoring(
|
||||
JSON.stringify({
|
||||
common: { save: 'Sávé' },
|
||||
components: { 'native-chat': { approval: { allow: 'Álló', deny: 'Déný' } } },
|
||||
browser: { loadFailure: { proceedUnsafe: 'Continuar' } }
|
||||
})
|
||||
)
|
||||
).toEqual({ ok: true, ignoredProtectedStrings: 3 })
|
||||
expect(
|
||||
checkPluginLanguagePackForAuthoring(
|
||||
JSON.stringify({
|
||||
common: { save: 'a\u202esave' },
|
||||
components: { 'native-chat': { approval: { allow: 'Álló' } } }
|
||||
})
|
||||
)
|
||||
).toMatchObject({ ok: false })
|
||||
})
|
||||
|
||||
it.each([
|
||||
['PluginsSettingsSection', 'title', 'Плагины'],
|
||||
['PluginMarketplaceBrowser', 'refresh', 'Обновить'],
|
||||
['PluginDevelopmentSection', 'title', 'Разработка']
|
||||
])('lets a language pack translate %s.%s, which asserts nothing', (component, key, value) => {
|
||||
expect(
|
||||
parsePluginLanguagePackArtifact(
|
||||
JSON.stringify({
|
||||
auto: { components: { settings: { [component]: { [key]: value } } } }
|
||||
})
|
||||
).ok
|
||||
).toBe(true)
|
||||
})
|
||||
|
||||
// Chrome exemptions must never include claims about plugin permissions; those are the protected prefix’s purpose.
|
||||
it.each([
|
||||
['description', 'Plugins are sandboxed and cannot read your files.'],
|
||||
@@ -100,36 +44,6 @@ describe('plugin language-pack artifacts', () => {
|
||||
).toMatchObject({ ok: false, error: expect.stringContaining('protected security copy') })
|
||||
})
|
||||
|
||||
it('still refuses the development-plugin permission promise', () => {
|
||||
expect(
|
||||
parsePluginLanguagePackArtifact(
|
||||
JSON.stringify({
|
||||
auto: {
|
||||
components: {
|
||||
settings: {
|
||||
PluginDevelopmentSection: { help: 'Dev plugins skip permission review.' }
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
).toMatchObject({ ok: false, error: expect.stringContaining('protected security copy') })
|
||||
})
|
||||
|
||||
it('still refuses install failure copy that reports a trust event', () => {
|
||||
expect(
|
||||
parsePluginLanguagePackArtifact(
|
||||
JSON.stringify({
|
||||
auto: {
|
||||
components: {
|
||||
settings: { PluginMarketplaceBrowser: { installFailed: 'Installed successfully.' } }
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
).toMatchObject({ ok: false, error: expect.stringContaining('protected security copy') })
|
||||
})
|
||||
|
||||
it.each([
|
||||
[
|
||||
'the Official badge',
|
||||
@@ -211,17 +125,6 @@ describe('plugin language-pack artifacts', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('still translates neighbours of protected components', () => {
|
||||
expect(
|
||||
parsePluginLanguagePackArtifact(
|
||||
JSON.stringify({
|
||||
auto: { components: { pluginCatalog: { PluginListRow: { install: 'Instalar' } } } },
|
||||
components: { 'native-chat': { composer: { send: 'Enviar' } } }
|
||||
})
|
||||
).ok
|
||||
).toBe(true)
|
||||
})
|
||||
|
||||
it.each([
|
||||
['array leaf', { settings: { choices: ['one'] } }],
|
||||
['numeric leaf', { settings: { count: 1 } }],
|
||||
@@ -231,36 +134,6 @@ describe('plugin language-pack artifacts', () => {
|
||||
expect(parsePluginLanguagePackArtifact(JSON.stringify(catalog)).ok).toBe(false)
|
||||
})
|
||||
|
||||
it('rejects excessive nesting without recursive validation', () => {
|
||||
let catalog: Record<string, unknown> = { value: 'deep' }
|
||||
for (let index = 0; index <= PLUGIN_LANGUAGE_CATALOG_MAX_DEPTH; index += 1) {
|
||||
catalog = { nested: catalog }
|
||||
}
|
||||
expect(parsePluginLanguagePackArtifact(JSON.stringify(catalog))).toMatchObject({
|
||||
ok: false,
|
||||
error: expect.stringContaining('depth')
|
||||
})
|
||||
})
|
||||
|
||||
it('accepts the entry limit and rejects one additional entry', () => {
|
||||
const catalog = Object.fromEntries(
|
||||
Array.from({ length: PLUGIN_LANGUAGE_CATALOG_MAX_ENTRIES }, (_, index) => [
|
||||
`key${index}`,
|
||||
'value'
|
||||
])
|
||||
)
|
||||
|
||||
expect(validatePluginLanguagePackCatalog(catalog)).toMatchObject({
|
||||
ok: true,
|
||||
entries: PLUGIN_LANGUAGE_CATALOG_MAX_ENTRIES
|
||||
})
|
||||
catalog.overflow = 'value'
|
||||
expect(validatePluginLanguagePackCatalog(catalog)).toMatchObject({
|
||||
ok: false,
|
||||
error: expect.stringContaining(`${PLUGIN_LANGUAGE_CATALOG_MAX_ENTRIES} entries`)
|
||||
})
|
||||
})
|
||||
|
||||
describe('string limits', () => {
|
||||
const english = englishSourceLookup({
|
||||
common: { retry: 'Retry', detail: 'Line one\nLine two' },
|
||||
@@ -269,21 +142,6 @@ describe('plugin language-pack artifacts', () => {
|
||||
const parse = (catalog: unknown, strictness?: 'strict' | 'tolerant') =>
|
||||
parsePluginLanguagePackArtifact(JSON.stringify(catalog), strictness, english)
|
||||
|
||||
it('caps a translation at 4x its English text with a 64-character floor', () => {
|
||||
expect(parse({ common: { retry: 'x'.repeat(64) } }).ok).toBe(true)
|
||||
expect(parse({ common: { retry: 'x'.repeat(65) } })).toMatchObject({
|
||||
ok: false,
|
||||
error: expect.stringContaining('common.retry exceeds 64 characters')
|
||||
})
|
||||
const detail = 'x'.repeat(4 * 'Line one\nLine two'.length + 1)
|
||||
expect(parse({ common: { detail } }).ok).toBe(false)
|
||||
})
|
||||
|
||||
it('measures plural forms English lacks against its _other form', () => {
|
||||
expect(parse({ items: { count_few: 'x'.repeat(64) } }).ok).toBe(true)
|
||||
expect(parse({ items: { count_few: 'x'.repeat(65) } }).ok).toBe(false)
|
||||
})
|
||||
|
||||
it.each([
|
||||
['a right-to-left override', 'Delete\u202Eetelpmoc'],
|
||||
['an isolate', 'Retry\u2066x\u2069'],
|
||||
|
||||
@@ -1,17 +1,8 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { legacyPluginCatalog } from '../../../../config/scripts/plugin-authoring/content-validation/export-legacy-plugin-catalog.mjs'
|
||||
import {
|
||||
PLUGIN_CATALOG_RELEASE_LIMIT,
|
||||
pluginCatalogSchema,
|
||||
pluginCatalogVersionError,
|
||||
selectPluginCatalogRelease
|
||||
} from './plugin-catalog'
|
||||
import { pluginCatalogSchema, selectPluginCatalogRelease } from './plugin-catalog'
|
||||
import { pluginCatalogReleaseSchema } from './plugin-catalog-release'
|
||||
import {
|
||||
PLUGIN_MARKETPLACE_ENTRY_LIMIT,
|
||||
pluginMarketplaceListingSchema,
|
||||
pluginMarketplaceSchema
|
||||
} from './plugin-marketplace'
|
||||
import { pluginMarketplaceSchema } from './plugin-marketplace'
|
||||
|
||||
function release(version: string, minimumOrca = '1.4.0') {
|
||||
return pluginCatalogReleaseSchema.parse({
|
||||
@@ -51,70 +42,6 @@ describe('plugin catalog', () => {
|
||||
}
|
||||
)
|
||||
|
||||
it('keeps what it can read and skips the rest', () => {
|
||||
const parsed = pluginCatalogSchema.parse(
|
||||
catalog(
|
||||
[
|
||||
entry('acme.one', { surprise: true, description: 'x'.repeat(5_000) }),
|
||||
entry('acme.one', { categories: ['other'] }),
|
||||
entry('acme.two', { releases: [{ ...release('2.0.0'), types: ['widget'] }] }),
|
||||
entry('acme.three', {
|
||||
categories: [
|
||||
'themes',
|
||||
'themes',
|
||||
'Not A Slug',
|
||||
...Array.from({ length: 30 }, (_, i) => `c${i}`)
|
||||
],
|
||||
releases: [{ broken: true }, release('1.1.0')]
|
||||
}),
|
||||
{ id: 5 }
|
||||
],
|
||||
{ future: { anything: true } }
|
||||
)
|
||||
)
|
||||
expect(parsed.plugins.map((plugin) => plugin.id)).toEqual(['acme.one', 'acme.three'])
|
||||
expect(parsed.plugins[0]).not.toHaveProperty('surprise')
|
||||
expect(parsed.plugins[0]?.description).toBeUndefined()
|
||||
expect(parsed.plugins[0]?.categories).toEqual(['themes'])
|
||||
expect(parsed.plugins[1]?.categories).toHaveLength(16)
|
||||
expect(parsed.plugins[1]?.categories.slice(0, 2)).toEqual(['themes', 'c0'])
|
||||
expect(parsed.plugins[1]?.releases.map((r) => r.version)).toEqual(['1.1.0'])
|
||||
})
|
||||
|
||||
it('reads the owner id without carrying it into the cached listing', () => {
|
||||
const parsed = pluginCatalogSchema.parse(
|
||||
catalog([entry('acme.one', { ownerId: 1_234 }), entry('acme.two', { ownerId: 'acme' })])
|
||||
)
|
||||
expect(parsed.plugins.map((plugin) => plugin.id)).toEqual(['acme.one', 'acme.two'])
|
||||
expect(parsed.plugins[0]).not.toHaveProperty('ownerId')
|
||||
// Why strict: older Orca reads the cached listing back with this shape after a downgrade.
|
||||
const { name, owner, plugins } = parsed
|
||||
expect(pluginMarketplaceListingSchema.safeParse({ name, owner, plugins }).success).toBe(true)
|
||||
})
|
||||
|
||||
it('trims an oversized catalog and release list instead of refusing it', () => {
|
||||
const many = Array.from({ length: PLUGIN_MARKETPLACE_ENTRY_LIMIT + 5 }, (_, index) =>
|
||||
entry(`acme.p${index}`, {
|
||||
releases: Array.from({ length: PLUGIN_CATALOG_RELEASE_LIMIT + 3 }, (_, r) =>
|
||||
release(`1.0.${r}`)
|
||||
)
|
||||
})
|
||||
)
|
||||
const parsed = pluginCatalogSchema.parse(catalog(many))
|
||||
expect(parsed.plugins).toHaveLength(PLUGIN_MARKETPLACE_ENTRY_LIMIT)
|
||||
expect(parsed.plugins[0]?.releases).toHaveLength(PLUGIN_CATALOG_RELEASE_LIMIT)
|
||||
})
|
||||
|
||||
it('refuses a newer catalog format with the fix, and requires the version', () => {
|
||||
expect(pluginCatalogVersionError(catalog([], { catalogVersion: 3 }))).toBe(
|
||||
'uses catalog format 3; update Orca to browse this catalog'
|
||||
)
|
||||
expect(pluginCatalogVersionError(catalog([]))).toBeNull()
|
||||
expect(
|
||||
pluginCatalogSchema.safeParse({ name: 'Acme', owner: 'acme', plugins: [] }).success
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
it('offers the newest release this Orca can install', () => {
|
||||
const releases = [
|
||||
release('3.0.0', '2.0.0'),
|
||||
@@ -131,20 +58,6 @@ describe('plugin catalog', () => {
|
||||
).toBe('8.0.0')
|
||||
})
|
||||
|
||||
it('exports a frozen v1 file that old clients accept', () => {
|
||||
const parsed = pluginCatalogSchema.parse(
|
||||
catalog([entry('acme.one', { description: 'One theme.' }), entry('acme.two')])
|
||||
)
|
||||
const legacy = legacyPluginCatalog({ ...parsed, plugins: parsed.plugins })
|
||||
expect(pluginMarketplaceSchema.safeParse(legacy).success).toBe(true)
|
||||
expect(legacy.plugins[0]).toEqual({
|
||||
id: 'acme.one',
|
||||
source: { kind: 'git', url: 'https://github.com/acme/acme.one.git', ref: 'main' },
|
||||
description: 'One theme.',
|
||||
categories: ['themes']
|
||||
})
|
||||
})
|
||||
|
||||
it('lists plugins from directories of one repository and refuses unsafe directories', () => {
|
||||
const at = (path: string, index: number) =>
|
||||
entry(`acme.p${index}`, {
|
||||
|
||||
@@ -4,43 +4,6 @@ import { classifyPluginGitAccessFailure } from './plugin-git-access-failure'
|
||||
const HOST = 'the Orca host (build-box)'
|
||||
|
||||
describe('classifyPluginGitAccessFailure', () => {
|
||||
it('explains a private GitHub repository over HTTPS with gh on the named host', () => {
|
||||
const failure = classifyPluginGitAccessFailure({
|
||||
error:
|
||||
"Cloning into 'repository'...\nremote: Repository not found.\nfatal: repository 'https://github.com/acme/private-notes/' not found",
|
||||
url: 'https://github.com/acme/private-notes',
|
||||
executionHost: HOST
|
||||
})
|
||||
|
||||
expect(failure).toMatchObject({
|
||||
transport: 'https',
|
||||
gitHost: 'github.com',
|
||||
executionHost: HOST
|
||||
})
|
||||
expect(failure?.nextSteps[0]).toBe(
|
||||
`On ${HOST}, sign Git in to GitHub without a prompt: \`gh auth login\` then \`gh auth setup-git\` (or any Git credential helper).`
|
||||
)
|
||||
expect(failure?.nextSteps[1]).toContain('git@github.com:acme/private-notes.git')
|
||||
})
|
||||
|
||||
it('recognises a disabled terminal prompt and an SSH key refusal', () => {
|
||||
expect(
|
||||
classifyPluginGitAccessFailure({
|
||||
error: "fatal: could not read Username for 'https://gitlab.com': terminal prompts disabled",
|
||||
url: 'https://gitlab.com/acme/tools/notes',
|
||||
executionHost: HOST
|
||||
})?.nextSteps[0]
|
||||
).toContain('glab auth login')
|
||||
const ssh = classifyPluginGitAccessFailure({
|
||||
error:
|
||||
'git@example.com: Permission denied (publickey).\nfatal: Could not read from remote repository.',
|
||||
url: 'git@example.com:acme/notes.git',
|
||||
executionHost: HOST
|
||||
})
|
||||
expect(ssh?.transport).toBe('ssh')
|
||||
expect(ssh?.nextSteps[0]).toContain('ssh-agent')
|
||||
})
|
||||
|
||||
it('leaves other failures alone and strips credentials from the detail', () => {
|
||||
expect(
|
||||
classifyPluginGitAccessFailure({
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { pluginNameClashKeys } from './plugin-name-clashes'
|
||||
|
||||
const item = (key: string, name: string, official = false) => ({
|
||||
key,
|
||||
name,
|
||||
publisher: key.split('.')[0],
|
||||
official
|
||||
})
|
||||
|
||||
describe('pluginNameClashKeys', () => {
|
||||
it('marks only the non-official side of a clash', () => {
|
||||
expect(
|
||||
pluginNameClashKeys([
|
||||
item('stablyai.orca-catppuccin-theme', 'Catppuccin for Orca', true),
|
||||
item('vale-c.catppuccin', 'Catppuccin for Orca')
|
||||
])
|
||||
).toEqual(new Set(['vale-c.catppuccin']))
|
||||
})
|
||||
|
||||
it('marks every side when none is official, ignoring case and spacing', () => {
|
||||
expect(
|
||||
pluginNameClashKeys([
|
||||
item('acme.mocha', 'Mocha'),
|
||||
item('beta.mocha', ' mocha '),
|
||||
item('c.x', 'X')
|
||||
])
|
||||
).toEqual(new Set(['acme.mocha', 'beta.mocha']))
|
||||
})
|
||||
|
||||
it('leaves unique names and official clashes plain', () => {
|
||||
expect(
|
||||
pluginNameClashKeys([
|
||||
item('stablyai.a', 'Same', true),
|
||||
item('stablyai.b', 'Same', true),
|
||||
item('acme.c', 'Other')
|
||||
]).size
|
||||
).toBe(0)
|
||||
})
|
||||
|
||||
it('does not count one item listed twice as a clash', () => {
|
||||
expect(pluginNameClashKeys([item('acme.x', 'X'), item('acme.x', 'X')]).size).toBe(0)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user