Skip to content

Simplify tests - #1464

Open
Archinowsk wants to merge 19 commits into
mainfrom
simplify-tests
Open

Archinowsk wants to merge 19 commits into
mainfrom
simplify-tests

Conversation

@Archinowsk

Copy link
Copy Markdown
Contributor

Simplify tests

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant