WikiEducationFoundation / WikiEduDashboard

Wiki Education Foundation's Wikipedia course dashboard system
https://dashboard.wikiedu.org
MIT License
392 stars 631 forks source link

Add Test for the assignments reducer #5966

Closed Formasitchijoh closed 1 month ago

Formasitchijoh commented 1 month ago

What this PR does

This PR addresses #2082 by adding comprehensive tests for the assignments reducer.

Files changed

Test

where ever the assignment reducer was used it was effectively tested so that is does not break existing code.

@ragesoss, @abhishekbvs , @gabina , When you have a chance, could you please review this? I'm happy to make any adjustments and ready to move on to the next reducers. or any other pressing issue,

Formasitchijoh commented 1 month ago

@ragesoss, I’d like to clarify something regarding the third test in this case. When multiple dispatches occur with the same data, should the sortKey be set to null for subsequent dispatches?

Currently, the sortByKey function nullifies the sortKey if it matches the previous key, which prevents it from being retained in the state. Should the sortKey remain null for these repeated dispatches, or should it persist for further operations?

Formasitchijoh commented 1 month ago

Hello @ragesoss just want to check in on this PR, Please let me know if there’s anything else I can do to help with the review process or if any changes are needed

ragesoss commented 1 month ago

Hello @ragesoss just want to check in on this PR, Please let me know if there’s anything else I can do to help with the review process or if any changes are needed

Thanks! I'll take a look at it today.

ragesoss commented 1 month ago

@ragesoss, I’d like to clarify something regarding the third test in this case. When multiple dispatches occur with the same data, should the sortKey be set to null for subsequent dispatches?

Currently, the sortByKey function nullifies the sortKey if it matches the previous key, which prevents it from being retained in the state. Should the sortKey remain null for these repeated dispatches, or should it persist for further operations?

Great question. The sortByKey function is a utility function we use for all the frontend sorting operations that we do on data corresponds to database records. It can take a sort key, along with a fallback default sort key. We use the sortKey behavior so that you can use UI controls to sort by a property and then reverse the sorting by passing the same key again. However, in this particular reducer, it only gets the RECEIVE_ASSIGNMENTS action with data from a single server endpoint, which does not have a sortKey, so the value is actually null in all cases for this reducer.

Formasitchijoh commented 1 month ago

@ragesoss I have updated the changes you requested, and also made some changes to the alert_actions.spec.js test because it was failing, I would appreciate your feedback on this change and how to improve it.