Files
ForgeBase/Max Avatar/tests/unit/skills.windowsSystemInfo.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

86 lines
2.8 KiB
TypeScript

import { describe, it, expect, vi, beforeEach } from 'vitest'
const execFileMock = vi.fn(
(
_cmd: string,
_args: string[],
_opts: unknown,
cb?: (err: Error | null, result: unknown) => void
) => {
const callback = typeof _opts === 'function' ? (_opts as typeof cb) : cb
callback?.(null, { stdout: '{}', stderr: '' })
}
)
vi.mock('child_process', () => ({ execFile: execFileMock }))
const { systemStatus } = await import('../../src/main/skills/windows/systemStatus')
const { systemStorage } = await import('../../src/main/skills/windows/systemStorage')
const { checkInternet } = await import('../../src/main/skills/windows/checkInternet')
function mockStdout(json: unknown): void {
execFileMock.mockImplementation(
(
_cmd: string,
_args: string[],
optsOrCb: unknown,
cb?: (err: Error | null, result: unknown) => void
) => {
const callback = typeof optsOrCb === 'function' ? (optsOrCb as typeof cb) : cb
callback?.(null, { stdout: JSON.stringify(json), stderr: '' })
}
)
}
beforeEach(() => {
vi.clearAllMocks()
})
describe('check_battery_and_cpu', () => {
it('should report no battery for a desktop computer', async () => {
mockStdout({ BatteryPercent: null, Charging: null, CpuPercent: 42 })
const result = await systemStatus.execute({})
expect(result).toMatch(/Pas de batterie detectee/)
expect(result).toMatch(/42%/)
})
it('should report battery level and charging state for a laptop', async () => {
mockStdout({ BatteryPercent: 80, Charging: true, CpuPercent: 10 })
const result = await systemStatus.execute({})
expect(result).toMatch(/Batterie a 80%/)
expect(result).toMatch(/en charge/)
})
})
describe('check_storage', () => {
it('should report usage for a single drive', async () => {
mockStdout({ DriveLetter: 'C', SizeGB: 500, FreeGB: 100 })
const result = await systemStorage.execute({})
expect(result).toMatch(/Disque C : 400\.0 Go utilises sur 500 Go \(100 Go libres\)/)
})
it('should report usage for multiple drives', async () => {
mockStdout([
{ DriveLetter: 'C', SizeGB: 500, FreeGB: 100 },
{ DriveLetter: 'D', SizeGB: 1000, FreeGB: 900 }
])
const result = await systemStorage.execute({})
expect(result).toMatch(/Disque C/)
expect(result).toMatch(/Disque D/)
})
})
describe('check_internet_connection', () => {
it('should report a working connection with its local IP', async () => {
mockStdout({ Connected: true, Ip: '192.168.1.10' })
const result = await checkInternet.execute({})
expect(result).toMatch(/Internet fonctionne/)
expect(result).toMatch(/192\.168\.1\.10/)
})
it('should report no connection', async () => {
mockStdout({ Connected: false, Ip: null })
const result = await checkInternet.execute({})
expect(result).toMatch(/Pas de connexion internet/)
})
})