Simplify tests - #1464
Open
Archinowsk wants to merge 19 commits into
Open
Simplify tests#1464Archinowsk wants to merge 19 commits into
Archinowsk wants to merge 19 commits into
Conversation
Every controller test spelled out the Authorization header with getJWT inline, 144 times. The helper returns the header object so a request reads .set(authorizedAs(group, username)).
Eight test files built and registered the mocked notification queue the same way, and the two that read it back went through the nullable global getter with a non-null assertion each time. The helper returns the queue so tests hold it directly.
programItemRepository tests spelled out the lottery-close arithmetic seven times, on both sides of the close. The existing before-lottery helper covers one side and the new one the other.
Two concurrency tests each declared an identical local request builder.
The Sentry tunnel and transport tests each wrapped a retrying call in the same fake-timer try/finally.
Twenty-six tests stubbed the event config's startTimesByParentIds map with the same five-line spy. The helper takes the program item and the batch time.
The padg and random test files were identical apart from the algorithm, and the random+padg file repeated two of their cases. The four generic cases now run through a describe.each in runAssignment.test.ts and the two duplicate files are gone.
Every bonus case built the same getList call and expected the same list item shape, so the twenty cases are now rows that name only the group, who holds a previous direct sign-up, and the gain.
The test file spelled out direct sign-up and event log item literals that the assignment test utils already build. getPreviousDirectSignup takes a signed-to time now and getEventLogItem is new.
saveAndNotify now loads the stored users and program items itself instead of every case reading them first, usersWithEventLogAction replaces the repeated event log filter, and findProgramItemSignups replaces the find over all direct sign-ups that forty tests spelled out.
Twenty-seven tests wrote the same lottery result literal by hand. The builder takes the user, the program item and the priority.
populateDb with clean set wipes the database itself, so the clearDb before it was a second wipe and an extra round-trip in twenty-five tests.
Nineteen specs spread the fixture into a lottery program item with the same three keys and thirty computed its end time the same way.
Two specs each built their own independent HH:mm formatter and a third asserted against the app's own formatter, which would move with the bug it is meant to catch.
Five clock-driven specs jumped by a literal "01:01" and only one of them said why.
programPhase and programDateDisplay seeded the same two program items with duplicated code, and programPhase pinned them to absolute dates against the suite's own convention.
Forty-two tests differed only in a start time and the sign-up time expected for it, so each group is now rows over one body. The two config spreads inside the file now start from its base config like the rest.
The EN and FI describes repeated the same four tables with different strings, and the relative time strings sat in two 24-assertion tests. Both are rows over one body now, so a failure names the case.
Seven tests shared the same start time and assertions and differed only in one override and the expected verdict.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Simplify tests