diff --git a/client/tests/unit/test_dev_harness_seed_logs.gd b/client/tests/unit/test_dev_harness_seed_logs.gd new file mode 100644 index 0000000..d8fb985 --- /dev/null +++ b/client/tests/unit/test_dev_harness_seed_logs.gd @@ -0,0 +1,25 @@ +extends "res://addons/gut/test.gd" +## Guards the two dev-only proving-scene seed logs (narrate_harness, +## npc_harness) against the same LogPlayer arg-slot regression the shell test +## guards (see test_main_window_shell.gd). Both scenes build their seed log's +## LogPlayer in _ready() with no network call until a button is pressed, so +## instantiate + add_child_autofree is cheap and touches no network. + +const NARRATE_SCENE := "res://scenes/narrate_harness.tscn" +const NPC_SCENE := "res://scenes/npc_harness.tscn" + + +func test_narrate_harness_seed_log_has_real_race_and_calling(): + var node = load(NARRATE_SCENE).instantiate() + add_child_autofree(node) + assert_true(Races.exists(node._log.player.race_id), "seed race must be a real race") + assert_true(Callings.exists(node._log.player.calling_id), "seed calling must be a real calling") + assert_ne(node._log.player.luck_descriptor, "", "the descriptor must not be lost to an arg-slot shift") + + +func test_npc_harness_seed_log_has_real_race_and_calling(): + var node = load(NPC_SCENE).instantiate() + add_child_autofree(node) + assert_true(Races.exists(node._canon_log.player.race_id), "seed race must be a real race") + assert_true(Callings.exists(node._canon_log.player.calling_id), "seed calling must be a real calling") + assert_ne(node._canon_log.player.luck_descriptor, "", "the descriptor must not be lost to an arg-slot shift") diff --git a/client/tests/unit/test_dev_harness_seed_logs.gd.uid b/client/tests/unit/test_dev_harness_seed_logs.gd.uid new file mode 100644 index 0000000..3adeb1a --- /dev/null +++ b/client/tests/unit/test_dev_harness_seed_logs.gd.uid @@ -0,0 +1 @@ +uid://bmaooitlx0ox4 diff --git a/client/tests/unit/test_entities.gd b/client/tests/unit/test_entities.gd index 1f0f643..77e6347 100644 --- a/client/tests/unit/test_entities.gd +++ b/client/tests/unit/test_entities.gd @@ -32,19 +32,6 @@ func test_log_player_rejects_a_dead_calling(): assert_true(p.set_race_id("dwarf")) -func test_log_player_ctor_populates_both_race_and_calling(): - # Regression: three call sites once passed the OLD 3-arg (name, class_id, - # luck_descriptor) shape against the NEW 4-arg (name, race_id, calling_id, - # luck_descriptor) constructor. Every param has a default, so GDScript - # compiled it silently โ€” the string meant as a calling landed in the - # race_id slot, got rejected, and both fields came out "". This asserts - # a properly-shaped call yields BOTH fields non-empty. - var p := LogPlayer.new("Aldric", "human", "sellsword", "Fortune spits on you") - var d := p.to_dict() - assert_ne(d["race_id"], "", "race_id must not be empty") - assert_ne(d["calling_id"], "", "calling_id must not be empty") - - func test_log_player_ctor_rejects_calling_passed_as_race(): # The exact shape of the bug: calling three broken call sites used to pass โ€” # LogPlayer.new(name, class_id, luck_descriptor) against the NEW ctor diff --git a/client/tests/unit/test_main_window_shell.gd b/client/tests/unit/test_main_window_shell.gd index 44413ab..13527d6 100644 --- a/client/tests/unit/test_main_window_shell.gd +++ b/client/tests/unit/test_main_window_shell.gd @@ -35,3 +35,15 @@ func test_shell_builds_a_code_owned_seed_log(): var node := _shell() assert_not_null(node._log, "a canon log exists to post (ยง11)") assert_gt(node._log.established_facts.size(), 0, "seed scene facts are code-owned") + + +func test_shell_seed_player_has_a_real_race_and_calling(): + # Regression: the shell's _build_seed_log() once called LogPlayer.new() with + # the OLD 3-arg (name, class_id, luck_descriptor) shape against the NEW + # 4-arg ctor. Every param defaults, so it compiled silently and both + # race_id/calling_id came out "" โ€” which 422s against the canon-log schema. + # Assert against the log the shell actually builds, not a fresh LogPlayer. + var node := _shell() + assert_true(Races.exists(node._log.player.race_id), "seed race must be a real race") + assert_true(Callings.exists(node._log.player.calling_id), "seed calling must be a real calling") + assert_ne(node._log.player.luck_descriptor, "", "the descriptor must not be lost to an arg-slot shift")