-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #378 from internxt/feat/update-b2b-subscription
[PB-2387]: fix/upgrade or downgrade b2b plans
- Loading branch information
Showing
7 changed files
with
175 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
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 |
---|---|---|
|
@@ -95,7 +95,7 @@ describe('GatewayUseCases', () => { | |
it('When user is not found, then it should throw', async () => { | ||
jest.spyOn(userRepository, 'findByUuid').mockResolvedValueOnce(null); | ||
await expect( | ||
service.updateWorkspaceStorage(v4(), maxSpaceBytes), | ||
service.updateWorkspaceStorage(v4(), maxSpaceBytes, 4), | ||
).rejects.toThrow(BadRequestException); | ||
}); | ||
|
||
|
@@ -104,7 +104,7 @@ describe('GatewayUseCases', () => { | |
jest.spyOn(workspaceUseCases, 'findOne').mockResolvedValueOnce(null); | ||
|
||
await expect( | ||
service.updateWorkspaceStorage(owner.uuid, maxSpaceBytes), | ||
service.updateWorkspaceStorage(owner.uuid, maxSpaceBytes, 4), | ||
).rejects.toThrow(NotFoundException); | ||
}); | ||
|
||
|
@@ -117,11 +117,13 @@ describe('GatewayUseCases', () => { | |
bridgeUser: workspaceUserEmail, | ||
}, | ||
}); | ||
const numberOfSeats = 4; | ||
const workspace = newWorkspace({ | ||
owner, | ||
attributes: { | ||
ownerId: owner.uuid, | ||
workspaceUserId: workspaceUser.uuid, | ||
numberOfSeats, | ||
}, | ||
}); | ||
|
||
|
@@ -134,12 +136,72 @@ describe('GatewayUseCases', () => { | |
.spyOn(workspaceUseCases, 'findOne') | ||
.mockResolvedValueOnce(workspace); | ||
|
||
await service.updateWorkspaceStorage(owner.uuid, maxSpaceBytes); | ||
await service.updateWorkspaceStorage( | ||
owner.uuid, | ||
maxSpaceBytes, | ||
numberOfSeats, | ||
); | ||
|
||
expect(networkService.setStorage).toHaveBeenCalledWith( | ||
workspaceUserEmail, | ||
maxSpaceBytes, | ||
); | ||
|
||
expect( | ||
workspaceUseCases.changeWorkspaceMembersStorageLimit, | ||
).toHaveBeenCalledWith(workspace.id, maxSpaceBytes / numberOfSeats); | ||
}); | ||
|
||
it('When owner and workspaces are found and a diferent number of seats is received, then it should update the workspaces completed', async () => { | ||
const workspaceUserEmail = '[email protected]'; | ||
const workspaceUser = newUser({ | ||
attributes: { | ||
email: workspaceUserEmail, | ||
username: workspaceUserEmail, | ||
bridgeUser: workspaceUserEmail, | ||
}, | ||
}); | ||
const numberOfSeats = 4; | ||
const workspace = newWorkspace({ | ||
owner, | ||
attributes: { | ||
ownerId: owner.uuid, | ||
workspaceUserId: workspaceUser.uuid, | ||
numberOfSeats: 3, | ||
}, | ||
}); | ||
|
||
jest | ||
.spyOn(userRepository, 'findByUuid') | ||
.mockResolvedValueOnce(owner) | ||
.mockResolvedValueOnce(workspaceUser); | ||
|
||
jest | ||
.spyOn(workspaceUseCases, 'findOne') | ||
.mockResolvedValueOnce(workspace); | ||
|
||
jest | ||
.spyOn(workspaceUseCases, 'updateWorkspaceMemberCount') | ||
.mockResolvedValueOnce(); | ||
|
||
await service.updateWorkspaceStorage( | ||
owner.uuid, | ||
maxSpaceBytes, | ||
numberOfSeats, | ||
); | ||
|
||
expect(networkService.setStorage).toHaveBeenCalledWith( | ||
workspaceUserEmail, | ||
maxSpaceBytes, | ||
); | ||
|
||
expect( | ||
workspaceUseCases.updateWorkspaceMemberCount, | ||
).toHaveBeenCalledWith(workspace.id, numberOfSeats); | ||
|
||
expect( | ||
workspaceUseCases.changeWorkspaceMembersStorageLimit, | ||
).toHaveBeenCalledWith(workspace.id, maxSpaceBytes / numberOfSeats); | ||
}); | ||
}); | ||
|
||
|
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
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