test(qa): add log-guarded headless QA suites

qa_all.ps1 runs the class scan, smoke, UI, core, input, and UI QA suites, checks PASS markers, and fails on any engine error in the log. New suites cover save migrations, daily logic, frames, level data, navigation, win overlays, and input gestures.
This commit is contained in:
Ratdoku Builder committed 2026-12-02 22:48:09 -06:00
1 parent 48c14864a4
commit 077c08bb5f
7 files changed
+1361

No files matched your search

+122
View File
@@ -0,0 +1,122 @@
param(
[switch]$Build,
[switch]$Screenshots
)
$ErrorActionPreference = "Stop"
$project = Split-Path $PSScriptRoot -Parent
$godot = "C:\Program Files (x86)\Steam\steamapps\common\Godot Engine\godot.windows.opt.tools.64.exe"
if (-not (Test-Path $godot)) {
throw "Godot executable not found."
}
$tempRoot = "C:\Users\enter\AppData\Local\Temp\opencode"
New-Item -ItemType Directory -Force -Path $tempRoot | Out-Null
$logFile = Join-Path $tempRoot "ratdoku-qa.log"
Remove-Item $logFile -Force -ErrorAction SilentlyContinue
$failures = @()
$checks = @()
function Write-Section([string]$text) {
Write-Host "`n=== $text ==="
Add-Content -Path $logFile -Value "=== $text ==="
}
function Quote-Args([string[]]$items) {
return ($items | ForEach-Object {
if ($_ -match '\s') { '"' + $_ + '"' } else { $_ }
}) -join " "
}
function Invoke-Godot([string[]]$arguments, [string]$name, [string]$marker) {
$outFile = Join-Path $tempRoot "qa-$name.out"
$errFile = Join-Path $tempRoot "qa-$name.err"
Remove-Item $outFile, $errFile -Force -ErrorAction SilentlyContinue
$process = Start-Process -FilePath $godot -ArgumentList (Quote-Args $arguments) `
-Wait -PassThru -RedirectStandardOutput $outFile -RedirectStandardError $errFile
$text = ""
if (Test-Path $outFile) { $text += (Get-Content $outFile -Raw) }
if (Test-Path $errFile) { $text += "`n" + (Get-Content $errFile -Raw) }
Add-Content -Path $logFile -Value $text
$hasMarker = $text -match [regex]::Escape($marker)
$hasError = $text -match 'ERROR:|SCRIPT ERROR:|Parse Error|FAIL:|Assertion failed'
if ($process.ExitCode -ne 0 -or -not $hasMarker -or $hasError) {
$script:failures += $name
Write-Host "FAIL $name (exit=$($process.ExitCode) marker=$hasMarker error=$hasError)"
if (-not $hasMarker) { Write-Host " missing marker: $marker" }
}
else {
Write-Host "PASS $name"
$script:checks += $name
}
}
Write-Section "Godot project scan"
Invoke-Godot @("--headless", "--path", $project, "--editor", "--quit") "class-scan" "Godot Engine"
$tests = @(
@{ File = "tools/smoke_test.gd"; Marker = "SMOKE TEST: PASS"; Name = "smoke" },
@{ File = "tools/ui_test.gd"; Marker = "UI TEST: PASS"; Name = "ui" },
@{ File = "tools/qa_core.gd"; Marker = "QA CORE: PASS"; Name = "qa-core" },
@{ File = "tools/qa_ui.gd"; Marker = "QA UI: PASS"; Name = "qa-ui" },
@{ File = "tools/qa_input.gd"; Marker = "QA INPUT: PASS"; Name = "qa-input" }
)
foreach ($test in $tests) {
$path = Join-Path $project $test.File
if (-not (Test-Path $path)) {
$script:failures += $test.Name
Write-Host "FAIL $($test.Name) (script missing: $($test.File))"
continue
}
Write-Section $test.Name
Invoke-Godot @(
"--headless", "--path", $project,
"--script", "res://$($test.File)", "--quit-after", "12000"
) $test.Name $test.Marker
}
if ($Screenshots) {
Write-Section "screenshots"
Invoke-Godot @("--path", $project, "--script", "res://tools/screenshot.gd", "--quit-after", "12000") "screenshots" "Saved"
}
if ($Build) {
Write-Section "android build"
$buildScript = Join-Path $PSScriptRoot "build_android.ps1"
$buildOut = Join-Path $tempRoot "qa-build.out"
$buildErr = Join-Path $tempRoot "qa-build.err"
Remove-Item $buildOut, $buildErr -Force -ErrorAction SilentlyContinue
$buildProc = Start-Process -FilePath "powershell.exe" `
-ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$buildScript`"" `
-Wait -PassThru -RedirectStandardOutput $buildOut -RedirectStandardError $buildErr
$buildOutput = ""
if (Test-Path $buildOut) { $buildOutput += (Get-Content $buildOut -Raw) }
if (Test-Path $buildErr) { $buildOutput += "`n" + (Get-Content $buildErr -Raw) }
Add-Content -Path $logFile -Value $buildOutput
$apk = Join-Path $project "build/Ratdoku.apk"
if ($buildProc.ExitCode -ne 0 -or $buildOutput -notmatch 'DONE' -or -not (Test-Path $apk)) {
$script:failures += "android-build"
Write-Host "FAIL android-build"
}
else {
Write-Host "PASS android-build"
$script:checks += "android-build"
}
}
Write-Section "summary"
Write-Host "Passed: $($checks.Count)"
Write-Host "Failed: $($failures.Count)"
if ($failures.Count -gt 0) {
Write-Host ("Failed suites: " + ($failures -join ", "))
}
Write-Host "Full log: $logFile"
if ($failures.Count -gt 0) { exit 1 }
exit 0
+503
View File
@@ -0,0 +1,503 @@
extends SceneTree
## Headless core QA: save migration, daily logic, frames, and game data.
## <godot> --headless --path . --script res://tools/qa_core.gd --quit-after 1200
##
## This suite only ever replaces the game's own save file (SaveGame.PATH).
## It leaves every other file alone and restores a clean save before it exits.
var failures := 0
var frames = null
func _init() -> void:
call_deferred("_run")
func _check(condition: bool, message: String) -> void:
if not condition:
failures += 1
print("FAIL: ", message)
func _note(message: String) -> void:
print("QA CORE: ", message)
func _run() -> void:
var save = root.get_node_or_null("SaveGame")
_check(save != null, "SaveGame autoload missing")
if save == null:
_finish()
return
# Resolve Frames at runtime: a static reference compiles it before the
# SaveGame autoload is registered when launched with --script.
frames = load("res://scripts/Frames.gd")
_check(frames != null, "Frames script missing")
if frames == null:
_finish()
return
_test_save_migrations(save)
_test_daily(save)
_test_frames(save)
_test_game_data(save)
_reset_to_clean(save)
_finish()
func _finish() -> void:
if failures == 0:
print("QA CORE: PASS")
quit(0)
else:
print("QA CORE: FAIL (%d)" % failures)
quit(1)
# ---------------------------------------------------------------------------
# Helpers
# ---------------------------------------------------------------------------
func _write_save(save, dict: Dictionary) -> void:
var file := FileAccess.open(save.PATH, FileAccess.WRITE)
if file == null:
_check(false, "could not open save path for writing: %s" % save.PATH)
return
file.store_string(JSON.stringify(dict, "\t"))
file.close()
func _remove_save(save) -> void:
if FileAccess.file_exists(save.PATH):
var err := DirAccess.remove_absolute(ProjectSettings.globalize_path(save.PATH))
if err != OK:
_check(false, "could not remove test save file")
func _reset_to_clean(save) -> void:
save.data = save._default_data()
save.save_game()
save.load_game()
func _same_value(a, b) -> bool:
if typeof(a) == TYPE_INT or typeof(a) == TYPE_FLOAT:
if typeof(b) == TYPE_INT or typeof(b) == TYPE_FLOAT:
return absf(float(a) - float(b)) < 0.0001
return false
if typeof(a) == TYPE_BOOL or typeof(b) == TYPE_BOOL:
return typeof(a) == TYPE_BOOL and typeof(b) == TYPE_BOOL and bool(a) == bool(b)
return str(a) == str(b)
func _is_default_daily(save, daily: Dictionary) -> bool:
var defaults: Dictionary = save._default_daily()
return (
str(daily.get("last_completed", "")) == str(defaults["last_completed"])
and _same_value(daily.get("streak", -1), defaults["streak"])
and _same_value(daily.get("best_streak", -1), defaults["best_streak"])
)
# ---------------------------------------------------------------------------
# 1. Save migration matrix
# ---------------------------------------------------------------------------
func _test_save_migrations(save) -> void:
_note("1. save migration matrix")
# (a) No save file at all -> fresh version-3 defaults.
_remove_save(save)
save.load_game()
_check(int(save.data.get("version", 0)) == 3, "fresh save should be version 3")
_check(bool(save.get_setting("double_tap_place")), "fresh save should default to double-tap")
_check(_is_default_daily(save, save.daily_data()), "fresh save should have default daily stats")
_check(save.selected_frame() == "plain", "fresh save should select the plain frame")
_check((save.data.get("completed_rooms") as Array).is_empty(), "fresh save should have no rooms")
_check((save.data.get("unlocked_guests") as Array).is_empty(), "fresh save should have no guests")
# (b) Version 1 with hold-to-place and no daily/frame keys -> migrate to v3.
var v1: Dictionary = save._default_data()
v1["version"] = 1
v1["settings"]["double_tap_place"] = false
v1.erase("daily")
v1.erase("profile_frame")
_write_save(save, v1)
save.load_game()
_check(int(save.data.get("version", 0)) == 3, "version 1 should migrate to version 3")
_check(bool(save.get_setting("double_tap_place")), "version 1 should migrate to double-tap")
_check(_is_default_daily(save, save.daily_data()), "version 1 missing daily should become defaults")
_check(save.selected_frame() == "plain", "version 1 missing frame should become plain")
# (c) Version 2 with hold-to-place -> stay on hold, gain v3 daily/frame data.
var v2: Dictionary = save._default_data()
v2["version"] = 2
v2["settings"]["double_tap_place"] = false
v2.erase("daily")
v2.erase("profile_frame")
_write_save(save, v2)
save.load_game()
_check(int(save.data.get("version", 0)) == 3, "version 2 should migrate to version 3")
_check(not bool(save.get_setting("double_tap_place")), "version 2 double_tap=false should stay false")
_check(_is_default_daily(save, save.daily_data()), "version 2 missing daily should become defaults")
_check(save.selected_frame() == "plain", "version 2 missing frame should become plain")
# (d) Valid JSON with the wrong top-level shape -> no crash, defaults restored.
var broken := FileAccess.open(save.PATH, FileAccess.WRITE)
if broken != null:
broken.store_string("[]")
broken.close()
else:
_check(false, "could not write wrong-shape save")
save.load_game()
_check(int(save.data.get("version", 0)) == 3, "wrong-shape save should restore version 3 defaults")
_check(bool(save.get_setting("double_tap_place")), "wrong-shape save should restore double-tap default")
_check(_is_default_daily(save, save.daily_data()), "wrong-shape save should restore daily defaults")
_check(save.selected_frame() == "plain", "wrong-shape save should restore plain frame")
_check((save.data.get("completed_rooms") as Array).is_empty(), "malformed JSON should have no rooms")
# (e) Missing individual setting keys are filled from DEFAULTS.
var partial: Dictionary = save._default_data()
partial["version"] = 3
partial["settings"] = {}
_write_save(save, partial)
save.load_game()
for key in save.DEFAULTS:
_check(save.data["settings"].has(key), "missing setting '%s' should be filled" % key)
_check(
_same_value(save.get_setting(key), save.DEFAULTS[key]),
"filled setting '%s' should match DEFAULTS" % key
)
# A version-3 save's explicit false must not be overwritten by a default.
var explicit_false: Dictionary = save._default_data()
explicit_false["version"] = 3
explicit_false["settings"]["double_tap_place"] = false
_write_save(save, explicit_false)
save.load_game()
_check(not bool(save.get_setting("double_tap_place")), "an explicit false should not be overwritten")
_check(bool(save.get_setting("patterns")), "unlisted settings should still be filled from DEFAULTS")
_reset_to_clean(save)
# ---------------------------------------------------------------------------
# 2. Daily logic
# ---------------------------------------------------------------------------
func _test_daily(save) -> void:
_note("2. daily logic")
var today: String = Daily.today_key()
_check(today.length() == 10, "today key should be YYYY-MM-DD (10 chars)")
_check(today.substr(4, 1) == "-" and today.substr(7, 1) == "-", "today key separators should be dashes")
_check(
today.substr(0, 4).is_valid_int()
and today.substr(5, 2).is_valid_int()
and today.substr(8, 2).is_valid_int(),
"today key date parts should be numeric"
)
var now: Dictionary = Time.get_date_dict_from_system()
_check(
today == "%04d-%02d-%02d" % [int(now["year"]), int(now["month"]), int(now["day"])],
"today key should match the system's local date"
)
_check(Daily.day_number("") == 0, "an empty key should map to day 0")
_check(Daily.day_number("bad-key") == 0, "a malformed key should map to day 0")
# Round trip between date keys and day numbers.
var base: int = Daily.day_number(today)
_note(
"day_number(%s)=%d, key_from_day_number=%s"
% [today, base, Daily.key_from_day_number(base)]
)
_check(Daily.key_from_day_number(base) == today, "key_from_day_number(day_number(today)) should be today")
for delta in [1, 7, 30, 100, 400]:
var key: String = Daily.key_from_day_number(base + delta)
_check(
Daily.day_number(key) == base + delta,
"day_number(key_from_day_number(%d)) should round trip" % delta
)
# Level selection: stable, in range, and valid on 30 consecutive dates.
_check(Daily.level_index(0, today) == -1, "level_index should be -1 with no levels")
_check(Daily.level_index(-5, today) == -1, "level_index should be -1 with a negative level count")
var idx: int = Daily.level_index(30, today)
_check(idx >= 0 and idx < 30, "level_index(30) should be in range")
_check(idx == Daily.level_index(30, today), "level_index should be stable for the same date")
var all_valid := true
var distinct := {}
for d in range(30):
var key: String = Daily.key_from_day_number(base + d)
var i: int = Daily.level_index(30, key)
if i < 0 or i >= 30:
all_valid = false
distinct[i] = true
_check(all_valid, "30 consecutive dates should all produce valid daily indices")
_note("distinct daily levels across 30 consecutive days: %d" % distinct.size())
_reset_to_clean(save)
# Consecutive days extend the streak and mark today complete.
var yesterday: String = Daily.key_from_day_number(Daily.day_number(today) - 1)
var daily: Dictionary = save._default_daily()
daily["last_completed"] = yesterday
daily["streak"] = 2
daily["best_streak"] = 2
save.data["daily"] = daily
var rooms_before: Array = (save.data["completed_rooms"] as Array).duplicate()
var guests_before: Array = (save.data["unlocked_guests"] as Array).duplicate()
_check(Daily.day_number(yesterday) == Daily.day_number(today) - 1, "yesterday key should be one day before today")
_check(save.complete_daily(today), "completing today's daily should count")
_check(int(save.daily_data().get("streak", 0)) == 3, "consecutive daily should extend the streak to 3")
_check(save.daily_streak() == 3, "daily_streak should report a live streak of 3")
_check(save.best_streak() == 3, "best_streak should rise to 3")
_check(save.daily_completed_today(), "daily_completed_today should be true")
_check((save.data["completed_rooms"] as Array) == rooms_before, "daily must not change completed_rooms")
_check((save.data["unlocked_guests"] as Array) == guests_before, "daily must not change unlocked_guests")
# Same-day replay and wrong dates do nothing.
_check(not save.complete_daily(today), "same-day replay should return false")
_check(int(save.daily_data().get("streak", 0)) == 3, "same-day replay should not change the streak")
_check(not save.complete_daily(yesterday), "an older date should not count")
_check(not save.complete_daily(""), "an empty key should not count")
_check(int(save.daily_data().get("streak", 0)) == 3, "rejected dates should not change the streak")
# A gap resets the current streak but keeps the best.
_reset_to_clean(save)
var older: String = Daily.key_from_day_number(Daily.day_number(today) - 3)
daily = save._default_daily()
daily["last_completed"] = older
daily["streak"] = 9
daily["best_streak"] = 9
save.data["daily"] = daily
_check(save.complete_daily(today), "a daily after a gap should still count")
_check(int(save.daily_data().get("streak", 0)) == 1, "a gap should reset the streak to 1")
_check(save.best_streak() == 9, "best_streak should survive a gap")
# Best streak persists; a stale streak is reported as dead.
var best: int = save.best_streak()
save.data["daily"]["streak"] = 0
save.save_game()
save.load_game()
_check(save.best_streak() == best, "best_streak should persist through save/load")
_check(save.daily_streak() == 0, "a zero streak should be reported as 0")
save.data["daily"] = save._default_daily()
_check(not save.daily_completed_today(), "a fresh daily state should not be complete today")
_check(save.daily_streak() == 0, "a fresh daily state should have no live streak")
_reset_to_clean(save)
# ---------------------------------------------------------------------------
# 3. Frames
# ---------------------------------------------------------------------------
func _test_frames(save) -> void:
_note("3. frames")
_reset_to_clean(save)
_check(frames.all().size() == 7, "there should be seven profile frames")
_check(frames.is_unlocked("plain"), "plain frame should always be unlocked")
_check(not frames.requirement_text("plain").is_empty(), "plain frame should have requirement text")
var locked_at_zero: Array = ["paper", "gold", "bell", "star", "regular", "night"]
for id in locked_at_zero:
_check(not frames.is_unlocked(str(id)), "%s should be locked with no progress" % id)
_check(not frames.requirement_text(str(id)).is_empty(), "%s should show a requirement while locked" % id)
_check(frames.by_id("does-not-exist").is_empty(), "unknown frame id should resolve to nothing")
_check(not frames.is_unlocked("does-not-exist"), "unknown frame should never be unlocked")
_check(frames.requirement_text("does-not-exist").is_empty(), "unknown frame should have empty requirement text")
var room_thresholds := {"paper": 5, "gold": 10, "bell": 20, "star": 30}
for id in room_thresholds:
var need: int = int(room_thresholds[id])
save.data["completed_rooms"] = []
for i in range(need - 1):
save.data["completed_rooms"].append("room-probe-%d" % i)
_check(not frames.is_unlocked(str(id)), "%s should be locked at %d rooms" % [id, need - 1])
save.data["completed_rooms"].append("room-probe-last")
_check(frames.is_unlocked(str(id)), "%s should unlock at %d rooms" % [id, need])
_reset_to_clean(save)
var streak_thresholds := {"regular": 3, "night": 7}
for id in streak_thresholds:
var need: int = int(streak_thresholds[id])
save.data["daily"]["best_streak"] = need - 1
_check(not frames.is_unlocked(str(id)), "%s should be locked at a %d-day best streak" % [id, need - 1])
save.data["daily"]["best_streak"] = need
_check(frames.is_unlocked(str(id)), "%s should unlock at a %d-day best streak" % [id, need])
# Selecting a locked frame must not make it unlocked.
_reset_to_clean(save)
save.select_frame("star")
save.save_game()
save.load_game()
_check(save.selected_frame() == "star", "selection itself should persist")
_check(not frames.is_unlocked("star"), "selecting a locked frame must not unlock it")
# A legitimately unlocked selection survives save/load.
_reset_to_clean(save)
for i in range(5):
save.data["completed_rooms"].append("room-%02d" % i)
save.select_frame("paper")
save.save_game()
save.load_game()
_check(frames.is_unlocked("paper"), "five-room unlock should survive save/load")
_check(save.selected_frame() == "paper", "frame selection should persist through save/load")
# Document reset_progress()'s actual behaviour instead of guessing.
_reset_to_clean(save)
save.data["completed_rooms"] = ["room-a", "room-b", "room-c"]
save.data["unlocked_guests"] = ["pepper", "miso"]
save.data["last_room"] = 3
save.data["daily"]["best_streak"] = 5
save.data["daily"]["streak"] = 2
save.data["daily"]["last_completed"] = Daily.today_key()
save.select_frame("regular")
save.reset_progress()
_note(
"reset_progress -> rooms=%d guests=%d last_room=%d best_streak=%d streak=%d last_completed=%s frame=%s"
% [
save.rooms_completed(),
(save.data["unlocked_guests"] as Array).size(),
int(save.data["last_room"]),
save.best_streak(),
int(save.daily_data().get("streak", -1)),
str(save.daily_data().get("last_completed", "")),
save.selected_frame()
]
)
_check(save.rooms_completed() == 0, "reset_progress should clear completed_rooms")
_check((save.data["unlocked_guests"] as Array).is_empty(), "reset_progress should clear unlocked_guests")
_check(int(save.data["last_room"]) == 0, "reset_progress should clear last_room")
_check(save.best_streak() == 5, "reset_progress should leave best_streak alone")
_check(int(save.daily_data().get("streak", 0)) == 2, "reset_progress should leave the daily streak alone")
_check(
str(save.daily_data().get("last_completed", "")) == Daily.today_key(),
"reset_progress should leave last_completed alone"
)
_check(save.selected_frame() == "regular", "reset_progress should leave the selected frame alone")
_reset_to_clean(save)
# ---------------------------------------------------------------------------
# 4. Level and guest data
# ---------------------------------------------------------------------------
func _test_game_data(save) -> void:
_note("4. level/guest data")
var levels: Array = Levels.load_all()
_check(levels.size() == 30, "there should be 30 levels")
if levels.is_empty():
return
var board := Board.new()
root.add_child(board)
var bad_shape := 0
var bad_solution := 0
var bad_clues := 0
var bad_regions := 0
var bad_rats := 0
var bad_region_rats := 0
var valid_guests: Dictionary = {}
for guest in Guests.all():
valid_guests[str(guest.get("id", ""))] = true
for level_variant in levels:
if typeof(level_variant) != TYPE_DICTIONARY:
bad_shape += 1
continue
var level: Dictionary = level_variant
var n: int = int(level.get("n", 0))
var regions: Array = level.get("regions", [])
var solution: Array = level.get("solution", [])
var clues: Array = level.get("clues", [])
var label: String = str(level.get("id", "?"))
if n != 8:
bad_shape += 1
if regions.size() != n:
bad_regions += 1
else:
for row in regions:
if (row as Array).size() != n:
bad_regions += 1
var region_ids := {}
for row in regions:
for value in row:
region_ids[int(value)] = true
if region_ids.size() != n:
bad_regions += 1
if solution.size() != n:
bad_solution += 1
else:
var cells := []
for r in n:
var row := []
for c in n:
row.append(Rules.EMPTY)
cells.append(row)
for r in n:
var c: int = int(solution[r])
if c >= 0 and c < n:
cells[r][c] = Rules.RAT
if not Rules.is_valid(cells, regions):
bad_solution += 1
if Rules.count_rats(cells) != n:
bad_solution += 1
if clues.size() != 3:
bad_clues += 1
else:
for clue in clues:
var cr: int = int(clue[0])
var cc: int = int(clue[1])
if cr < 0 or cr >= n or cc < 0 or cc >= n or int(solution[cr]) != cc:
bad_clues += 1
board.set_level(level)
if board.region_rats.size() != 8:
bad_region_rats += 1
var seen := {}
for id_variant in board.region_rats:
var id: String = str(id_variant)
if seen.has(id) or not valid_guests.has(id):
bad_region_rats += 1
seen[id] = true
if seen.size() != 8:
bad_region_rats += 1
if board.fixed.size() != 3:
bad_rats += 1
_check(bad_shape == 0, "every level should have n=8 (%d bad)" % bad_shape)
_check(bad_regions == 0, "every level should have an 8x8 region grid with 8 regions (%d bad)" % bad_regions)
_check(bad_solution == 0, "every solution should be a legal board under Rules (%d bad)" % bad_solution)
_check(bad_clues == 0, "every level should have 3 clues matching its solution (%d bad)" % bad_clues)
_check(bad_region_rats == 0, "every level should carry 8 unique guest ids in Board.region_rats (%d bad)" % bad_region_rats)
_check(bad_rats == 0, "every level should fix 3 clue rats on its board (%d bad)" % bad_rats)
board.free()
var guests: Array = Guests.all()
_check(guests.size() == 25, "guest manifest should contain 25 guests")
var guest_ids := {}
var duplicate_guests := 0
for guest in guests:
var id: String = str(guest.get("id", ""))
if guest_ids.has(id) or id.is_empty():
duplicate_guests += 1
guest_ids[id] = true
_check(FileAccess.file_exists(Guests.portrait(id, "thumbs")), "missing thumb portrait for '%s'" % id)
_check(FileAccess.file_exists(Guests.portrait(id, "full")), "missing card portrait for '%s'" % id)
_check(duplicate_guests == 0, "guest ids should be non-empty and unique (%d bad)" % duplicate_guests)
_check(FileAccess.file_exists("res://art/crumb_head.png"), "Crumb head art should exist")
_check(FileAccess.file_exists("res://art/crumb.png"), "Crumb art should exist")
+1
View File
@@ -0,0 +1 @@
uid://dsjew0n3nwi1
+428
View File
@@ -0,0 +1,428 @@
extends SceneTree
## Headless input QA: board placement modes, Guest Book tap/scroll gestures,
## and scroll pass-through on the scrolling screens.
## <godot> --headless --path <project> --script res://tools/qa_input.gd --quit-after 1800
var failures := 0
var finished := false
func _init() -> void:
call_deferred("_run")
func _check(condition: bool, message: String) -> void:
if not condition:
failures += 1
print("FAIL: ", message)
func _finish() -> void:
if finished:
return
finished = true
print("QA INPUT: ", "PASS" if failures == 0 else "FAIL (%d)" % failures)
quit(0 if failures == 0 else 1)
func _run() -> void:
# Failsafe: never leave the command line hanging.
var watchdog := Timer.new()
watchdog.wait_time = 20.0
watchdog.one_shot = true
watchdog.timeout.connect(func() -> void:
if not finished:
_check(false, "QA timed out")
_finish()
)
root.add_child(watchdog)
watchdog.start()
var save = root.get_node_or_null("SaveGame")
_check(save != null, "SaveGame autoload missing")
if save == null:
_finish()
return
# Snapshot so the user's settings are exactly as we found them.
var original_settings: Dictionary = save.data["settings"].duplicate(true)
_test_board_modes(save)
var err := change_scene_to_file("res://scenes/Main.tscn")
if err != OK:
_check(false, "could not load Main (%d)" % err)
_restore_settings(save, original_settings)
_finish()
return
await process_frame
await process_frame
var main = current_scene
_check(main != null, "Main scene missing")
if main == null:
_restore_settings(save, original_settings)
_finish()
return
await _test_scroll_pass_through(main)
await _test_guest_book_input(main)
_restore_settings(save, original_settings)
_finish()
func _restore_settings(save, original: Dictionary) -> void:
for key in original:
save.set_setting(key, original[key])
save.save_game()
# --- Board -------------------------------------------------------------------
func _test_board_modes(save) -> void:
var levels: Array = Levels.load_all()
_check(levels.size() > 0, "no levels available")
if levels.is_empty():
return
var level: Dictionary = levels[0]
var board := Board.new()
root.add_child(board)
board.size = Vector2(640, 640)
board.set_level(level)
board._update_layout()
_reset_press(board)
# ---------------------------------------------------------------- hold mode
save.set_setting("hold_seconds", 0.35)
save.set_setting("double_tap_place", false)
_check(not board.double_tap_place, "hold mode setting did not reach Board")
# Quick press + release marks an X.
var tap_cell := _find_empty(board)
_check(tap_cell.x >= 0, "no empty cell for hold-mode tap")
if tap_cell.x >= 0:
_mouse_button(board, tap_cell, true)
_mouse_button(board, tap_cell, false)
_check(int(board.cells[tap_cell.x][tap_cell.y]) == Board.X,
"hold mode: press + release should mark X")
# A press held past the threshold checks a guest in, and releasing keeps it.
var hold_cell := _find_empty(board)
_check(hold_cell.x >= 0, "no empty cell for hold")
if hold_cell.x >= 0:
_mouse_button(board, hold_cell, true)
board._process(board.hold_seconds + 0.05)
_check(int(board.cells[hold_cell.x][hold_cell.y]) == Board.RAT,
"hold past the threshold should place a rat")
_check(board.hold_fired, "hold_fired should be set after the threshold")
_mouse_button(board, hold_cell, false)
_check(int(board.cells[hold_cell.x][hold_cell.y]) == Board.RAT,
"releasing after a hold should keep the rat")
_check(board.press_cell == Vector2i(-1, -1), "release should clear press_cell")
_check(not board.hold_fired, "release should clear hold_fired")
# Right-click checks a guest in, then out.
var right_cell := _find_empty(board)
_check(right_cell.x >= 0, "no empty cell for right-click")
if right_cell.x >= 0:
_right_click(board, right_cell)
_check(int(board.cells[right_cell.x][right_cell.y]) == Board.RAT,
"right-click should check a guest in")
_right_click(board, right_cell)
_check(int(board.cells[right_cell.x][right_cell.y]) == Board.EMPTY,
"right-click should check a guest out")
# Fixed clues cannot be changed by any input path.
if board.fixed.is_empty():
_check(false, "test level has no fixed clues")
else:
var fixed_cell: Vector2i = board.fixed.keys()[0]
_check(int(board.cells[fixed_cell.x][fixed_cell.y]) == Board.RAT,
"fixed clue should start as a rat")
board._toggle_rat(fixed_cell)
_check(int(board.cells[fixed_cell.x][fixed_cell.y]) == Board.RAT,
"right-click must not remove a fixed clue")
board._tap(fixed_cell)
_check(int(board.cells[fixed_cell.x][fixed_cell.y]) == Board.RAT,
"tap must not clear a fixed clue")
_reset_press(board)
_mouse_button(board, fixed_cell, true)
_mouse_button(board, fixed_cell, false)
_check(int(board.cells[fixed_cell.x][fixed_cell.y]) == Board.RAT,
"press + release must not change a fixed clue")
# Undo and restart discard a tap waiting for its partner.
var undo_cell := _find_empty(board)
_check(undo_cell.x >= 0, "no empty cell for pending-undo test")
_check(not board.history.is_empty(), "board history should be non-empty before undo")
board.pending_tap_cell = undo_cell
board.pending_tap_at = Time.get_ticks_msec()
board.undo()
_check(board.pending_tap_cell == Vector2i(-1, -1), "undo should clear a pending tap")
var restart_cell := _find_empty(board)
_check(restart_cell.x >= 0, "no empty cell for pending-restart test")
board.pending_tap_cell = restart_cell
board.pending_tap_at = Time.get_ticks_msec()
board.restart()
_check(board.pending_tap_cell == Vector2i(-1, -1), "restart should clear a pending tap")
# --------------------------------------------------------- double-tap mode
save.set_setting("double_tap_place", true)
_check(board.double_tap_place, "double-tap setting did not reach Board")
board.set_level(level)
board._update_layout()
_reset_press(board)
# One tap leaves the cell untouched until the window expires.
var first := _find_empty(board)
_check(first.x >= 0, "no empty cell for first tap")
if first.x >= 0:
board._handle_tap(first)
_check(int(board.cells[first.x][first.y]) == Board.EMPTY,
"first tap should leave the cell empty")
_check(board.pending_tap_cell == first, "first tap should be pending")
board.pending_tap_at -= Board.DOUBLE_TAP_MS + 1
board._process(0.0)
_check(int(board.cells[first.x][first.y]) == Board.X,
"a lone tap should mark X after the double-tap window")
# Two quick taps check a guest in, then out again.
var pair := _find_empty(board)
_check(pair.x >= 0, "no empty cell for double tap")
if pair.x >= 0:
board._handle_tap(pair)
board._handle_tap(pair)
_check(int(board.cells[pair.x][pair.y]) == Board.RAT,
"two quick taps should check a guest in")
board._handle_tap(pair)
board._handle_tap(pair)
_check(int(board.cells[pair.x][pair.y]) == Board.EMPTY,
"two quick taps on a rat should check them out")
# Holding does nothing while double-tap mode is on.
var held := _find_empty(board)
_check(held.x >= 0, "no empty cell for hold-in-double-tap test")
if held.x >= 0:
_reset_press(board)
_mouse_button(board, held, true)
board._process(board.hold_seconds + 1.0)
_check(int(board.cells[held.x][held.y]) == Board.EMPTY,
"hold should not place a rat in double-tap mode")
_check(not board.hold_fired, "hold_fired must stay clear in double-tap mode")
_mouse_button(board, held, false)
board.pending_tap_cell = Vector2i(-1, -1)
# Right-click still works in double-tap mode.
var right2 := _find_empty(board)
_check(right2.x >= 0, "no empty cell for double-tap right-click")
if right2.x >= 0:
_right_click(board, right2)
_check(int(board.cells[right2.x][right2.y]) == Board.RAT,
"right-click should check in during double-tap mode")
_right_click(board, right2)
_check(int(board.cells[right2.x][right2.y]) == Board.EMPTY,
"right-click should check out during double-tap mode")
# Switching modes flushes a pending tap (and a half-finished hold).
var flush := _find_empty(board)
_check(flush.x >= 0, "no empty cell for mode-switch test")
if flush.x >= 0:
board._handle_tap(flush)
_check(board.pending_tap_cell == flush, "pending tap should be set up")
save.set_setting("double_tap_place", false)
_check(not board.double_tap_place, "switch to hold mode did not reach Board")
_check(board.pending_tap_cell == Vector2i(-1, -1),
"switching out of double-tap should flush the pending tap")
_check(int(board.cells[flush.x][flush.y]) == Board.X,
"flushed pending tap should mark X")
board.press_cell = flush
board.hold_fired = true
save.set_setting("double_tap_place", true)
_check(board.double_tap_place, "switch back to double-tap did not reach Board")
_check(board.press_cell == Vector2i(-1, -1),
"switching to double-tap should clear a held press")
_check(not board.hold_fired, "switching to double-tap should clear hold_fired")
board.free()
func _find_empty(board: Board) -> Vector2i:
for r in board.n:
for c in board.n:
if (
int(board.cells[r][c]) == Board.EMPTY
and not board.fixed.has(Vector2i(r, c))
and not board.auto_x[r][c]
):
return Vector2i(r, c)
return Vector2i(-1, -1)
func _reset_press(board: Board) -> void:
board.press_cell = Vector2i(-1, -1)
board.press_elapsed = 0.0
board.hold_fired = false
board.pending_tap_cell = Vector2i(-1, -1)
func _mouse_button(board: Board, cell: Vector2i, pressed: bool) -> void:
var event := InputEventMouseButton.new()
event.button_index = MOUSE_BUTTON_LEFT
event.pressed = pressed
event.position = board._cell_rect(cell.x, cell.y).get_center()
board._gui_input(event)
func _right_click(board: Board, cell: Vector2i) -> void:
var event := InputEventMouseButton.new()
event.button_index = MOUSE_BUTTON_RIGHT
event.pressed = true
event.position = board._cell_rect(cell.x, cell.y).get_center()
board._gui_input(event)
# --- Scroll pass-through ------------------------------------------------------
func _test_scroll_pass_through(main) -> void:
main.open_settings("home")
await process_frame
var sheet = main.settings_sheet
_check(sheet != null, "settings sheet missing")
if sheet != null:
for key in ["patterns", "show_timer", "reduce_motion", "double_tap_place"]:
if sheet.toggles.has(key):
_check(sheet.toggles[key].mouse_filter == Control.MOUSE_FILTER_PASS,
"settings row '%s' should pass swipes" % key)
main.close_settings()
main.show_screen("guest_book")
await process_frame
var book = main.guest_book
_check(book != null, "Guest Book missing")
if book != null:
_check(book.grid.mouse_filter == Control.MOUSE_FILTER_PASS,
"guest grid should pass swipes")
for card in book.grid.get_children():
_check(card.mouse_filter == Control.MOUSE_FILTER_PASS,
"guest cards should pass swipes")
main.show_screen("rules")
await process_frame
var rulebook = main.rulebook
_check(rulebook != null, "Rulebook missing")
if rulebook != null:
var scrolls = rulebook.find_children("*", "ScrollContainer", true, false)
_check(scrolls.size() > 0, "rules ScrollContainer missing")
if scrolls.size() > 0:
var content = scrolls[0].get_child(0)
_check(content.mouse_filter == Control.MOUSE_FILTER_PASS,
"rules content should pass swipes")
var tutorial = rulebook.tutorial_board
_check(tutorial != null, "tutorial board missing")
if tutorial != null:
_check(tutorial.mouse_filter == Control.MOUSE_FILTER_STOP,
"tutorial board should keep its own input")
# --- Guest Book input ---------------------------------------------------------
func _test_guest_book_input(main) -> void:
main.show_screen("guest_book")
await process_frame
var book = main.guest_book
_check(book != null, "Guest Book missing")
if book == null:
return
var guests: Array = Guests.all()
_check(guests.size() > 0, "no guests to test")
if guests.is_empty():
return
var guest: Dictionary = guests[0]
book.scroll.scroll_vertical = 0
book._press_scroll = 0
book._suppress_until = 0
book._dragged = false
book.detail_layer.visible = false
# A short, stationary press + release opens the card.
_card_mouse(book, guest, Vector2(100, 300), true)
_card_mouse(book, guest, Vector2(100, 300), false)
_check(book.detail_layer.visible, "stationary press/release should open detail")
book.detail_layer.visible = false
book._suppress_until = 0
book._dragged = false
book.scroll.scroll_vertical = 0
# Movement beyond 12dp makes it a scroll, not a tap.
_card_mouse(book, guest, Vector2(100, 300), true)
var motion := InputEventMouseMotion.new()
motion.global_position = Vector2(170, 300)
book._on_card_input(motion, guest, false)
_card_mouse(book, guest, Vector2(170, 300), false)
_check(not book.detail_layer.visible, "a >12dp drag should not open detail")
book._suppress_until = 0
book._dragged = false
book.scroll.scroll_vertical = 0
# A press whose scroll offset changes is a scroll, not a tap.
_card_mouse(book, guest, Vector2(100, 300), true)
book.scroll.scroll_vertical = 60
if absi(book.scroll.scroll_vertical - book._press_scroll) <= 1:
# The headless layout may clamp scrolling; emulate the changed offset.
book._press_scroll = book.scroll.scroll_vertical - 60
_card_mouse(book, guest, Vector2(100, 300), false)
_check(not book.detail_layer.visible, "a scrolled press should not open detail")
book.scroll.scroll_vertical = 0
book._press_scroll = 0
book._suppress_until = 0
book._dragged = false
# A tap right after a fling is suppressed.
book._suppress_until = Time.get_ticks_msec() + 1000
_card_mouse(book, guest, Vector2(100, 300), true)
_card_mouse(book, guest, Vector2(100, 300), false)
_check(not book.detail_layer.visible, "post-drag suppression should block a tap")
book._suppress_until = 0
book._dragged = false
# The opening tap must not immediately close the sheet.
_card_mouse(book, guest, Vector2(100, 300), true)
_card_mouse(book, guest, Vector2(100, 300), false)
_check(book.detail_layer.visible, "a clean tap should open detail")
book._try_close_detail()
_check(book.detail_layer.visible, "close should be guarded right after opening")
book._detail_opened_at -= 300
book._try_close_detail()
_check(not book.detail_layer.visible, "close should work after the guard")
# A later release on the scrim closes the sheet.
_card_mouse(book, guest, Vector2(100, 300), true)
_card_mouse(book, guest, Vector2(100, 300), false)
_check(book.detail_layer.visible, "a clean tap should reopen detail")
book._detail_opened_at -= 300
var up := InputEventMouseButton.new()
up.button_index = MOUSE_BUTTON_LEFT
up.pressed = false
up.global_position = Vector2(20, 20)
book.detail_layer.emit_signal("gui_input", up)
_check(not book.detail_layer.visible, "a later scrim release should close detail")
func _card_mouse(book, guest: Dictionary, pos: Vector2, pressed: bool) -> void:
var event := InputEventMouseButton.new()
event.button_index = MOUSE_BUTTON_LEFT
event.pressed = pressed
event.global_position = pos
book._on_card_input(event, guest, false)
+1
View File
@@ -0,0 +1 @@
uid://b017p64qwfkhk
+305
View File
@@ -0,0 +1,305 @@
extends SceneTree
## Headless UI QA sweep: screens, settings, profile frames, daily/campaign
## win flows and the Guest Book detail guard.
## <godot> --headless --path . --script res://tools/qa_ui.gd --quit-after 1800
var failures := 0
var frames
func _init() -> void:
call_deferred("_run")
func _check(condition: bool, message: String) -> void:
if not condition:
failures += 1
print("FAIL: ", message)
func _run() -> void:
var err := change_scene_to_file("res://scenes/Main.tscn")
if err != OK:
print("FAIL: could not load Main")
quit(1)
return
await process_frame
await process_frame
var main = current_scene
var save = root.get_node_or_null("SaveGame")
_check(save != null, "SaveGame autoload missing")
if save == null:
quit(1)
return
# Resolve Frames at runtime: a static reference would compile it before
# autoloads are registered when this script is launched with --script.
frames = load("res://scripts/Frames.gd")
_check(frames != null, "Frames script missing")
_test_screen_cycle(main)
await _test_settings(main, save)
await _test_profile(main, save)
await _test_daily(main, save)
await _test_campaign(main, save)
await _test_guest_book(main)
_restore_defaults(save)
print("QA UI: ", "PASS" if failures == 0 else "FAIL (%d)" % failures)
quit(0 if failures == 0 else 1)
func _test_screen_cycle(main) -> void:
var expected: Array[String] = ["home", "game", "guest_book", "rules", "profile"]
_check(main.screens.size() == expected.size(), "Main should expose all five screens")
for name in expected:
_check(main.screens.has(name) and main.screens[name] != null, "screen missing: %s" % name)
_check(
main.home != null and main.game != null and main.guest_book != null
and main.rulebook != null and main.profile != null,
"named screen references should all exist"
)
_check(main.settings_sheet != null, "settings sheet missing")
var keys: Array = main.screens.keys()
for name in expected:
main.show_screen(name, false)
for key in keys:
_check(
bool(main.screens[key].visible) == (key == name),
"only %s should be visible after show_screen(%s)" % [key, name]
)
main.show_screen("home", false)
func _test_settings(main, save) -> void:
main.show_screen("home", false)
main.open_settings("home")
await process_frame
_check(main.settings_sheet.visible, "settings sheet should open from home")
_check(main.settings_sheet.resume_button.text == "Close", "home settings should use Close")
_check(not main.settings_sheet.game_actions.visible, "home settings should hide game actions")
var toggles: Dictionary = main.settings_sheet.toggles
_check(toggles.has("patterns") and toggles.has("double_tap_place"), "settings toggles missing")
_check(toggles["patterns"].mouse_filter == Control.MOUSE_FILTER_PASS, "settings rows should pass swipes")
# Changes made through SaveGame must be reflected after an explicit refresh.
save.set_setting("patterns", false)
save.set_setting("double_tap_place", false)
main.settings_sheet.refresh()
_check(not toggles["patterns"].button_pressed, "sheet should refresh patterns from SaveGame")
_check(not toggles["double_tap_place"].button_pressed, "sheet should refresh double-tap from SaveGame")
_check(main.settings_sheet.hold_slider.editable, "hold slider should be editable with double-tap off")
# The sheet's own toggles must write back to SaveGame.
toggles["patterns"].button_pressed = true
_check(bool(save.get_setting("patterns")), "patterns toggle should update SaveGame")
toggles["double_tap_place"].button_pressed = true
_check(bool(save.get_setting("double_tap_place")), "double-tap toggle should update SaveGame")
_check(not main.settings_sheet.hold_slider.editable, "hold slider should be disabled with double-tap on")
main.close_settings()
await process_frame
_check(not main.settings_sheet.visible, "settings sheet should close from home")
main.show_screen("game", false)
main.open_settings("game")
await process_frame
_check(main.settings_sheet.visible, "settings sheet should open from game")
_check(main.settings_sheet.resume_button.text == "Resume", "game settings should use Resume")
_check(main.settings_sheet.game_actions.visible, "game settings should show Restart/Lobby")
_check(main.game.ui_paused, "game should pause while settings are open")
main.close_settings()
await process_frame
_check(not main.settings_sheet.visible, "settings sheet should close from game")
_check(not main.game.ui_paused, "game should resume after closing settings")
main.show_screen("home", false)
func _test_profile(main, save) -> void:
# Five campaign rooms and a three-day streak unlock Paper and Regular.
save.reset_progress()
var stats: Dictionary = save.daily_data().duplicate(true)
stats["best_streak"] = 3
save.data["daily"] = stats
save.select_frame("plain")
for i in range(5):
save.data["completed_rooms"].append("qa-frame-%02d" % i)
save.save_game()
save.progress_changed.emit()
main.show_screen("profile", false)
await process_frame
await process_frame
var profile = main.profile
_check(profile != null, "Profile screen missing")
if profile == null:
return
var expected: int = frames.all().size()
_check(profile.frame_grid.get_child_count() == expected, "Profile should show every frame")
for i in range(profile.frame_grid.get_child_count()):
_check(
profile.frame_grid.get_child(i).mouse_filter == Control.MOUSE_FILTER_PASS,
"frame card %d should pass swipes" % i
)
_check(profile.rooms_label.text == "5 / 30", "profile room count should reflect save data")
_check(profile.best_label.text == "3", "profile best streak should reflect save data")
var regular_index := -1
var night_index := -1
for i in range(frames.all().size()):
var id := str(frames.all()[i].get("id", ""))
if id == "regular":
regular_index = i
if id == "night":
night_index = i
_check(regular_index >= 0 and night_index >= 0, "Regular and Night owl frames should exist")
_check(frames.is_unlocked("regular"), "a three-day best streak should unlock Regular")
_check(not frames.is_unlocked("night"), "Night owl should still be locked")
if regular_index < 0 or night_index < 0:
return
# Regression: rebuilding the card grid while `pressed` is on the stack
# frees the emitting node under Godot. Watch the card from inside the
# signal, before the deferred frame change has a chance to run.
var card = profile.frame_grid.get_child(regular_index)
var probe := {"valid": false, "inside": false, "count": -1}
var watcher := func() -> void:
var valid := is_instance_valid(card)
probe["valid"] = valid
probe["inside"] = valid and card.is_inside_tree()
probe["count"] = profile.frame_grid.get_child_count()
card.pressed.connect(watcher)
var count_before: int = profile.frame_grid.get_child_count()
card.pressed.emit()
_check(bool(probe["valid"]) and bool(probe["inside"]), "frame card must stay alive while pressed emits")
_check(int(probe["count"]) == count_before, "frame grid must stay stable while pressed emits")
await process_frame
await process_frame
_check(save.selected_frame() == "regular", "pressing an unlocked frame should select it")
_check(profile.frame_grid.get_child_count() == count_before, "frame grid should stay stable after selection")
_check(profile.status_label.text.find("Now wearing") >= 0, "selection should be reported in profile status")
var locked_card = profile.frame_grid.get_child(night_index)
locked_card.pressed.emit()
await process_frame
_check(
profile.status_label.text.find(frames.requirement_text("night")) >= 0,
"locked frame should show its requirement"
)
_check(save.selected_frame() == "regular", "locked frame must not change the selection")
func _test_daily(main, save) -> void:
main.show_screen("home", false)
var today := Daily.today_key()
var yesterday := Daily.key_from_day_number(Daily.day_number(today) - 1)
var daily: Dictionary = save._default_daily()
daily["last_completed"] = yesterday
daily["streak"] = 2
daily["best_streak"] = 3
save.data["daily"] = daily
save.save_game()
var streak_before: int = save.daily_streak()
var rooms_before: Array = (save.data["completed_rooms"] as Array).duplicate()
main._on_daily()
await process_frame
await process_frame
_check(main.game.daily_mode, "daily button should start daily mode")
_check(main.game.level_label.text == "Daily room", "daily mode should label the room")
_check(main.game.daily_key == today, "daily mode should carry today's key")
await _solve_board(main.game, "daily room")
_check(main.game.overlay.visible, "daily win overlay should appear after the timer")
_check(main.game.win_title.text == "Daily room complete!", "daily win title should be correct")
_check(main.game.win_next.text == "Back to lobby", "daily win button should say Back to lobby")
_check(save.daily_streak() == streak_before + 1, "daily streak should increment exactly once")
_check(save.daily_completed_today(), "today should be marked complete")
_check((save.data["completed_rooms"] as Array) == rooms_before, "daily must not touch completed rooms")
main.game.win_next.pressed.emit()
await process_frame
await process_frame
_check(main.current == "home", "Back to lobby should return to home")
_check(main.home.visible, "home should be visible after the daily win")
func _test_campaign(main, save) -> void:
main.show_screen("game", false)
main.game.start_level(0)
await process_frame
var room_id := str(main.game.current_level_id)
var guest: Dictionary = Guests.for_room(1)
var guest_id := str(guest.get("id", ""))
await _solve_board(main.game, "campaign room 1")
_check(main.game.overlay.visible, "campaign win overlay should appear")
_check(main.game.win_title.text == "Everyone checked in!", "campaign win title should be correct")
_check(main.game.win_next.text == "Next room", "campaign win button should say Next room")
_check((save.data["completed_rooms"] as Array).has(room_id), "campaign room should be recorded")
_check(guest_id != "" and save.is_guest_unlocked(guest_id), "room 1 should unlock a guest")
main.game.win_next.pressed.emit()
await process_frame
_check(not main.game.daily_mode, "next room should not be daily mode")
_check(main.game.level_index == 1, "next room should be room 2")
_check(main.game.level_label.text == "Room 2", "room 2 should be labelled correctly")
_check(not main.game.overlay.visible, "overlay should hide when room 2 starts")
func _test_guest_book(main) -> void:
main.show_screen("guest_book", false)
await process_frame
var book = main.guest_book
_check(book != null, "Guest Book missing")
if book == null:
return
var guest: Dictionary = Guests.all()[0]
book._show_detail(guest)
_check(book.detail_layer.visible, "guest detail should open")
_check(book.detail_name.text == str(guest.get("name", "")), "guest detail should name the guest")
book._try_close_detail()
_check(book.detail_layer.visible, "close should be guarded right after opening")
book._detail_opened_at -= 300
book._try_close_detail()
_check(not book.detail_layer.visible, "close should work after the guard")
main.show_screen("home", false)
func _solve_board(game, label: String) -> void:
var board = game.board
var solved := false
for i in range(12):
if Rules.is_valid(board.cells, board.regions) or game.win_shown:
solved = true
break
board.hint()
await process_frame
if not solved:
solved = Rules.is_valid(board.cells, board.regions) or game.win_shown
_check(solved, "%s should solve within 12 hints" % label)
await create_timer(0.6).timeout
await process_frame
func _restore_defaults(save) -> void:
save.reset_progress()
save.data["daily"] = save._default_daily()
save.data["last_room"] = 0
save.select_frame("plain")
save.set_setting("patterns", true)
save.set_setting("show_timer", true)
save.set_setting("reduce_motion", false)
save.set_setting("hold_seconds", 0.35)
save.set_setting("double_tap_place", true)
save.save_game()
_check(save.rooms_completed() == 0, "save progress should be restored")
_check(save.daily_data() == save._default_daily(), "save daily should be restored")
_check(save.selected_frame() == "plain", "save frame should be restored")
+1
View File
@@ -0,0 +1 @@
uid://dm888jqtkwin7