WikiEducationFoundation / WikiEduDashboard

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

Write tests for Redux reducers that cover all action types and ensure that state is not mutated #2082

Open ragesoss opened 6 years ago

ragesoss commented 6 years ago

The reducers that make up the main Redux reducer should all be pure functions that are free of side effects and do not mutate their inputs. This makes unit tests particularly easy to implement, but important for making sure we avoid state-mutation bugs.

The handful of existing specs in test/reducers offer clear examples for how individual actions can be tested for these reducers, with deepFreeze being called on the initial state to guarantee that nothing in the reducer is mutating it.

Choose one or more reducers, and add tests for the functionality of each action type supported by that reducer. This should be done one reducer per commit. If you're working on this, please post a comment to say which reducer you're working on, so that others can work on different reducers.

Ideally, the set of tests for each reducer will provide 100% coverage of that reducer. You can check the coverage by running npm test and then opening coverage/lcov-report/index.html, which includes coverages maps of each javascript file.

sunny-lan commented 5 years ago

(GCI 2018)

I'll be making tests for uploads.js

sunny-lan commented 5 years ago

Is it possible to get the tests working without setting up the whole env? I tried just doing yarn and gulp to build, but that results in a large amount of errors from gulp concerning bundler (I have bundler installed)

ragesoss commented 5 years ago

@sunny-lan you must do bundle install before gulp will run, because one of the steps in the gulp pipeline involves calling the ruby script that generates the JS versions of the interface message translations.

ragesoss commented 5 years ago

That said, I don't think the javascript tests even depend on generating the assets. If you did yarn and it ran without error, you should be able to do yarn test to just run the jest tests.

kagehina919 commented 5 years ago

@ragesoss can I work on adding some of the tests? I have set up the development environment (and opened a PR for #2197).

AZReed commented 5 years ago

I'll take user related reducers: user_profile user_revisions user_training_status user

If someone is doing these let me know.

ragesoss commented 2 years ago

Here's what the current coverage on the reducers looks like: reducer coverage

shruti862 commented 10 months ago

@ragesoss I want to work for adding test for some of the reducers. Plz assign this issue to me.

fillingtothemomo commented 9 months ago

@ragesoss I would like to pick up this issue, can you assign it to me.

ragesoss commented 9 months ago

We do not assign issues, but you can choose a reducer and work on it.

zhjiang1103 commented 8 months ago

@ragesoss I opened a PR for the correction I did. Could you please confirm if my correction meets your approval? Once confirmed, I'll proceed to begin implementing tests for reducers.

FormasitChijoh324 commented 3 weeks ago

Greetings, @ragesoss i will like to take the active_courses reducer,

DanAletor commented 1 week ago

Hi @ragesoss I would love to work on this

ragesoss commented 1 week ago

Hi @ragesoss I would love to work on this

Per the issue instructions, please post which one you're working on so that others can choose different reducers.

DanAletor commented 1 day ago

Hi @ragesoss I would love to work on this

Per the issue instructions, please post which one you're working on so that others can choose different reducers.

articles.js is what I want to work on now