Files
PacketStation/frontend/src/test/packets.ts
T
spencermandClaude Fable 5.1 37d9a0cb50 Phase 2: core domain, policy engine, packet API, Clerical screen
Migration 0003: projects, aliases, renumbers, units, packets and every child table,
change orders, assets, documents, ITPs, station limits, department weld flag.
Policy package: Principal, PacketState, Action rules, custody, preconditions,
CO hold, order of checks, can/blocked/holder on reads. docs/POLICY.md with the
tightenings table for Seth. Write pipeline: FOR UPDATE, CAS on status and dept,
If-Match row versions, server-assigned numbers, field CAS, version bump, packet
log, audit, NOTIFY, signatures, IT reasons, filed lock and HMAC seal.
API: /api/packets (header, transitions, work orders, pages, docs, move, remove,
BOM, shorts, welds, heat tags, heat table, stage, checklist, clock, warehouse
stage, Q.C., change orders, log, seal), /api/projects, /api/units, /api/assets,
/_blob. Frontend: Clerical home, projects and units, packet page with pdf.js
and QR codes, hand draft, heat map, send to warehouse, department or Q.C.
Tests: policy matrix, API, concurrency, schema, projects; Playwright Clerical
draft scenario. Verified on docker-1 with the CI stack and the Samba DC.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-10-16 09:31:45 -06:00

131 lines
3.0 KiB
TypeScript

// Synthetic packet answers for the screen tests. No real job data.
import type { PacketCard, PacketRead, Project, Unit } from "../api/types";
export function makeCard(over: Partial<PacketCard> = {}): PacketCard {
return {
id: 1,
version: 1,
unit: { id: 11, number: "L999001" },
project: { id: 7, number: "L999", name: "CI project" },
dept: { code: "03", name: "Weld Parts" },
op: "WELD-PART",
title: "CI spool",
customer: "Test Co",
drawing: "CI-DWG-1",
rev: "0",
status: "draft",
status_at: "2026-10-16T08:00:00Z",
station: null,
welder: null,
routed_to: null,
vclosed: null,
source_kind: "hand",
flag: null,
open_cos: [],
open_shorts: 0,
wh_stage: null,
due_effective: null,
updated_at: "2026-10-16T08:00:00Z",
holder: "Clerical",
can: [],
blocked: {},
...over,
};
}
export function makePacket(over: Partial<PacketRead> = {}): PacketRead {
return {
id: 1,
version: 3,
unit: {
id: 11,
number: "L999001",
lot: "001",
name: null,
project: { id: 7, number: "L999", name: "CI project", customer: "Test Co", po: null, status: "open" },
due_effective: null,
},
dept: { code: "03", name: "Weld Parts", weld: true },
op: "WELD-PART",
title: "CI spool",
customer: "Test Co",
drawing: "CI-DWG-1",
rev: "0",
wps: null,
status: "draft",
status_at: "2026-10-16T08:00:00Z",
station: null,
welder: null,
for_sup: null,
heat_map: null,
wh_skipped: false,
wh_sent_at: null,
routed_to: null,
return_note: null,
vclosed: null,
databook_at: null,
source_kind: "hand",
source: { kind: "hand" },
drawing_state: "none",
flags: ["hand"],
visual: {},
removed: null,
work_orders: [{ id: 1, wo_base: "L999001", lot: "001", split: "0", sub: "0", qty: 1, target_hrs: 2, row_version: 1 }],
pages: [],
bom: [],
welds: [],
heat_tags: [],
heat_table: [],
stage: null,
stages: [],
wh: null,
qc: null,
qc_history: [],
change_orders: [],
open_cos: [],
open_shorts: 0,
docs: [],
seal: null,
can: ["edit_header", "edit_drawing_ref", "edit_document_set", "move_unit", "remove"],
blocked: { send_to_warehouse: ["Say whether this packet needs a heat map."] },
holder: "Clerical",
checklist_items: [],
qc_items: [],
flag: null,
...over,
};
}
export function makeProject(over: Partial<Project> = {}): Project {
return {
id: 7,
number: "L999",
name: "CI project",
customer: "Test Co",
po: null,
due: null,
status: "open",
notes: null,
units: 1,
packets: { draft: 1, warehouse: 0, shop: 0, qc: 0, complete: 0, filed: 0, total: 1 },
version: 1,
...over,
};
}
export function makeUnit(over: Partial<Unit> = {}): Unit {
return {
id: 11,
project_id: 7,
number: "L999001",
lot: "001",
name: null,
due: null,
due_effective: null,
status: "open",
notes: null,
version: 1,
...over,
};
}