diff --git a/apps/server/src/modules/user-login-migration/service/user-login-migration.service.spec.ts b/apps/server/src/modules/user-login-migration/service/user-login-migration.service.spec.ts index 17dcd716c54..0edaf9d1a38 100644 --- a/apps/server/src/modules/user-login-migration/service/user-login-migration.service.spec.ts +++ b/apps/server/src/modules/user-login-migration/service/user-login-migration.service.spec.ts @@ -525,7 +525,7 @@ describe(UserLoginMigrationService.name, () => { const setup = () => { const userLoginMigration: UserLoginMigrationDO = userLoginMigrationDOFactory.buildWithId({ startedAt: mockedDate, - mandatorySince: mockedDate, + mandatorySince: undefined, }); userLoginMigrationRepo.save.mockResolvedValue(userLoginMigration); @@ -540,7 +540,10 @@ describe(UserLoginMigrationService.name, () => { await service.setMigrationMandatory(userLoginMigration, true); - expect(userLoginMigrationRepo.save).toHaveBeenCalledWith(userLoginMigration); + expect(userLoginMigrationRepo.save).toHaveBeenCalledWith({ + ...userLoginMigration, + mandatorySince: mockedDate, + }); }); }); @@ -548,7 +551,7 @@ describe(UserLoginMigrationService.name, () => { const setup = () => { const userLoginMigration: UserLoginMigrationDO = userLoginMigrationDOFactory.buildWithId({ startedAt: mockedDate, - mandatorySince: undefined, + mandatorySince: mockedDate, }); return { @@ -559,9 +562,12 @@ describe(UserLoginMigrationService.name, () => { it('should call save the user login migration', async () => { const { userLoginMigration } = setup(); - await service.setMigrationMandatory(userLoginMigration, true); + await service.setMigrationMandatory(userLoginMigration, false); - expect(userLoginMigrationRepo.save).toHaveBeenCalledWith(userLoginMigration); + expect(userLoginMigrationRepo.save).toHaveBeenCalledWith({ + ...userLoginMigration, + mandatorySince: undefined, + }); }); }); diff --git a/apps/server/src/modules/user-login-migration/uc/start-user-login-migration.uc.ts b/apps/server/src/modules/user-login-migration/uc/start-user-login-migration.uc.ts index 97199182f0a..1bf47635d83 100644 --- a/apps/server/src/modules/user-login-migration/uc/start-user-login-migration.uc.ts +++ b/apps/server/src/modules/user-login-migration/uc/start-user-login-migration.uc.ts @@ -1,7 +1,7 @@ import { AuthorizationContext, AuthorizationContextBuilder, AuthorizationService } from '@modules/authorization'; import { LegacySchoolService } from '@modules/legacy-school'; import { Injectable } from '@nestjs/common/decorators/core/injectable.decorator'; -import { LegacySchoolDo, Permission, User, UserLoginMigrationDO } from '@shared/domain'; +import { EntityId, LegacySchoolDo, Permission, User, UserLoginMigrationDO } from '@shared/domain'; import { Logger } from '@src/core/logger'; import { SchoolNumberMissingLoggableException, @@ -21,7 +21,7 @@ export class StartUserLoginMigrationUc { this.logger.setContext(StartUserLoginMigrationUc.name); } - async startMigration(userId: string, schoolId: string): Promise { + async startMigration(userId: EntityId, schoolId: EntityId): Promise { await this.checkPreconditions(userId, schoolId); let userLoginMigration: UserLoginMigrationDO | null = await this.userLoginMigrationService.findMigrationBySchool(