Files
MusicPlayer/tests/integration/test_player_keybinds.gd
SansanandClaude Opus 5.5 70e970b24c
Build / test (push) Successful in 1m30s
Build / build (push) Successful in 1m17s
Make the buttons consistent and rework the player list
Buttons get 12 px of side padding. The top bar buttons, the quiz toolbar and
Show answer/Next are laid out in rows with 12 px gaps and are all 36 px tall,
and the ±1 buttons use a compact StepButton style. "Randomize new track" is now
"Next song".

Player rows show the name and the score apart, alternate like the other lists
and highlight the character under the mouse. The name field is a LineEdit with
a 10-letter limit; blank and duplicate names are refused, and a full list says
"Up to 7 players". Remove buttons update when editing is switched instead of
every frame, and the spacer panels are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 21:35:24 +02:00

153 lines
4.7 KiB
GDScript

extends MainWindowTestSuite
## Alt+<number> gives a point to the player in that row of the player list and
## Ctrl+Alt+<number> takes one away. These tests check that the keybinds keep
## following the rows while players are added and removed, and that points always
## end up with the right player.
var _crono: PlayerObject
var _marle: PlayerObject
var _lucca: PlayerObject
func before_test() -> void:
await super()
_crono = _add_player("Crono")
_marle = _add_player("Marle")
_lucca = _add_player("Lucca")
await _play_first_song()
func _song_points() -> Array[String]:
return Playlist.song_object_array[Playlist.currently_playing_song].players_given_point
func test_alt_number_gives_point_to_player_in_that_row() -> void:
await _give_point_with_keybind(2)
assert_array(_scores()).contains_exactly([0, 1, 0])
assert_array(_song_points()).contains_exactly([_marle.id])
func test_ctrl_alt_number_takes_point_from_player_in_that_row() -> void:
await _give_point_with_keybind(3)
await _give_point_with_keybind(3)
await _take_point_with_keybind(3)
assert_array(_scores()).contains_exactly([0, 0, 1])
func test_taking_last_point_removes_player_from_song() -> void:
await _give_point_with_keybind(1)
await _take_point_with_keybind(1)
assert_int(_crono.player_score).is_equal(0)
assert_array(_song_points()).is_empty()
func test_each_keybind_only_affects_its_own_player() -> void:
await _give_point_with_keybind(1)
await _give_point_with_keybind(3)
await _give_point_with_keybind(3)
assert_int(_crono.player_score).is_equal(1)
assert_int(_marle.player_score).is_equal(0)
assert_int(_lucca.player_score).is_equal(2)
assert_array(_song_points()).contains_exactly([_crono.id, _lucca.id])
func test_number_without_player_does_nothing() -> void:
await _give_point_with_keybind(4)
assert_array(_scores()).contains_exactly([0, 0, 0])
assert_array(_song_points()).is_empty()
func test_keybinds_move_up_when_first_player_is_removed() -> void:
await _remove_player(_crono)
await _give_point_with_keybind(1)
await _give_point_with_keybind(2)
await _give_point_with_keybind(2)
assert_int(_marle.player_score).is_equal(1)
assert_int(_lucca.player_score).is_equal(2)
assert_array(_song_points()).contains_exactly([_marle.id, _lucca.id])
func test_keybind_after_last_row_does_nothing_after_removal() -> void:
await _remove_player(_marle)
await _give_point_with_keybind(3)
assert_int(_crono.player_score).is_equal(0)
assert_int(_lucca.player_score).is_equal(0)
func test_removing_player_removes_only_their_points() -> void:
await _give_point_with_keybind(1)
await _give_point_with_keybind(2)
await _give_point_with_keybind(3)
await _remove_player(_marle)
assert_array(_song_points()).contains_exactly([_crono.id, _lucca.id])
assert_int(_crono.player_score).is_equal(1)
assert_int(_lucca.player_score).is_equal(1)
func test_new_player_gets_next_free_keybind_after_removal() -> void:
await _remove_player(_marle)
var robo: PlayerObject = _add_player("Robo")
await _give_point_with_keybind(2)
await _give_point_with_keybind(3)
assert_int(_lucca.player_score).is_equal(1)
assert_int(robo.player_score).is_equal(1)
assert_int(_crono.player_score).is_equal(0)
assert_array(_song_points()).contains_exactly([_lucca.id, robo.id])
func test_new_player_does_not_inherit_removed_players_points() -> void:
await _give_point_with_keybind(3)
await _remove_player(_lucca)
var robo: PlayerObject = _add_player("Robo")
assert_int(robo.player_score).is_equal(0)
assert_array(_song_points()).is_empty()
func test_points_follow_players_through_several_changes() -> void:
await _give_point_with_keybind(1)
await _remove_player(_crono)
var robo: PlayerObject = _add_player("Robo")
await _give_point_with_keybind(1)
await _remove_player(_marle)
var ayla: PlayerObject = _add_player("Ayla")
await _give_point_with_keybind(3)
await _give_point_with_keybind(2)
await _take_point_with_keybind(2)
# Rows are now: Lucca, Robo, Ayla
assert_array(Settings.player_array).contains_exactly([_lucca, robo, ayla])
assert_int(_lucca.player_score).is_equal(0)
assert_int(robo.player_score).is_equal(0)
assert_int(ayla.player_score).is_equal(1)
assert_array(_song_points()).contains_exactly([ayla.id])
func test_player_list_shows_rows_in_player_order() -> void:
await _remove_player(_crono)
var robo: PlayerObject = _add_player("Robo")
var rows: Array[Node] = _quiz.get_node(
"PlayersPanel/VBoxContainer/ScrollContainer/PlayersListVBoxContainer").get_children()
assert_array(rows.map(func(row: PlayerRow) -> PlayerObject: return row.player_object)) \
.contains_exactly([_marle, _lucca, robo])
assert_array(rows.map(func(row: PlayerRow) -> int: return row.list_index)) \
.contains_exactly([0, 1, 2])