63 lines
3.2 KiB
GDScript
63 lines
3.2 KiB
GDScript
extends SceneTree
|
|
|
|
var failures := 0
|
|
|
|
|
|
func _initialize() -> void:
|
|
call_deferred("_run")
|
|
|
|
|
|
func _run() -> void:
|
|
var service = root.get_node("ExamSimulationService")
|
|
var theme_service = root.get_node("UIThemeService")
|
|
var prior_dark_mode: bool = theme_service.is_dark_mode()
|
|
service.readiness = {"ready": true, "hasActiveSimulation": true, "availableQuestions": 300, "requiredQuestions": 232}
|
|
service.simulation = {"id": "active", "state": "between_blocks", "currentBlock": 2, "totalBlocks": 12, "createdUtc": "2026-07-16T22:04:00Z"}
|
|
service.history = [{"id": "completed", "state": "completed", "currentBlock": 11, "totalBlocks": 12, "createdUtc": "2026-07-15T20:35:00Z", "predictedScore": 236, "rangeLow": 221, "rangeHigh": 248, "passProbability": 0.82}]
|
|
service.history_next_cursor = "next-page"
|
|
_assert(service._is_stale_submit_failure("submit"), "a submit failure after reaching between-block state should be ignored")
|
|
service.simulation["state"] = "completed"
|
|
_assert(service._is_stale_submit_failure("submit"), "a submit failure after completion should be ignored")
|
|
_assert(not service._is_stale_submit_failure("save"), "non-submit failures should still be surfaced")
|
|
service.simulation["state"] = "between_blocks"
|
|
var host := Control.new()
|
|
host.size = Vector2(1400, 800)
|
|
root.add_child(host)
|
|
var screen = load("res://scripts/ui/simulation_history.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, "history should render completed attempts without duplicating the active simulation")
|
|
_assert(screen.load_more_button.visible, "history should expose pagination when the API returns a cursor")
|
|
var active_layout: BoxContainer = screen.find_child("ActiveCardLayout", true, false)
|
|
_assert(active_layout != null and not active_layout.vertical, "wide exam screens should use the table-oriented layout")
|
|
theme_service.set_dark_mode(false)
|
|
await process_frame
|
|
var light_active_box := screen.active_section.get_theme_stylebox("panel") as StyleBoxFlat
|
|
_assert(light_active_box.bg_color.is_equal_approx(screen._section_box(false).bg_color), "the Exams page should apply its light surface after a live theme change")
|
|
theme_service.set_dark_mode(true)
|
|
await process_frame
|
|
var dark_active_box := screen.active_section.get_theme_stylebox("panel") as StyleBoxFlat
|
|
_assert(dark_active_box.bg_color.is_equal_approx(screen._section_box(true).bg_color), "the Exams page should restore its dark surface after a live 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 exam screens should stack the active simulation card")
|
|
_assert(not screen.table_header.visible, "narrow exam screens should replace the table header with history cards")
|
|
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)
|