Connect graphical CCS interviews to cases
This commit is contained in:
@@ -3,6 +3,13 @@ extends SceneTree
|
||||
var failures := 0
|
||||
|
||||
|
||||
class ScreenHost extends Control:
|
||||
var shown_screen := ""
|
||||
|
||||
func show_screen(screen_name: String, _payload: Variant = null) -> void:
|
||||
shown_screen = screen_name
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
call_deferred("_run")
|
||||
|
||||
@@ -20,25 +27,71 @@ func _run() -> void:
|
||||
await process_frame
|
||||
ProjectSettings.set_setting("step3/deployment_environment", prior_environment)
|
||||
|
||||
var host := Control.new()
|
||||
var service = root.get_node("CCSService")
|
||||
var prior_attempt: Dictionary = service.attempt.duplicate(true)
|
||||
var prior_cases: Array = service.cases.duplicate(true)
|
||||
var prior_origin: String = service.launch_origin
|
||||
var host := ScreenHost.new()
|
||||
host.size = Vector2(1200.0, 700.0)
|
||||
root.add_child(host)
|
||||
var screen = load("res://scripts/ui/ccs_cases_2_screen.gd").new()
|
||||
screen.main = host
|
||||
host.add_child(screen)
|
||||
await process_frame
|
||||
screen.on_show()
|
||||
|
||||
service.cases = [
|
||||
{"externalId": "interactive", "title": "Interactive case", "system": "Endocrine", "difficulty": 2, "realTimeMinutes": 20, "interactiveInterviewAvailable": true},
|
||||
{"externalId": "legacy", "title": "Legacy case", "interactiveInterviewAvailable": false}
|
||||
]
|
||||
service.attempt = {}
|
||||
screen.cases_loaded = true
|
||||
screen.active_loaded = true
|
||||
screen._render_state()
|
||||
await process_frame
|
||||
_assert(screen.current_view == "doctor_office", "CCS Cases 2 should open directly in the doctor office")
|
||||
_assert(screen.active_scene != null, "CCS Cases 2 should instantiate the doctor-office scene")
|
||||
_assert(screen.current_view == "case_selection", "CCS Cases 2 should begin with compatible case selection")
|
||||
_assert(screen.case_list.get_child_count() == 1, "legacy cases should be excluded from graphical selection")
|
||||
|
||||
service.attempt = _sample_attempt(false)
|
||||
screen._render_state()
|
||||
await process_frame
|
||||
_assert(screen.current_view == "doctor_office", "an active interactive attempt should open the doctor office")
|
||||
_assert(screen.active_scene.dialogue_text.text == "Hello, doctor.", "the patient bubble should use the server-provided current node")
|
||||
_assert(screen.active_scene.choice_container.get_child_count() == 1, "the scene should render server-provided dialogue choices")
|
||||
_assert(is_equal_approx(screen.stage_root.scale.x, screen.stage_root.scale.y), "the graphical stage should preserve its aspect ratio")
|
||||
|
||||
service.attempt = _sample_attempt(true)
|
||||
screen._on_attempt_changed()
|
||||
await process_frame
|
||||
_assert(screen.active_scene.dialogue_text.text == "Okay, doctor.", "attempt updates should advance the rendered patient response")
|
||||
_assert(screen.active_scene.choice_container.get_child_count() == 1, "terminal dialogue should expose the management handoff")
|
||||
screen.active_scene.interview_continue_requested.emit()
|
||||
_assert(host.shown_screen == "ccs_player", "terminal dialogue should hand off the same attempt to the CCS player")
|
||||
|
||||
screen.on_hide()
|
||||
await process_frame
|
||||
_assert(screen.active_scene == null and screen.current_view.is_empty(), "hiding CCS Cases 2 should release the prototype scene")
|
||||
_assert(screen.active_scene == null, "hiding CCS Cases 2 should release the doctor scene")
|
||||
host.queue_free()
|
||||
service.attempt = prior_attempt
|
||||
service.cases = prior_cases
|
||||
service.launch_origin = prior_origin
|
||||
await process_frame
|
||||
quit(1 if failures > 0 else 0)
|
||||
|
||||
|
||||
func _sample_attempt(completed: bool) -> Dictionary:
|
||||
var node := {
|
||||
"id": "done" if completed else "greeting",
|
||||
"patientText": "Okay, doctor." if completed else "Hello, doctor.",
|
||||
"isTerminal": completed,
|
||||
"choices": [] if completed else [{"id": "ask_reason", "text": "What brings you in?", "nextNodeId": "done"}]
|
||||
}
|
||||
return {
|
||||
"id": "attempt-1", "state": "active", "revision": 1,
|
||||
"openingCompleted": completed,
|
||||
"interview": {"currentNodeId": node.id, "currentNode": node, "visitedChoiceIds": [], "completed": completed}
|
||||
}
|
||||
|
||||
|
||||
func _assert(condition: bool, message: String) -> void:
|
||||
if condition:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user