119 lines
5.5 KiB
GDScript
119 lines
5.5 KiB
GDScript
extends SceneTree
|
|
|
|
var failures := 0
|
|
|
|
|
|
func _initialize() -> void:
|
|
call_deferred("_run")
|
|
|
|
|
|
func _run() -> void:
|
|
var prior_environment: String = ProjectSettings.get_setting("step3/deployment_environment", "development")
|
|
ProjectSettings.set_setting("step3/deployment_environment", "uat")
|
|
var dashboard_service = root.get_node("DashboardService")
|
|
var mission_service = root.get_node("DailyMissionService")
|
|
var weekly_goal_service = root.get_node("WeeklyGoalService")
|
|
var prior_data: Dictionary = dashboard_service.data
|
|
var prior_missions: Dictionary = mission_service.state
|
|
var prior_weekly_goal: Dictionary = weekly_goal_service.state
|
|
dashboard_service.data = _dashboard_data()
|
|
mission_service.state = {"replacementAvailable": true, "missions": [
|
|
{"id": "m1", "type": "due_reviews", "title": "Complete 3 scheduled reviews", "target": 3, "progress": 1, "completed": false},
|
|
{"id": "m2", "type": "weak_system_correct", "title": "Get 3 correct", "target": 3, "progress": 3, "completed": true},
|
|
{"id": "m3", "type": "difficulty_four_correct", "title": "Get 3 hard correct", "target": 3, "progress": 0, "completed": false}
|
|
]}
|
|
weekly_goal_service.state = {"completed": false, "suggestedSystem": "Cardiovascular System", "components": [
|
|
{"type": "active_days", "label": "Study on 4 different days", "progress": 2, "target": 4, "completed": false},
|
|
{"type": "system_breadth", "label": "Study 3 Step 3 systems", "progress": 1, "target": 3, "completed": false},
|
|
{"type": "hard_correct", "label": "Get 5 hard answers correct", "progress": 3, "target": 5, "completed": false}
|
|
]}
|
|
var dashboard = load("res://scripts/ui/dashboard_screen.gd").new()
|
|
dashboard.size = Vector2(1280, 900)
|
|
root.add_child(dashboard)
|
|
await process_frame
|
|
dashboard._render()
|
|
await process_frame
|
|
|
|
_assert(dashboard.system_list.get_child_count() == 14, "dashboard should render all 14 Step 3 systems")
|
|
_assert(dashboard.mastery_rows.size() == 14, "dashboard should render one mastery action row per system")
|
|
var first_mastery_row: BoxContainer = dashboard.mastery_rows[0]
|
|
_assert(not first_mastery_row.vertical, "desktop mastery rows should remain horizontal")
|
|
_assert(dashboard.mission_rows.size() == 3, "dashboard should render all three daily missions")
|
|
_assert(dashboard.weekly_goal_content.get_child_count() == 5, "dashboard should render the weekly header, three components, and reward note")
|
|
var first_mission_row: BoxContainer = dashboard.mission_rows[0]
|
|
_assert(not first_mission_row.vertical, "desktop mission rows should remain horizontal")
|
|
dashboard.size = Vector2(640, 900)
|
|
dashboard._update_responsive()
|
|
_assert(first_mastery_row.vertical, "narrow mastery rows should stack to avoid clipping")
|
|
_assert(first_mission_row.vertical, "narrow mission rows should stack to avoid clipping")
|
|
_assert(dashboard.rating_toggle.button_pressed, "rating should be the default trend mode")
|
|
_assert(dashboard.trend_chart.mode == "rating", "chart should initially render rating history")
|
|
dashboard._set_trend_mode("accuracy")
|
|
_assert(dashboard.trend_chart.mode == "accuracy", "correct percentage toggle should switch the chart series")
|
|
_assert(dashboard.trend_chart.points.size() == 30, "chart should retain all 30 calendar points")
|
|
|
|
dashboard.queue_free()
|
|
await process_frame
|
|
|
|
ProjectSettings.set_setting("step3/deployment_environment", "prd")
|
|
var production_dashboard = load("res://scripts/ui/dashboard_screen.gd").new()
|
|
production_dashboard.size = Vector2(1280, 900)
|
|
root.add_child(production_dashboard)
|
|
await process_frame
|
|
production_dashboard._render()
|
|
await process_frame
|
|
_assert(production_dashboard.mission_content == null, "production should omit daily mission UI")
|
|
_assert(production_dashboard.weekly_goal_content == null, "production should omit weekly goal UI")
|
|
_assert(production_dashboard.rank_content == null, "production should omit clinical progression UI")
|
|
_assert(production_dashboard.mastery_rows.is_empty(), "production should render legacy system performance instead of mastery actions")
|
|
_assert(production_dashboard.system_list.get_child_count() == 14, "production should retain the system performance breakdown")
|
|
production_dashboard.queue_free()
|
|
dashboard_service.data = prior_data
|
|
mission_service.state = prior_missions
|
|
weekly_goal_service.state = prior_weekly_goal
|
|
ProjectSettings.set_setting("step3/deployment_environment", prior_environment)
|
|
await process_frame
|
|
quit(1 if failures > 0 else 0)
|
|
|
|
|
|
func _dashboard_data() -> Dictionary:
|
|
var systems: Array = []
|
|
for index in range(14):
|
|
systems.append({
|
|
"system": "System %02d" % index,
|
|
"correct": 1 if index == 0 else 0,
|
|
"total": 1 if index == 0 else 0,
|
|
"accuracy": 100 if index == 0 else 0,
|
|
"masteryScore": 82 if index == 0 else 0,
|
|
"masteryState": "strong" if index == 0 else "unseen",
|
|
"distinctQuestions": 15 if index == 0 else 0,
|
|
"difficulty4PlusSuccessful": 4 if index == 0 else 0,
|
|
"pendingReviews": 0,
|
|
"refreshDue": false,
|
|
"recommendedAction": {"type": "practice", "label": "Challenge this system", "questionCount": 10, "difficultyMin": 4, "difficultyMax": 5}
|
|
})
|
|
var trend: Array = []
|
|
for index in range(30):
|
|
trend.append({
|
|
"dateUtc": "2026-07-%02dT00:00:00Z" % (index + 1),
|
|
"correct": 1 if index % 2 == 0 else 0,
|
|
"total": 1 if index % 2 == 0 else 0,
|
|
"accuracy": 100 if index % 2 == 0 else 0,
|
|
"questionBankRating": 1000 + index
|
|
})
|
|
return {
|
|
"questionBankRating": 1029,
|
|
"ratedQuestionCount": 30,
|
|
"performanceTrend": trend,
|
|
"systems": systems,
|
|
"weeklyActivity": [],
|
|
"recentActivity": []
|
|
}
|
|
|
|
|
|
func _assert(condition: bool, message: String) -> void:
|
|
if condition:
|
|
return
|
|
failures += 1
|
|
push_error(message)
|