extends SceneTree const FixtureCleanup := preload("res://tests/helpers/ui_audio_fixture_cleanup.gd") 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") var _audio_cleanup_final: Dictionary = await FixtureCleanup.free_owner_and_wait(self, main) if not bool(_audio_cleanup_final.get(&"passed", false)): push_error("Ordinary fixture audio cleanup failed: %s" % str(_audio_cleanup_final)) quit(96) return await process_frame;await process_frame print("Dashboard coalescing: %d checks, %d failures" % [checks,failures]);quit(failures)