diff --git a/src/renderer/src/lib/browser-uuid.test.ts b/src/renderer/src/lib/browser-uuid.test.ts deleted file mode 100644 index 8ad0616200a..00000000000 --- a/src/renderer/src/lib/browser-uuid.test.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { afterEach, describe, expect, it, vi } from 'vitest' -import { createBrowserUuid } from './browser-uuid' - -describe('createBrowserUuid', () => { - afterEach(() => { - vi.unstubAllGlobals() - }) - - it('uses native randomUUID when it is available', () => { - vi.stubGlobal('crypto', { - randomUUID: () => 'native-id' - }) - - expect(createBrowserUuid()).toBe('native-id') - }) - - it('falls back to getRandomValues when randomUUID is unavailable', () => { - vi.stubGlobal('crypto', { - getRandomValues: (bytes: Uint8Array) => { - for (let index = 0; index < bytes.length; index += 1) { - bytes[index] = index - } - return bytes - } - }) - - expect(createBrowserUuid()).toBe('00010203-0405-4607-8809-0a0b0c0d0e0f') - }) -}) diff --git a/src/shared/agent-skill-sharing-contract.test.ts b/src/shared/agent-skill-sharing-contract.test.ts index 7df3af25cdf..99fae320497 100644 --- a/src/shared/agent-skill-sharing-contract.test.ts +++ b/src/shared/agent-skill-sharing-contract.test.ts @@ -13,6 +13,12 @@ describe('agent skill sharing contract', () => { }) it('rejects arbitrary source paths and more than 512 explicit selectors', () => { + expect( + AgentSkillShareRequestSchema.parse({ + skillSelectors: Array.from({ length: 512 }, (_, index) => `skill-${index}`), + bundleName: 'team-skills' + }).skillSelectors + ).toHaveLength(512) expect( AgentSkillShareRequestSchema.safeParse({ skillSelectors: ['alpha'], diff --git a/src/shared/binary-file-extensions.test.ts b/src/shared/binary-file-extensions.test.ts index d54cd53638c..031e1c36318 100644 --- a/src/shared/binary-file-extensions.test.ts +++ b/src/shared/binary-file-extensions.test.ts @@ -14,8 +14,8 @@ describe('hasBinaryFileExtension', () => { it('rejects text files, dotfiles, and extensionless paths', () => { expect(hasBinaryFileExtension('src/index.ts')).toBe(false) - expect(hasBinaryFileExtension('.gitignore')).toBe(false) - expect(hasBinaryFileExtension('scripts/.eslintrc')).toBe(false) + expect(hasBinaryFileExtension('.png')).toBe(false) + expect(hasBinaryFileExtension('scripts/.png')).toBe(false) expect(hasBinaryFileExtension('Makefile')).toBe(false) expect(hasBinaryFileExtension(undefined)).toBe(false) }) diff --git a/src/shared/bundled-skill-locations.test.ts b/src/shared/bundled-skill-locations.test.ts index 84f0c6b2cd2..1eaf7a1b1ab 100644 --- a/src/shared/bundled-skill-locations.test.ts +++ b/src/shared/bundled-skill-locations.test.ts @@ -26,7 +26,7 @@ describe('collapseHomePath', () => { }) describe('bundledSkillLocation', () => { - it('names the shared folder and agent folders, and tells a kept link from a kept copy', () => { + it('describes shared updates, kept agent links, and edited locations', () => { expect(bundledSkillLocation(op({ kind: 'update' }), '/home/u')).toMatchObject({ displayPath: '~/.agents/skills/orca-cli', place: { kind: 'shared' }, diff --git a/src/shared/uuid-v4.test.ts b/src/shared/uuid-v4.test.ts index a12396accca..50b72551b53 100644 --- a/src/shared/uuid-v4.test.ts +++ b/src/shared/uuid-v4.test.ts @@ -1,25 +1,37 @@ import { afterEach, describe, expect, it, vi } from 'vitest' import { createUuidV4 } from './uuid-v4' -const UUID_V4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/ - describe('createUuidV4', () => { - afterEach(() => vi.unstubAllGlobals()) + afterEach(() => { + vi.unstubAllGlobals() + vi.restoreAllMocks() + }) - it('uses the browser crypto fallback when randomUUID is unavailable', () => { + it('uses native randomUUID when it is available', () => { + vi.stubGlobal('crypto', { + randomUUID: () => 'native-id' + }) + + expect(createUuidV4()).toBe('native-id') + }) + + it('falls back to getRandomValues when randomUUID is unavailable', () => { vi.stubGlobal('crypto', { getRandomValues: (bytes: Uint8Array) => { - bytes.fill(0xab) + for (let index = 0; index < bytes.length; index += 1) { + bytes[index] = index + } return bytes } }) - expect(createUuidV4()).toMatch(UUID_V4) + expect(createUuidV4()).toBe('00010203-0405-4607-8809-0a0b0c0d0e0f') }) it('still returns a UUID when Web Crypto is unavailable', () => { vi.stubGlobal('crypto', undefined) + vi.spyOn(Math, 'random').mockReturnValue(255 / 256) - expect(createUuidV4()).toMatch(UUID_V4) + expect(createUuidV4()).toBe('ffffffff-ffff-4fff-bfff-ffffffffffff') }) })