test: assert seed-log fields, not a fresh LogPlayer
The previous regression tests in test_entities.gd only constructed their own LogPlayer and never touched the seed logs the real call sites build — reverting main_window_shell.gd:124 to the broken 3-arg call still left the whole suite green. Not a real regression guard. Now assert against node._log.player in the shell test and against the two dev-harness scenes' seed logs (narrate_harness, npc_harness — both cheaply testable via instantiate + add_child_autofree, no scaffolding needed). Proved the new shell assertion fails when the call site is reverted to the 3-arg shape (226/227, one failure), then passes restored (227/227). Removed a redundant ctor test from test_entities.gd; kept the one that exercises the exact broken-shape call. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QYa9u7Kdxv5gX4AnwWexy8
This commit is contained in:
25
client/tests/unit/test_dev_harness_seed_logs.gd
Normal file
25
client/tests/unit/test_dev_harness_seed_logs.gd
Normal file
@@ -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")
|
||||||
1
client/tests/unit/test_dev_harness_seed_logs.gd.uid
Normal file
1
client/tests/unit/test_dev_harness_seed_logs.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://bmaooitlx0ox4
|
||||||
@@ -32,19 +32,6 @@ func test_log_player_rejects_a_dead_calling():
|
|||||||
assert_true(p.set_race_id("dwarf"))
|
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():
|
func test_log_player_ctor_rejects_calling_passed_as_race():
|
||||||
# The exact shape of the bug: calling three broken call sites used to pass —
|
# 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
|
# LogPlayer.new(name, class_id, luck_descriptor) against the NEW ctor
|
||||||
|
|||||||
@@ -35,3 +35,15 @@ func test_shell_builds_a_code_owned_seed_log():
|
|||||||
var node := _shell()
|
var node := _shell()
|
||||||
assert_not_null(node._log, "a canon log exists to post (§11)")
|
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")
|
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")
|
||||||
|
|||||||
Reference in New Issue
Block a user