Don't list unplayed songs on the statistics cards
Cards only list songs that have been played. With fewer than six played songs they are all listed as most played, so no song is listed twice. The soundtrack popup still lists every song. Closes #46
This commit is contained in:
1 parent
06f457b027
commit
cd4331881c
2 files changed
+69
-13
No files matched your search
@@ -12,6 +12,7 @@ const STATISTICS: Array[Dictionary] = [
|
||||
{"song_name": "To Far Away Times", "times_played": 0},
|
||||
{"song_name": "Schala's Theme", "times_played": 4},
|
||||
{"song_name": "Peaceful Days", "times_played": 1},
|
||||
{"song_name": "Zeal Palace", "times_played": 1},
|
||||
]},
|
||||
{"soundtrack_uuid": "st-2", "soundtrack_name": "Terranigma", "soundtrack_played": 0,
|
||||
"songs": [{"song_name": "Underworld", "times_played": 0}]},
|
||||
@@ -151,20 +152,48 @@ func test_card_shows_plays_last_played_and_most_and_least_played_songs() -> void
|
||||
assert_str(card.last_played_label.text).is_equal("Last played 2026-09-30")
|
||||
assert_array(_visible_texts(card.most_played_list)).contains_exactly(
|
||||
["4 × Schala's Theme", "3 × Frog's Theme", "2 × Battle with Magus"])
|
||||
# Songs never played are left out, so the least played are the least played of those
|
||||
assert_array(_visible_texts(card.least_played_list)).contains_exactly(
|
||||
["0 × To Far Away Times", "0 × Wind Scene", "1 × Corridors of Time"])
|
||||
["1 × Corridors of Time", "1 × Peaceful Days", "1 × Zeal Palace"])
|
||||
assert_bool(card.least_played_header.visible).is_true()
|
||||
|
||||
|
||||
func test_card_of_never_played_soundtrack() -> void:
|
||||
func test_card_of_never_played_soundtrack_lists_no_songs() -> void:
|
||||
await _open_statistics()
|
||||
var card: SoundtrackCard = _card("Terranigma")
|
||||
|
||||
assert_str(card.played_label.text).is_equal("Never played")
|
||||
assert_bool(card.last_played_label.visible).is_false()
|
||||
assert_array(_visible_texts(card.most_played_list)).contains_exactly(["0 × Underworld"])
|
||||
assert_str(card.most_played_header.text).is_equal("No songs played yet")
|
||||
assert_array(_visible_texts(card.most_played_list)).is_empty()
|
||||
assert_bool(card.least_played_header.visible).is_false()
|
||||
|
||||
|
||||
func test_card_with_one_played_song_lists_only_it() -> void:
|
||||
await _open_statistics()
|
||||
var card: SoundtrackCard = _card("Final Fantasy VI")
|
||||
|
||||
assert_str(card.most_played_header.text).is_equal("Most played")
|
||||
assert_array(_visible_texts(card.most_played_list)).contains_exactly(["1 × Dancing Mad"])
|
||||
assert_bool(card.least_played_header.visible).is_false()
|
||||
assert_array(_visible_texts(card.least_played_list)).is_empty()
|
||||
|
||||
|
||||
func test_card_with_fewer_than_six_played_songs_lists_them_all_as_most_played() -> void:
|
||||
var songs: Array[Dictionary] = [{"song_name": "Never", "times_played": 0}]
|
||||
for i: int in 5:
|
||||
songs.append({"song_name": "Song %d" % (i + 1), "times_played": i + 1})
|
||||
_server.respond_json("/statistics/soundtracks", [
|
||||
{"soundtrack_name": "Lufia II", "soundtrack_played": 15, "songs": songs}])
|
||||
await _open_statistics()
|
||||
var card: SoundtrackCard = _card("Lufia II")
|
||||
|
||||
assert_array(_visible_texts(card.most_played_list)).contains_exactly(
|
||||
["5 × Song 5", "4 × Song 4", "3 × Song 3", "2 × Song 2", "1 × Song 1"])
|
||||
assert_bool(card.least_played_header.visible).is_false()
|
||||
assert_array(_visible_texts(card.least_played_list)).is_empty()
|
||||
|
||||
|
||||
func test_card_without_songs() -> void:
|
||||
await _open_statistics()
|
||||
var card: SoundtrackCard = _card("earthbound")
|
||||
@@ -300,13 +329,14 @@ func test_clicking_a_card_shows_all_its_songs_most_played_first() -> void:
|
||||
assert_bool(popup.visible).is_true()
|
||||
assert_str(popup.title_label.text).is_equal("Chrono Trigger")
|
||||
assert_str(popup.summary_label.text) \
|
||||
.is_equal("Played 5 times · Last played 2026-09-30 · 7 songs")
|
||||
.is_equal("Played 5 times · Last played 2026-09-30 · 8 songs")
|
||||
var rows: Array[String] = []
|
||||
for row: ListRow in popup.song_list.get_children():
|
||||
rows.append(row.text)
|
||||
assert_array(rows).contains_exactly([
|
||||
"4 × Schala's Theme", "3 × Frog's Theme", "2 × Battle with Magus",
|
||||
"1 × Corridors of Time", "1 × Peaceful Days", "0 × To Far Away Times", "0 × Wind Scene",
|
||||
"1 × Corridors of Time", "1 × Peaceful Days", "1 × Zeal Palace",
|
||||
"0 × To Far Away Times", "0 × Wind Scene",
|
||||
])
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user