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:
1 parent
56e9fe66d3
commit
c985a6ce5b
559 files changed
+32474
-2100
No files matched your search
@@ -1,261 +0,0 @@
|
||||
class_name FullFlowTest
|
||||
extends GdUnitTestSuite
|
||||
|
||||
|
||||
func test_fetch_song_list_at_start_populates_playlist():
|
||||
# Mock Settings.make_request2
|
||||
var original_make_request = Settings.make_request2
|
||||
|
||||
Settings.make_request2 = func(address: String, func_name: Callable, expect_data: bool) -> void:
|
||||
if address == "/music/list":
|
||||
func_name.call([
|
||||
{"SongNo": 1, "Soundtrack": "Test Soundtrack 1", "Song": "Test Song 1"},
|
||||
{"SongNo": 2, "Soundtrack": "Test Soundtrack 2", "Song": "Test Song 2"}
|
||||
])
|
||||
|
||||
Playlist.clear_song_list()
|
||||
|
||||
var main_window = MainWindow.new()
|
||||
main_window.fetch_song_list_at_start()
|
||||
|
||||
# Wait for async
|
||||
await main_window.get_tree().create_timer(0.1).timeout
|
||||
|
||||
assert_eq(Playlist.song_object_array.size(), 2)
|
||||
|
||||
Settings.make_request2 = original_make_request
|
||||
|
||||
|
||||
func test_fetch_song_adds_to_playlist():
|
||||
# Mock Settings.make_request2
|
||||
var original_make_request = Settings.make_request2
|
||||
var rand_called = false
|
||||
var info_called = false
|
||||
var add_que_called = false
|
||||
|
||||
Settings.make_request2 = func(address: String, func_name: Callable, expect_data: bool) -> void:
|
||||
if address == "/music/rand":
|
||||
rand_called = true
|
||||
var test_stream = TestHelpers.create_mock_audio_stream()
|
||||
func_name.call(test_stream.get_data())
|
||||
elif address == "/music/info":
|
||||
info_called = true
|
||||
func_name.call({"SongNo": 3, "Soundtrack": "New Soundtrack", "Song": "New Song"})
|
||||
elif address == "/music/addQue":
|
||||
add_que_called = true
|
||||
func_name.call()
|
||||
|
||||
Playlist.clear_song_list()
|
||||
Playlist.is_song_downloading = false
|
||||
|
||||
var main_window = MainWindow.new()
|
||||
main_window.fetch_song()
|
||||
|
||||
# Wait for async
|
||||
await main_window.get_tree().create_timer(0.2).timeout
|
||||
|
||||
assert_true(rand_called)
|
||||
assert_true(info_called)
|
||||
assert_true(add_que_called)
|
||||
assert_eq(Playlist.song_object_array.size(), 1)
|
||||
|
||||
Settings.make_request2 = original_make_request
|
||||
|
||||
|
||||
func test_search_function_filters_soundtracks():
|
||||
var main_window = MainWindow.new()
|
||||
|
||||
# Setup test data
|
||||
main_window.soundtracks = ["Soundtrack 1", "Soundtrack 2", "Test Soundtrack"]
|
||||
|
||||
# This is a simplified test - in reality, search would be more complex
|
||||
# We're testing that the search_view gets the list
|
||||
var mock_search_view = mock(Control)
|
||||
mock_search_view.get_list_of_soundtracks = func():
|
||||
pass # Mock implementation
|
||||
|
||||
main_window.search_view = mock_search_view
|
||||
|
||||
# Call the method that populates the list
|
||||
main_window.get_suggestion_list()
|
||||
|
||||
# Wait for async
|
||||
await main_window.get_tree().create_timer(0.1).timeout
|
||||
|
||||
# Verify search_view was called
|
||||
assert_true(mock_search_view.get_list_of_soundtracks.was_called())
|
||||
|
||||
|
||||
func test_player_list_updates_on_add():
|
||||
var main_window = MainWindow.new()
|
||||
|
||||
Settings.player_array.clear()
|
||||
Settings.edit_players = false
|
||||
|
||||
# Setup mock container
|
||||
var mock_container = mock(VBoxContainer)
|
||||
main_window.players_list_container = mock_container
|
||||
|
||||
# Add a player
|
||||
var player_obj = PlayerObject.new("Test Player", 0)
|
||||
Settings.player_array.append(player_obj)
|
||||
|
||||
main_window.load_players()
|
||||
|
||||
# Verify player was added to container
|
||||
assert_eq(mock_container.get_child_count(), 1)
|
||||
|
||||
|
||||
func test_player_list_updates_on_remove():
|
||||
var main_window = MainWindow.new()
|
||||
|
||||
Settings.player_array.clear()
|
||||
|
||||
# Setup mock container
|
||||
var mock_container = mock(VBoxContainer)
|
||||
main_window.players_list_container = mock_container
|
||||
|
||||
# Add players
|
||||
for i in range(3):
|
||||
var player_obj = PlayerObject.new("Player %d" % i, i)
|
||||
Settings.player_array.append(player_obj)
|
||||
|
||||
main_window.load_players()
|
||||
assert_eq(mock_container.get_child_count(), 3)
|
||||
|
||||
# Remove a player
|
||||
main_window._on_player_removed(1)
|
||||
|
||||
assert_eq(Settings.player_array.size(), 2)
|
||||
assert_eq(mock_container.get_child_count(), 2)
|
||||
|
||||
|
||||
func test_point_given_updates_log_and_playlist():
|
||||
var main_window = MainWindow.new()
|
||||
|
||||
# Setup
|
||||
Settings.player_array.clear()
|
||||
var player = PlayerObject.new("Test Player", 0)
|
||||
Settings.player_array.append(player)
|
||||
|
||||
Playlist.clear_song_list()
|
||||
var song = TestHelpers.create_test_song_object(1)
|
||||
Playlist.add_to_playlist(song)
|
||||
Playlist.currently_playing_song = 0
|
||||
|
||||
# Mock log window
|
||||
var mock_log = mock(Control)
|
||||
mock_log.add_log_row = func(text: String):
|
||||
pass
|
||||
|
||||
main_window.log_window = mock_log
|
||||
|
||||
# Emit point given
|
||||
player.player_point_given.emit()
|
||||
|
||||
# Wait for async
|
||||
await main_window.get_tree().create_timer(0.1).timeout
|
||||
|
||||
# Verify log was updated
|
||||
assert_true(mock_log.add_log_row.was_called())
|
||||
# Verify playlist was updated
|
||||
assert_true(song.players_given_point.has(0))
|
||||
|
||||
|
||||
func test_point_taken_updates_log_and_playlist():
|
||||
var main_window = MainWindow.new()
|
||||
|
||||
# Setup
|
||||
Settings.player_array.clear()
|
||||
var player = PlayerObject.new("Test Player", 0)
|
||||
player.player_score = 5
|
||||
Settings.player_array.append(player)
|
||||
|
||||
Playlist.clear_song_list()
|
||||
var song = TestHelpers.create_test_song_object(1)
|
||||
song.players_given_point.append(0)
|
||||
Playlist.add_to_playlist(song)
|
||||
Playlist.currently_playing_song = 0
|
||||
|
||||
# Mock log window
|
||||
var mock_log = mock(Control)
|
||||
mock_log.add_log_row = func(text: String):
|
||||
pass
|
||||
|
||||
main_window.log_window = mock_log
|
||||
|
||||
# Emit point taken
|
||||
player.player_point_taken.emit()
|
||||
|
||||
# Wait for async
|
||||
await main_window.get_tree().create_timer(0.1).timeout
|
||||
|
||||
# Verify log was updated
|
||||
assert_true(mock_log.add_log_row.was_called())
|
||||
# Verify playlist was updated
|
||||
assert_false(song.players_given_point.has(0))
|
||||
|
||||
|
||||
func test_player_won_shows_winner_window():
|
||||
var main_window = MainWindow.new()
|
||||
|
||||
# Setup
|
||||
Settings.player_array.clear()
|
||||
var player = PlayerObject.new("Test Player", 0)
|
||||
Settings.player_array.append(player)
|
||||
|
||||
# Mock winner window
|
||||
var mock_winner_window = mock(Control)
|
||||
mock_winner_window.show_winner = func(winning_player_id: int):
|
||||
pass
|
||||
|
||||
main_window.winner_window = mock_winner_window
|
||||
|
||||
# Emit winner
|
||||
player.winner_triggerd.emit()
|
||||
|
||||
# Wait for async
|
||||
await main_window.get_tree().create_timer(0.1).timeout
|
||||
|
||||
# Verify winner window was shown
|
||||
assert_true(mock_winner_window.show_winner.was_called_with([0]))
|
||||
|
||||
|
||||
func test_show_answer_pressed_marks_song_as_answered():
|
||||
var main_window = MainWindow.new()
|
||||
|
||||
Playlist.clear_song_list()
|
||||
var song = TestHelpers.create_test_song_object(1)
|
||||
song.is_answered = false
|
||||
Playlist.add_to_playlist(song)
|
||||
Playlist.currently_playing_song = 0
|
||||
|
||||
main_window.show_answer_pressed()
|
||||
|
||||
assert_true(song.is_answered)
|
||||
|
||||
|
||||
func test_update_song_list_refreshes_ui():
|
||||
var main_window = MainWindow.new()
|
||||
|
||||
# Setup mock UI elements
|
||||
var mock_soundtrack_label = mock(Label)
|
||||
var mock_song_label = mock(Label)
|
||||
var mock_music_list = mock(VBoxContainer)
|
||||
|
||||
main_window.soundtrack_label = mock_soundtrack_label
|
||||
main_window.song_label = mock_song_label
|
||||
main_window.music_list = mock_music_list
|
||||
|
||||
Playlist.clear_song_list()
|
||||
var song = TestHelpers.create_test_song_object(1, "Test Soundtrack", "Test Song")
|
||||
song.is_answered = true
|
||||
song.has_played = true
|
||||
Playlist.add_to_playlist(song)
|
||||
Playlist.currently_playing_song = 0
|
||||
|
||||
main_window.update_song_list()
|
||||
|
||||
# Verify labels were updated
|
||||
assert_eq(mock_soundtrack_label.text, "Test Soundtrack")
|
||||
assert_eq(mock_song_label.text, "Test Song")
|
||||
@@ -0,0 +1,80 @@
|
||||
extends MainWindowTestSuite
|
||||
## Main window flows: startup, playing songs and resetting.
|
||||
|
||||
|
||||
func test_startup_loads_soundtracks_and_preloads_a_song() -> void:
|
||||
assert_int(_server.count("/music/list")).is_equal(1)
|
||||
assert_int(_server.count("/music/all")).is_equal(1)
|
||||
assert_array(_server.requested_paths).contains(["/music/rand", "/music/addQue", "/music/info"])
|
||||
assert_int(Playlist.song_object_array.size()).is_equal(1)
|
||||
assert_bool((_window.get_node("NextButton") as Button).disabled).is_false()
|
||||
|
||||
|
||||
func test_low_played_mode_fetches_from_low_played_endpoint() -> void:
|
||||
Settings.use_low_played_mode = true
|
||||
_server.respond_bytes(
|
||||
"/music/rand/low", FileAccess.get_file_as_bytes("res://tests/data/short.mp3"))
|
||||
|
||||
_runner.invoke("fetch_song")
|
||||
|
||||
assert_int(_server.count("/music/rand/low")).is_equal(1)
|
||||
|
||||
|
||||
func test_next_plays_preloaded_song_and_fetches_another() -> void:
|
||||
_next_song_is(SONG_INFO[1])
|
||||
|
||||
_press("NextButton")
|
||||
await _runner.simulate_frames(2)
|
||||
|
||||
assert_int(Playlist.currently_playing_song).is_equal(0)
|
||||
assert_bool(Playlist.song_object_array[0].has_played).is_true()
|
||||
assert_int(Playlist.song_object_array.size()).is_equal(2)
|
||||
assert_int(_server.count("/music/rand")).is_equal(2)
|
||||
|
||||
|
||||
func test_title_is_hidden_until_answer_is_shown() -> void:
|
||||
var soundtrack_label: Label = _window.get_node("VBoxContainer/SoundtrackLabel")
|
||||
_press("NextButton")
|
||||
await _runner.simulate_frames(2)
|
||||
|
||||
assert_str(soundtrack_label.text).is_equal("????????")
|
||||
|
||||
_press("ShowAnswerButton")
|
||||
|
||||
assert_str(soundtrack_label.text).is_equal("Chrono Trigger")
|
||||
assert_int(_server.count("/music/played?song=0")).is_equal(1)
|
||||
|
||||
|
||||
func test_reset_playlist_clears_server_and_preloads_again() -> void:
|
||||
_press("NextButton")
|
||||
await _runner.simulate_frames(2)
|
||||
|
||||
_press("ResetPlaylistButton")
|
||||
|
||||
assert_int(_server.count("/music/reset")).is_equal(1)
|
||||
assert_int(Playlist.currently_playing_song).is_equal(-1)
|
||||
assert_int(Playlist.song_object_array.size()).is_equal(1)
|
||||
assert_bool(Playlist.song_object_array[0].has_played).is_false()
|
||||
|
||||
|
||||
func test_reset_points_sets_all_scores_to_zero() -> void:
|
||||
_add_player("Crono").add_point()
|
||||
_add_player("Marle").add_point()
|
||||
|
||||
_press("ResetPointsButton")
|
||||
|
||||
assert_int(Settings.player_array[0].player_score).is_equal(0)
|
||||
assert_int(Settings.player_array[1].player_score).is_equal(0)
|
||||
|
||||
|
||||
func test_cannot_add_more_than_max_players() -> void:
|
||||
for i: int in Settings.MAX_NUMBER_OF_PLAYERS + 1:
|
||||
_add_player("Player %d" % i)
|
||||
|
||||
assert_int(Settings.player_array.size()).is_equal(Settings.MAX_NUMBER_OF_PLAYERS)
|
||||
|
||||
|
||||
func test_cannot_add_player_without_name() -> void:
|
||||
_add_player("")
|
||||
|
||||
assert_array(Settings.player_array).is_empty()
|
||||
@@ -0,0 +1 @@
|
||||
uid://c1a77blpbbckh
|
||||
@@ -0,0 +1,152 @@
|
||||
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:
|
||||
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] = _window.get_node(
|
||||
"Players/VBoxContainer/ScrollContainer/PlayersListVBoxContainer").get_children()
|
||||
|
||||
assert_array(rows.map(func(row: Player) -> PlayerObject: return row.player_object)) \
|
||||
.contains_exactly([_marle, _lucca, robo])
|
||||
assert_array(rows.map(func(row: Player) -> int: return row.list_index)) \
|
||||
.contains_exactly([0, 1, 2])
|
||||
@@ -0,0 +1 @@
|
||||
uid://k3q6jrbpg3wa
|
||||
@@ -0,0 +1,145 @@
|
||||
extends GdUnitTestSuite
|
||||
|
||||
var _server: FakeHttpTransport
|
||||
var _snapshot: AutoloadSnapshot
|
||||
var _runner: GdUnitSceneRunner
|
||||
var _window: Control
|
||||
|
||||
|
||||
func before_test() -> void:
|
||||
_snapshot = AutoloadSnapshot.take([Settings])
|
||||
Settings.currently_syncing = false
|
||||
_server = FakeHttpTransport.new().install()
|
||||
_server.respond_bytes("/sync", PackedByteArray())
|
||||
_runner = scene_runner("res://SyncWindow.tscn")
|
||||
_window = _runner.scene()
|
||||
|
||||
|
||||
func after_test() -> void:
|
||||
_server.uninstall()
|
||||
_snapshot.restore()
|
||||
|
||||
|
||||
func _node(unique_name: String) -> Control:
|
||||
return _window.get_node("%" + unique_name)
|
||||
|
||||
|
||||
func _finish_sync(result: Dictionary) -> void:
|
||||
_server.respond_json("/sync/progress", result)
|
||||
_runner.invoke("_on_sync_timeout")
|
||||
|
||||
|
||||
func _empty_result() -> Dictionary:
|
||||
return {
|
||||
"soundtracks_added": [],
|
||||
"soundtracks_re_added": [],
|
||||
"soundtracks_changed_title": {},
|
||||
"soundtracks_changed_content": [],
|
||||
"soundtracks_removed": [],
|
||||
"catched_errors": [],
|
||||
"total_time": "00:00:03",
|
||||
}
|
||||
|
||||
|
||||
func test_start_sync_asks_server_and_shows_progress() -> void:
|
||||
monitor_signals(_window, false)
|
||||
|
||||
_runner.invoke("start_sync")
|
||||
|
||||
assert_array(_server.requested_paths).contains_exactly(["/sync"])
|
||||
assert_bool(Settings.currently_syncing).is_true()
|
||||
assert_bool(_node("ProgressHBoxContainer").visible).is_true()
|
||||
assert_str(_node("SyncTitleLabel").text).is_equal("Sync in Progress")
|
||||
await assert_signal(_window).is_emitted("sync_started")
|
||||
|
||||
|
||||
func test_start_sync_does_nothing_while_already_syncing() -> void:
|
||||
Settings.currently_syncing = true
|
||||
|
||||
_runner.invoke("start_sync")
|
||||
|
||||
assert_array(_server.requested_paths).is_empty()
|
||||
|
||||
|
||||
func test_progress_updates_progress_bar() -> void:
|
||||
_runner.invoke("start_sync")
|
||||
_server.respond_json("/sync/progress", {"progress": "42", "time_spent": "00:00:12"})
|
||||
|
||||
_runner.invoke("_on_sync_timeout")
|
||||
|
||||
assert_float(_node("SyncProgressBar").value).is_equal(42.0)
|
||||
assert_str(_node("SyncTime").text).is_equal("00:00:12")
|
||||
|
||||
|
||||
func test_finished_sync_shows_only_sections_with_changes() -> void:
|
||||
_runner.invoke("start_sync")
|
||||
monitor_signals(_window, false)
|
||||
var result: Dictionary = _empty_result()
|
||||
result.soundtracks_added = ["Chrono Cross", "Xenogears"]
|
||||
result.soundtracks_removed = ["Bad Rip"]
|
||||
|
||||
_finish_sync(result)
|
||||
|
||||
assert_bool(_node("SoundtracksAddedVBox").visible).is_true()
|
||||
assert_bool(_node("SoundtracksRemovedVBox").visible).is_true()
|
||||
assert_bool(_node("SoundtracksReAddedVBox").visible).is_false()
|
||||
assert_bool(_node("SoundtracksChangedTitleVBox").visible).is_false()
|
||||
assert_bool(_node("NoChangesLabel").visible).is_false()
|
||||
# Header plus one label per soundtrack
|
||||
assert_int(_node("SoundtracksAddedVBox").get_child_count()).is_equal(3)
|
||||
assert_str(_node("SyncTime").text).is_equal("Total time: 00:00:03")
|
||||
assert_bool(Settings.currently_syncing).is_false()
|
||||
await assert_signal(_window).is_emitted("sync_finished")
|
||||
|
||||
|
||||
func test_separator_shown_only_between_visible_sections() -> void:
|
||||
_runner.invoke("start_sync")
|
||||
var result: Dictionary = _empty_result()
|
||||
result.soundtracks_added = ["Chrono Cross"]
|
||||
result.soundtracks_removed = ["Bad Rip"]
|
||||
|
||||
_finish_sync(result)
|
||||
|
||||
assert_bool(_node("SoundtracksAddedSeparator").visible).is_true()
|
||||
assert_bool(_node("SoundtracksRemovedSeparator").visible).is_false()
|
||||
|
||||
|
||||
func test_changed_titles_list_old_and_new_title() -> void:
|
||||
_runner.invoke("start_sync")
|
||||
var result: Dictionary = _empty_result()
|
||||
result.soundtracks_changed_title = {"FF7": "Final Fantasy VII"}
|
||||
|
||||
_finish_sync(result)
|
||||
|
||||
var vbox: Control = _node("SoundtracksChangedTitleVBox")
|
||||
assert_bool(vbox.visible).is_true()
|
||||
assert_str((vbox.get_child(1) as Label).text).is_equal(
|
||||
"FF7\nchanged title to\nFinal Fantasy VII")
|
||||
|
||||
|
||||
func test_no_changes_shows_no_changes_label() -> void:
|
||||
_runner.invoke("start_sync")
|
||||
|
||||
_finish_sync(_empty_result())
|
||||
|
||||
assert_bool(_node("NoChangesLabel").visible).is_true()
|
||||
|
||||
|
||||
func test_errors_are_listed() -> void:
|
||||
_runner.invoke("start_sync")
|
||||
var result: Dictionary = _empty_result()
|
||||
result.catched_errors = ["Could not read tags in broken.mp3"]
|
||||
|
||||
_finish_sync(result)
|
||||
|
||||
assert_bool(_node("CatchedErrorsVBox").visible).is_true()
|
||||
|
||||
|
||||
func test_reopening_after_sync_shows_result_without_syncing_again() -> void:
|
||||
_runner.invoke("start_sync")
|
||||
_finish_sync(_empty_result())
|
||||
|
||||
_runner.invoke("start_sync")
|
||||
|
||||
assert_int(_server.count("/sync")).is_equal(1)
|
||||
assert_str(_node("SyncTitleLabel").text).is_equal("Sync Result")
|
||||
@@ -0,0 +1 @@
|
||||
uid://bvi8cyucyd8j4
|
||||
Reference in new issue
Block a user