test: ExportPanel als eigenständige Szene mit eigenem Test

Die Probe aufs Exempel für die Modularisierung: `ExportPanel` liegt jetzt in
`scenes/export/export_panel.tscn`, die Whiteboard-Szene instanziiert sie nur
noch. Der neue `run_export_panel_tests.gd` lädt ausschließlich diese Szene und
prüft die Signale — 15 Assertions ohne WhiteboardController.

Damit ist zum ersten Mal ein Baustein nicht nur im Code, sondern auch in der
Prüfbarkeit getrennt. Die übrigen Suiten starten weiter die volle Szene.

Stolpersteine, beide dokumentiert: Kindknoten eines Szenen-Roots brauchen
`parent="."`, und ein eigener Test braucht `root.size` vor `popup_centered`,
sonst landen Fenster headless auf negativen Koordinaten.
This commit is contained in:
torsten 2026-11-13 15:03:07 +01:00
parent e47b8e0a9a
commit 94ec11ad87
7 changed files with 290 additions and 131 deletions

View file

@ -0,0 +1,131 @@
extends SceneTree
## Headless test for `ExportPanel` on its own.
##
## No WhiteboardController, no routine scene: the panel is instantiated from
## `scenes/export/export_panel.tscn` and reports its choices through signals.
## This is the measure of whether the module is really separate.
##
## Run with:
## godot --headless --path rinkplanner --script res://tests/run_export_panel_tests.gd
const PanelScene := preload("res://scenes/export/export_panel.tscn")
var _assertions: int = 0
var _failures: PackedStringArray = PackedStringArray()
func _init() -> void:
_run.call_deferred()
func _run() -> void:
var panel := PanelScene.instantiate() as ExportPanel
_check(panel != null, "the panel scene carries its script")
if panel == null:
_finish()
return
# Without a window size, popup_centered places dialogs at negative offsets
# in headless runs; give the root window a sane size.
root.size = Vector2i(1280, 800)
root.add_child(panel)
await process_frame
_check(
panel.dialog != null and panel.done_dialog != null,
"both dialogs are wired"
)
_check(
panel.format_option.item_count == 3,
"three export formats are offered"
)
var routine := Routine.new()
routine.routine_id = "panel-test"
routine.title = "Kür am See"
routine.rink = RinkDimensions.new()
var section := RoutineSection.new()
section.section_id = "s1"
section.title = "Abschnitt 1"
# Lambdas capture by value: mutate the dictionary instead of rebinding it.
var captured: Dictionary = {}
panel.export_requested.connect(
func(
path: String,
format: int,
section_id: String,
open_after: bool
) -> void:
captured["path"] = path
captured["format"] = format
captured["section_id"] = section_id
captured["open_after"] = open_after
)
panel.open_for(routine, section, Vector2i(480, 520))
_check(panel.dialog.visible, "the dialog opens")
_check(panel.name_edit.text == "Kür am See", "the routine title fills the name")
panel.dialog.confirmed.emit()
_check(
str(captured.get("path", "")).ends_with("kür_am_see.svg"),
"the default format is SVG with a clean file stem (%s)"
% captured.get("path", "")
)
_check(int(captured.get("format", -1)) == 0, "the format id is passed")
_check(
str(captured.get("section_id", "x")).is_empty(),
"the whole routine is the default scope"
)
panel.scope_option.select(1)
panel.format_option.select(2)
captured.clear()
panel.dialog.confirmed.emit()
_check(int(captured.get("format", -1)) == 2, "the PDF format is passed")
_check(
str(captured.get("path", "")).ends_with("_abschnitt_1.pdf"),
"the section suffix is added (%s)" % captured.get("path", "")
)
_check(
str(captured.get("section_id", "")) == "s1",
"the section id is passed"
)
var messages: Array = []
panel.message_requested.connect(
func(text: String) -> void:
messages.append(text)
)
panel.name_edit.text = " "
captured.clear()
panel.dialog.confirmed.emit()
_check(captured.is_empty(), "an empty name does not export")
_check(not messages.is_empty(), "an empty name asks for input")
# The done dialog only enables "open" for an existing file.
panel.show_done("/tmp/does-not-exist.pdf", Vector2i(660, 320))
_check(panel.open_button.disabled, "missing files cannot be opened")
_check(panel.done_dialog.visible, "the done dialog opens")
panel.queue_free()
await process_frame
_finish()
func _check(condition: bool, message: String) -> void:
_assertions += 1
if not condition:
_failures.append(message)
func _finish() -> void:
if _failures.is_empty():
print("PASS: %d assertions" % _assertions)
quit(0)
return
for failure: String in _failures:
printerr("FAIL: %s" % failure)
printerr("%d of %d assertions failed" % [_failures.size(), _assertions])
quit(1)

View file

@ -0,0 +1 @@
uid://b6r15yds80ibm