/**
 * Test fixtures — consistent test data used across integration tests.
 *
 * These mirror the PRD data models and are used to seed/verify API responses.
 * All IDs are prefixed "test-" to distinguish from real data in a shared dev DB.
 */

// ── Auth ────────────────────────────────────────────────────────────

export const CREDENTIALS = {
  superAdmin: { username: 'admin', password: 'admin123' },
  staff: { username: 'staff1', password: 'staff123' },
  classTeacher: { username: 'teacher1', password: 'teacher123' },
  student: { username: 'student1', password: 'student123' },
} as const;

// ── Student (PRD §3) ────────────────────────────────────────────────

export const SAMPLE_STUDENT = {
  name: '测试学员A',
  phone: '13800000001',
  idCard: '110101200001011234',
  gender: '男',
  ethnicity: '汉族',
  status: 'active',
  emergencyContact: '张三',
  emergencyPhone: '13900000001',
  studentNo: 'TEST-2026-001',
};

export const SAMPLE_STUDENT_B = {
  name: '测试学员B',
  phone: '13800000002',
  idCard: '110101200001011235',
  gender: '女',
  ethnicity: '汉族',
  status: 'active',
  emergencyContact: '李四',
  emergencyPhone: '13900000002',
  studentNo: 'TEST-2026-002',
};

// ── Class (PRD §5) ──────────────────────────────────────────────────

export const SAMPLE_CLASS = {
  name: '2026届文化课冲刺1班',
  code: 'TEST-WHK-2026-001',
  classType: '文化课',
  startDate: '2026-03-01',
  endDate: '2026-06-30',
  status: '在读',
  maxStudents: 40,
};

// ── Schedule (PRD §6) ───────────────────────────────────────────────

export const SAMPLE_SCHEDULE = {
  weekDay: 1, // 周一
  startTime: '09:00',
  endTime: '10:30',
  subject: '语文',
  scheduleType: 'INTERNAL',
  status: 'active',
};

// Conflicting schedule: same classroom, same weekday, overlapping time
export const CONFLICT_SCHEDULE = {
  weekDay: 1,
  startTime: '09:30', // overlaps with 09:00-10:30
  endTime: '11:00',
  subject: '数学',
  scheduleType: 'INTERNAL',
  status: 'active',
};

// Non-conflicting: same classroom, same weekday, non-overlapping
export const NON_CONFLICT_SCHEDULE = {
  weekDay: 1,
  startTime: '10:30', // exactly at boundary — no overlap
  endTime: '12:00',
  subject: '英语',
  scheduleType: 'INTERNAL',
  status: 'active',
};

// ── Room / Dormitory (PRD §7) ───────────────────────────────────────

export const SAMPLE_ROOM = {
  roomNumber: 'TEST-401',
  building: '1号楼',
  floor: 4,
  capacity: 6,
  status: 'available',
  gender: '男',
  rentalCategory: 'short',
  roomType: '标准间',
};

export const SAMPLE_LONG_RENT_ROOM = {
  roomNumber: 'TEST-501',
  building: '1号楼',
  floor: 5,
  capacity: 4,
  status: 'available',
  gender: '女',
  rentalCategory: 'long',
  monthlyRate: 800,
  roomType: '标准间',
};

// ── Occupancy (PRD §8) ──────────────────────────────────────────────

export const SAMPLE_OCCUPANCY = {
  checkInDate: '2026-03-01',
  billingStartDate: '2026-03-01',
  billingEndDate: '2026-06-30',
  stayType: 'short',
};

// ── Bill / Expense (PRD §9-10) ──────────────────────────────────────

export const SAMPLE_EXPENSE = {
  type: 'water',
  amount: 150.0,
  billingMonth: '2026-03',
  description: '3月水费公摊',
};

export const SAMPLE_PERSONAL_EXPENSE = {
  type: 'damage',
  amount: 50.0,
  description: '损坏赔偿-台灯',
};

// ── Deposit (PRD §11) ───────────────────────────────────────────────

export const SAMPLE_DEPOSIT = {
  amount: 500.0,
  type: 'collect' as const,
  notes: '入学押金',
};

// ── Attendance (PRD §13) ────────────────────────────────────────────

export const SAMPLE_ATTENDANCE = {
  attendanceDate: '2026-03-15',
  session: '上午',
  status: '出勤',
  source: '人工点名',
  courseName: '语文',
};

export const SAMPLE_ATTENDANCE_ABSENT = {
  attendanceDate: '2026-03-16',
  session: '上午',
  status: '缺勤',
  source: '人工点名',
  courseName: '语文',
};

// ── Classroom (PRD §6) ──────────────────────────────────────────────

export const SAMPLE_CLASSROOM = {
  name: 'TEST-301教室',
  building: '教学楼A',
  floor: 3,
  capacity: 50,
  roomType: '大',
  status: 'available',
};

// ── Organization (PRD §12) ────────────────────────────────────────────────

export const SAMPLE_TENANT = {
  name: '测试合作机构A',
  contact: '王经理',
  phone: '13700000001',
  color: '#1890ff',
  status: 'active',
};

// ── Operation Log expectation (PRD §18) ─────────────────────────────

export const LOG_ACTIONS = {
  STUDENT_CREATE: { module: 'students', action: 'create' },
  STUDENT_UPDATE: { module: 'students', action: 'update' },
  STUDENT_DELETE: { module: 'students', action: 'delete' },
  BILL_GENERATE: { module: 'bills', action: 'generate' },
  BILL_CONFIRM: { module: 'bills', action: 'confirm' },
  DEPOSIT_COLLECT: { module: 'deposits', action: 'collect' },
  DEPOSIT_REFUND: { module: 'deposits', action: 'refund' },
  OCCUPANCY_CHECKIN: { module: 'occupancies', action: 'create' },
  OCCUPANCY_CHECKOUT: { module: 'occupancies', action: 'checkout' },
  EXPENSE_CREATE: { module: 'expenses', action: 'create' },
  CLASS_CREATE: { module: 'classes', action: 'create' },
  CLASS_DELETE: { module: 'classes', action: 'delete' },
  SCHEDULE_CREATE: { module: 'schedules', action: 'create' },
  ATTENDANCE_BATCH: { module: 'attendance', action: 'batch' },
  SENSITIVE_VIEW: { module: 'students', action: 'view_sensitive' },
} as const;

// ── Permission nodes (PRD §17) ──────────────────────────────────────

export const PERMISSION_NODES = [
  'student:view',
  'student:add',
  'student:update',
  'student:delete',
  'student:import',
  'student:export',
  'room:view',
  'room:add',
  'room:update',
  'room:delete',
  'occupancy:view',
  'occupancy:add',
  'occupancy:update',
  'bill:view',
  'bill:generate',
  'bill:confirm',
  'bill:markPaid',
  'bill:export',
  'expense:view',
  'expense:add',
  'expense:update',
  'expense:delete',
  'deposit:view',
  'deposit:collect',
  'deposit:refund',
  'class:view',
  'class:add',
  'class:update',
  'class:delete',
  'schedule:view',
  'schedule:add',
  'schedule:update',
  'schedule:delete',
  'attendance:view',
  'attendance:add',
  'attendance:update',
  'attendance:delete',
  'attendance:batch',
  'classroom:view',
  'classroom:add',
  'classroom:update',
  'classroom:delete',
  'organization:view',
  'organization:create',
  'organization:edit',
  'organization:delete',
  'rental:view',
  'rental:add',
  'rental:update',
  'rental:delete',
  'archive:view',
  'archive:import',
  'archive:export',
  'report:generate',
  'log:view',
  'role:view',
  'role:add',
  'role:update',
  'role:delete',
  'user:view',
  'user:add',
  'user:update',
  'dashboard:view',
] as const;
