Files
TheTree_mock/tests/ui/test_dashboard_coalescing.gd
T
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

41 lines
2.1 KiB
GDScript

extends SceneTree
var checks:=0
var failures:=0
func expect(ok: bool,label: String) -> void:
checks+=1
if not ok: failures+=1;push_error(label)
func _initialize() -> void:call_deferred("run")
func run() -> void:
var runtime: Variant=root.get_node("SimulationRuntime")
var clock: Variant=root.get_node("GameClock")
var state: Variant=root.get_node("GameState")
clock.reset(1,6,0);state.reset();runtime.initialize(clock,state,42605);clock.set_paused(true)
var main: Control=load("res://scenes/main/main.tscn").instantiate()
main.set_script(load("res://tests/ui/fixtures/counted_dashboard.gd"))
root.add_child(main)
runtime.configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false})
await process_frame;await process_frame
var before: Dictionary=runtime.create_snapshot()
var initial: int=main.dashboard_refresh_count
clock.advance_minutes(3)
expect(clock.absolute_minute==363,"three simulation minutes still advance")
expect(main.dashboard_refresh_count==initial,"tick notifications do not rebuild dashboard synchronously")
expect(main._dashboard_refresh_pending,"batch schedules a dashboard refresh")
var after: Dictionary=runtime.create_snapshot()
await process_frame;await process_frame
expect(main.dashboard_refresh_count==initial+1,"three publications produce one completed display refresh")
expect(not main._dashboard_refresh_pending,"display refresh clears pending flag")
expect(runtime.create_snapshot()==after,"deferred display refresh cannot mutate simulation state")
main._flush_dashboard_refresh()
expect(main.dashboard_refresh_count==initial+1,"empty flush does not rebuild dashboard")
clock.advance_one_minute()
await process_frame;await process_frame
expect(main.dashboard_refresh_count==initial+2,"next frame gets a fresh display refresh")
expect(runtime.restore_snapshot(before),"restore initial simulation checkpoint")
await process_frame;await process_frame
clock.advance_minutes(3)
expect(runtime.create_snapshot()==after,"coalesced display preserves deterministic simulation replay")
main.queue_free()
await process_frame;await process_frame
print("Dashboard coalescing: %d checks, %d failures" % [checks,failures]);quit(failures)