From 3014bdaa5ffb14220be401e0fc4e1f3a0b5a2f55 Mon Sep 17 00:00:00 2001 From: OrcaWin Date: Sun, 15 Nov 2026 23:30:47 -0800 Subject: [PATCH] test: remove six low-value suites and trim parser coverage (#43014) Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> --- .../scripts/ci/sharding/ci-shard-timings.json | 1 - .../git/maintenance/loose-ref-count.test.ts | 64 ------ .../appearance/plugin-theme-settings.test.ts | 121 ----------- .../search-subprocess-lines.test.ts | 9 - .../repository/manual-repo-order.test.ts | 62 ------ .../nvm-default-alias.test.ts | 100 --------- .../issue-12656-terminal-link-tooltip.spec.ts | 189 ------------------ tests/e2e/plugin-syntax-smoke.spec.ts | 73 ------- 8 files changed, 619 deletions(-) delete mode 100644 src/shared/git/maintenance/loose-ref-count.test.ts delete mode 100644 src/shared/plugins/appearance/plugin-theme-settings.test.ts delete mode 100644 src/shared/repository/manual-repo-order.test.ts delete mode 100644 src/shared/shell/command-resolution/nvm-default-alias.test.ts delete mode 100644 tests/e2e/issue-12656-terminal-link-tooltip.spec.ts delete mode 100644 tests/e2e/plugin-syntax-smoke.spec.ts diff --git a/config/scripts/ci/sharding/ci-shard-timings.json b/config/scripts/ci/sharding/ci-shard-timings.json index f0b27612a74..1b4166d56a0 100644 --- a/config/scripts/ci/sharding/ci-shard-timings.json +++ b/config/scripts/ci/sharding/ci-shard-timings.json @@ -4906,7 +4906,6 @@ "tests/e2e/headless-serve-desktop-activation.spec.ts": 16700, "tests/e2e/headless-serve-focused-terminal-create.spec.ts": 13200, "tests/e2e/host-parked-pane-remote-viewer.spec.ts": 144000, - "tests/e2e/issue-12656-terminal-link-tooltip.spec.ts": 21000, "tests/e2e/korean-ime-terminal-shift-enter-commit.spec.ts": 104400, "tests/e2e/landing-preflight-runtime-routing.spec.ts": 11000, "tests/e2e/large-diff-freeze-repro.spec.ts": 35800, diff --git a/src/shared/git/maintenance/loose-ref-count.test.ts b/src/shared/git/maintenance/loose-ref-count.test.ts deleted file mode 100644 index 83f645ede5e..00000000000 --- a/src/shared/git/maintenance/loose-ref-count.test.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { mkdir, mkdtemp, rm, symlink, writeFile } from 'node:fs/promises' -import { tmpdir } from 'node:os' -import { join } from 'node:path' -import { afterEach, describe, expect, it } from 'vitest' - -import { countLooseRefs } from './loose-ref-count' - -const roots: string[] = [] - -async function makeRefsTree(counts: Record): Promise { - const root = await mkdtemp(join(tmpdir(), 'orca-loose-refs-')) - roots.push(root) - const refs = join(root, 'refs') - for (const [namespace, count] of Object.entries(counts)) { - const directory = join(refs, namespace) - await mkdir(directory, { recursive: true }) - for (let index = 0; index < count; index += 1) { - await writeFile(join(directory, `ref-${index}`), 'a'.repeat(40)) - } - } - await mkdir(refs, { recursive: true }) - return refs -} - -afterEach(async () => { - await Promise.all(roots.splice(0).map((root) => rm(root, { recursive: true, force: true }))) -}) - -describe('countLooseRefs', () => { - it('counts files across nested namespaces', async () => { - const refs = await makeRefsTree({ heads: 3, 'remotes/origin': 4, 'remotes/fork/deep': 2 }) - - await expect(countLooseRefs(refs, 100)).resolves.toEqual({ count: 9, saturated: false }) - }) - - it('stops at the budget instead of walking the whole backlog', async () => { - const refs = await makeRefsTree({ 'remotes/origin': 500 }) - - const result = await countLooseRefs(refs, 10) - - expect(result).toEqual({ count: 10, saturated: true }) - }) - - it('reports zero for a repository with no refs directory', async () => { - const root = await mkdtemp(join(tmpdir(), 'orca-loose-refs-missing-')) - roots.push(root) - - await expect(countLooseRefs(join(root, 'refs'), 100)).resolves.toEqual({ - count: 0, - saturated: false - }) - }) - - it('does not follow directory symlinks into a loop', async () => { - const refs = await makeRefsTree({ heads: 2 }) - await symlink(refs, join(refs, 'loop'), 'dir') - - const result = await countLooseRefs(refs, 100) - - expect(result.saturated).toBe(false) - // The symlink is one dirent, never a second traversal of the tree. - expect(result.count).toBe(3) - }) -}) diff --git a/src/shared/plugins/appearance/plugin-theme-settings.test.ts b/src/shared/plugins/appearance/plugin-theme-settings.test.ts deleted file mode 100644 index 5a35e6dffb4..00000000000 --- a/src/shared/plugins/appearance/plugin-theme-settings.test.ts +++ /dev/null @@ -1,121 +0,0 @@ -import { describe, expect, it } from 'vitest' - -import { - hasLegacyMatchTerminalSidebar, - legacyMatchTerminalSidebarWrite, - syncLegacyMatchTerminalSidebar, - pluginThemeSettingsAfterRemoval -} from './plugin-theme-settings' - -const colors = { background: '#1b1430', foreground: '#e8e0ff', red: '#ff6b8b' } - -describe('plugin theme settings', () => { - it('forgets an uninstalled plugin and restores the earlier Theme choice', () => { - expect( - pluginThemeSettingsAfterRemoval( - { - theme: 'dark', - themeBeforePlugin: 'system', - pluginAppTheme: 'plugin:samples.dusk/dusk', - pluginIconTheme: 'plugin:samples.dusk/icons', - terminalThemeDark: 'plugin:samples.dusk/dusk', - terminalThemeLight: 'Builtin Tango Light', - terminalPluginPalettes: [{ id: 'plugin:samples.dusk/dusk', colors }] - }, - 'samples.dusk' - ) - ).toEqual({ - pluginAppTheme: null, - themeBeforePlugin: null, - theme: 'system', - pluginIconTheme: null, - terminalThemeDark: '', - terminalPluginPalettes: [] - }) - expect( - pluginThemeSettingsAfterRemoval( - { - theme: 'light', - pluginAppTheme: 'plugin:samples.dusk-two/dusk', - terminalThemeDark: '', - terminalThemeLight: '' - }, - 'samples.dusk' - ) - ).toEqual({}) - }) - - it("clears only the removed plugin's light or dark slot", () => { - expect( - pluginThemeSettingsAfterRemoval( - { - theme: 'system', - pluginAppThemeLight: 'plugin:other.dawn/dawn', - pluginAppThemeDark: 'plugin:samples.dusk/dusk', - editorThemeLight: 'plugin:samples.dusk/dusk', - editorThemeDark: 'light', - terminalThemeDark: '', - terminalThemeLight: '' - }, - 'samples.dusk' - ) - ).toEqual({ pluginAppThemeDark: null, editorThemeLight: null }) - }) - - it('moves the legacy Match Terminal sidebar into the empty app theme slots', () => { - const legacy = { - leftSidebarAppearanceMode: 'match-terminal' as const, - pluginAppThemeLight: null, - pluginAppThemeDark: 'plugin:samples.dusk/dusk' as const - } - expect(hasLegacyMatchTerminalSidebar(legacy)).toBe(true) - expect(syncLegacyMatchTerminalSidebar(legacy, true)).toEqual({ - leftSidebarAppearanceMode: 'match-terminal', - pluginAppThemeLight: 'match-terminal', - pluginAppThemeDark: 'plugin:samples.dusk/dusk' - }) - }) - - it('keeps the sidebar value in step with the slots so older Orca still matches the terminal', () => { - const current = { - leftSidebarAppearanceMode: 'match-terminal' as const, - pluginAppThemeLight: 'match-terminal' as const, - pluginAppThemeDark: 'match-terminal' as const - } - // Choosing Built-in for one mode keeps the mirror; for both, it clears it without refilling. - expect(legacyMatchTerminalSidebarWrite(current, { pluginAppThemeLight: null })).toMatchObject({ - leftSidebarAppearanceMode: 'match-terminal', - pluginAppThemeLight: null - }) - const builtIn = legacyMatchTerminalSidebarWrite(current, { - pluginAppThemeLight: null, - pluginAppThemeDark: null - }) - expect(builtIn.leftSidebarAppearanceMode).toBe('default') - expect(hasLegacyMatchTerminalSidebar({ ...current, ...builtIn })).toBe(false) - // A full-settings write keeps the mirror beside the cleared slots; that is not legacy intent. - expect( - legacyMatchTerminalSidebarWrite(current, { - ...current, - pluginAppThemeLight: null, - pluginAppThemeDark: null - }) - ).toMatchObject({ - pluginAppThemeLight: null, - pluginAppThemeDark: null, - leftSidebarAppearanceMode: 'default' - }) - expect( - legacyMatchTerminalSidebarWrite( - { ...current, pluginAppThemeLight: null, pluginAppThemeDark: null }, - { leftSidebarAppearanceMode: 'match-terminal' } - ) - ).toMatchObject({ pluginAppThemeLight: 'match-terminal', pluginAppThemeDark: 'match-terminal' }) - expect( - legacyMatchTerminalSidebarWrite(current, { leftSidebarAppearanceMode: 'tinted' }) - ).toMatchObject({ - leftSidebarAppearanceMode: 'tinted' - }) - expect(legacyMatchTerminalSidebarWrite(current, { editorAutoSave: true })).toEqual({}) - }) -}) diff --git a/src/shared/process-streams/search-subprocess-lines.test.ts b/src/shared/process-streams/search-subprocess-lines.test.ts index 7cdf6734a87..5423971042b 100644 --- a/src/shared/process-streams/search-subprocess-lines.test.ts +++ b/src/shared/process-streams/search-subprocess-lines.test.ts @@ -33,15 +33,6 @@ describe('SearchSubprocessLineAccumulator', () => { expect(lines).toEqual(['four']) expect(parser.finish()).toBeNull() }) - - it('preserves empty lines and line order within one chunk', () => { - const parser = new SearchSubprocessLineAccumulator(8) - const lines: string[] = [] - - expect(parser.push(Buffer.from('\na\n\n'), (line) => lines.push(line))).toBe(true) - - expect(lines).toEqual(['', 'a', '']) - }) }) describe('oversized search record continuation', () => { diff --git a/src/shared/repository/manual-repo-order.test.ts b/src/shared/repository/manual-repo-order.test.ts deleted file mode 100644 index 882a6ba8036..00000000000 --- a/src/shared/repository/manual-repo-order.test.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { describe, expect, it } from 'vitest' -import type { Repo } from './repo-types' -import type { ManualRepoOrderEntry } from '../ui-chrome-types' -import { - applyManualRepoOrder, - getManualRepoOrder, - normalizeManualRepoOrder -} from './manual-repo-order' - -function repo(id: string, hostId: Repo['executionHostId']): Repo { - return { - id, - path: `/${hostId}/${id}`, - displayName: id, - badgeColor: '#000', - addedAt: 1, - executionHostId: hostId - } -} - -const localAlpha = repo('alpha', 'local') -const localBravo = repo('bravo', 'local') -const remoteCharlie = repo('charlie', 'runtime:node-b') -const remoteDelta = repo('delta', 'runtime:node-b') - -describe('manual repo order', () => { - it('places a late host into its saved positions', () => { - const order = getManualRepoOrder([localAlpha, remoteCharlie, localBravo, remoteDelta]) - const localOnly = applyManualRepoOrder([localBravo, localAlpha], order) - - expect(applyManualRepoOrder([...localOnly, remoteDelta, remoteCharlie], order)).toEqual([ - localAlpha, - remoteCharlie, - localBravo, - remoteDelta - ]) - }) - - it('distinguishes duplicate bare repo ids on different hosts', () => { - const local = repo('same-id', 'local') - const remote = repo('same-id', 'runtime:node-b') - const order = getManualRepoOrder([remote, local]) - - expect(applyManualRepoOrder([local, remote], order)).toEqual([remote, local]) - }) - - it('normalizes malformed, invalid-host, and duplicate entries', () => { - const value = [ - null, - { hostId: 'bogus', repoId: 'bad-host' }, - { hostId: 'local', repoId: '' }, - { hostId: 'runtime:node-b', repoId: 'same-id' }, - { hostId: 'runtime:node-b', repoId: 'same-id' }, - { hostId: 'local', repoId: 'same-id' } - ] as unknown as ManualRepoOrderEntry[] - - expect(normalizeManualRepoOrder(value)).toEqual([ - { hostId: 'runtime:node-b', repoId: 'same-id' }, - { hostId: 'local', repoId: 'same-id' } - ]) - }) -}) diff --git a/src/shared/shell/command-resolution/nvm-default-alias.test.ts b/src/shared/shell/command-resolution/nvm-default-alias.test.ts deleted file mode 100644 index d4cc4680e4d..00000000000 --- a/src/shared/shell/command-resolution/nvm-default-alias.test.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { chmodSync, mkdirSync, mkdtempSync, writeFileSync } from 'node:fs' -import { tmpdir } from 'node:os' -import { join } from 'node:path' -import { describe, expect, it } from 'vitest' -import { getVersionManagerBinPaths, resolveCliCommand } from './node-cli-command-resolution' - -/** Default Node seeds fallback when login probing times out or omits nvm. Newest-first hid CLIs installed under the default (#10932). */ -function makeNvmHome(options: { - versions: string[] - defaultAlias?: string - aliases?: Record - cliIn?: string -}): string { - const home = mkdtempSync(join(tmpdir(), 'orca-nvm-')) - for (const version of options.versions) { - const bin = join(home, '.nvm', 'versions', 'node', version, 'bin') - mkdirSync(bin, { recursive: true }) - for (const name of ['node', 'node.exe']) { - writeFileSync(join(bin, name), '') - chmodSync(join(bin, name), 0o755) - } - if (options.cliIn === version) { - writeFileSync(join(bin, 'codex'), '') - chmodSync(join(bin, 'codex'), 0o755) - } - } - if (options.defaultAlias !== undefined) { - mkdirSync(join(home, '.nvm', 'alias'), { recursive: true }) - writeFileSync(join(home, '.nvm', 'alias', 'default'), `${options.defaultAlias}\n`) - } - for (const [name, value] of Object.entries(options.aliases ?? {})) { - const file = join(home, '.nvm', 'alias', name) - mkdirSync(join(file, '..'), { recursive: true }) - writeFileSync(file, `${value}\n`) - } - return home -} - -function seededNvmDir(homePath: string): string | undefined { - return getVersionManagerBinPaths({ platform: 'darwin', pathEnv: '', homePath }).find((entry) => - entry.includes('.nvm') - ) -} - -describe('nvm default alias decides the seeded runtime', () => { - it('seeds the default version, not the newest install (#10932)', () => { - // The exact shape that broke: `nvm install 26` adds a bare newest version - // while every CLI lives under the default. - const home = makeNvmHome({ - versions: ['v24.18.0', 'v26.7.0'], - defaultAlias: '24', - cliIn: 'v24.18.0' - }) - expect(seededNvmDir(home)).toBe(join(home, '.nvm', 'versions', 'node', 'v24.18.0', 'bin')) - }) - - it('resolves a partial default to the highest matching install', () => { - const home = makeNvmHome({ - versions: ['v24.9.0', 'v24.18.0', 'v26.7.0'], - defaultAlias: '24', - cliIn: 'v24.18.0' - }) - expect(seededNvmDir(home)).toBe(join(home, '.nvm', 'versions', 'node', 'v24.18.0', 'bin')) - }) - - // Real lts/* aliases cannot be materialized on Win32 (* is reserved). Keep faithful names and skip there; the resolver test targets darwin. - it.skipIf(process.platform === 'win32')( - 'follows an alias chain (default -> lts/* -> lts/krypton -> version)', - () => { - const home = makeNvmHome({ - versions: ['v22.9.0', 'v26.7.0'], - defaultAlias: 'lts/*', - aliases: { 'lts/*': 'lts/krypton', 'lts/krypton': 'v22.9.0' }, - cliIn: 'v22.9.0' - }) - expect(seededNvmDir(home)).toBe(join(home, '.nvm', 'versions', 'node', 'v22.9.0', 'bin')) - } - ) - - it('survives a cyclic alias chain instead of hanging', () => { - const home = makeNvmHome({ - versions: ['v24.18.0', 'v26.7.0'], - defaultAlias: 'a', - aliases: { a: 'b', b: 'a' } - }) - expect(seededNvmDir(home)).toBe(join(home, '.nvm', 'versions', 'node', 'v26.7.0', 'bin')) - }) - - it('still finds a CLI that lives outside the default version', () => { - // Default-first is preference only; retain other installed versions as CLI fallbacks. - const home = makeNvmHome({ - versions: ['v24.18.0', 'v26.7.0'], - defaultAlias: '24', - cliIn: 'v26.7.0' - }) - expect(resolveCliCommand('codex', { platform: 'darwin', pathEnv: '', homePath: home })).toBe( - join(home, '.nvm', 'versions', 'node', 'v26.7.0', 'bin', 'codex') - ) - }) -}) diff --git a/tests/e2e/issue-12656-terminal-link-tooltip.spec.ts b/tests/e2e/issue-12656-terminal-link-tooltip.spec.ts deleted file mode 100644 index a096d648c0f..00000000000 --- a/tests/e2e/issue-12656-terminal-link-tooltip.spec.ts +++ /dev/null @@ -1,189 +0,0 @@ -import { randomUUID } from 'node:crypto' -import type { Page, TestInfo } from '@stablyai/playwright-test' -import { expect, test } from './helpers/orca-app' -import { ensureTerminalVisible, waitForSessionReady } from './helpers/store' -import { - getTerminalContent, - sendToTerminal, - waitForActivePanePtyId, - waitForActiveTerminalManager, - waitForTerminalOutput -} from './helpers/terminal' -import { waitForPtyShellEcho } from './terminal-pty-readiness' - -type LinkProbe = { - tabId: string - col: number - row: number -} - -type TooltipState = { - display: string - text: string - cursor: string - paneBottom: number - terminalBottom: number - paddingY: number - tooltipTop: number - tooltipBottom: number - tooltipHeight: number -} - -async function locateUrl(page: Page, url: string): Promise { - return page.evaluate((url) => { - const state = window.__store?.getState() - const worktreeId = state?.activeWorktreeId - const tabId = - state?.activeTabType === 'terminal' - ? (state.activeTabId ?? null) - : worktreeId - ? (state.activeTabIdByWorktree?.[worktreeId] ?? null) - : null - const manager = tabId ? window.__paneManagers?.get(tabId) : null - const pane = manager?.getActivePane?.() ?? manager?.getPanes?.()[0] ?? null - if (!tabId || !pane) { - return null - } - - const buffer = pane.terminal.buffer.active - for (let row = 0; row < pane.terminal.rows; row += 1) { - const line = buffer.getLine(buffer.viewportY + row) - const col = line?.translateToString(true).indexOf(url) ?? -1 - if (col >= 0) { - return { - tabId, - col: col + Math.floor(url.length / 2), - row - } - } - } - return null - }, url) -} - -async function moveToLink(page: Page, probe: LinkProbe): Promise { - const point = await page.evaluate(({ col, row, tabId }) => { - const manager = window.__paneManagers?.get(tabId) - const pane = manager?.getActivePane?.() ?? manager?.getPanes?.()[0] ?? null - const screen = pane?.terminal.element?.querySelector('.xterm-screen') - if (!pane || !screen) { - throw new Error('xterm-screen element unavailable') - } - const cell = pane.terminal.dimensions?.css.cell - if (!cell?.width || !cell.height) { - throw new Error('terminal cell dimensions unavailable') - } - const rect = screen.getBoundingClientRect() - return { - x: rect.left + (col + 0.5) * cell.width, - y: rect.top + (row + 0.5) * cell.height - } - }, probe) - await page.mouse.move(point.x, point.y) -} - -async function readTooltipState(page: Page, tabId: string): Promise { - return page.evaluate((tabId) => { - const manager = window.__paneManagers?.get(tabId) - const pane = manager?.getActivePane?.() ?? manager?.getPanes?.()[0] ?? null - const screen = pane?.terminal.element?.querySelector('.xterm-screen') - if (!pane || !screen) { - throw new Error('terminal pane unavailable') - } - - const paneRect = pane.container.getBoundingClientRect() - const terminalRect = pane.terminal.element?.parentElement?.getBoundingClientRect() - const tooltipRect = pane.linkTooltip.getBoundingClientRect() - // Mirrors the 4px fallback terminal.css uses when no padding setting is applied. - const paddingVar = getComputedStyle(pane.container).getPropertyValue('--pane-padding-y').trim() - const paddingY = paddingVar ? Number.parseFloat(paddingVar) : 4 - - return { - display: pane.linkTooltip.style.display, - text: pane.linkTooltip.textContent ?? '', - cursor: getComputedStyle(screen).cursor, - paneBottom: paneRect.bottom, - terminalBottom: terminalRect?.bottom ?? 0, - paddingY, - tooltipTop: tooltipRect.top, - tooltipBottom: tooltipRect.bottom, - tooltipHeight: tooltipRect.height - } - }, tabId) -} - -// The terminal keeps exactly its bottom padding inset (#36789); a hover that shrank it would grow this. -function terminalBottomInsetDrift(state: TooltipState): number { - return Math.abs(state.paneBottom - state.paddingY - state.terminalBottom) -} - -async function captureProof(page: Page, testInfo: TestInfo, name: string): Promise { - await page.screenshot({ path: testInfo.outputPath(name), animations: 'disabled' }) -} - -test.describe('Issue #12656 terminal link tooltip', () => { - test('clears hover state without permanently shrinking the terminal', async ({ - orcaPage - }, testInfo) => { - await waitForSessionReady(orcaPage) - await ensureTerminalVisible(orcaPage) - await waitForActiveTerminalManager(orcaPage) - - const ptyId = await waitForActivePanePtyId(orcaPage) - await waitForPtyShellEcho(orcaPage, ptyId, 15_000) - - const url = `https://example.com/orca-issue-12656-${randomUUID().slice(0, 8)}` - await sendToTerminal( - orcaPage, - ptyId, - `printf 'issue-12656-output-%02d\\n' $(seq 1 64); printf '${url}\\n'\r` - ) - await waitForTerminalOutput(orcaPage, url) - - const located: { probe: LinkProbe | null } = { probe: null } - await expect - .poll( - async () => { - located.probe = await locateUrl(orcaPage, url) - return located.probe - }, - { timeout: 5_000, message: 'URL did not become visible in the terminal viewport' } - ) - .not.toBeNull() - if (!located.probe) { - throw new Error('URL probe disappeared before hover') - } - let probe: LinkProbe = located.probe - const idle = await readTooltipState(orcaPage, probe.tabId) - expect(terminalBottomInsetDrift(idle)).toBeLessThanOrEqual(1) - await expect - .poll(async () => { - const currentProbe = await locateUrl(orcaPage, url) - if (!currentProbe) { - return { display: 'none', text: '' } - } - probe = currentProbe - await moveToLink(orcaPage, currentProbe) - return readTooltipState(orcaPage, currentProbe.tabId) - }) - .toMatchObject({ display: '', text: expect.stringContaining(url) }) - - const hovered = await readTooltipState(orcaPage, probe.tabId) - expect(hovered.text).toContain(url) - expect(hovered.tooltipHeight).toBeGreaterThan(0) - expect(terminalBottomInsetDrift(hovered)).toBeLessThanOrEqual(1) - expect(Math.abs(hovered.paneBottom - hovered.tooltipBottom)).toBeLessThanOrEqual(1) - expect(hovered.tooltipTop).toBeLessThan(hovered.terminalBottom) - await captureProof(orcaPage, testInfo, 'issue-12656-fixed-hover.png') - - await orcaPage.evaluate(() => window.dispatchEvent(new Event('blur'))) - await expect - .poll(() => readTooltipState(orcaPage, probe.tabId)) - .toMatchObject({ display: 'none', cursor: 'text' }) - const cleared = await readTooltipState(orcaPage, probe.tabId) - expect(terminalBottomInsetDrift(cleared)).toBeLessThanOrEqual(1) - await captureProof(orcaPage, testInfo, 'issue-12656-fixed-after-blur.png') - - await expect.poll(() => getTerminalContent(orcaPage)).toContain(url) - }) -}) diff --git a/tests/e2e/plugin-syntax-smoke.spec.ts b/tests/e2e/plugin-syntax-smoke.spec.ts deleted file mode 100644 index 7ce26d324fa..00000000000 --- a/tests/e2e/plugin-syntax-smoke.spec.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Invariant: a plugin syntax highlights an already-open plain-text file without a reload, - * re-highlights it when the grammar updates, and lets go when the plugin is disabled. - */ - -import { cp, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises' -import { tmpdir } from 'node:os' -import { join } from 'node:path' -import type { Page } from '@stablyai/playwright-test' -import { expect, test } from './helpers/orca-app' -import { - disablePluginSystem, - editorTokenClasses, - editorTokenColor, - enableDevPlugins, - openRepoFile -} from './helpers/plugin-smoke' - -const FILE = 'plugin-syntax-smoke.gleam' -const OTHER = 'plugin-syntax-smoke-other.txt' -// Monaco's built-in light and dark theme colors for the tokens the Gleam pack maps to. -const COMMENT = ['rgb(0, 128, 0)', 'rgb(96, 139, 78)'] -const TYPE = ['rgb(0, 128, 128)', 'rgb(61, 201, 176)'] -const NUMBER = ['rgb(9, 134, 88)', 'rgb(181, 206, 168)'] - -const colorIn = async (page: Page, text: string, palette: string[]): Promise => - palette.includes((await editorTokenColor(page, text)) ?? '') - -test('plugin syntax highlights live and follows updates', async ({ orcaPage, seededRepoPath }) => { - const pluginRoot = await mkdtemp(join(tmpdir(), 'orca-syntax-smoke-')) - const grammarPath = join(pluginRoot, 'syntaxes', 'gleam.tmLanguage.json') - try { - await cp(join(process.cwd(), 'examples', 'plugins', 'orca-gleam-syntax'), pluginRoot, { - recursive: true - }) - await writeFile(join(seededRepoPath, FILE), '// a comment\npub fn main() -> Int { 42 }\n') - await writeFile(join(seededRepoPath, OTHER), 'plain\n') - await openRepoFile(orcaPage, seededRepoPath, FILE) - await expect.poll(() => editorTokenClasses(orcaPage, 'a comment')).toHaveLength(1) - - await enableDevPlugins(orcaPage, [pluginRoot]) - await expect.poll(() => editorTokenClasses(orcaPage), { timeout: 15_000 }).not.toHaveLength(1) - // Colors come from the theme rules core languages use, not one generic color. - await expect.poll(() => colorIn(orcaPage, '// a comment', COMMENT)).toBe(true) - await expect.poll(() => colorIn(orcaPage, 'Int', TYPE)).toBe(true) - await expect.poll(() => colorIn(orcaPage, '42', NUMBER)).toBe(true) - - // Switching away and back reuses the kept model; it must come back highlighted. - await openRepoFile(orcaPage, seededRepoPath, OTHER) - await expect.poll(() => colorIn(orcaPage, 'plain', COMMENT)).toBe(false) - await openRepoFile(orcaPage, seededRepoPath, FILE) - await expect - .poll(() => colorIn(orcaPage, '// a comment', COMMENT), { timeout: 15_000 }) - .toBe(true) - const commentBefore = await editorTokenClasses(orcaPage, 'a comment') - - // An update that colors comments like keywords re-highlights the open file in place. - const grammar = await readFile(grammarPath, 'utf8') - await writeFile(grammarPath, grammar.replaceAll('comment.line.gleam', 'keyword.control.gleam')) - await orcaPage.evaluate(() => window.api.plugins.refresh()) - await expect - .poll(() => editorTokenClasses(orcaPage, 'a comment'), { timeout: 15_000 }) - .not.toEqual(commentBefore) - - await disablePluginSystem(orcaPage) - await expect.poll(() => editorTokenClasses(orcaPage), { timeout: 15_000 }).toHaveLength(1) - } finally { - await disablePluginSystem(orcaPage).catch(() => undefined) - await rm(join(seededRepoPath, FILE), { force: true }) - await rm(join(seededRepoPath, OTHER), { force: true }) - await rm(pluginRoot, { recursive: true, force: true }) - } -})