refactor: Fetch role and permissions for current user in create connection tests
This commit is contained in:
@@ -29,6 +29,17 @@ describe('POST /api/v1/apps/:appKey/connections', () => {
|
||||
|
||||
currentUser = await createUser({ roleId: role.id });
|
||||
|
||||
currentUser = await currentUser
|
||||
.$query()
|
||||
.leftJoinRelated({
|
||||
role: true,
|
||||
permissions: true,
|
||||
})
|
||||
.withGraphFetched({
|
||||
role: true,
|
||||
permissions: true,
|
||||
});
|
||||
|
||||
token = await createAuthTokenByUserId(currentUser.id);
|
||||
});
|
||||
|
||||
|
@@ -10,17 +10,5 @@ export const createUser = async (params = {}) => {
|
||||
|
||||
const user = await User.query().insertAndFetch(params);
|
||||
|
||||
// important to mimic request.currentUser functionality.
|
||||
const userWithRoleAndPermissions = await user
|
||||
.$query()
|
||||
.leftJoinRelated({
|
||||
role: true,
|
||||
permissions: true,
|
||||
})
|
||||
.withGraphFetched({
|
||||
role: true,
|
||||
permissions: true,
|
||||
});
|
||||
|
||||
return userWithRoleAndPermissions;
|
||||
return user;
|
||||
};
|
||||
|
Reference in New Issue
Block a user