extends MainWindowTestSuite ## The About popup: the game's version history next to the server's. const HISTORY: Array[Dictionary] = [ {"version": "5.0.0", "changelog": ["Statistics for every soundtrack", "Tokens"]}, {"version": "4.5.0", "changelog": ["Download the newest player"]}, ] var _popup: AboutPopup func _before_window_starts() -> void: _server.respond_json("/version/history", HISTORY) func before_test() -> void: await super() _popup = _window.get_node("AboutPopup") func _open_with_top_bar_button() -> void: await _click_at((_window.get_node("TopBar/%AboutButton") as Control).get_global_rect() .get_center()) func test_about_button_opens_the_popup_and_clicking_outside_closes_it() -> void: await _open_with_top_bar_button() assert_bool(_popup.visible).is_true() await _click_at(Vector2(100, 1000)) assert_bool(_popup.visible).is_false() func test_shows_the_server_versions_in_the_servers_order() -> void: await _open_with_top_bar_button() assert_int(_server.count("/version/history")).is_equal(1) assert_str(_popup.server_version_label.text).is_equal("5.0.0") assert_str(_popup.server_history_label.text).is_equal( "5.0.0\nStatistics for every soundtrack\nTokens\n\n4.5.0\nDownload the newest player") func test_still_shows_the_games_own_versions() -> void: await _open_with_top_bar_button() assert_str(_popup.version_label.text).is_equal(Settings.version) var lines: PackedStringArray = _popup.whats_new_label.text.split("\n") for version: String in AboutPopup.WHATS_NEW: assert_bool(lines.has(version)).override_failure_message(version + " is missing") \ .is_true() assert_str(_popup.whats_new_label.text).starts_with(AboutPopup.WHATS_NEW.keys()[0] + "\n") func test_columns_sit_side_by_side_in_the_window() -> void: await _open_with_top_bar_button() var game: Rect2 = _popup.find_child("PlayerHeader").get_global_rect() var server: Rect2 = _popup.find_child("ServerHeader").get_global_rect() assert_float(server.position.x).is_greater(game.end.x) assert_float(server.position.y).is_equal(game.position.y) assert_bool(Rect2(Vector2.ZERO, Vector2(1920, 1080)).encloses( _popup.about_panel.get_global_rect())).is_true() func test_server_error_says_so() -> void: _server.respond_json("/version/history", {"error": "Internal Server Error"}, 500) await _open_with_top_bar_button() assert_str(_popup.server_version_label.text).is_equal("Could not reach the server") assert_str(_popup.server_history_label.text).is_empty() func test_shows_loading_until_the_server_answers() -> void: _server.hold("/version/history") await _open_with_top_bar_button() assert_str(_popup.server_version_label.text).is_equal("Loading…") _server.release("/version/history") assert_str(_popup.server_version_label.text).is_equal("5.0.0") func test_opening_again_asks_the_server_again() -> void: _popup.open() _popup.close() _popup.open() assert_int(_server.count("/version/history")).is_equal(2) func test_description_is_centred_above_both_columns() -> void: await _open_with_top_bar_button() var description: Label = _popup.find_child("DescriptionLabel") assert_object(description.get_parent()).is_same(_popup.about_panel) assert_int(description.horizontal_alignment).is_equal(HORIZONTAL_ALIGNMENT_CENTER) assert_float(description.get_global_rect().end.y) \ .is_less_equal(_popup.find_child("PlayerHeader").get_global_rect().position.y) assert_float(description.get_global_rect().get_center().x) \ .is_equal_approx(_popup.about_panel.get_global_rect().get_center().x, 1.0)