Files
Classeo/frontend/tests/unit/lib/data/demo-data.test.ts
Mathias STRASSER b45ef735db feat: Dashboard placeholder avec preview Score Sérénité
Permet aux parents de visualiser une démo du Score Sérénité dès leur
première connexion, avant même que les données réelles soient disponibles.
Les autres rôles (enseignant, élève, admin) ont également leur dashboard
adapté avec des sections placeholder.

La landing page redirige automatiquement vers /dashboard si l'utilisateur
est déjà authentifié, offrant un accès direct au tableau de bord.
2026-02-04 18:34:08 +01:00

88 lines
2.9 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import demoData from '$lib/data/demo-data.json';
describe('demo-data.json', () => {
describe('serenityScore', () => {
it('should have a value between 0 and 100', () => {
expect(demoData.serenityScore.value).toBeGreaterThanOrEqual(0);
expect(demoData.serenityScore.value).toBeLessThanOrEqual(100);
});
it('should have a valid emoji', () => {
expect(['💚', '🟡', '🔴']).toContain(demoData.serenityScore.emoji);
});
it('should have a valid trend', () => {
expect(['stable', 'up', 'down']).toContain(demoData.serenityScore.trend);
});
it('should have components with scores and labels', () => {
const { components } = demoData.serenityScore;
expect(components).toHaveProperty('notes');
expect(components).toHaveProperty('absences');
expect(components).toHaveProperty('devoirs');
for (const [, component] of Object.entries(components)) {
expect(component).toHaveProperty('score');
expect(component).toHaveProperty('label');
expect(typeof component.score).toBe('number');
expect(typeof component.label).toBe('string');
expect(component.score).toBeGreaterThanOrEqual(0);
expect(component.score).toBeLessThanOrEqual(100);
}
});
});
describe('schedule', () => {
it('should have today array with schedule items', () => {
expect(Array.isArray(demoData.schedule.today)).toBe(true);
expect(demoData.schedule.today.length).toBeGreaterThan(0);
});
it('should have valid schedule items with time, subject, and room', () => {
for (const item of demoData.schedule.today) {
expect(item).toHaveProperty('time');
expect(item).toHaveProperty('subject');
expect(item).toHaveProperty('room');
expect(typeof item.time).toBe('string');
expect(typeof item.subject).toBe('string');
expect(typeof item.room).toBe('string');
}
});
});
describe('grades', () => {
it('should have recent array with grade items', () => {
expect(Array.isArray(demoData.grades.recent)).toBe(true);
});
it('should have valid grade items', () => {
for (const item of demoData.grades.recent) {
expect(item).toHaveProperty('subject');
expect(item).toHaveProperty('value');
expect(item).toHaveProperty('max');
expect(item).toHaveProperty('date');
expect(typeof item.value).toBe('number');
expect(typeof item.max).toBe('number');
}
});
});
describe('homework', () => {
it('should have upcoming array with homework items', () => {
expect(Array.isArray(demoData.homework.upcoming)).toBe(true);
});
it('should have valid homework items', () => {
for (const item of demoData.homework.upcoming) {
expect(item).toHaveProperty('subject');
expect(item).toHaveProperty('title');
expect(item).toHaveProperty('dueDate');
expect(item).toHaveProperty('status');
expect(['pending', 'done', 'late']).toContain(item.status);
}
});
});
});