Unify CCS case management flow

This commit is contained in:
hz
2026-07-19 21:29:24 -05:00
parent dacf2b89b2
commit f12904bf73
13 changed files with 938 additions and 47 deletions
+26
View File
@@ -0,0 +1,26 @@
extends SceneTree
var failures := 0
func _initialize() -> void:
call_deferred("_run")
func _run() -> void:
var hub = load("res://scripts/ui/ccs_hub.gd")
_assert(hub.has_active_case({"state": "active"}), "active CCS attempts should be resumable")
_assert(hub.has_active_case({"state": "final_orders"}), "final-orders CCS attempts should be resumable")
_assert(not hub.has_active_case({"state": "completed"}), "completed CCS attempts should not appear active")
_assert(not hub.has_active_case({"state": "abandoned"}), "abandoned CCS attempts should not appear active")
_assert(hub.remaining_time_text({"state": "active", "deadlineUtc": "2026-07-19T12:15:00Z"}, 1784462400.0) == "15 min remaining", "active case countdown should use the case deadline")
_assert(hub.humanize("emergency_department") == "Emergency Department", "CCS locations should be human readable")
_assert(hub.format_datetime_parts({"year": 2026, "month": 7, "day": 19, "hour": 13, "minute": 5}) == "Jul 19, 2026\n1:05 PM", "history dates should use the compact local format")
quit(1 if failures > 0 else 0)
func _assert(condition: bool, message: String) -> void:
if condition:
return
failures += 1
push_error(message)
+1
View File
@@ -0,0 +1 @@
uid://fi27rqa8vcoj
+57
View File
@@ -0,0 +1,57 @@
extends SceneTree
var failures := 0
func _initialize() -> void:
call_deferred("_run")
func _run() -> void:
var service = root.get_node("CCSService")
var theme_service = root.get_node("UIThemeService")
var prior_dark_mode: bool = theme_service.is_dark_mode()
service.cases = [{"externalId": "case-1"}]
service.attempt = {"id": "active", "state": "active", "createdUtc": "2026-07-19T12:00:00Z", "deadlineUtc": "2026-07-19T12:20:00Z", "location": "emergency_department"}
service.rating = {"elo": 1040, "ratedCaseCount": 3}
service.prediction = {"ccsScore": 72.0, "contributingCases": 3}
service.history = [{"id": "completed", "caseTitle": "Completed case", "state": "completed", "createdUtc": "2026-07-18T12:00:00Z", "score": 80.0}]
service.history_next_cursor = "next-page"
var host := Control.new()
host.size = Vector2(1400, 800)
root.add_child(host)
var screen = load("res://scripts/ui/ccs_hub.gd").new()
screen.size = host.size
host.add_child(screen)
await process_frame
screen._update_responsive_layout()
screen._render_active_section()
screen._render_history()
await process_frame
_assert(screen.history_list.get_child_count() == 1, "CCS history should render terminal attempts")
_assert(screen.load_more_button.visible, "CCS history should expose cursor pagination")
var active_layout: BoxContainer = screen.find_child("ActiveCardLayout", true, false)
_assert(active_layout != null and not active_layout.vertical, "wide CCS screens should use the horizontal active card")
var primary: Button = screen.find_child("PrimaryCcsAction", true, false)
_assert(primary != null and primary.text == "Resume Case", "an unfinished case should expose Resume Case")
theme_service.set_dark_mode(false)
await process_frame
var light_box := screen.active_section.get_theme_stylebox("panel") as StyleBoxFlat
_assert(light_box.bg_color.is_equal_approx(screen._section_box(false).bg_color), "CCS should apply its light surface after a theme change")
screen.size = Vector2(760, 800)
screen._update_responsive_layout()
await process_frame
active_layout = screen.find_child("ActiveCardLayout", true, false)
_assert(active_layout != null and active_layout.vertical, "narrow CCS screens should stack the active card")
_assert(not screen.table_header.visible, "narrow CCS screens should render history cards without a table header")
host.queue_free()
await process_frame
theme_service.set_dark_mode(prior_dark_mode)
quit(1 if failures > 0 else 0)
func _assert(condition: bool, message: String) -> void:
if condition:
return
failures += 1
push_error(message)
+1
View File
@@ -0,0 +1 @@
uid://c64rhs53ln007