feat: improve attendance scheduling and API validation

This commit is contained in:
2026-07-14 23:12:14 +08:00
parent c75a08affe
commit e45da7f998
33 changed files with 869 additions and 297 deletions

View File

@@ -209,6 +209,28 @@ describe('DatabaseMigrationsService — course attendance schema', () => {
expect(runner.release).toHaveBeenCalled();
});
it('adds the configurable attendance window to existing schedules', async () => {
const runner = mockRunner({
getTables: [
{ name: 'class_schedule', columns: [{ name: 'id' }] },
{ name: 'attendance_records', columns: [{ name: 'id' }] },
{ name: 'attendance_sessions', columns: [{ name: 'id' }] },
],
});
runner.getTable.mockImplementation(async (name: string) =>
name === 'class_schedule'
? { name, columns: [{ name: 'id' }] }
: { name, columns: [{ name: 'id' }, { name: 'schedule_id' }, { name: 'attendance_session_id' }] },
);
await bootstrapCourseAttendance(runner);
await service.ensureCourseAttendanceSchema();
expect(runner.query).toHaveBeenCalledWith(
expect.stringContaining('ALTER TABLE class_schedule ADD COLUMN attendance_advance_minutes'),
);
});
it('creates attendance_sessions with FK RESTRICT constraints when table is missing', async () => {
const runner = mockRunner({
getTables: [{ name: 'attendance_records', columns: [{ name: 'id' }] }],