Add dashboard performance trends
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
extends SceneTree
|
||||
|
||||
var failures := 0
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
call_deferred("_run")
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
var Chart = load("res://scripts/ui/dashboard_chart.gd")
|
||||
_test_point_values(Chart)
|
||||
_test_axis_bounds(Chart)
|
||||
await _test_runtime_modes(Chart)
|
||||
quit(1 if failures > 0 else 0)
|
||||
|
||||
|
||||
func _test_point_values(Chart: GDScript) -> void:
|
||||
var active := {"accuracy": 75, "total": 4, "questionBankRating": 1042}
|
||||
var inactive := {"accuracy": 0, "total": 0, "questionBankRating": null}
|
||||
_assert(Chart.point_value(active, "accuracy") == 75.0, "accuracy mode should expose active-day accuracy")
|
||||
_assert(Chart.point_value(inactive, "accuracy") == null, "accuracy mode should leave inactive days empty")
|
||||
_assert(Chart.point_value(active, "rating") == 1042.0, "rating mode should expose stored Elo")
|
||||
_assert(Chart.point_value(inactive, "rating") == null, "rating mode should preserve pre-baseline gaps")
|
||||
|
||||
|
||||
func _test_axis_bounds(Chart: GDScript) -> void:
|
||||
_assert(Chart.axis_bounds([], "accuracy") == Vector2(0, 100), "accuracy should use a fixed 0-100 axis")
|
||||
var rating_points := [
|
||||
{"questionBankRating": 1000},
|
||||
{"questionBankRating": 1020}
|
||||
]
|
||||
var bounds: Vector2 = Chart.axis_bounds(rating_points, "rating")
|
||||
_assert(bounds.x < 1000 and bounds.y > 1020, "rating bounds should include padded values")
|
||||
_assert(bounds.y - bounds.x >= 100, "rating bounds should preserve a useful minimum span")
|
||||
|
||||
|
||||
func _test_runtime_modes(Chart: GDScript) -> void:
|
||||
var chart = Chart.new()
|
||||
chart.size = Vector2(560, 190)
|
||||
root.add_child(chart)
|
||||
await process_frame
|
||||
var series := [
|
||||
{"dateUtc": "2026-07-23T00:00:00Z", "total": 2, "accuracy": 50, "questionBankRating": null},
|
||||
{"dateUtc": "2026-07-24T00:00:00Z", "total": 0, "accuracy": 0, "questionBankRating": 1000},
|
||||
{"dateUtc": "2026-07-25T00:00:00Z", "total": 1, "accuracy": 100, "questionBankRating": 1018}
|
||||
]
|
||||
chart.set_series(series, "rating", true)
|
||||
_assert(chart.mode == "rating" and chart.points.size() == 3, "chart should accept dated rating series")
|
||||
chart.set_series(series, "accuracy", false)
|
||||
_assert(chart.mode == "accuracy" and not chart.dark, "chart should switch modes and themes")
|
||||
chart.queue_free()
|
||||
await process_frame
|
||||
|
||||
|
||||
func _assert(condition: bool, message: String) -> void:
|
||||
if condition:
|
||||
return
|
||||
failures += 1
|
||||
push_error(message)
|
||||
@@ -0,0 +1 @@
|
||||
uid://di0806e6g2872
|
||||
@@ -0,0 +1,66 @@
|
||||
extends SceneTree
|
||||
|
||||
var failures := 0
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
call_deferred("_run")
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
var dashboard_service = root.get_node("DashboardService")
|
||||
var prior_data: Dictionary = dashboard_service.data
|
||||
dashboard_service.data = _dashboard_data()
|
||||
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.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()
|
||||
dashboard_service.data = prior_data
|
||||
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
|
||||
})
|
||||
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)
|
||||
@@ -0,0 +1 @@
|
||||
uid://bxm4twkfwu455
|
||||
Reference in New Issue
Block a user