63 lines
2.0 KiB
GDScript
63 lines
2.0 KiB
GDScript
extends SceneTree
|
|
## Headless smoke test for DiscoveryApiClient.
|
|
|
|
func _init() -> void:
|
|
print("[SMOKE] Starting DiscoveryApiClient smoke test...")
|
|
|
|
# 1. Test WorldSummary parsing
|
|
var test_dict := {
|
|
"id": 42,
|
|
"name": "Neon Arcade",
|
|
"description": "Retro gaming lounge",
|
|
"category": "Arcade",
|
|
"tags": ["retro", "multiplayer"],
|
|
"play_count": 128,
|
|
"created_at": "2026-09-15T12:00:00Z",
|
|
"owner": {
|
|
"id": 7,
|
|
"username": "arcadegamer"
|
|
}
|
|
}
|
|
|
|
var summary := DiscoveryApiClient.WorldSummary.from_dict(test_dict)
|
|
assert(summary.id == 42, "summary id mismatch")
|
|
assert(summary.name == "Neon Arcade", "summary name mismatch")
|
|
assert(summary.category == "Arcade", "summary category mismatch")
|
|
assert(summary.tags.size() == 2, "summary tags size mismatch")
|
|
assert(summary.play_count == 128, "summary play_count mismatch")
|
|
assert(summary.owner_id == 7, "summary owner_id mismatch")
|
|
assert(summary.owner_username == "arcadegamer", "summary owner_username mismatch")
|
|
print("[PASS] WorldSummary parsing verified")
|
|
|
|
# 2. Test DiscoveryResult parsing
|
|
var page_dict := {
|
|
"items": [test_dict],
|
|
"total": 1,
|
|
"skip": 0,
|
|
"limit": 50
|
|
}
|
|
var res := DiscoveryApiClient.DiscoveryResult.from_dict(page_dict)
|
|
assert(res.total == 1, "res total mismatch")
|
|
assert(res.items.size() == 1, "res items size mismatch")
|
|
assert(res.items[0].id == 42, "res items[0] id mismatch")
|
|
print("[PASS] DiscoveryResult parsing verified")
|
|
|
|
# 3. Test ApiClient integration
|
|
var api_script = load("res://scripts/api_client.gd")
|
|
if not api_script:
|
|
printerr("[FAIL] Could not load api_client.gd")
|
|
quit(1)
|
|
return
|
|
|
|
var api: Node = api_script.new()
|
|
root.add_child(api)
|
|
|
|
assert(api.has_method("get_discovery_worlds"), "Missing get_discovery_worlds on ApiClient")
|
|
assert(api.has_method("get_discovery_categories"), "Missing get_discovery_categories on ApiClient")
|
|
assert(api.has_method("record_world_visit"), "Missing record_world_visit on ApiClient")
|
|
print("[PASS] ApiClient discovery methods verified")
|
|
|
|
api.queue_free()
|
|
print("[SMOKE] DiscoveryApiClient smoke test PASSED")
|
|
quit(0)
|