Replace the broken test suite with working GdUnit4 tests

The previous tests never compiled: they used GUT's assert functions,
Godot 3 APIs and reassigned autoload functions, so no test ran.

- 90 tests: unit tests for the playlist, songs, player scoring, time
  formatting, search and the server client, plus integration tests
  that run MainWindow and SyncWindow against a fake server
- Keybind tests check that Alt+<number> and Ctrl+Alt+<number> keep
  following the player rows while players are added and removed
- run_tests.sh finds Godot and runs the suite headless (~10 seconds)
- CI runs the tests before the build job in gitea-build.yaml; the
  separate test.yml used a GitHub action that does not exist
- GdUnit4 is committed instead of ignored, since the project enables
  it, and .gitea/ is no longer ignored
- Exported builds leave out tests/ and addons/gdUnit4/
This commit is contained in:
Sansan committed 2026-10-06 08:32:56 +02:00
1 parent 56e9fe66d3
commit c985a6ce5b
559 files changed
+32474 -2100

No files matched your search

+119
View File
@@ -0,0 +1,119 @@
extends GdUnitTestSuite
var _winning_score: int
var _player: PlayerObject
func before_test() -> void:
_winning_score = Settings.winning_score
Settings.winning_score = 3
_player = PlayerObject.new("Crono")
func after_test() -> void:
Settings.winning_score = _winning_score
func test_first_point_triggers_first_point_signal() -> void:
monitor_signals(_player, false)
_player.add_point()
assert_int(_player.player_score).is_equal(1)
await assert_signal(_player).is_emitted("first_point_triggerd")
await assert_signal(_player).is_emitted("player_point_given")
func test_one_point_from_winning_triggers_match_point() -> void:
_player.add_point()
monitor_signals(_player, false)
_player.add_point()
await assert_signal(_player).is_emitted("match_point_triggerd")
func test_reaching_winning_score_triggers_winner() -> void:
_player.add_point()
_player.add_point()
monitor_signals(_player, false)
_player.add_point()
assert_int(_player.player_score).is_equal(3)
await assert_signal(_player).is_emitted("winner_triggerd")
func test_score_does_not_go_past_winning_score() -> void:
for i: int in 3:
_player.add_point()
monitor_signals(_player, false)
_player.add_point()
assert_int(_player.player_score).is_equal(3)
await assert_signal(_player).wait_until(50).is_not_emitted("player_point_given")
func test_ordinary_point_plays_point_sound() -> void:
Settings.winning_score = 10
_player.add_point()
monitor_signals(_player, false)
_player.add_point()
await assert_signal(_player).is_emitted("point_given_sound")
func test_minus_point_lowers_score() -> void:
_player.add_point()
monitor_signals(_player, false)
_player.minus_point()
assert_int(_player.player_score).is_equal(0)
await assert_signal(_player).is_emitted("player_point_taken")
func test_score_does_not_go_below_zero() -> void:
monitor_signals(_player, false)
_player.minus_point()
assert_int(_player.player_score).is_equal(0)
await assert_signal(_player).wait_until(50).is_not_emitted("player_point_taken")
func test_dropping_back_to_zero_allows_first_point_again() -> void:
_player.add_point()
_player.minus_point()
monitor_signals(_player, false)
_player.add_point()
await assert_signal(_player).is_emitted("first_point_triggerd")
func test_reset_points() -> void:
_player.add_point()
_player.add_point()
_player.reset_points()
assert_int(_player.player_score).is_equal(0)
assert_bool(_player.is_first_point).is_true()
func test_id_is_a_uuid() -> void:
var uuid_pattern: RegEx = RegEx.create_from_string(
"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$")
assert_object(uuid_pattern.search(_player.id)).is_not_null()
func test_every_player_gets_a_different_id() -> void:
var ids: Dictionary = {}
for i: int in 100:
ids[PlayerObject.new("Player %d" % i).id] = true
assert_int(ids.size()).is_equal(100)