refactor: move app code into Max Avatar/ subfolder (monorepo prep for backend)
Step 1 of adding a backend proxy server (API keys held server-side instead of shipped in the installer). Moves everything app-specific into "Max Avatar/" via git mv (preserves history): src/, tests/, scripts/, assets/, build/, resources/, package.json/-lock.json, electron-builder.yml, electron.vite.config.ts, eslint.config.mjs, playwright.config.ts, vitest.config.mts, sonar-project.properties, tsconfig*.json, Dockerfile, .editorconfig/.env*/.gitignore/.prettier*. CLAUDE.md, README.md, docs/, .claude/, .gitea/, .husky/, .vscode/, and the docker-compose files stay at the repo root, since they'll apply to both the app and the future backend. No application code needed changes (all its internal paths are relative to its own tree). Adjusted what referenced the old root from outside: - .husky/pre-commit: cd into "Max Avatar" before lint-staged - .gitea/workflows/*.yml: working-directory + cache-dependency-path + artifact paths + SonarQube projectBaseDir - docker-compose.yml: build context -> ./Max Avatar - Max Avatar/Dockerfile: node:20-alpine -> node:24-alpine (same node:sqlite issue already fixed elsewhere, never applied here before) - .vscode/launch.json, README.md: updated paths/instructions Verified from Max Avatar/ after the move: npm ci, typecheck, lint, test:coverage (473/473, same coverage numbers), build, and dev all work unchanged. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
60e2fb26af
commit
1c2f002eb3
@@ -0,0 +1,130 @@
|
||||
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-skills-test-'))
|
||||
|
||||
vi.mock('electron', () => ({
|
||||
app: { getPath: () => tempDir }
|
||||
}))
|
||||
|
||||
vi.mock('../../src/main/coach/exerciseWindow', () => ({
|
||||
requestWrittenAnswers: vi.fn(async (items: { question: string }[]) =>
|
||||
items.map(() => 'une reponse')
|
||||
)
|
||||
}))
|
||||
|
||||
const { setResearchSummary } = await import('../../src/main/coach/coachStore')
|
||||
const { generateCoursePlan } = await import('../../src/main/skills/coach/generateCoursePlan')
|
||||
const { writeModuleContent } = await import('../../src/main/skills/coach/writeModuleContent')
|
||||
const { completeModule } = await import('../../src/main/skills/coach/completeModule')
|
||||
const { askWrittenExercise } = await import('../../src/main/skills/coach/askWrittenExercise')
|
||||
|
||||
const VALID_CONTENT = [
|
||||
'Accroche',
|
||||
'Un vendeur doit calculer rapidement combien de tissu acheter pour 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.',
|
||||
'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')
|
||||
|
||||
const SUBJECT = 'trigonometrie-pipeline-test'
|
||||
|
||||
describe('generate_course_plan', () => {
|
||||
it('should refuse when no research exists yet for the subject', async () => {
|
||||
await expect(
|
||||
generateCoursePlan.execute({
|
||||
subject: 'sujet-jamais-recherche',
|
||||
objective: 'Tu seras capable de calculer un sinus dans un triangle rectangle',
|
||||
modules: [{ name: 'Module 1' }]
|
||||
})
|
||||
).rejects.toThrow(/Aucune recherche/)
|
||||
})
|
||||
|
||||
it('should refuse when the objective is missing', async () => {
|
||||
setResearchSummary(SUBJECT, JSON.stringify({ sources: [] }))
|
||||
await expect(
|
||||
generateCoursePlan.execute({ subject: SUBJECT, objective: '', modules: [{ name: 'A' }] })
|
||||
).rejects.toThrow(/objective manquant/)
|
||||
})
|
||||
|
||||
it('should create the course plan once research and objective are present', async () => {
|
||||
const result = await generateCoursePlan.execute({
|
||||
subject: SUBJECT,
|
||||
objective: 'Tu seras capable de calculer un sinus dans un triangle rectangle',
|
||||
modules: [{ name: 'Module A' }, { name: 'Module B' }]
|
||||
})
|
||||
expect(result).toMatch(/Module A/)
|
||||
expect(result).toMatch(/Module B/)
|
||||
})
|
||||
})
|
||||
|
||||
describe('write_module_content', () => {
|
||||
it('should reject content missing required sections', async () => {
|
||||
await expect(
|
||||
writeModuleContent.execute({ subject: SUBJECT, module: 'Module A', content: 'Trop court.' })
|
||||
).rejects.toThrow(/Contenu invalide/)
|
||||
})
|
||||
|
||||
it('should accept well-structured content for the first (unlocked) module', async () => {
|
||||
const result = await writeModuleContent.execute({
|
||||
subject: SUBJECT,
|
||||
module: 'Module A',
|
||||
content: VALID_CONTENT
|
||||
})
|
||||
expect(result).toMatch(/enregistre/)
|
||||
})
|
||||
})
|
||||
|
||||
describe('complete_module', () => {
|
||||
it('should refuse when no assessment exists yet for the module', async () => {
|
||||
await expect(completeModule.execute({ subject: SUBJECT, module: 'Module A' })).rejects.toThrow(
|
||||
/Aucune evaluation/
|
||||
)
|
||||
})
|
||||
|
||||
it('should refuse when only a single difficulty level was used', async () => {
|
||||
await askWrittenExercise.execute({
|
||||
subject: SUBJECT,
|
||||
kind: 'module',
|
||||
questions: [
|
||||
{
|
||||
question: 'Question facile ?',
|
||||
type: 'free_text',
|
||||
concept: 'Module A',
|
||||
difficulty: 'facile'
|
||||
}
|
||||
]
|
||||
})
|
||||
await expect(completeModule.execute({ subject: SUBJECT, module: 'Module A' })).rejects.toThrow(
|
||||
/niveau de difficulte/
|
||||
)
|
||||
})
|
||||
|
||||
it('should validate the module once at least two difficulty levels were used and answers were correct', async () => {
|
||||
await askWrittenExercise.execute({
|
||||
subject: SUBJECT,
|
||||
kind: 'module',
|
||||
questions: [
|
||||
{
|
||||
question: 'Question difficile ?',
|
||||
type: 'free_text',
|
||||
concept: 'Module A',
|
||||
difficulty: 'difficile'
|
||||
}
|
||||
]
|
||||
})
|
||||
const result = await completeModule.execute({ subject: SUBJECT, module: 'Module A' })
|
||||
expect(result).toMatch(/valide/)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user