Fix seeding perf + batch role targets creation (#16337)

This commit is contained in:
Weiko
2025-12-04 20:29:48 +01:00
committed by GitHub
parent e653385485
commit 1991ee850e
11 changed files with 156 additions and 110 deletions
@@ -110,7 +110,7 @@ describe('UserWorkspaceService', () => {
{
provide: UserRoleService,
useValue: {
assignRoleToUserWorkspace: jest.fn(),
assignRoleToManyUserWorkspace: jest.fn(),
},
},
{
@@ -417,7 +417,7 @@ describe('UserWorkspaceService', () => {
jest.spyOn(service, 'create').mockResolvedValue(userWorkspace);
jest.spyOn(service, 'createWorkspaceMember').mockResolvedValue(undefined);
jest
.spyOn(userRoleService, 'assignRoleToUserWorkspace')
.spyOn(userRoleService, 'assignRoleToManyUserWorkspace')
.mockResolvedValue(undefined);
jest
.spyOn(workspaceInvitationService, 'invalidateWorkspaceInvitation')
@@ -439,9 +439,11 @@ describe('UserWorkspaceService', () => {
workspace.id,
user,
);
expect(userRoleService.assignRoleToUserWorkspace).toHaveBeenCalledWith({
expect(
userRoleService.assignRoleToManyUserWorkspace,
).toHaveBeenCalledWith({
workspaceId: workspace.id,
userWorkspaceId: userWorkspace.id,
userWorkspaceIds: [userWorkspace.id],
roleId: workspace.defaultRoleId,
});
expect(
@@ -157,9 +157,9 @@ export class UserWorkspaceService extends TypeOrmQueryService<UserWorkspaceEntit
);
}
await this.userRoleService.assignRoleToUserWorkspace({
await this.userRoleService.assignRoleToManyUserWorkspace({
workspaceId: workspace.id,
userWorkspaceId: userWorkspace.id,
userWorkspaceIds: [userWorkspace.id],
roleId: defaultRoleId,
});