Files
ForgeBase/Max Avatar/tests/unit/skills.index.test.ts
T
william b8aec9ed6b chore(cleanup): remove basic-only utility skills
Removes the system-action skills that were only ever available in the now
-retired Basic/Assistant modes (play_music, open/close_app, open_notepad,
create_document, create_powerpoint, control_volume, control_media_playback,
take_screenshot, clipboard, search_file, set_reminder, lock_screen,
empty_recycle_bin, show_notification, print_file, create_folder,
create_file, delete_file, fill_browser_field) along with their
windows/lib helpers (appRegistry, fileSearch, locations, sendVirtualKey)
and the fillField browser-window helper. Keeps the read-only, side-effect
-free transversal skills (search_web, navigate_browser and friends,
check_system_memory/storage/battery/internet). Drops the now-unused
docx/pptxgenjs dependencies and the stale coachStore/meetingStore entries
from the coverage exclude list.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-31 19:33:04 +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(5)
})
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()
})
})