code-dot-org / dance-party

Renderer for the Dance game type. Based on p5.js and p5.play.js.
https://code-dot-org.github.io/dance-party/
13 stars 13 forks source link

Handle invalid background/foreground effects #671

Closed sanchitmalhotra126 closed 12 months ago

sanchitmalhotra126 commented 12 months ago

Handle invalid background/foreground effects & palettes being set. This is pretty unlikely to happen, but if it does then we'd hit a crash trying to call init() on undefined. This could potentially occur, for example, if we accidentally change one of the AI outputs to an invalid value. This change will also log a warning to a supplied logger if it exists, which will look like:

Screenshot 2023-11-16 at 3 30 51 PM

Trello: https://trello.com/c/qUhwOQHI Pairs with: https://github.com/code-dot-org/code-dot-org/pull/54999

cnbrenci commented 12 months ago

Should we have some UTs to validate no crash?

sanchitmalhotra126 commented 12 months ago

Should we have some UTs to validate no crash?

Good call! I kind of just assumed we had no unit testing on this code and would need to follow up later to add tests, but looks like we do