// Test data for offline packs - shared by the specs, never imported by app code. import type { StoredPack } from "@/lib/offline/db"; import type { ColonyOverviewRow, OfflinePackV1 } from "./field-types"; export const MINUTE_MS = 60 * 1000; export const HOUR_MS = 60 * MINUTE_MS; export const DAY_MS = 24 * HOUR_MS; type PackColony = OfflinePackV1["colonies"][number]; type PackInspection = NonNullable[number]; type PackTask = NonNullable[number]; type PackQueen = NonNullable[number]; export function packColony(id: string, code: string, overrides: Partial = {}): PackColony { return { id, code, apiaryId: "apiary-1", status: "ACTIVE", colonyType: "PRODUCTION_COLONY", hiveType: "Zander", strength: 8, occupiedFrames: 9, broodStatus: "GOOD", feedStatus: "GOOD", healthStatus: "GOOD", currentQueenId: null, notes: null, ...overrides, }; } export function overviewRow(colony: PackColony, overrides: Partial = {}): ColonyOverviewRow { return { id: colony.id, code: colony.code, status: colony.status, strength: colony.strength, occupiedFrames: colony.occupiedFrames, broodStatus: colony.broodStatus, feedStatus: colony.feedStatus, healthStatus: colony.healthStatus, lastInspectionDate: new Date().toISOString(), inspectionDueOn: null, segment: null, nextStepTitle: null, openWarnings: 0, openCritical: 0, ...overrides, }; } export function packInspection( id: string, colonyId: string, date: string, overrides: Partial = {}, ): PackInspection { return { id, colonyId, date, weather: null, temperature: null, colonyStrength: null, broodAmount: null, broodFrames: null, broodPattern: null, openBroodPresent: null, cappedBroodPresent: null, eggsPresent: null, queenSeen: null, queenCellsPresent: null, swarmMood: null, gentleness: null, combBehavior: null, feedStatus: null, honeySuperStatus: null, healthIssues: null, varroaIssues: null, measures: null, notes: null, createdAt: date, ...overrides, }; } export function packTask(id: string, title: string, overrides: Partial = {}): PackTask { return { id, title, description: null, dueDate: null, priority: "NORMAL", status: "OPEN", relatedType: "COLONY", relatedId: null, ...overrides, }; } export function packQueen(id: string, code: string, overrides: Partial = {}): PackQueen { return { id, code, hatchYear: 2025, breed: "Carnica", markingColor: "Rot", markingNumber: "12", status: "ACTIVE", ...overrides, }; } interface PackOptions { apiaryId?: string; apiaryName?: string; colonies?: PackColony[]; queens?: OfflinePackV1["queens"]; inspections?: OfflinePackV1["inspections"]; tasks?: OfflinePackV1["tasks"]; inspectionsVisible?: boolean; } /** A pack as the server sends it: colonies, their overview rows and the sections. */ export function offlinePack({ apiaryId = "apiary-1", apiaryName = "Obstwiese", colonies = [packColony("colony-1", "A1", { apiaryId })], queens = [], inspections = [], tasks = [], inspectionsVisible = true, }: PackOptions = {}): OfflinePackV1 { return { version: 1, generatedAt: "2026-10-13T08:00:00.000Z", apiary: { id: apiaryId, name: apiaryName, location: "Hinterm Hof", status: "ACTIVE" }, overview: { apiaryId, inspectionsVisible, rows: colonies.map((colony) => overviewRow(colony)), }, colonies, queens, inspections, tasks, }; } export function storedPack( pack: OfflinePackV1, { ownerUserId = "user-1", savedAt = new Date().toISOString() } = {}, ): StoredPack { return { apiaryId: pack.apiary.id, ownerUserId, savedAt, pack }; }