mirror of
https://github.com/stablyai/orca.git
synced 2026-11-15 10:27:33 +00:00
test: remove catalogue and animation suites and repeated input cases (#42238)
* test: remove catalogue and animation bookkeeping cases * test: trim repeated extension inputs and pairing copy checks --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -1,70 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
import { act, cleanup, render } from '@testing-library/react'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { ChatUiDemoCard, ChatUiHereFeatureTipVisual } from './ChatUiHereFeatureTipVisual'
|
||||
|
||||
function motion(initial: boolean): (matches: boolean) => void {
|
||||
const target = new EventTarget()
|
||||
const media = {
|
||||
matches: initial,
|
||||
addEventListener: target.addEventListener.bind(target),
|
||||
removeEventListener: target.removeEventListener.bind(target)
|
||||
}
|
||||
vi.stubGlobal('matchMedia', () => media)
|
||||
return (matches) => {
|
||||
media.matches = matches
|
||||
const event = new Event('change')
|
||||
Object.defineProperty(event, 'matches', { value: matches })
|
||||
target.dispatchEvent(event)
|
||||
}
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
cleanup()
|
||||
vi.useRealTimers()
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
|
||||
describe('chat tip visual lifetime', () => {
|
||||
it('keeps one beat timer through a complete loop, stops for motion changes and retires it on unmount', () => {
|
||||
vi.useFakeTimers()
|
||||
const changeMotion = motion(false)
|
||||
const { container, unmount } = render(<ChatUiHereFeatureTipVisual />)
|
||||
const initial = container.innerHTML
|
||||
const started = Date.now()
|
||||
// Each act settles the next production beat; passing the loop boundary must make progress.
|
||||
for (let beats = 0; Date.now() - started < 13_000 && beats < 250; beats++) {
|
||||
expect(vi.getTimerCount()).toBe(1)
|
||||
act(() => vi.advanceTimersToNextTimer())
|
||||
}
|
||||
expect(Date.now() - started).toBeGreaterThanOrEqual(13_000)
|
||||
expect(container.innerHTML).not.toBe(initial)
|
||||
act(() => changeMotion(true))
|
||||
expect(vi.getTimerCount()).toBe(0)
|
||||
const finished = container.innerHTML
|
||||
act(() => vi.advanceTimersByTime(30_000))
|
||||
expect(container.innerHTML).toBe(finished)
|
||||
act(() => changeMotion(false))
|
||||
expect(vi.getTimerCount()).toBe(1)
|
||||
unmount()
|
||||
expect(vi.getTimerCount()).toBe(0)
|
||||
})
|
||||
|
||||
it('holds the finished one-shot frame without leaving a timer running', () => {
|
||||
vi.useFakeTimers()
|
||||
const changeMotion = motion(false)
|
||||
const { container } = render(<ChatUiDemoCard loop={false} />)
|
||||
for (let beat = 0; vi.getTimerCount() > 0 && beat < 250; beat++) {
|
||||
act(() => vi.advanceTimersToNextTimer())
|
||||
}
|
||||
expect(vi.getTimerCount()).toBe(0)
|
||||
expect(container.querySelectorAll('[data-on="true"]').length).toBeGreaterThan(10)
|
||||
const finished = container.innerHTML
|
||||
act(() => vi.advanceTimersByTime(30_000))
|
||||
expect(container.innerHTML).toBe(finished)
|
||||
act(() => changeMotion(true))
|
||||
act(() => changeMotion(false))
|
||||
expect(vi.getTimerCount()).toBe(0)
|
||||
expect(container.innerHTML).toBe(finished)
|
||||
})
|
||||
})
|
||||
-4
@@ -47,7 +47,6 @@ describe('RuntimePairingGeneratorForm', () => {
|
||||
webClientUrl: 'https://example.test/?pair=stale-secret'
|
||||
})
|
||||
|
||||
expect(markup).toContain('The connection address changed.')
|
||||
expect(markup).not.toContain('stale-secret')
|
||||
})
|
||||
|
||||
@@ -59,11 +58,8 @@ describe('RuntimePairingGeneratorForm', () => {
|
||||
}
|
||||
const live = renderForm('another', '100.76.32.125', generated, { kind: 'expires', at: 0 })
|
||||
expect(live).toContain('old-secret')
|
||||
expect(live).toContain('Unused link expires at')
|
||||
|
||||
const expired = renderForm('another', '100.76.32.125', generated, { kind: 'expired' })
|
||||
expect(expired).toContain('Link expired')
|
||||
expect(expired).not.toContain('old-secret')
|
||||
expect(expired).toContain('Create link')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -27,24 +27,6 @@ function resolveSelection(repos: Repo[], persisted: string[], preferred?: string
|
||||
}
|
||||
|
||||
describe('task page initial repo selection', () => {
|
||||
it('normalizes persisted selections without a repository scan for every stored ID', () => {
|
||||
let reads = 0
|
||||
const repos: Repo[] = Array.from({ length: 1000 }, (_, index) => ({
|
||||
get id() {
|
||||
reads++
|
||||
return `repo-${index}`
|
||||
},
|
||||
path: `/repos/${index}`,
|
||||
displayName: `Repo ${index}`,
|
||||
badgeColor: '',
|
||||
addedAt: index,
|
||||
kind: 'git'
|
||||
}))
|
||||
const persisted = Array.from({ length: 1000 }, (_, index) => `repo-${index}`)
|
||||
expect(resolveSelection(repos, persisted)).toEqual(persisted)
|
||||
expect(reads).toBeLessThan(40_000)
|
||||
})
|
||||
|
||||
it('ignores persisted IDs for ineligible repos, including folder workspaces', () => {
|
||||
const repos: Repo[] = [
|
||||
{
|
||||
|
||||
@@ -8,13 +8,7 @@ const CALLER = 'a'.repeat(32)
|
||||
const OTHER = 'b'.repeat(32)
|
||||
|
||||
describe('resolveBrowserExtensionRequestedUrl', () => {
|
||||
it.each([
|
||||
'file:///etc/passwd',
|
||||
'javascript:alert(1)',
|
||||
'data:text/html,<script>1</script>',
|
||||
'chrome://settings',
|
||||
'chrome-extension://not-an-id/page.html'
|
||||
])('refuses %s', (raw) => {
|
||||
it.each(['file:///etc/passwd', 'chrome-extension://not-an-id/page.html'])('refuses %s', (raw) => {
|
||||
expect(resolveBrowserExtensionRequestedUrl(raw, CALLER)).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,44 +1,15 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
isChromeWebStoreUrl,
|
||||
parseChromeWebStoreExtensionInput
|
||||
} from './browser-extension-webstore'
|
||||
import { parseChromeWebStoreExtensionInput } from './browser-extension-webstore'
|
||||
|
||||
const BITWARDEN = 'nngceckbapebfimnlniiiahkandclblb'
|
||||
|
||||
describe('parseChromeWebStoreExtensionInput', () => {
|
||||
it.each([
|
||||
'',
|
||||
'bitwarden',
|
||||
BITWARDEN.slice(1),
|
||||
'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz',
|
||||
`http://chromewebstore.google.com/detail/bitwarden/${BITWARDEN}`,
|
||||
`https://chromewebstore.google.com.evil.tld/detail/bitwarden/${BITWARDEN}`,
|
||||
`https://evil.tld/chromewebstore.google.com/detail/bitwarden/${BITWARDEN}`,
|
||||
`https://user@chromewebstore.google.com/detail/bitwarden/${BITWARDEN}`,
|
||||
`https://chromewebstore.google.com/search/${BITWARDEN}`,
|
||||
`https://addons.mozilla.org/detail/${BITWARDEN}`
|
||||
`https://chromewebstore.google.com/search/${BITWARDEN}`
|
||||
])('rejects %j', (input) => {
|
||||
expect(parseChromeWebStoreExtensionInput(input)).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('isChromeWebStoreUrl', () => {
|
||||
it('accepts only the exact store origin', () => {
|
||||
expect(isChromeWebStoreUrl(`https://chromewebstore.google.com/detail/x/${BITWARDEN}`)).toBe(
|
||||
true
|
||||
)
|
||||
expect(isChromeWebStoreUrl('https://chromewebstore.google.com')).toBe(true)
|
||||
for (const url of [
|
||||
'https://chromewebstore.google.com.evil.tld/',
|
||||
'https://evil.chromewebstore.google.com/',
|
||||
'http://chromewebstore.google.com/',
|
||||
'https://chromewebstore.google.com:8443/',
|
||||
'https://evil.tld/?https://chromewebstore.google.com',
|
||||
'chrome-extension://chromewebstore.google.com/',
|
||||
'not a url'
|
||||
]) {
|
||||
expect(isChromeWebStoreUrl(url), url).toBe(false)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -13,22 +13,4 @@ describe('formatter command arguments', () => {
|
||||
)
|
||||
).toEqual(['formatter', '--stdin-filepath', file, '--relative=src/${file}.ts'])
|
||||
})
|
||||
|
||||
it('keeps native Windows paths and executable spaces intact', () => {
|
||||
expect(
|
||||
editorFormatterArgv(
|
||||
'"C:\\Program Files\\Formatter\\fmt.exe" --path "${file}"',
|
||||
'C:\\repo\\a b.ts',
|
||||
'a b.ts',
|
||||
'win32'
|
||||
)
|
||||
).toEqual(['C:\\Program Files\\Formatter\\fmt.exe', '--path', 'C:\\repo\\a b.ts'])
|
||||
})
|
||||
|
||||
it.each(['', 'formatter "unfinished', 'formatter --write ${file}', 'gofmt -w ${file}'])(
|
||||
'rejects invalid or file-writing command %s',
|
||||
(command) => {
|
||||
expect(() => editorFormatterArgv(command, '/repo/a.ts', 'a.ts', 'linux')).toThrow()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
getCompletedFeatureTipIds,
|
||||
getOrderedUnseenFeatureTips,
|
||||
normalizeFeatureTipIds,
|
||||
type FeatureTipId
|
||||
} from './feature-tips'
|
||||
|
||||
describe('feature tips', () => {
|
||||
it('skips tips the user has already seen', () => {
|
||||
const tips = getOrderedUnseenFeatureTips({
|
||||
seenTipIds: new Set<FeatureTipId>([
|
||||
'chat-ui-here',
|
||||
'voice-dictation',
|
||||
'orca-cli',
|
||||
'cmd-j-palette',
|
||||
'agent-session-search'
|
||||
])
|
||||
})
|
||||
|
||||
expect(tips.map((tip) => tip.id)).toEqual([])
|
||||
})
|
||||
|
||||
it('skips tips for features the user has already completed', () => {
|
||||
const tips = getOrderedUnseenFeatureTips({
|
||||
// cmd-j is a seen-based tip with no feature completion, so mark it seen here.
|
||||
seenTipIds: new Set<FeatureTipId>(['cmd-j-palette']),
|
||||
completedTipIds: getCompletedFeatureTipIds({
|
||||
cliInstalled: true,
|
||||
voiceDictationEnabled: true,
|
||||
sessionSearchTipCompleted: true,
|
||||
chatUiLaunchTipCompleted: true
|
||||
})
|
||||
})
|
||||
|
||||
expect(tips.map((tip) => tip.id)).toEqual([])
|
||||
})
|
||||
|
||||
it('skips tips for features the user has already interacted with', () => {
|
||||
const tips = getOrderedUnseenFeatureTips({
|
||||
seenTipIds: new Set<FeatureTipId>(),
|
||||
completedTipIds: getCompletedFeatureTipIds({
|
||||
cliInstalled: false,
|
||||
voiceDictationEnabled: false,
|
||||
sessionSearchTipCompleted: true,
|
||||
chatUiLaunchTipCompleted: true,
|
||||
featureInteractions: {
|
||||
'voice-dictation': { firstInteractedAt: 100, interactionCount: 1 }
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
expect(tips.map((tip) => tip.id)).toEqual(['orca-cli', 'cmd-j-palette'])
|
||||
})
|
||||
|
||||
it('normalizes persisted tip ids', () => {
|
||||
expect(
|
||||
normalizeFeatureTipIds([
|
||||
'feature-tour',
|
||||
'orca-cli',
|
||||
'bogus',
|
||||
'cmd-j-palette',
|
||||
'voice-dictation'
|
||||
])
|
||||
).toEqual(['orca-cli', 'cmd-j-palette', 'voice-dictation'])
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user