Files
TheTree_mock/tests/ui/test_opening_assignment.gd
Takeshi 5dde0c5ec2 Record original-alignment implementation and traceability checkpoint
Capture current source, content data, tests, asset licenses, and original-specification traceability. Original implementation remains incomplete. The accepted matching UI generation passed 154 suites and 12,253 checks, with eight rendered staff-contract screens reviewed. Latest native Windows and full-original acceptance remain outstanding.
2026-09-30 23:52:24 +09:00

68 lines
3.4 KiB
GDScript

extends SceneTree
const Guide = preload("res://scripts/ui/inn_opening_guide.gd")
class Registry extends RefCounted:
var definition := FacilityDefinition.new()
func get_facility(_id): return definition
class Staff extends RefCounted:
var members: Array[StaffRuntime] = []
var shifts: Array[ShiftInstance] = []
var plans := {}
var reads := 0
func get_staff_members(): return members
func get_work_assignment(id): return plans.get(id, {}).duplicate(true)
func get_shifts():
reads += 1
return shifts.duplicate()
class Runtime extends RefCounted:
var definition_registry := Registry.new()
var staff_service := Staff.new()
class Clock extends RefCounted:
var absolute_minute := 60
var checks := 0
var failures := 0
func _initialize(): call_deferred("run")
func expect(value: bool, label: String):
checks += 1
if not value:
failures += 1
push_error(label)
func run():
var runtime := Runtime.new()
var clock := Clock.new()
var reception := FacilityInstance.new()
reception.instance_id = &"desk"
runtime.definition_registry.definition.required_roles = [&"receptionist"]
var guide := Guide.new();guide._runtime=runtime;guide._clock=clock
expect(not guide._has_reception_assignment(reception), "no employees cannot open reception")
var staff := StaffRuntime.new();staff.staff_id=&"worker";staff.role_id=&"manager"
runtime.staff_service.members.append(staff);reception.active_staff_ids.append(staff.staff_id)
expect(not guide._has_reception_assignment(reception), "active manager is not a receptionist")
staff.role_id=&"receptionist"
expect(guide._has_reception_assignment(reception), "active receptionist qualifies")
reception.active_staff_ids.clear()
runtime.staff_service.plans[staff.staff_id]={&"facility_id":&"desk"}
expect(guide._has_reception_assignment(reception), "off-duty repeating assignment qualifies")
var shift := ShiftInstance.new();shift.staff_id=staff.staff_id;shift.end_at=61;shift.assigned_facility_id=&"desk"
runtime.staff_service.shifts.append(shift)
runtime.staff_service.plans[staff.staff_id]={&"facility_id":&"elsewhere"}
expect(not guide._has_reception_assignment(reception), "current reassignment overrides old shifts")
runtime.staff_service.plans.clear()
expect(guide._has_reception_assignment(reception), "legacy future shift qualifies without repeating plan")
shift.end_at=60
expect(not guide._has_reception_assignment(reception), "shift ending now is expired")
shift.end_at=61;shift.cancelled=true
expect(not guide._has_reception_assignment(reception), "cancelled future shift cannot qualify")
shift.cancelled=false;shift.assigned_facility_id=&"elsewhere"
expect(not guide._has_reception_assignment(reception), "other facility shift cannot qualify")
shift.assigned_facility_id=&"desk";shift.staff_id=&"missing"
expect(not guide._has_reception_assignment(reception), "shift for absent employee cannot qualify")
for n in 49:
var extra := StaffRuntime.new();extra.staff_id=StringName("extra%d"%n);extra.role_id=&"receptionist";runtime.staff_service.members.append(extra)
runtime.staff_service.reads=0
expect(not guide._has_reception_assignment(reception), "unassigned team remains incomplete")
expect(runtime.staff_service.reads==1, "historical shifts enumerated once for whole team")
shift.staff_id=&"extra48"
expect(guide._has_reception_assignment(reception), "last employee legacy assignment remains discoverable")
guide.free()
print("Opening assignment: %d checks, %d failures"%[checks,failures]);quit(failures)