refactor: deduplicate unit test support functions (#323) - #328
Open
smigiska wants to merge 1 commit into
Open
Conversation
Contributor
|
Looks like you did not link an issue to this PR. If this PR completes a task, consider linking it. |
smigiska
force-pushed
the
refactor/deduplicate-test-support-functions
branch
from
July 16, 2026 20:55
9913c65 to
edde204
Compare
mini-bomba
reviewed
Jul 27, 2026
mini-bomba
left a comment
Member
There was a problem hiding this comment.
🔥, but i've got a few suggestions
| ): Promise<{ user: User; token: string }> { | ||
| const user = await User.create({ | ||
| email: uniqueEmail(prefix), | ||
| password: "Passw0rd!", |
Member
There was a problem hiding this comment.
minor suggestion: maybe generate a random password and return it along with the user object & token?
Comment on lines
+34
to
+38
| const { user: u1, token: t1 } = await createUserWithToken( | ||
| uniqueEmail, | ||
| "u1", | ||
| "User 1", | ||
| ); |
Member
There was a problem hiding this comment.
passing in a function that generates email addresses seems weird
imo we can drop the idea of using separate fake domains per test file - the emails contain a random string anyway, they shouldn't collide.
| "User 8", | ||
| ); | ||
|
|
||
| await user.refresh(); |
Member
There was a problem hiding this comment.
why is this refresh here? it should probably be a part of the utility function if the function returns a bad user object without this
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.
Extracted repeated helper functions (uniqueEmail, makeToken, ensureSolvroAdminRoleId, assignSolvroAdmin) from drafts_acl.spec.ts, permissions.spec.ts, permissions_cleanup.spec.ts, and users_management.spec.ts into a shared auth_helpers.ts module, imported wherever needed.
Also added createUserWithToken / createAdminWithToken helpers to reduce repeated "create user + get token" boilerplate across the same test files.
CLOSES: #323