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>
91 lines
3.3 KiB
TypeScript
91 lines
3.3 KiB
TypeScript
import { describe, it, expect, vi } from 'vitest'
|
|
|
|
const clickElementByText = vi.fn(async (text: string) => text !== 'introuvable')
|
|
const goBack = vi.fn(async () => true)
|
|
const highlightText = vi.fn(async (text: string) => text !== 'introuvable')
|
|
const navigateTo = vi.fn(async () => 'Titre de la page')
|
|
const readPageText = vi.fn(async () => 'Contenu de la page')
|
|
|
|
vi.mock('../../src/main/browser/browserWindow', () => ({
|
|
clickElementByText,
|
|
goBack,
|
|
highlightText,
|
|
navigateTo,
|
|
readPageText
|
|
}))
|
|
|
|
const { clickBrowserElement } = await import('../../src/main/skills/browser/clickBrowserElement')
|
|
const { goBackBrowser } = await import('../../src/main/skills/browser/goBackBrowser')
|
|
const { highlightBrowserText } = await import('../../src/main/skills/browser/highlightBrowserText')
|
|
const { navigateBrowser } = await import('../../src/main/skills/browser/navigateBrowser')
|
|
const { readBrowserPage } = await import('../../src/main/skills/browser/readBrowserPage')
|
|
|
|
describe('click_browser_element', () => {
|
|
it('should refuse an empty text', async () => {
|
|
await expect(clickBrowserElement.execute({ text: '' })).rejects.toThrow(/text manquant/)
|
|
})
|
|
|
|
it('should report success when the element is found and clicked', async () => {
|
|
const result = await clickBrowserElement.execute({ text: 'Connexion' })
|
|
expect(result).toMatch(/Clic effectue/)
|
|
})
|
|
|
|
it('should report failure when no matching element is found', async () => {
|
|
const result = await clickBrowserElement.execute({ text: 'introuvable' })
|
|
expect(result).toMatch(/Echec/)
|
|
})
|
|
})
|
|
|
|
describe('go_back_browser', () => {
|
|
it('should report success when going back worked', async () => {
|
|
const result = await goBackBrowser.execute({})
|
|
expect(result).toMatch(/Retour/)
|
|
})
|
|
|
|
it('should report failure when there is no previous page', async () => {
|
|
goBack.mockResolvedValueOnce(false)
|
|
const result = await goBackBrowser.execute({})
|
|
expect(result).toMatch(/Echec/)
|
|
})
|
|
})
|
|
|
|
describe('highlight_browser_text', () => {
|
|
it('should refuse an empty text', async () => {
|
|
await expect(highlightBrowserText.execute({ text: '' })).rejects.toThrow(/text manquant/)
|
|
})
|
|
|
|
it('should report success when the text is found', async () => {
|
|
const result = await highlightBrowserText.execute({ text: 'un passage' })
|
|
expect(result).toMatch(/surligne/)
|
|
})
|
|
|
|
it('should report failure when the text is not found', async () => {
|
|
const result = await highlightBrowserText.execute({ text: 'introuvable' })
|
|
expect(result).toMatch(/Echec/)
|
|
})
|
|
})
|
|
|
|
describe('navigate_browser', () => {
|
|
it('should refuse an empty URL', async () => {
|
|
await expect(navigateBrowser.execute({ url: '' })).rejects.toThrow(/url manquante/)
|
|
})
|
|
|
|
it('should navigate and report the page title', async () => {
|
|
const result = await navigateBrowser.execute({ url: 'https://example.com' })
|
|
expect(result).toMatch(/Titre de la page/)
|
|
})
|
|
})
|
|
|
|
describe('read_browser_page', () => {
|
|
it('should return the page text', async () => {
|
|
const result = await readBrowserPage.execute({})
|
|
expect(result).toBe('Contenu de la page')
|
|
})
|
|
|
|
it('should report an empty/unreadable page', async () => {
|
|
readPageText.mockResolvedValueOnce('')
|
|
const result = await readBrowserPage.execute({})
|
|
expect(result).toMatch(/vide ou n'a pas pu/)
|
|
})
|
|
})
|