amplitudejs icon indicating copy to clipboard operation
amplitudejs copied to clipboard

Fix player breaking when `starting_playlist_song is `0`

Open janlucaklees opened this issue 5 years ago • 0 comments

As mentioned in #407 the player breaks and is unusable, when supplying a starting_playlist_song that is (int) 0.

To alleviate this issue, I adapted the way playlists get initialized and covered my chagnes with tests.

What has changed?

Basically, we now check more closely if the supplied values for starting_playlist and starting_playlist_song are valid. We not check their type and value, but also validate them against the playlist data. So an non existing starting_playlist_song index is as invalid as a NaN for example.

What was adapted to make this change possible?

In order to write tests that could check a larger variety of cases, I needed to adapt the way test data was initalized, so that I could supply my own values. I also adapted the function that resets the configuration after each test in a similar way. But in hind sight that was not necessary.

The newly added test are partially redundant with some existing ones that check the initialization of the playlists. Also I think it might make sense to move all playlist tests from the tests/index.test.js file to the newly added tests/playlist/init.test.js file for an easier to graps structure. But I didn't want to change things around so much without asking. If requested I'll move the playlist tests as mentioned.

More details can be found in the commit messages.

janlucaklees avatar Jun 07 '20 14:06 janlucaklees