-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: admin update super admin status
- Loading branch information
1 parent
2832681
commit 37d6272
Showing
5 changed files
with
89 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsBoolean, IsDate, IsEmail, IsOptional, IsString } from 'class-validator'; | ||
import { EMAIL_REMINDERS_FREQUENCY } from '../../utils/constants'; | ||
|
||
export class AdminUpdateUserDto { | ||
@IsString() | ||
@IsOptional() | ||
@ApiProperty({ type: String }) | ||
name: string; | ||
|
||
@IsBoolean() | ||
@IsOptional() | ||
@ApiProperty({ type: Boolean }) | ||
contactPermission: boolean; | ||
|
||
@IsBoolean() | ||
@IsOptional() | ||
@ApiProperty({ type: Boolean }) | ||
serviceEmailsPermission: boolean; | ||
|
||
@IsOptional() | ||
@IsString() | ||
@ApiProperty({ type: String }) | ||
emailRemindersFrequency: EMAIL_REMINDERS_FREQUENCY; | ||
|
||
@IsString() | ||
@IsOptional() | ||
@ApiProperty({ type: String }) | ||
signUpLanguage: string; | ||
|
||
@IsDate() | ||
@IsOptional() | ||
@ApiProperty({ type: 'date' }) | ||
lastActiveAt: Date; | ||
|
||
@IsEmail({}) | ||
@IsOptional() | ||
@ApiProperty({ type: 'email' }) | ||
email: string; | ||
|
||
@IsBoolean({}) | ||
@IsOptional() | ||
@ApiProperty({ type: 'boolean' }) | ||
isSuperAdmin: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ import { createQueryBuilderMock } from '../../test/utils/mockUtils'; | |
import { AuthService } from '../auth/auth.service'; | ||
import { UserEntity } from '../entities/user.entity'; | ||
import { PartnerAccessService } from '../partner-access/partner-access.service'; | ||
import { AdminUpdateUserDto } from './dtos/admin-update-user.dto'; | ||
import { CreateUserDto } from './dtos/create-user.dto'; | ||
import { UpdateUserDto } from './dtos/update-user.dto'; | ||
import { UserService } from './user.service'; | ||
|
@@ -542,4 +543,19 @@ describe('UserService', () => { | |
expect(users).toEqual([{ ...mockUserEntity, email: '[email protected]' }]); | ||
}); | ||
}); | ||
|
||
describe('adminUpdateUser', () => { | ||
it("should update user's superAdmin status", async () => { | ||
const user = mockUserEntity; | ||
const userSaveSpy = jest.spyOn(repo, 'save').mockImplementationOnce(async () => { | ||
return user; | ||
}); | ||
const updatedUser = await service.adminUpdateUser( | ||
{ isSuperAdmin: true } as AdminUpdateUserDto, | ||
user.id, | ||
); | ||
expect(updatedUser).toHaveProperty('isSuperAdmin', true); | ||
expect(userSaveSpy).toHaveBeenCalled(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters