feat: add CI/CD, code quality, testing and security hardening
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>
This commit is contained in:
william
2026-10-29 09:05:21 +01:00
co-authored by Claude Sonnet 5
parent 1959ddb41a
commit e9690a49f9
230 changed files with 22781 additions and 448 deletions
@@ -0,0 +1,88 @@
import { describe, it, expect } from 'vitest'
import { validateModuleContent, missingContentSections } from '../../src/main/coach/coachStore'
function buildValidContent(): string {
return [
'Accroche',
'Un vendeur doit calculer rapidement combien de tissu acheter pour couvrir un mur triangulaire. '.repeat(
16
),
'Developpement theorique',
'Idee centrale, analogie, definition formelle, exemple resolu et contre-exemple. '.repeat(35),
'Phase guidee',
'ETAPE 1 : identifier les donnees. ETAPE 2 : appliquer la formule. ETAPE 3 : verifier le resultat.',
'Exercices progressifs',
'EXERCICE 1 facile. EXERCICE 2 facile. EXERCICE 3 moyen. EXERCICE 4 moyen. EXERCICE 5 difficile. EXERCICE 6 difficile.',
'Exercice de debogage',
"Trouve l'erreur dans ce calcul errone et corrige-la.",
'Synthese',
'Resume final avec question de meta-cognition et test Feynman. '.repeat(15)
].join('\n\n')
}
describe('missingContentSections()', () => {
it('should return every required section when content is empty', () => {
const missing = missingContentSections('')
expect(missing).toContain('Accroche')
expect(missing).toContain('Synthese')
expect(missing.length).toBe(6)
})
it('should return no missing section when all section headers are present', () => {
expect(missingContentSections(buildValidContent())).toEqual([])
})
})
describe('validateModuleContent()', () => {
it('should accept well-structured content meeting all requirements', () => {
expect(validateModuleContent(buildValidContent())).toEqual([])
})
it('should reject content with missing sections', () => {
const violations = validateModuleContent('Accroche\nTrop court.')
expect(violations.length).toBeGreaterThan(0)
expect(violations[0]).toMatch(/Sections manquantes/)
})
it('should accept accented "ETAPE"/"EXERCICE" headers (regression: accent-insensitive match)', () => {
const content = buildValidContent().replace('ETAPE', 'ÉTAPE').replace('EXERCICE', 'ÉXERCICE')
expect(validateModuleContent(content)).toEqual([])
})
it('should reject a "Phase guidee" section with fewer than 3 numbered steps', () => {
const content = buildValidContent().replace(
'ETAPE 1 : identifier les donnees. ETAPE 2 : appliquer la formule. ETAPE 3 : verifier le resultat.',
'ETAPE 1 : identifier les donnees.'
)
const violations = validateModuleContent(content)
expect(violations.some((v) => /Phase guidee/.test(v))).toBe(true)
})
it('should reject an "Exercices progressifs" section with fewer than 6 numbered exercises', () => {
const content = buildValidContent().replace(
'EXERCICE 1 facile. EXERCICE 2 facile. EXERCICE 3 moyen. EXERCICE 4 moyen. EXERCICE 5 difficile. EXERCICE 6 difficile.',
'EXERCICE 1 facile. EXERCICE 2 moyen.'
)
const violations = validateModuleContent(content)
expect(violations.some((v) => /Exercices progressifs/.test(v))).toBe(true)
})
it('should reject an "Exercice de debogage" section that never mentions an error', () => {
const content = buildValidContent().replace(
"Trouve l'erreur dans ce calcul errone et corrige-la.",
'Resous ce calcul.'
)
const violations = validateModuleContent(content)
expect(violations.some((v) => /debogage/.test(v))).toBe(true)
})
it('should reject a section shorter than its required minimum word count', () => {
const shortAccroche =
'Un vendeur doit calculer rapidement combien de tissu acheter pour couvrir un mur triangulaire. '.repeat(
16
)
const content = buildValidContent().replace(shortAccroche, 'Phrase courte.')
const violations = validateModuleContent(content)
expect(violations.some((v) => /Accroche.*trop courte/.test(v))).toBe(true)
})
})