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,134 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { buildCircleSector } from '../../src/main/coach/presets/circleSector'
|
||||
import { buildCoordinateAxes } from '../../src/main/coach/presets/coordinateAxes'
|
||||
import { buildRegularPolygon } from '../../src/main/coach/presets/regularPolygon'
|
||||
import { buildRightTriangle } from '../../src/main/coach/presets/rightTriangle'
|
||||
import { buildTriangle } from '../../src/main/coach/presets/triangle'
|
||||
import { buildVennDiagram } from '../../src/main/coach/presets/vennDiagram'
|
||||
|
||||
describe('buildCircleSector()', () => {
|
||||
it('should return one arc shape per slice, with angles summing to 360 degrees', () => {
|
||||
const shapes = buildCircleSector({
|
||||
slices: [
|
||||
{ value: 50, label: 'A' },
|
||||
{ value: 50, label: 'B' }
|
||||
]
|
||||
})
|
||||
expect(shapes).toHaveLength(2)
|
||||
expect(shapes[0]?.startAngle).toBe(-90)
|
||||
expect(shapes[1]?.endAngle).toBe(270)
|
||||
})
|
||||
|
||||
it('should ignore slices with a zero or negative value', () => {
|
||||
const shapes = buildCircleSector({ slices: [{ value: 0 }, { value: -5 }, { value: 10 }] })
|
||||
expect(shapes).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('should return an empty array when there are no valid slices', () => {
|
||||
expect(buildCircleSector({ slices: [] })).toEqual([])
|
||||
expect(buildCircleSector({})).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildCoordinateAxes()', () => {
|
||||
it('should always return the two perpendicular axis arrows plus axis labels', () => {
|
||||
const shapes = buildCoordinateAxes({})
|
||||
const arrows = shapes.filter((s) => s.type === 'arrow')
|
||||
expect(arrows).toHaveLength(2)
|
||||
expect(arrows[0]?.y).toBe(arrows[0]?.y2)
|
||||
expect(arrows[1]?.x).toBe(arrows[1]?.x2)
|
||||
})
|
||||
|
||||
it('should add a circle for each valid point provided', () => {
|
||||
const shapes = buildCoordinateAxes({
|
||||
points: [
|
||||
{ x: 1, y: 2, label: 'P' },
|
||||
{ x: 3, y: 4 }
|
||||
]
|
||||
})
|
||||
const circles = shapes.filter((s) => s.type === 'circle')
|
||||
expect(circles).toHaveLength(2)
|
||||
expect(circles[0]?.label).toBe('P')
|
||||
})
|
||||
|
||||
it('should ignore non-object entries in the points array', () => {
|
||||
const shapes = buildCoordinateAxes({ points: [null, 'invalid', { x: 1, y: 1 }] })
|
||||
expect(shapes.filter((s) => s.type === 'circle')).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildRegularPolygon()', () => {
|
||||
it('should return exactly as many line segments as sides requested', () => {
|
||||
const shapes = buildRegularPolygon({ sides: 5 })
|
||||
expect(shapes).toHaveLength(5)
|
||||
expect(shapes.every((s) => s.type === 'line')).toBe(true)
|
||||
})
|
||||
|
||||
it('should clamp the number of sides between 3 and 12', () => {
|
||||
expect(buildRegularPolygon({ sides: 1 })).toHaveLength(3)
|
||||
expect(buildRegularPolygon({ sides: 100 })).toHaveLength(12)
|
||||
})
|
||||
|
||||
it('should attach the provided labels/captions by index', () => {
|
||||
const shapes = buildRegularPolygon({ sides: 3, labels: ['a', 'b', 'c'] })
|
||||
expect(shapes.map((s) => s.label)).toEqual(['a', 'b', 'c'])
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildRightTriangle()', () => {
|
||||
it('should return the three sides, the right-angle marker and the angle arc', () => {
|
||||
const shapes = buildRightTriangle({})
|
||||
expect(shapes.filter((s) => s.type === 'line')).toHaveLength(3)
|
||||
expect(shapes.some((s) => s.type === 'rect')).toBe(true)
|
||||
expect(shapes.some((s) => s.type === 'arc')).toBe(true)
|
||||
})
|
||||
|
||||
it('should use the default labels when none are provided', () => {
|
||||
const shapes = buildRightTriangle({})
|
||||
const labels = shapes.map((s) => s.label)
|
||||
expect(labels).toContain('Adjacent')
|
||||
expect(labels).toContain('Opposé')
|
||||
expect(labels).toContain('Hypoténuse')
|
||||
})
|
||||
|
||||
it('should use custom labels when provided', () => {
|
||||
const shapes = buildRightTriangle({ adjacentLabel: 'Cote A' })
|
||||
expect(shapes.some((s) => s.label === 'Cote A')).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildTriangle()', () => {
|
||||
it('should return the three sides of the triangle', () => {
|
||||
const shapes = buildTriangle({})
|
||||
expect(shapes.filter((s) => s.type === 'line')).toHaveLength(3)
|
||||
})
|
||||
|
||||
it('should include an apex text label when apexLabel is provided', () => {
|
||||
const shapes = buildTriangle({ apexLabel: 'A' })
|
||||
expect(shapes.some((s) => s.type === 'text' && s.content === 'A')).toBe(true)
|
||||
})
|
||||
|
||||
it('should omit the apex text shape when no apexLabel is provided', () => {
|
||||
const shapes = buildTriangle({})
|
||||
expect(shapes.some((s) => s.type === 'text')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildVennDiagram()', () => {
|
||||
it('should return 2 circles by default', () => {
|
||||
const shapes = buildVennDiagram({})
|
||||
expect(shapes).toHaveLength(2)
|
||||
expect(shapes.every((s) => s.type === 'circle')).toBe(true)
|
||||
})
|
||||
|
||||
it('should return 3 circles when 3 labels are given', () => {
|
||||
const shapes = buildVennDiagram({ labels: ['A', 'B', 'C'] })
|
||||
expect(shapes).toHaveLength(3)
|
||||
expect(shapes.map((s) => s.label)).toEqual(['A', 'B', 'C'])
|
||||
})
|
||||
|
||||
it('should clamp to at most 3 circles even with more labels', () => {
|
||||
const shapes = buildVennDiagram({ labels: ['A', 'B', 'C', 'D', 'E'] })
|
||||
expect(shapes).toHaveLength(3)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user