From a3bf245d42374407fcfb7eb43b2d57c427a87caf Mon Sep 17 00:00:00 2001 From: OrcaWin <293788423+OrcaWin@users.noreply.github.com> Date: Thu, 12 Nov 2026 13:33:33 -0800 Subject: [PATCH] test: prune low-value theme and icon artifact samples --- .../plugin-icon-theme-artifact.test.ts | 49 ----------------- .../artifacts/plugin-theme-artifact.test.ts | 54 ------------------- 2 files changed, 103 deletions(-) diff --git a/src/shared/plugins/artifacts/plugin-icon-theme-artifact.test.ts b/src/shared/plugins/artifacts/plugin-icon-theme-artifact.test.ts index c51cab98b5a..62cae24915e 100644 --- a/src/shared/plugins/artifacts/plugin-icon-theme-artifact.test.ts +++ b/src/shared/plugins/artifacts/plugin-icon-theme-artifact.test.ts @@ -1,6 +1,5 @@ import { describe, expect, it } from 'vitest' import { - isPlausiblePluginIconSvg, isPluginIconThemeRegistration, parsePluginIconThemeArtifact } from './plugin-icon-theme-artifact' @@ -16,28 +15,6 @@ describe('plugin icon theme artifacts', () => { parse({ schemaVersion: 1, folderNames, folderNamesExpanded: folderNames }) ).toThrow(/mappings/) }) - - it.each([ - ['a case-only duplicate', { schemaVersion: 1, fileExtensions: { ts: 'a.svg', TS: 'b.svg' } }], - ['an unknown slot', { schemaVersion: 1, icons: { 'sidebar.search': 'a.svg' } }], - ['a path in a file name', { schemaVersion: 1, fileNames: { 'a/b': 'a.svg' } }], - ['a path in a folder name', { schemaVersion: 1, folderNames: { 'a\\b': 'a.svg' } }], - [ - 'a case-only duplicate folder', - { schemaVersion: 1, folderNamesExpanded: { src: 'a.svg', Src: 'b.svg' } } - ], - ['an escaping icon path', { schemaVersion: 1, icons: { file: '../a.svg' } }] - ])('rejects %s', (_label, value) => { - expect(() => parse(value)).toThrow() - }) - - it('skips unknown slots at runtime', () => { - expect( - parsePluginIconThemeArtifact( - JSON.stringify({ schemaVersion: 1, icons: { file: 'f.svg', 'sidebar.search': 'a.svg' } }) - ).icons - ).toEqual({ file: 'f.svg' }) - }) }) describe('plugin icon theme artifact prototype keys', () => { @@ -81,14 +58,6 @@ describe('isPluginIconThemeRegistration', () => { folderNamesExpanded: {} } - it.each([ - ['an index past the SVG list', { constructor: 1 }], - ['a negative index', { constructor: -1 }], - ['a fractional index', { constructor: 0.5 }] - ])('rejects %s', (_label, fileNames) => { - expect(isPluginIconThemeRegistration({ ...base, fileNames })).toBe(false) - }) - it('checks the range of an own __proto__ index too', () => { const fileNames = JSON.parse('{"__proto__":5}') expect(isPluginIconThemeRegistration({ ...base, fileNames })).toBe(false) @@ -96,22 +65,4 @@ describe('isPluginIconThemeRegistration', () => { isPluginIconThemeRegistration({ ...base, fileNames: JSON.parse('{"__proto__":0}') }) ).toBe(true) }) - - it('checks folder indexes too', () => { - expect( - isPluginIconThemeRegistration({ ...base, fileNames: {}, folderNamesExpanded: { src: 1 } }) - ).toBe(false) - }) -}) - -describe('isPlausiblePluginIconSvg', () => { - it.each([ - ['an SVG', '', true], - ['an XML declaration and comment first', '', true], - ['a DOCTYPE', '', false], - ['an entity declaration', '', false], - ['HTML', '', false] - ])('accepts %s: %s', (_label, svg, expected) => { - expect(isPlausiblePluginIconSvg(svg)).toBe(expected) - }) }) diff --git a/src/shared/plugins/artifacts/plugin-theme-artifact.test.ts b/src/shared/plugins/artifacts/plugin-theme-artifact.test.ts index 2f3c0531b6c..e9363925381 100644 --- a/src/shared/plugins/artifacts/plugin-theme-artifact.test.ts +++ b/src/shared/plugins/artifacts/plugin-theme-artifact.test.ts @@ -1,39 +1,10 @@ import { describe, expect, it } from 'vitest' import { parsePluginAppThemeArtifact } from './plugin-theme-artifact' -import { parsePluginTerminalThemeArtifact } from './plugin-terminal-theme-artifact' const parseApp = (value: unknown) => () => parsePluginAppThemeArtifact(JSON.stringify(value), 'strict') describe('plugin app theme artifacts', () => { - it.each([ - ['a private token', { base: 'dark', tokens: { '--internal-gap': '#000' } }], - ['a URL', { base: 'dark', tokens: { '--background': 'url(x)' } }], - ['a var() chain', { base: 'dark', tokens: { '--background': 'var(--a)' } }], - ['declaration syntax', { base: 'dark', tokens: { '--background': '#000; color: red' } }], - ['no tokens', { base: 'dark', tokens: {} }], - [ - 'transparent', - { base: 'dark', tokens: { '--background': 'transparent', '--foreground': '#fff' } } - ], - ['an unknown key', { base: 'dark', tokens: { '--border': '#000' }, extra: 1 }] - ])('rejects %s', (_label, value) => { - expect(parseApp(value)).toThrow() - }) - - it('skips unknown tokens and keys at runtime so newer themes still load', () => { - const theme = parsePluginAppThemeArtifact( - JSON.stringify({ - schemaVersion: 1, - base: 'dark', - tokens: { '--background': '#000', '--foreground': '#fff', '--future': '#123' }, - future: true - }) - ) - expect(theme.tokens).not.toHaveProperty('--future') - expect(parseApp({ schemaVersion: 2, base: 'dark', tokens: {} })).toThrow() - }) - it('reads a background image, strict for authors and never fatal at runtime', () => { const base = { base: 'dark', tokens: { '--background': '#000', '--foreground': '#fff' } } const background = { path: 'images/dusk.webp', opacity: 0.35, size: 'tile' } @@ -73,28 +44,3 @@ describe('plugin app theme artifacts', () => { ).toEqual([{ scope: ['keyword'], settings: { foreground: '#ff79c6' } }]) }) }) - -describe('plugin terminal theme artifacts', () => { - const terminal = { background: '#000000', foreground: '#ffffff', green: '#00ff00' } - - it('skips unknown slots at runtime', () => { - expect( - parsePluginTerminalThemeArtifact( - JSON.stringify({ schemaVersion: 1, terminal: { ...terminal, glow: '#000000' } }) - ) - ).toEqual({ mode: 'unknown', terminal }) - }) - - it.each([ - ['an unknown slot', { ...terminal, glow: '#000000' }], - ['an invalid color', { ...terminal, red: 'red; x' }], - ['no ANSI color', { background: '#000000', foreground: '#ffffff' }] - ])('rejects %s', (_label, colors) => { - expect(() => - parsePluginTerminalThemeArtifact( - JSON.stringify({ schemaVersion: 1, terminal: colors }), - 'strict' - ) - ).toThrow() - }) -})