Files
ForgeBase/Max Avatar/tests/unit/skills.index.test.ts
T
william 9aa5abc121 chore(cleanup): remove mode selection system
Max no longer has a Basic/Coach/Assistant mode selection: it will start
directly as a freelance coach, with a single server-side pipeline built in
a later step. Removes the Mode type/state, the skill-to-mode mapping, the
per-mode skill filtering and system prompt branching, and the 3-way mode
submenu in the context menu. Skills now always load as a single flat set
via loadSkills(); mode-specific behavior removal is a prerequisite for
retiring the old pipeline itself in the next cleanup commit.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-31 17:51:30 +01:00

69 lines
2.3 KiB
TypeScript

import { describe, it, expect, vi } from 'vitest'
import { mkdtempSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
const tempDir = mkdtempSync(join(tmpdir(), 'forge-avatar-skillsindex-test-'))
vi.mock('electron', () => ({
app: { getPath: () => tempDir },
shell: { openPath: vi.fn(), openExternal: vi.fn() },
clipboard: { readText: vi.fn(), writeText: vi.fn() },
Notification: class {
show = vi.fn()
},
desktopCapturer: { getSources: vi.fn(async () => []) },
screen: { getPrimaryDisplay: () => ({ size: { width: 0, height: 0 } }) },
BrowserWindow: class {
static getAllWindows(): unknown[] {
return []
}
on = vi.fn()
webContents = { on: vi.fn(), send: vi.fn(), isLoading: () => false, once: vi.fn() }
loadURL = vi.fn()
loadFile = vi.fn()
setAlwaysOnTop = vi.fn()
maximize = vi.fn()
},
ipcMain: { on: vi.fn(), handle: vi.fn() },
session: { defaultSession: { webRequest: { onHeadersReceived: vi.fn() } } }
}))
// @electron-toolkit/utils fait lui-meme `require('electron')` en interne : hors runtime Electron,
// le vrai paquet 'electron' exporte juste une chaine (chemin du binaire), ce qui casse l'interop
// ESM/CJS pour tout import nomme ulterieur de 'electron' dans le graphe de modules. On le mocke
// directement pour ne jamais toucher le vrai paquet.
vi.mock('@electron-toolkit/utils', () => ({
is: { dev: false },
electronApp: { setAppUserModelId: vi.fn() },
optimizer: { watchWindowShortcuts: vi.fn() }
}))
const { loadSkills, findSkill } = await import('../../src/main/skills')
describe('loadSkills()', () => {
it('should load a non-empty list of skills without throwing', () => {
const skills = loadSkills()
expect(skills.length).toBeGreaterThan(20)
})
it('should not register the same skill name twice', () => {
const names = loadSkills().map((s) => s.name)
expect(new Set(names).size).toBe(names.length)
})
it('should include a transversal skill', () => {
expect(loadSkills().map((s) => s.name)).toContain('search_web')
})
})
describe('findSkill()', () => {
it('should find a registered skill by name', () => {
expect(findSkill('search_web')?.name).toBe('search_web')
})
it('should return undefined for an unknown skill name', () => {
expect(findSkill('inexistant')).toBeUndefined()
})
})