CI / quality (push) Failing after 6m22s
Implements Max_Code_Quality_CICD_Production.md: TypeScript strict mode, ESLint flat config with type-checking and security plugin, Prettier, Husky + lint-staged, Vitest with 80%+ coverage (473 tests), Playwright e2e, Electron security hardening (contextIsolation, CSP, IPC validation), electron-builder + electron-updater, Dockerfile, Gitea Actions CI/release workflows, and SonarQube docker-compose setup. Also fixes two real bugs found while writing tests: unawaited clipboard promises and a mermaid container ref timing issue in CoachDrawingView. Fixes lint-staged on Windows/Node 24 by invoking eslint/prettier via `node <bin>.js` instead of their .cmd shims, which Node's child_process now refuses to spawn without shell:true. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
116 lines
4.1 KiB
TypeScript
116 lines
4.1 KiB
TypeScript
import { describe, it, expect, vi } from 'vitest'
|
|
|
|
const clickElementByText = vi.fn(async (text: string) => text !== 'introuvable')
|
|
const fillField = vi.fn(async (field: string) => field !== '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,
|
|
fillField,
|
|
goBack,
|
|
highlightText,
|
|
navigateTo,
|
|
readPageText
|
|
}))
|
|
|
|
const { clickBrowserElement } = await import('../../src/main/skills/browser/clickBrowserElement')
|
|
const { fillBrowserField } = await import('../../src/main/skills/browser/fillBrowserField')
|
|
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('fill_browser_field', () => {
|
|
it('should refuse an empty field name', async () => {
|
|
await expect(fillBrowserField.execute({ field: '', value: 'x' })).rejects.toThrow(
|
|
/field manquant/
|
|
)
|
|
})
|
|
|
|
it('should report success and mention submission when requested', async () => {
|
|
const result = await fillBrowserField.execute({
|
|
field: 'email',
|
|
value: 'a@b.com',
|
|
submit: true
|
|
})
|
|
expect(result).toMatch(/rempli et formulaire valide/)
|
|
})
|
|
|
|
it('should report failure when no matching field is found', async () => {
|
|
const result = await fillBrowserField.execute({ field: 'introuvable', value: 'x' })
|
|
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/)
|
|
})
|
|
})
|