diff --git a/server/apps/immich/src/api-v1/user/user.service.spec.ts b/server/apps/immich/src/api-v1/user/user.service.spec.ts index abed003833..9962752cae 100644 --- a/server/apps/immich/src/api-v1/user/user.service.spec.ts +++ b/server/apps/immich/src/api-v1/user/user.service.spec.ts @@ -1,5 +1,5 @@ import { UserEntity } from '@app/database/entities/user.entity'; -import { BadRequestException, NotFoundException } from '@nestjs/common'; +import { BadRequestException, NotFoundException, UnauthorizedException } from '@nestjs/common'; import { newUserRepositoryMock } from '../../../test/test-utils'; import { AuthUserDto } from '../../decorators/auth-user.decorator'; import { IUserRepository } from './user-repository'; @@ -127,5 +127,16 @@ describe('UserService', () => { }); expect(result).rejects.toBeInstanceOf(NotFoundException); }); + + it('cannot delete admin user', () => { + const requestor = adminAuthUser; + + userRepositoryMock.get.mockImplementationOnce(() => Promise.resolve(adminUser)); + userRepositoryMock.get.mockImplementationOnce(() => Promise.resolve(adminUser)); + + const result = sui.deleteUser(requestor, adminAuthUser.id); + + expect(result).rejects.toBeInstanceOf(BadRequestException); + }); }); });