Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AdminController Test Suite (acmucsd#187)
* Add tests for "/bonus" and "/emails" routes Squashed set of commits for 6f51db8...c70e444. Merge conflict was on package-lock, which was hard to fix, so I just redid the commits. * nit: "proxyUser" -> "adminUser" for admin tests * Adjust array equality checks on admin tests * Remove test for non-present emails Test is not necessary due to lack of filtering in original controller. * Inline functions and variables in admin tests * Modify test to check bonus points for all users * Combine both bonus points tests into one Tests had basically the same boilerplate. Combine them to check both conditions at once. The test already checked if we were adding bonus point to _specifically_ the emails we passed in, so it's best to also check if an extra user wasn't included at the same time. * Rearrange asserts to suffix response calls * Rename adminUser to admin in admin test suite * Adjust order of assertions in admin test * Adjust name of extraneous user in admin test * Make variable for UserController in admin test Inlining UserController made one line too long. Since it is used multiple times in the test, extract variable to make its usage less verbose. * Fix nits and check attendance response details * Check for correct activities in admin test suite * Add points field of ActivityModel in test suite ActivityModel is missing the `pointsEarned` field whenever creating an Activity after attending an event. This only happens in our mock tester. Add a check for this field's presence, along with fixing the inherent bug within the mock state. * Port EventFactory code from acmucsd#181 Code from acmucsd#181 adds ability to fake events in the past, future or present. Taken verbatim from commit 18a952c. * Adjust test suite to account for factory bug Account creation can occur after event attendance, causing activities to be out of order chronologically. Guarantee order in activities by introducing retroactive attendance in a future event. Bug in factory is not a reproducible issue in production, since account creation will always occur before event attendance in real time. * Revert event factory code changes * Adjust transaction order when saving factory state Mock factory `write` function incorrectly saves attendance before any possible activities, typically causing event attendances to be stored in the database prior to activities being stored. Adjust order of flushing to database in order to consistently set smaller timestamps for account-related activities, such as account creation. * Revert transaction order adjustment This reverts commit b5f03dc. Tests continue to be non-deterministic despite this change. My assumption was wrong. * Guarantee correct activity order in failed tests Create users at beginning of the Unix epoch to ensure guarantee of event attendance activity being second is fulfilled. Since Activities are sorted by timestamp, we need to guarantee account creation does not occur before attendance of event. Fix issue with above workaround, providing explicit method whenever necessary. * Merge user creation methods to have optional args Rather than having two explicit methods, merge methods and use optional timestamp argument to allow for custom creation of users at explicit times. * Adjust user creation method to have set timestamp Use specified timestamp of 1 month before current time to place account creation in time before most activities for testing. * Fix argument call for creating users in test suite Co-authored-by: Matei-Alexandru Gardus <[email protected]>
- Loading branch information