fix: Release-Härtung, JSON-Dateiformat und Quality-Meilenstein
- Export: Runtime-Bridge-Autoload und Skater-GLB samt Texturen einschließen, Editor-Addons ausschließen - tools/check_export.sh als headless Smoke-Test; ./tools/test.sh --export - RoutineFile: JSON-Format, atomare Saves, Whitelist für Legacy-.tres - Überschreibschutz für Speichern unter/Export, Session- und Autosave-Restore - Globaler Delete-Shortcut blockiert bei offenen Dialogen - Sync akzeptiert .json und Legacy-.tres, Konfliktnamen behalten die Endung - Tests für Dateiformat, Überschreiben, Session und Legacy-Schutz - Quality-Meilenstein mit 'Als Nächstes' und 'Danach' in der Roadmap
This commit is contained in:
parent
edf12a11c2
commit
7bbd8c9c1d
21 changed files with 1711 additions and 158 deletions
|
|
@ -8,6 +8,8 @@ From the repository root:
|
|||
|
||||
```bash
|
||||
./tools/test.sh
|
||||
# inklusive Export-Smoke-Test:
|
||||
./tools/test.sh --export
|
||||
```
|
||||
|
||||
Or manually:
|
||||
|
|
@ -23,6 +25,9 @@ $GODOT --headless --path rinkplanner --import
|
|||
# Run model tests
|
||||
$GODOT --headless --path rinkplanner --script res://tests/run_model_tests.gd
|
||||
|
||||
# Run JSON/legacy file-format tests
|
||||
$GODOT --headless --path rinkplanner --script res://tests/run_file_format_tests.gd
|
||||
|
||||
# Run ISU element catalog tests
|
||||
$GODOT --headless --path rinkplanner --script res://tests/run_rules_tests.gd
|
||||
|
||||
|
|
|
|||
332
rinkplanner/tests/run_file_format_tests.gd
Normal file
332
rinkplanner/tests/run_file_format_tests.gd
Normal file
|
|
@ -0,0 +1,332 @@
|
|||
extends SceneTree
|
||||
|
||||
## Headless tests for the routine file format: JSON round-trip, schema checks,
|
||||
## atomic writes and the legacy `.tres` whitelist.
|
||||
##
|
||||
## Run with:
|
||||
## godot --headless --path rinkplanner --script res://tests/run_file_format_tests.gd
|
||||
|
||||
const JSON_PATH := "user://test_format.json"
|
||||
const LEGACY_PATH := "user://test_format_legacy.tres"
|
||||
const EVIL_PATH := "user://test_format_evil.tres"
|
||||
const EVIL_SCRIPT_PATH := "user://test_format_evil_script.tres"
|
||||
|
||||
var _assertions: int = 0
|
||||
var _failures: PackedStringArray = PackedStringArray()
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
_run.call_deferred()
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
_test_json_roundtrip()
|
||||
_test_json_rejects()
|
||||
_test_atomic_write()
|
||||
_test_legacy_roundtrip()
|
||||
_test_legacy_guard()
|
||||
_cleanup()
|
||||
_finish()
|
||||
|
||||
|
||||
func _test_json_roundtrip() -> void:
|
||||
var routine := _make_routine()
|
||||
var encoded := RoutineFile.encode(routine)
|
||||
_check(
|
||||
encoded.contains("\"format\": \"rinkplanner.routine\""),
|
||||
"JSON contains the format marker"
|
||||
)
|
||||
_check(
|
||||
encoded.contains("\"direction\": \"backward\""),
|
||||
"enums are stored as readable names"
|
||||
)
|
||||
|
||||
var result := RoutineFile.decode_json(encoded)
|
||||
_check(str(result["error"]).is_empty(), "encoded JSON decodes without error")
|
||||
var loaded: Routine = result["routine"]
|
||||
_check(loaded != null, "decoded JSON yields a routine")
|
||||
if loaded == null:
|
||||
return
|
||||
|
||||
_check(loaded.routine_id == routine.routine_id, "routine id survives")
|
||||
_check(loaded.title == routine.title, "title survives")
|
||||
_check(loaded.skater_name == routine.skater_name, "skater name survives")
|
||||
_check(loaded.adult_category == routine.adult_category, "category survives")
|
||||
_check_approx(
|
||||
loaded.assumed_pcs_average,
|
||||
routine.assumed_pcs_average,
|
||||
"PCS assumption survives"
|
||||
)
|
||||
_check(loaded.assumed_falls == routine.assumed_falls, "fall count survives")
|
||||
_check_approx(loaded.rink.length_m, 40.0, "rink length survives")
|
||||
_check(loaded.sections.size() == 1, "section survives")
|
||||
|
||||
var section := loaded.get_section_by_id("section-001")
|
||||
_check(section != null, "section id survives")
|
||||
if section == null:
|
||||
return
|
||||
_check(section.title == "Abschnitt 1", "section title survives")
|
||||
_check(section.segments.size() == 3, "all segments survive")
|
||||
|
||||
var arc := section.get_segment_by_id("seg-arc")
|
||||
_check(arc != null, "arc segment survives")
|
||||
if arc != null:
|
||||
_check(arc.direction == PathSegment.Direction.BACKWARD, "direction survives")
|
||||
_check(arc.edge == PathSegment.Edge.INSIDE, "edge survives")
|
||||
_check(arc.timing_mode == PathSegment.TimingMode.DURATION, "timing mode survives")
|
||||
_check(arc.template == PathSegment.Template.ARC, "arc template survives")
|
||||
_check(arc.label == "Kür & Test", "label survives")
|
||||
_check(arc.element_type == PathSegment.ElementType.JUMP, "element type survives")
|
||||
_check(arc.element_code == "3Lz", "element code survives")
|
||||
_check(
|
||||
arc.combination_jumps == PackedStringArray(["2T", "2S"]),
|
||||
"jump combination survives"
|
||||
)
|
||||
_check(
|
||||
arc.element_features == PackedStringArray(["difficult_exit"]),
|
||||
"features survive"
|
||||
)
|
||||
_check(arc.curve.point_count == 2, "curve points survive")
|
||||
_check_vec(
|
||||
arc.curve.get_point_position(0),
|
||||
Vector2(-10.0, -5.0),
|
||||
"first curve point survives"
|
||||
)
|
||||
_check_vec(
|
||||
arc.curve.get_point_in(0),
|
||||
Vector2(-1.0, 0.5),
|
||||
"curve in-handle survives"
|
||||
)
|
||||
_check_vec(
|
||||
arc.curve.get_point_out(1),
|
||||
Vector2(2.0, -0.5),
|
||||
"curve out-handle survives"
|
||||
)
|
||||
|
||||
var marker := section.get_segment_by_id("seg-marker")
|
||||
_check(marker != null, "marker survives")
|
||||
if marker != null:
|
||||
_check(marker.is_element_marker(), "marker stays a point marker")
|
||||
_check(marker.curve.point_count == 1, "marker keeps one point")
|
||||
_check_approx(
|
||||
marker.element_duration_seconds,
|
||||
0.7,
|
||||
"marker stand time survives"
|
||||
)
|
||||
|
||||
|
||||
func _test_json_rejects() -> void:
|
||||
_check(
|
||||
not str(RoutineFile.decode_json("{}")["error"]).is_empty(),
|
||||
"empty JSON object is rejected"
|
||||
)
|
||||
_check(
|
||||
not str(RoutineFile.decode_json("{")["error"]).is_empty(),
|
||||
"broken JSON is rejected"
|
||||
)
|
||||
var too_new := RoutineFile.decode_json(
|
||||
'{"format":"rinkplanner.routine","format_version":1,'
|
||||
+ '"schema_version":99,"rink":{},"sections":[]}'
|
||||
)
|
||||
_check(not str(too_new["error"]).is_empty(), "newer schema is rejected")
|
||||
|
||||
var routine := _make_routine()
|
||||
var encoded := RoutineFile.encode(routine)
|
||||
var bad_direction := encoded.replace(
|
||||
"\"direction\": \"backward\"",
|
||||
"\"direction\": \"sideways\""
|
||||
)
|
||||
_check(
|
||||
not str(RoutineFile.decode_json(bad_direction)["error"]).is_empty(),
|
||||
"unknown enum value is rejected"
|
||||
)
|
||||
_check(
|
||||
RoutineFile.json_path("user://kuer.tres") == "user://kuer.json",
|
||||
"legacy paths migrate to the JSON extension"
|
||||
)
|
||||
_check(
|
||||
RoutineFile.json_path("user://kuer") == "user://kuer.json",
|
||||
"paths without extension get .json"
|
||||
)
|
||||
|
||||
|
||||
func _test_atomic_write() -> void:
|
||||
var routine := _make_routine()
|
||||
_check(
|
||||
RoutineFile.save(routine, JSON_PATH).is_empty(),
|
||||
"routine saves without error"
|
||||
)
|
||||
_check(FileAccess.file_exists(JSON_PATH), "JSON file exists")
|
||||
_check(not FileAccess.file_exists(JSON_PATH + ".tmp"), "no temp file remains")
|
||||
_check(not FileAccess.file_exists(JSON_PATH + ".bak"), "no backup remains")
|
||||
|
||||
routine.title = "Zweite Fassung"
|
||||
_check(
|
||||
RoutineFile.save(routine, JSON_PATH).is_empty(),
|
||||
"routine can be replaced atomically"
|
||||
)
|
||||
var result := RoutineFile.load_file(JSON_PATH)
|
||||
var loaded: Routine = result["routine"]
|
||||
_check(
|
||||
loaded != null and loaded.title == "Zweite Fassung",
|
||||
"atomic replacement writes the new content"
|
||||
)
|
||||
|
||||
|
||||
func _test_legacy_roundtrip() -> void:
|
||||
var routine := _make_routine()
|
||||
_check(
|
||||
ResourceSaver.save(routine, LEGACY_PATH) == OK,
|
||||
"legacy resource can be written"
|
||||
)
|
||||
var result := RoutineFile.load_file(LEGACY_PATH)
|
||||
_check(str(result["error"]).is_empty(), "benign legacy file passes the guard")
|
||||
var loaded: Routine = result["routine"]
|
||||
_check(loaded != null, "benign legacy file loads")
|
||||
if loaded != null:
|
||||
_check(loaded.title == routine.title, "legacy fields survive")
|
||||
_check(loaded.sections.size() == 1, "legacy sections survive")
|
||||
|
||||
|
||||
func _test_legacy_guard() -> void:
|
||||
var embedded := (
|
||||
"[gd_resource type=\"Resource\" format=3]\n\n"
|
||||
+ "[sub_resource type=\"GDScript\" id=\"1_script\"]\n"
|
||||
+ "script/source = \"extends Resource\\n\\nfunc _init():\\n"
|
||||
+ "\\tprint(\\\"PWNED\\\")\\n\"\n\n"
|
||||
+ "[resource]\nscript = SubResource(\"1_script\")\n"
|
||||
)
|
||||
_write(EVIL_PATH, embedded)
|
||||
var evil_result := RoutineFile.load_file(EVIL_PATH)
|
||||
_check(evil_result["routine"] == null, "embedded GDScript is rejected")
|
||||
_check(
|
||||
str(evil_result["error"]).contains("eingebetteten Code"),
|
||||
"embedded code error is explicit"
|
||||
)
|
||||
|
||||
var foreign_script := (
|
||||
"[gd_resource type=\"Resource\" script_class=\"Routine\" format=3]\n\n"
|
||||
+ "[ext_resource type=\"Script\" "
|
||||
+ "path=\"res://src/whiteboard/ctrl/whiteboard_controller.gd\" id=\"1\"]\n\n"
|
||||
+ "[resource]\nscript = ExtResource(\"1\")\n"
|
||||
)
|
||||
_write(EVIL_SCRIPT_PATH, foreign_script)
|
||||
var script_result := RoutineFile.load_file(EVIL_SCRIPT_PATH)
|
||||
_check(script_result["routine"] == null, "foreign script reference is rejected")
|
||||
_check(
|
||||
str(script_result["error"]).contains("unerlaubtes Skript"),
|
||||
"foreign script error is explicit"
|
||||
)
|
||||
|
||||
|
||||
func _make_routine() -> Routine:
|
||||
var routine := Routine.new()
|
||||
routine.routine_id = "format-test"
|
||||
routine.title = "Format Test"
|
||||
routine.skater_name = "Erika"
|
||||
routine.adult_category = "gold"
|
||||
routine.assumed_pcs_average = 4.75
|
||||
routine.assumed_falls = 1
|
||||
routine.rink = RinkDimensions.new()
|
||||
routine.rink.length_m = 40.0
|
||||
routine.rink.width_m = 20.0
|
||||
routine.rink.corner_radius_m = 6.0
|
||||
|
||||
var section := RoutineSection.new()
|
||||
section.section_id = "section-001"
|
||||
section.title = "Abschnitt 1"
|
||||
section.sequence_order = 0
|
||||
|
||||
var line := PathSegment.new()
|
||||
line.segment_id = "seg-line"
|
||||
line.curve = Curve2D.new()
|
||||
line.curve.add_point(Vector2(-15.0, 0.0))
|
||||
line.curve.add_point(Vector2(-5.0, 0.0))
|
||||
line.set_speed_mps(4.0)
|
||||
|
||||
var arc := PathSegment.new()
|
||||
arc.segment_id = "seg-arc"
|
||||
arc.direction = PathSegment.Direction.BACKWARD
|
||||
arc.edge = PathSegment.Edge.INSIDE
|
||||
arc.timing_mode = PathSegment.TimingMode.DURATION
|
||||
arc.duration_seconds = 2.5
|
||||
arc.speed_mps = 4.0
|
||||
arc.template = PathSegment.Template.ARC
|
||||
arc.arc_depth_ratio = 0.35
|
||||
arc.arc_bulge_left = false
|
||||
arc.label = "Kür & Test"
|
||||
arc.curve = Curve2D.new()
|
||||
arc.curve.add_point(
|
||||
Vector2(-10.0, -5.0),
|
||||
Vector2(-1.0, 0.5),
|
||||
Vector2(1.0, -0.5)
|
||||
)
|
||||
arc.curve.add_point(
|
||||
Vector2(0.0, -5.0),
|
||||
Vector2(-2.0, 0.5),
|
||||
Vector2(2.0, -0.5)
|
||||
)
|
||||
arc.set_element(PathSegment.ElementType.JUMP, "3Lz", 0)
|
||||
arc.set_element_features(PackedStringArray(["difficult_exit"]))
|
||||
arc.set_jump_combination(
|
||||
PathSegment.JumpKind.COMBINATION,
|
||||
PackedStringArray(["2T", "2S"])
|
||||
)
|
||||
|
||||
var marker := PathSegment.new()
|
||||
marker.segment_id = "seg-marker"
|
||||
marker.curve = Curve2D.new()
|
||||
marker.curve.add_point(Vector2(5.0, 5.0))
|
||||
marker.speed_mps = 4.0
|
||||
marker.set_element(PathSegment.ElementType.SPIN, "CCoSp4", 4)
|
||||
marker.set_element_duration(0.7)
|
||||
|
||||
section.segments = [line, arc, marker]
|
||||
routine.sections = [section]
|
||||
return routine
|
||||
|
||||
|
||||
func _write(path: String, text: String) -> void:
|
||||
var file := FileAccess.open(path, FileAccess.WRITE)
|
||||
file.store_string(text)
|
||||
file.close()
|
||||
|
||||
|
||||
func _cleanup() -> void:
|
||||
for path: String in [JSON_PATH, LEGACY_PATH, EVIL_PATH, EVIL_SCRIPT_PATH]:
|
||||
for suffix: String in ["", ".tmp", ".bak"]:
|
||||
if FileAccess.file_exists(path + suffix):
|
||||
DirAccess.remove_absolute(
|
||||
ProjectSettings.globalize_path(path + suffix)
|
||||
)
|
||||
|
||||
|
||||
func _check(condition: bool, message: String) -> void:
|
||||
_assertions += 1
|
||||
if not condition:
|
||||
_failures.append(message)
|
||||
|
||||
|
||||
func _check_approx(actual: float, expected: float, message: String) -> void:
|
||||
_check(
|
||||
absf(actual - expected) <= 0.001,
|
||||
"%s (expected %.3f, got %.3f)" % [message, expected, actual]
|
||||
)
|
||||
|
||||
|
||||
func _check_vec(actual: Vector2, expected: Vector2, message: String) -> void:
|
||||
_check(
|
||||
actual.distance_to(expected) <= 0.001,
|
||||
"%s (expected %s, got %s)" % [message, expected, actual]
|
||||
)
|
||||
|
||||
|
||||
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)
|
||||
1
rinkplanner/tests/run_file_format_tests.gd.uid
Normal file
1
rinkplanner/tests/run_file_format_tests.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bchm7iw3mfvw7
|
||||
|
|
@ -27,50 +27,50 @@ func _run() -> void:
|
|||
|
||||
func _test_plan() -> void:
|
||||
var local := {
|
||||
"neu.tres": {"mtime": 100, "size": 10},
|
||||
"lokal.tres": {"mtime": 200, "size": 10},
|
||||
"server.tres": {"mtime": 300, "size": 10},
|
||||
"beide.tres": {"mtime": 400, "size": 10},
|
||||
"gleich.tres": {"mtime": 500, "size": 10},
|
||||
"entfernt.tres": {"mtime": 600, "size": 10},
|
||||
"neu.json": {"mtime": 100, "size": 10},
|
||||
"lokal.json": {"mtime": 200, "size": 10},
|
||||
"server.json": {"mtime": 300, "size": 10},
|
||||
"beide.json": {"mtime": 400, "size": 10},
|
||||
"gleich.json": {"mtime": 500, "size": 10},
|
||||
"entfernt.json": {"mtime": 600, "size": 10},
|
||||
}
|
||||
var remote := {
|
||||
"server-neu.tres": {"modify": 700, "size": 10},
|
||||
"lokal.tres": {"modify": 200, "size": 10},
|
||||
"server.tres": {"modify": 900, "size": 10},
|
||||
"beide.tres": {"modify": 900, "size": 10},
|
||||
"gleich.tres": {"modify": 500, "size": 10},
|
||||
"entfernt.tres": {"modify": 600, "size": 10},
|
||||
"server-neu.json": {"modify": 700, "size": 10},
|
||||
"lokal.json": {"modify": 200, "size": 10},
|
||||
"server.json": {"modify": 900, "size": 10},
|
||||
"beide.json": {"modify": 900, "size": 10},
|
||||
"gleich.json": {"modify": 500, "size": 10},
|
||||
"entfernt.json": {"modify": 600, "size": 10},
|
||||
}
|
||||
var state := {
|
||||
"lokal.tres": {"local_mtime": 100, "remote_modify": 200},
|
||||
"server.tres": {"local_mtime": 300, "remote_modify": 300},
|
||||
"beide.tres": {"local_mtime": 401, "remote_modify": 400},
|
||||
"gleich.tres": {"local_mtime": 500, "remote_modify": 500},
|
||||
"entfernt.tres": {"local_mtime": 600, "remote_modify": 600},
|
||||
"lokal.json": {"local_mtime": 100, "remote_modify": 200},
|
||||
"server.json": {"local_mtime": 300, "remote_modify": 300},
|
||||
"beide.json": {"local_mtime": 401, "remote_modify": 400},
|
||||
"gleich.json": {"local_mtime": 500, "remote_modify": 500},
|
||||
"entfernt.json": {"local_mtime": 600, "remote_modify": 600},
|
||||
}
|
||||
var plan := SyncPlan.build(local, remote, state)
|
||||
var actions := {}
|
||||
for entry: Dictionary in plan:
|
||||
actions[entry["name"]] = entry["action"]
|
||||
|
||||
_check(actions.get("neu.tres") == SyncPlan.Action.UPLOAD, "nur lokal wird hochgeladen")
|
||||
_check(actions.get("server-neu.tres") == SyncPlan.Action.DOWNLOAD, "nur Server wird geladen")
|
||||
_check(actions.get("neu.json") == SyncPlan.Action.UPLOAD, "nur lokal wird hochgeladen")
|
||||
_check(actions.get("server-neu.json") == SyncPlan.Action.DOWNLOAD, "nur Server wird geladen")
|
||||
_check(
|
||||
actions.get("beide.tres") == SyncPlan.Action.CONFLICT,
|
||||
actions.get("beide.json") == SyncPlan.Action.CONFLICT,
|
||||
"beidseitige Änderung ist ein Konflikt"
|
||||
)
|
||||
_check(actions.get("lokal.tres") == SyncPlan.Action.UPLOAD, "lokale Änderung wird hochgeladen")
|
||||
_check(actions.get("server.tres") == SyncPlan.Action.DOWNLOAD, "Server-Änderung wird geladen")
|
||||
_check(actions.get("gleich.tres") == SyncPlan.Action.SKIP, "unverändert wird übersprungen")
|
||||
_check(actions.get("lokal.json") == SyncPlan.Action.UPLOAD, "lokale Änderung wird hochgeladen")
|
||||
_check(actions.get("server.json") == SyncPlan.Action.DOWNLOAD, "Server-Änderung wird geladen")
|
||||
_check(actions.get("gleich.json") == SyncPlan.Action.SKIP, "unverändert wird übersprungen")
|
||||
_check(
|
||||
actions.get("entfernt.tres") == SyncPlan.Action.SKIP,
|
||||
actions.get("entfernt.json") == SyncPlan.Action.SKIP,
|
||||
"Server-Datei verschwunden: nicht wiederherstellen"
|
||||
)
|
||||
|
||||
var first_sync := SyncPlan.build(
|
||||
{"a.tres": {"mtime": 1, "size": 1}},
|
||||
{"a.tres": {"modify": 2, "size": 1}},
|
||||
{"a.json": {"mtime": 1, "size": 1}},
|
||||
{"a.json": {"modify": 2, "size": 1}},
|
||||
{}
|
||||
)
|
||||
_check(
|
||||
|
|
@ -80,8 +80,8 @@ func _test_plan() -> void:
|
|||
|
||||
var local_deleted := SyncPlan.build(
|
||||
{},
|
||||
{"weg.tres": {"modify": 2, "size": 1}},
|
||||
{"weg.tres": {"local_mtime": 1, "remote_modify": 2}}
|
||||
{"weg.json": {"modify": 2, "size": 1}},
|
||||
{"weg.json": {"local_mtime": 1, "remote_modify": 2}}
|
||||
)
|
||||
_check(
|
||||
local_deleted.size() == 1 and local_deleted[0]["action"] == SyncPlan.Action.SKIP,
|
||||
|
|
@ -91,25 +91,36 @@ func _test_plan() -> void:
|
|||
|
||||
func _test_naming() -> void:
|
||||
_check(
|
||||
SyncPlan.conflict_file_name("kuer.tres", "2026-10-30 1050")
|
||||
== "kuer (Server 2026-10-30 1050).tres",
|
||||
SyncPlan.conflict_file_name("kuer.json", "2026-10-30 1050")
|
||||
== "kuer (Server 2026-10-30 1050).json",
|
||||
"Konfliktname enthält Zeitstempel"
|
||||
)
|
||||
var used := {"kuer (Server 2026-10-30 1050).tres": true}
|
||||
var used := {"kuer (Server 2026-10-30 1050).json": true}
|
||||
_check(
|
||||
SyncPlan.unique_name("kuer (Server 2026-10-30 1050).tres", used)
|
||||
== "kuer (Server 2026-10-30 1050) 2.tres",
|
||||
SyncPlan.unique_name("kuer (Server 2026-10-30 1050).json", used)
|
||||
== "kuer (Server 2026-10-30 1050) 2.json",
|
||||
"Konfliktname wird bei Bedarf durchnummeriert"
|
||||
)
|
||||
_check(
|
||||
SyncPlan.unique_name("frei.tres", used) == "frei.tres",
|
||||
SyncPlan.unique_name("frei.json", used) == "frei.json",
|
||||
"freier Name bleibt unverändert"
|
||||
)
|
||||
_check(
|
||||
SyncPlan.local_backup_file_name("kuer.tres", "2026-10-30 1050")
|
||||
== "kuer (Lokal 2026-10-30 1050).tres",
|
||||
SyncPlan.local_backup_file_name("kuer.json", "2026-10-30 1050")
|
||||
== "kuer (Lokal 2026-10-30 1050).json",
|
||||
"lokale Sicherung trägt den Lokal-Zeitstempel"
|
||||
)
|
||||
_check(
|
||||
SyncPlan.conflict_file_name("alt.tres", "2026-10-30 1050")
|
||||
== "alt (Server 2026-10-30 1050).tres",
|
||||
"Legacy-Dateien behalten ihre .tres-Endung"
|
||||
)
|
||||
_check(
|
||||
RoutineSync.is_routine_file("kuer.json")
|
||||
and RoutineSync.is_routine_file("alt.tres")
|
||||
and not RoutineSync.is_routine_file("sync.cfg"),
|
||||
"der Sync akzeptiert JSON und Legacy-.tres"
|
||||
)
|
||||
var label := SyncPlan.timestamp_label(0)
|
||||
_check(
|
||||
label.length() == 15 and label.contains("-") and label.contains(" "),
|
||||
|
|
@ -142,14 +153,14 @@ func _test_parsers() -> void:
|
|||
func _test_state_roundtrip() -> void:
|
||||
var path := "user://test_sync_state.cfg"
|
||||
var state := {
|
||||
"kuer.tres": {"local_mtime": 111, "remote_modify": 222},
|
||||
"zweite.tres": {"local_mtime": 333, "remote_modify": 444},
|
||||
"kuer.json": {"local_mtime": 111, "remote_modify": 222},
|
||||
"zweite.json": {"local_mtime": 333, "remote_modify": 444},
|
||||
}
|
||||
RoutineSync.save_state(path, state)
|
||||
var loaded := RoutineSync.load_state(path)
|
||||
_check(loaded.size() == 2, "Sync-Stand wird gespeichert und geladen")
|
||||
_check(
|
||||
int(loaded.get("kuer.tres", {}).get("remote_modify", 0)) == 222,
|
||||
int(loaded.get("kuer.json", {}).get("remote_modify", 0)) == 222,
|
||||
"Sync-Stand behält die Server-Zeit"
|
||||
)
|
||||
DirAccess.remove_absolute(ProjectSettings.globalize_path(path))
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ func _run() -> void:
|
|||
_check_approx(bronze.get_speed_mps(), 3.0, "new segment uses the bronze preset")
|
||||
_check_approx(bronze.duration_seconds, 2.0, "bronze duration follows the length")
|
||||
|
||||
var save_path := "user://test_timing.tres"
|
||||
var save_path := "user://test_timing.json"
|
||||
_check(controller.save_to_path(save_path), "timing routine can be saved")
|
||||
_check(controller.load_from_path(save_path), "timing routine can be loaded")
|
||||
var loaded_first := controller.get_routine().get_section_by_id(
|
||||
|
|
|
|||
|
|
@ -1061,7 +1061,7 @@ func _run() -> void:
|
|||
var saved_marker_id: String = jump.segment_id
|
||||
|
||||
# Save/load round-trip.
|
||||
var roundtrip_path := "user://test_roundtrip.tres"
|
||||
var roundtrip_path := "user://test_roundtrip.json"
|
||||
var saved_section_title := controller.get_active_section().title
|
||||
var saved_segment_count := controller.get_active_section().segments.size()
|
||||
var saved_arc_id := arc_left.segment_id
|
||||
|
|
@ -1158,7 +1158,7 @@ func _run() -> void:
|
|||
|
||||
controller.save_name_edit.text = "Test Kür"
|
||||
controller.save_as_dialog.confirmed.emit()
|
||||
var save_as_path := "user://routines/test_kür.tres"
|
||||
var save_as_path := "user://routines/test_kür.json"
|
||||
_check(
|
||||
FileAccess.file_exists(save_as_path),
|
||||
"save-as dialog writes a normalized filename"
|
||||
|
|
@ -1514,6 +1514,111 @@ func _run() -> void:
|
|||
)
|
||||
controller.help_dialog.hide()
|
||||
|
||||
# Save-as must not replace an existing file without confirmation.
|
||||
var overwrite_path := "user://routines/overwrite.json"
|
||||
_check(
|
||||
RoutineFile.save(controller.get_routine(), overwrite_path).is_empty(),
|
||||
"overwrite fixture can be saved"
|
||||
)
|
||||
var overwrite_before := FileAccess.get_file_as_string(overwrite_path)
|
||||
controller.save_name_edit.text = "overwrite"
|
||||
controller.save_as_dialog.confirmed.emit()
|
||||
_check(
|
||||
controller.confirm_dialog.visible,
|
||||
"save-as asks before replacing an existing file"
|
||||
)
|
||||
_check(
|
||||
FileAccess.get_file_as_string(overwrite_path) == overwrite_before,
|
||||
"the existing file stays untouched before confirmation"
|
||||
)
|
||||
controller.confirm_dialog.canceled.emit()
|
||||
controller.confirm_dialog.hide()
|
||||
_check(
|
||||
FileAccess.get_file_as_string(overwrite_path) == overwrite_before,
|
||||
"canceling keeps the existing file"
|
||||
)
|
||||
controller.save_as_dialog.confirmed.emit()
|
||||
controller.confirm_dialog.confirmed.emit()
|
||||
controller.confirm_dialog.hide()
|
||||
_check(
|
||||
FileAccess.get_file_as_string(overwrite_path) != overwrite_before,
|
||||
"confirming replaces the existing file"
|
||||
)
|
||||
_check(
|
||||
controller.get_current_path() == overwrite_path,
|
||||
"confirmed save-as becomes the current file"
|
||||
)
|
||||
DirAccess.remove_absolute(overwrite_path)
|
||||
|
||||
# Global Delete shortcut must not reach the canvas through a modal.
|
||||
var delete_section := controller.get_active_section()
|
||||
var segment_count := delete_section.segments.size()
|
||||
var doomed := controller.add_segment(
|
||||
Vector2(-18.0, 10.0),
|
||||
Vector2(-12.0, 10.0),
|
||||
PathSegment.Direction.FORWARD,
|
||||
PathSegment.Edge.OUTSIDE
|
||||
)
|
||||
controller.select_segment(doomed.segment_id)
|
||||
controller.undo_button.grab_focus()
|
||||
controller.message_dialog.hide()
|
||||
controller.validation_dialog.popup_centered()
|
||||
await process_frame
|
||||
var delete_event := InputEventKey.new()
|
||||
delete_event.keycode = KEY_DELETE
|
||||
delete_event.pressed = true
|
||||
controller._unhandled_key_input(delete_event)
|
||||
_check(
|
||||
delete_section.segments.size() == segment_count + 1,
|
||||
"a visible dialog blocks the Delete shortcut"
|
||||
)
|
||||
controller.validation_dialog.hide()
|
||||
controller._unhandled_key_input(delete_event)
|
||||
_check(
|
||||
delete_section.segments.size() == segment_count,
|
||||
"Delete works again after the dialog closes"
|
||||
)
|
||||
|
||||
# A dirty autosave is restored and reattached to the last file path.
|
||||
var session_path := "user://routines/session_test.json"
|
||||
controller.autosave_enabled = true
|
||||
_check(controller.save_to_path(session_path), "session fixture can be saved")
|
||||
controller.get_routine().title = "Autosave-Fassung"
|
||||
controller._mark_dirty()
|
||||
controller._save_autosave()
|
||||
OS.delay_msec(1100)
|
||||
controller._dirty = true
|
||||
controller._save_autosave()
|
||||
_check(controller._restore_session(), "session restore succeeds")
|
||||
_check(
|
||||
controller.get_current_path() == session_path,
|
||||
"autosave restore keeps the last file path"
|
||||
)
|
||||
_check(controller.is_dirty(), "restored autosave is marked dirty")
|
||||
_check(
|
||||
controller.get_routine().title == "Autosave-Fassung",
|
||||
"autosave content wins over the older file"
|
||||
)
|
||||
_check(controller.save_to_path(session_path), "restored autosave can be saved")
|
||||
_check(
|
||||
not FileAccess.file_exists(WhiteboardController.AUTOSAVE_PATH),
|
||||
"saving removes the stale autosave"
|
||||
)
|
||||
_check(controller._restore_session(), "clean session restore succeeds")
|
||||
_check(
|
||||
not controller.is_dirty()
|
||||
and controller.get_current_path() == session_path,
|
||||
"clean session restores the file without dirty state"
|
||||
)
|
||||
controller.autosave_enabled = false
|
||||
for path: String in [
|
||||
session_path,
|
||||
WhiteboardController.AUTOSAVE_PATH,
|
||||
WhiteboardController.LEGACY_AUTOSAVE_PATH,
|
||||
]:
|
||||
if FileAccess.file_exists(path):
|
||||
DirAccess.remove_absolute(ProjectSettings.globalize_path(path))
|
||||
|
||||
scene.queue_free()
|
||||
await process_frame
|
||||
_finish()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue