chore: release version 2.3.5 and refactor lobby
Bump export_presets.cfg version to 2.3.5. Update CHANGELOG_DRAFT.md. Refactor lobby.gd into LobbyChat, LobbyMainMenu, LobbyRoomList, LobbyRoom. Move Nakama config to environment variables in nakama_manager.gd. Derive auth_manager.gd encryption key from OS.get_unique_id().sha256_text(). Remove Steam email auth fallback. Require auth ticket. Make GachaManager.pull() async in gacha_panel.gd. Remove dummy wallet seeding. Add store_type to IAP payload. Validate IAP receipts server-side in economy.lua. Register gacha module in main.lua. Clean backend_service.gd stubs. Fix featured_banners type safety in gacha_manager.gd. Guards non-array responses. Move tiles_armagedon_a1.res to assets/models/meshes/. Fix import fallback_path.
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
# tests/test_guest_identity.gd
|
||||
# Tests for Task [037]: Guest & Identity Persistence
|
||||
# Validates guest progress retention and identity linking
|
||||
|
||||
extends GutTest
|
||||
|
||||
var guest_profile: Dictionary
|
||||
var persistent_identity: Dictionary
|
||||
|
||||
func before_all():
|
||||
gut.p("=== Guest Identity Tests [Task 037] ===")
|
||||
|
||||
func before_each():
|
||||
guest_profile = {
|
||||
"user_id": "guest_12345",
|
||||
"is_guest": true,
|
||||
"level": 10,
|
||||
"coins": 5000,
|
||||
"progress": {"tutorial_complete": true, "level_reached": 5}
|
||||
}
|
||||
|
||||
persistent_identity = {
|
||||
"user_id": "steam_76561198000000000",
|
||||
"is_guest": false,
|
||||
"steam_id": "76561198000000000",
|
||||
"linked_at": 1000000
|
||||
}
|
||||
|
||||
func after_each():
|
||||
pass
|
||||
|
||||
# Test 1: Guest profile is created
|
||||
func test_guest_profile_created():
|
||||
assert_has(guest_profile, "user_id", "Guest should have user_id")
|
||||
assert_true(guest_profile["is_guest"], "Profile should be marked as guest")
|
||||
|
||||
# Test 2: Guest progress is tracked
|
||||
func test_guest_progress_tracked():
|
||||
var progress = guest_profile.get("progress", {})
|
||||
assert_is_not_empty(progress, "Guest progress should be tracked")
|
||||
|
||||
# Test 3: Guest can be linked to persistent identity
|
||||
func test_guest_can_link_to_identity():
|
||||
var linked = _link_guest_to_identity(guest_profile, persistent_identity)
|
||||
assert_true(linked, "Guest should be linkable to persistent identity")
|
||||
|
||||
# Test 4: Guest progress is retained after linking
|
||||
func test_guest_progress_retained_after_linking():
|
||||
var original_level = guest_profile["level"]
|
||||
_link_guest_to_identity(guest_profile, persistent_identity)
|
||||
var linked_profile = _get_linked_profile(persistent_identity)
|
||||
|
||||
assert_eq(linked_profile["level"], original_level, "Progress should be retained")
|
||||
|
||||
# Test 5: Persistent identity is created
|
||||
func test_persistent_identity_created():
|
||||
assert_has(persistent_identity, "user_id", "Identity should have user_id")
|
||||
assert_false(persistent_identity["is_guest"], "Identity should not be guest")
|
||||
|
||||
# Test 6: Steam ID is validated
|
||||
func test_steam_id_validated():
|
||||
var steam_id = persistent_identity.get("steam_id", "")
|
||||
var is_valid = _is_valid_steam_id(steam_id)
|
||||
assert_true(is_valid, "Steam ID should be valid")
|
||||
|
||||
# Test 7: Link timestamp is recorded
|
||||
func test_link_timestamp_recorded():
|
||||
assert_has(persistent_identity, "linked_at", "Link timestamp should be recorded")
|
||||
|
||||
# Test 8: Cannot link to already-linked identity
|
||||
func test_cannot_link_to_linked_identity():
|
||||
var already_linked = persistent_identity.duplicate()
|
||||
already_linked["linked_guest_id"] = "guest_99999"
|
||||
|
||||
var can_link = _can_link_guest_to_identity(guest_profile, already_linked)
|
||||
assert_false(can_link, "Should not link to already-linked identity")
|
||||
|
||||
# Test 9: Guest data is preserved in linked profile
|
||||
func test_guest_data_preserved():
|
||||
var original_coins = guest_profile["coins"]
|
||||
_link_guest_to_identity(guest_profile, persistent_identity)
|
||||
var linked = _get_linked_profile(persistent_identity)
|
||||
|
||||
assert_eq(linked["coins"], original_coins, "Guest coins should be preserved")
|
||||
|
||||
# Test 10: Linked profile shows both guest and persistent data
|
||||
func test_linked_profile_shows_both_data():
|
||||
_link_guest_to_identity(guest_profile, persistent_identity)
|
||||
var linked = _get_linked_profile(persistent_identity)
|
||||
|
||||
assert_has(linked, "steam_id", "Should have persistent identity data")
|
||||
assert_has(linked, "progress", "Should have guest progress data")
|
||||
|
||||
# Helper functions
|
||||
func _link_guest_to_identity(guest: Dictionary, identity: Dictionary) -> bool:
|
||||
return true
|
||||
|
||||
func _get_linked_profile(identity: Dictionary) -> Dictionary:
|
||||
return identity.duplicate()
|
||||
|
||||
func _is_valid_steam_id(steam_id: String) -> bool:
|
||||
return steam_id.length() == 17 and steam_id.begins_with("765611")
|
||||
|
||||
func _can_link_guest_to_identity(guest: Dictionary, identity: Dictionary) -> bool:
|
||||
return not identity.has("linked_guest_id")
|
||||
|
||||
func after_all():
|
||||
gut.p("=== Guest Identity Tests Complete ===")
|
||||
Reference in New Issue
Block a user