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:
1 parent
48c14864a4
commit
077c08bb5f
7 files changed
+1361
No files matched your search
+305
@@ -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")
|
||||
Reference in new issue
Block a user