-
Notifications
You must be signed in to change notification settings - Fork 5
Hotfix - Email fix for PS-455 #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,11 +139,13 @@ const mockEventService: jest.Mocked<Partial<EventService>> = { | |
| }; | ||
|
|
||
| const memberUpdateMock = jest.fn(); | ||
| const memberUpdateManyMock = jest.fn(); | ||
| const mockMemberPrisma: any = { | ||
| // Only the parts used by UserService need to be mocked | ||
| member: { | ||
| create: jest.fn(), | ||
| update: memberUpdateMock, | ||
| updateMany: memberUpdateManyMock, | ||
| }, | ||
| }; | ||
|
|
||
|
|
@@ -1565,6 +1567,7 @@ describe('UserService', () => { | |
| jest.clearAllMocks(); | ||
|
|
||
| memberUpdateMock.mockResolvedValue(undefined); | ||
| memberUpdateManyMock.mockResolvedValue({ count: 1 }); | ||
|
|
||
| // Mock checkEmailAvailabilityForUser | ||
| mockCheckEmail = jest | ||
|
|
@@ -1656,8 +1659,8 @@ describe('UserService', () => { | |
| { userId: 1, handle: 'testuser' }, | ||
| ); | ||
| expect(result).toEqual(mockUser); | ||
| expect(memberUpdateMock).toHaveBeenCalledWith({ | ||
| where: { userId }, | ||
| expect(memberUpdateManyMock).toHaveBeenCalledWith({ | ||
| where: { userId: BigInt(userId) }, | ||
| data: { email: newEmail.toLowerCase() }, | ||
| }); | ||
| }); | ||
|
|
@@ -1892,7 +1895,7 @@ describe('UserService', () => { | |
| }, | ||
| ); | ||
|
|
||
| memberUpdateMock.mockRejectedValueOnce( | ||
| memberUpdateManyMock.mockRejectedValueOnce( | ||
| new Error('Member update failed'), | ||
| ); | ||
|
|
||
|
|
@@ -1903,8 +1906,8 @@ describe('UserService', () => { | |
| ); | ||
|
|
||
| expect(result).toEqual(mockUser); | ||
| expect(memberUpdateMock).toHaveBeenCalledWith({ | ||
| where: { userId }, | ||
| expect(memberUpdateManyMock).toHaveBeenCalledWith({ | ||
| where: { userId: BigInt(userId) }, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| data: { email: newEmail.toLowerCase() }, | ||
| }); | ||
| expect(loggerErrorSpy).toHaveBeenCalledWith( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1558,17 +1558,18 @@ export class UserService { | |
| } | ||
|
|
||
| if (emailChanged) { | ||
| const memberUserId = BigInt(userId); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| try { | ||
| await this.memberPrisma.member.update({ | ||
| where: { userId }, | ||
| const updateResult = await this.memberPrisma.member.update({ | ||
| where: { userId: memberUserId }, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [💡 |
||
| data: { email: normalizedEmail }, | ||
| }); | ||
| this.logger.log( | ||
| `Updated members.member email to ${normalizedEmail} for user ${userId}`, | ||
| `Updated members.member email to ${normalizedEmail} for user ${memberUserId}`, | ||
| ); | ||
| } catch (error) { | ||
| this.logger.error( | ||
| `Failed to update members.member email for user ${userId}: ${error.message}`, | ||
| `Failed to update members.member email for user ${memberUserId}: ${error.message}`, | ||
| error.stack, | ||
| ); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[⚠️
correctness]The use of
BigIntforuserIdin thewhereclause is inconsistent with other parts of the code whereuserIdis used as a number. Ensure that the data type is consistent across the application to avoid potential type-related issues.