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:
william
2026-10-31 12:15:30 +01:00
co-authored by Claude Sonnet 5
parent 60e2fb26af
commit 1c2f002eb3
224 changed files with 135 additions and 18 deletions
@@ -0,0 +1,111 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { render, screen, act } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import type { ExerciseForm } from '../../../src/shared/coach'
let onFormCallback: ((form: ExerciseForm) => void) | undefined
const submitWrittenForm = vi.fn()
function setupWindowApi(): void {
;(window as unknown as { api: Record<string, unknown> }).api = {
onAskWrittenForm: vi.fn((cb: (form: ExerciseForm) => void) => {
onFormCallback = cb
return () => {}
}),
submitWrittenForm
}
}
const { default: CoachExerciseView } =
await import('../../../src/renderer/src/components/CoachExerciseView')
const FORM: ExerciseForm = {
requestId: 'req-1',
items: [
{
id: '0',
question: 'Quelle est la capitale de la France ?',
type: 'free_text',
options: null
},
{ id: '1', question: 'Vrai ou faux : 2+2=4', type: 'true_false', options: null },
{ id: '2', question: 'Choisis la bonne reponse', type: 'multiple_choice', options: ['A', 'B'] }
]
}
describe('<CoachExerciseView />', () => {
beforeEach(() => {
vi.clearAllMocks()
setupWindowApi()
})
it('should show a waiting message before any form is received', () => {
render(<CoachExerciseView />)
expect(screen.getByText(/En attente de questions/)).toBeInTheDocument()
})
it('should display every question once a form is received', () => {
render(<CoachExerciseView />)
act(() => onFormCallback?.(FORM))
expect(screen.getByText(/capitale de la France/)).toBeInTheDocument()
expect(screen.getByText(/2\+2=4/)).toBeInTheDocument()
expect(screen.getByText(/bonne reponse/)).toBeInTheDocument()
})
it('should keep the submit button disabled until every question is answered', async () => {
const user = userEvent.setup()
render(<CoachExerciseView />)
act(() => onFormCallback?.(FORM))
const submitButton = screen.getByText('Soumettre tout le formulaire')
expect(submitButton).toBeDisabled()
await user.type(screen.getByRole('textbox'), 'Paris')
await user.click(screen.getByText('Vrai'))
await user.click(screen.getByText('A'))
expect(submitButton).toBeEnabled()
})
it('should allow answering "Je ne sais pas" to satisfy a question', async () => {
const user = userEvent.setup()
render(<CoachExerciseView />)
act(() => onFormCallback?.({ requestId: 'req-2', items: [FORM.items[0]!] }))
const submitButton = screen.getByText('Soumettre tout le formulaire')
expect(submitButton).toBeDisabled()
await user.click(screen.getByText('Je ne sais pas'))
expect(submitButton).toBeEnabled()
})
it('should submit all answers and show the confirmation message', async () => {
const user = userEvent.setup()
render(<CoachExerciseView />)
act(() => onFormCallback?.(FORM))
await user.type(screen.getByRole('textbox'), 'Paris')
await user.click(screen.getByText('Vrai'))
await user.click(screen.getByText('A'))
await user.click(screen.getByText('Soumettre tout le formulaire'))
expect(submitWrittenForm).toHaveBeenCalledWith('req-1', [
{ id: '0', answer: 'Paris' },
{ id: '1', answer: 'Vrai' },
{ id: '2', answer: 'A' }
])
expect(screen.getByText(/Reponses envoyees a Max/)).toBeInTheDocument()
})
it('should reset state and show a fresh form when a second form arrives', () => {
render(<CoachExerciseView />)
act(() => onFormCallback?.(FORM))
act(() =>
onFormCallback?.({
requestId: 'req-3',
items: [{ id: '0', question: 'Autre question', type: 'free_text', options: null }]
})
)
expect(screen.getByText(/Autre question/)).toBeInTheDocument()
expect(screen.queryByText(/capitale de la France/)).not.toBeInTheDocument()
})
})