Skip to content

Commit

Permalink
N21-1447 review fixes 3
Browse files Browse the repository at this point in the history
  • Loading branch information
arnegns committed Nov 14, 2023
1 parent 50fb935 commit c4b3105
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ describe(UserLoginMigrationService.name, () => {
const setup = () => {
const userLoginMigration: UserLoginMigrationDO = userLoginMigrationDOFactory.buildWithId({
startedAt: mockedDate,
mandatorySince: mockedDate,
mandatorySince: undefined,
});

userLoginMigrationRepo.save.mockResolvedValue(userLoginMigration);
Expand All @@ -540,15 +540,18 @@ describe(UserLoginMigrationService.name, () => {

await service.setMigrationMandatory(userLoginMigration, true);

expect(userLoginMigrationRepo.save).toHaveBeenCalledWith(userLoginMigration);
expect(userLoginMigrationRepo.save).toHaveBeenCalledWith({
...userLoginMigration,
mandatorySince: mockedDate,
});
});
});

describe('when migration is set to optional', () => {
const setup = () => {
const userLoginMigration: UserLoginMigrationDO = userLoginMigrationDOFactory.buildWithId({
startedAt: mockedDate,
mandatorySince: undefined,
mandatorySince: mockedDate,
});

return {
Expand All @@ -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,
});
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -21,7 +21,7 @@ export class StartUserLoginMigrationUc {
this.logger.setContext(StartUserLoginMigrationUc.name);
}

async startMigration(userId: string, schoolId: string): Promise<UserLoginMigrationDO> {
async startMigration(userId: EntityId, schoolId: EntityId): Promise<UserLoginMigrationDO> {
await this.checkPreconditions(userId, schoolId);

let userLoginMigration: UserLoginMigrationDO | null = await this.userLoginMigrationService.findMigrationBySchool(
Expand Down

0 comments on commit c4b3105

Please sign in to comment.