// test/factories/shift.factory.ts export type ShiftPayload = { timesheet_id: number; bank_code_id: number; date: string; // ISO date (jour) start_time: string; // ISO datetime (heure) end_time: string; // ISO datetime (heure) description: string; // requis par le DTO }; const randInt = (min: number, max: number) => Math.floor(Math.random() * (max - min + 1)) + min; const isoDate = (y: number, m: number, d: number) => new Date(Date.UTC(y, m - 1, d, 0, 0, 0)).toISOString(); const isoTime = (h: number, m = 0) => new Date(Date.UTC(1970, 0, 1, h, m, 0)).toISOString(); export function makeShift( tsId: number, bcId: number, overrides: Partial = {} ): ShiftPayload { // 8h pile pour ne pas dépasser DAILY_LIMIT_HOURS (8 par défaut) const startH = 8; const endH = 16; return { timesheet_id: tsId, bank_code_id: bcId, date: isoDate(2024, 5, randInt(1, 28)), start_time: isoTime(startH), end_time: isoTime(endH), description: `Shift ${randInt(100, 999)}`, ...overrides, }; } // payload invalide pour 400 via ValidationPipe export function makeInvalidShift(): Record { return { timesheet_id: 'nope' }; // types volontairement faux }