Files
MusicPlayer/tests/integration/test_main_window_startup.gd
T
Sansan e94c75e84d Split now playing, the quiz buttons and song loading out of the quiz
NowPlaying, QuizToolbar and SongControls become their own scenes, the auto
repeat switch moves into the music player scene, and downloading songs moves
into a SongLoader node. The quiz only wires the parts together. Every node
keeps its place on screen.

Screenshots of every UI state are pixel-identical to before, the layout test
still matches the original baseline, and each new part has its own tests.
2026-10-06 11:11:18 +02:00

42 lines
1.3 KiB
GDScript

extends MainWindowTestSuite
## Startup with a slow /music/list response.
func _before_window_starts() -> void:
_server.respond_json("/music/list", [
{"SongNo": 0, "Soundtrack": "Chrono Trigger", "Song": "Corridors of Time"},
])
_next_song_is({"SongNo": 1, "Soundtrack": "Final Fantasy VI", "Song": "Dancing Mad"})
_server.hold("/music/list")
func test_preloaded_song_survives_a_slow_song_list() -> void:
_server.release("/music/list")
# The song already on the server, then the preloaded one
assert_int(Playlist.song_object_array.size()).is_equal(2)
assert_str(Playlist.song_object_array[1].song_title).is_equal("Dancing Mad")
assert_int(Playlist.get_preloaded_songs()).is_equal(1)
func test_next_plays_the_preloaded_song_after_a_slow_song_list() -> void:
_server.release("/music/list")
await _play_first_song()
assert_int(Playlist.currently_playing_song).is_equal(1)
func test_failed_song_list_is_retried_before_preloading() -> void:
_quiz.song_loader.retry_seconds = 0.05
_server.respond_json("/music/list", [], 503)
_server.release("/music/list")
assert_int(_server.count("/music/rand")).is_equal(0)
_server.respond_json("/music/list", [])
await await_millis(200)
assert_int(_server.count("/music/rand")).is_equal(1)
assert_int(Playlist.get_preloaded_songs()).is_equal(1)