Part of #41. The top bar has Quiz and Statistics tabs instead of the Statistics button. The Statistics tab replaces the quiz below the top bar (the song keeps playing) and shows every soundtrack as a card with its plays, last played date and most and least played songs, loaded from the new GET /api/v1/statistics/soundtracks. The cards can be searched (with the Search popup's matching, now in SoundtrackSearch), filtered on played or never played, and sorted A-Z, Z-A, most or least played. Clicking a card opens a popup with all its songs. Screenshots of the other states only differ in the top bar, and the layout baseline is taken again with the new statistics states.
79 lines
2.3 KiB
GDScript
79 lines
2.3 KiB
GDScript
extends GdUnitTestSuite
|
|
## How SoundtrackSearch, used by the Search popup and the statistics view, finds and
|
|
## orders matching soundtracks.
|
|
|
|
var _search: SoundtrackSearch
|
|
|
|
|
|
func before_test() -> void:
|
|
_search = SoundtrackSearch.new()
|
|
_search.set_names([
|
|
"Chrono Trigger",
|
|
"Final Fantasy VI",
|
|
"Mario & Luigi: Superstar Saga",
|
|
"Pokémon Red",
|
|
"Q*bert",
|
|
"Super Mario 64",
|
|
"The Legend of Zelda: A Link to the Past",
|
|
])
|
|
|
|
|
|
func test_plain_text_matches_case_insensitively() -> void:
|
|
assert_array(_search.find_matches("chrono")).contains_exactly(["Chrono Trigger"])
|
|
|
|
|
|
func test_contains_matches_come_before_letter_order_matches() -> void:
|
|
var matches: Array[String] = _search.find_matches("mario")
|
|
|
|
assert_array(matches).contains_exactly([
|
|
"Mario & Luigi: Superstar Saga",
|
|
"Super Mario 64",
|
|
])
|
|
|
|
|
|
func test_ignores_spaces() -> void:
|
|
assert_array(_search.find_matches("finalfantasy")).contains_exactly(["Final Fantasy VI"])
|
|
|
|
|
|
func test_and_matches_ampersand() -> void:
|
|
assert_array(_search.find_matches("mario and luigi")) \
|
|
.contains(["Mario & Luigi: Superstar Saga"])
|
|
|
|
|
|
func test_accented_letters_match_plain_letters() -> void:
|
|
assert_array(_search.find_matches("pokemon")).contains_exactly(["Pokémon Red"])
|
|
|
|
|
|
func test_letters_in_order_match_abbreviations() -> void:
|
|
assert_array(_search.find_matches("lozlttp")).contains_exactly([
|
|
"The Legend of Zelda: A Link to the Past",
|
|
])
|
|
|
|
|
|
func test_regex_characters_are_matched_literally() -> void:
|
|
assert_array(_search.find_matches("q*b")).contains_exactly(["Q*bert"])
|
|
|
|
|
|
func test_no_matches() -> void:
|
|
assert_array(_search.find_matches("metroid")).is_empty()
|
|
|
|
|
|
func test_clean_term() -> void:
|
|
assert_str(SoundtrackSearch.clean_term("Rock 'n Roll Racing")).is_equal("rockandrollracing")
|
|
assert_str(SoundtrackSearch.clean_term("Ys I & II")).is_equal("ysiandii")
|
|
|
|
|
|
func test_search_popup_searches_with_soundtrack_search() -> void:
|
|
var popup: SearchPopup = auto_free(load("res://popups/SearchPopup.tscn").instantiate())
|
|
add_child(popup)
|
|
popup.set_soundtracks(["Chrono Trigger", "Super Mario 64"])
|
|
popup.show_all_soundtracks()
|
|
|
|
popup.perform_search("smr")
|
|
|
|
var shown: Array[String] = []
|
|
for label: Label in popup.search_list.get_children():
|
|
if label.visible:
|
|
shown.append(label.text)
|
|
assert_array(shown).contains_exactly(["Super Mario 64"])
|