feat(server,web): update email address (#1186)

* feat: change email

* test: change email
This commit is contained in:
Jason Rasmussen 2022-12-27 11:36:31 -05:00 committed by GitHub
parent fdf51a8855
commit 380f719fd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 72 additions and 9 deletions

View file

@ -102,6 +102,28 @@ describe('UserService', () => {
await expect(result).rejects.toBeInstanceOf(ForbiddenException);
});
it('should let a user change their email', async () => {
const dto = { id: immichUser.id, email: 'updated@test.com' };
userRepositoryMock.get.mockResolvedValue(immichUser);
userRepositoryMock.update.mockResolvedValue(immichUser);
await sut.updateUser(immichUser, dto);
expect(userRepositoryMock.update).toHaveBeenCalledWith(immichUser.id, { email: 'updated@test.com' });
});
it('should not let a user change their email to one already in use', async () => {
const dto = { id: immichUser.id, email: 'updated@test.com' };
userRepositoryMock.get.mockResolvedValue(immichUser);
userRepositoryMock.getByEmail.mockResolvedValue(adminUser);
await expect(sut.updateUser(immichUser, dto)).rejects.toBeInstanceOf(BadRequestException);
expect(userRepositoryMock.update).not.toHaveBeenCalled();
});
it('admin can update any user information', async () => {
const update: UpdateUserDto = {
id: immichUser.id,