Skip to content
This repository was archived by the owner on Jan 28, 2020. It is now read-only.

Conversation

amir-qayyum-khan
Copy link
Contributor

Hi

In this PR I wrote test cases for all reactjs classes i.e VocabularyComponent, TermComponent, AddTermsComponent, AddVocabulary, TaxonomyComponent

#322

@pdpinch @pwilkins @carsongee @noisecapella

@noisecapella
Copy link
Contributor

There will be some changes coming in regarding the javascript tests so you will need to adjust this PR after my PR is reviewed and merged (#309). Hopefully we'll get a good process nailed down soon for javascript unit tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you could move this and updateParent inside the test where they are being used. In general we want to define variables as close to their use as possible

@noisecapella
Copy link
Contributor

I also did some refactoring in PR #340 FYI, you may want to adjust your code accordingly. The most significant change is that state.terms was removed since it was a duplicate piece of state, a callback is used instead to update TaxonomyComponent

@noisecapella
Copy link
Contributor

One more thing, I noticed that the vocabulary type radio box is not covered by tests, and that failures of various AJAX calls are not covered either. You can look at test_learning_resources.jsx for examples of this.

Thanks for all your help!

@amir-qayyum-khan amir-qayyum-khan force-pushed the test/aq/unit_tests_manage_taxonomies branch 6 times, most recently from ee2d2c7 to 6e5e6f7 Compare July 14, 2015 13:07
@amir-qayyum-khan
Copy link
Contributor Author

@noisecapella please review, I think it is ready to merge

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable is used in two tests. Please create a local variable within each test instead. We want to limit global state as much as possible, especially given the complexity of our test framework. The way it is now, one test may affect another tests result which will make test failures hard to debug.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should move the rest of the code inside this function so that things are executed in proper order and done() is called only after everything else completes.

@noisecapella
Copy link
Contributor

Looks good overall, just address the code coverage comment I made and move the code around to avoid race conditions as indicated in my comments, and this should be good to go

@amir-qayyum-khan amir-qayyum-khan force-pushed the test/aq/unit_tests_manage_taxonomies branch 3 times, most recently from eed1c39 to f6bf38c Compare July 23, 2015 13:17
@amir-qayyum-khan
Copy link
Contributor Author

Done @noisecapella

@noisecapella
Copy link
Contributor

Unchecking the learning resource type checkbox is still uncovered. You should be able to test this case by just unchecking it with Simulate.change, use forceUpdate to wait for state change and verify that this.state.learningResourceTypes.length is 0

@amir-qayyum-khan
Copy link
Contributor Author

@noisecapella which test you are referring to, please tell me. I have added this check here https://github.com/mitodl/lore/pull/328/files#diff-0f3ee7bcc78eb4497e0092ea2083d2e5R801 for TaxonomyComponent

@amir-qayyum-khan
Copy link
Contributor Author

@noisecapella
Copy link
Contributor

I see the confusion, state.learningResourceTypes in TaxonomyComponent is a list of all available learning resource types but state.learningResourceTypes in AddVocabulary is a list of the currently checked learning resource types. You need to uncheck a learning resource type checkbox then verify that it is unchecked in state.learningResourceTypes in AddVocabulary.

You currently only check checkboxes which are previously unchecked so the code path that unchecks checkboxes is uncovered.

@amir-qayyum-khan
Copy link
Contributor Author

got it

@amir-qayyum-khan
Copy link
Contributor Author

Done @noisecapella

@amir-qayyum-khan amir-qayyum-khan force-pushed the test/aq/unit_tests_manage_taxonomies branch from f6bf38c to cdf14ff Compare July 24, 2015 08:18
@noisecapella
Copy link
Contributor

This is great, thanks for your help!

noisecapella added a commit that referenced this pull request Jul 24, 2015
Extended tests for manage_taxonomies.jsx file
@noisecapella noisecapella merged commit f074907 into master Jul 24, 2015
@noisecapella noisecapella deleted the test/aq/unit_tests_manage_taxonomies branch July 24, 2015 16:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants