test(game-engine): Add unit tests for auto-generated credits screen functionality

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
autocommit 2026-04-29 09:41:38 -07:00
parent 9a92017e45
commit 3eb0c35b45

View file

@ -60,6 +60,44 @@ func test_credits_script_loads_sections_list() -> void:
instance.free()
# ── Audio auto-section: groups sources.csv by attribution into credit rows ─
func test_credits_declares_audio_auto_section() -> void:
var data: Dictionary = _load_credits()
var auto: Array = data.get("auto_sections", []) as Array
assert_gt(auto.size(), 0, "credits.json must declare at least one auto_section")
var sources: Array[String] = []
for entry_variant: Variant in auto:
if entry_variant is Dictionary:
sources.append(String((entry_variant as Dictionary).get("source", "")))
assert_true(sources.has("audio_sources_csv"),
"credits.json must list audio_sources_csv as an auto-section source")
func test_audio_credit_entries_grouped_by_pack() -> void:
var instance: Node = CreditsScript.new()
var entries: Array = instance.call("_audio_credit_entries") as Array
instance.free()
assert_gte(entries.size(), 2,
"audio credits must surface at least two distinct packs (we ship Kenney + rubberduck/Junkala)")
var names: Array[String] = []
for e_variant: Variant in entries:
assert_true(e_variant is Dictionary, "entry must be a dict")
var e: Dictionary = e_variant
assert_true(e.has("name") and not String(e["name"]).is_empty(),
"audio credit entry must have a non-empty name")
var role: String = String(e.get("role", ""))
assert_true(role.contains("file") and role.contains("CC"),
"role must announce the file count and the CC licence — got '%s'" % role)
names.append(String(e["name"]))
# No duplicates — the grouping is the whole point.
var dedup: Dictionary = {}
for n: String in names:
assert_false(dedup.has(n), "pack '%s' appears twice — grouping is broken" % n)
dedup[n] = true
func test_vocabulary_has_credits_key() -> void:
assert_true(ThemeVocabulary.has_key("credits"),
"vocabulary must expose a 'credits' label for the button")