-
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.
- Loading branch information
Showing
12 changed files
with
109 additions
and
42 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
migrations/20240716131219-add-number-of-seats-to-workspaces-table.js
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,16 @@ | ||
'use strict'; | ||
|
||
const tableName = 'workspaces'; | ||
const newColumn = 'number_of_seats'; | ||
|
||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
await queryInterface.addColumn(tableName, newColumn, { | ||
type: Sequelize.INTEGER, | ||
}); | ||
}, | ||
|
||
async down(queryInterface) { | ||
await queryInterface.removeColumn(tableName, newColumn); | ||
}, | ||
}; |
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
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
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 |
---|---|---|
|
@@ -163,6 +163,11 @@ describe('WorkspacesUsecases', () => { | |
jest | ||
.spyOn(service, 'getAssignableSpaceInWorkspace') | ||
.mockResolvedValueOnce(6000000); | ||
|
||
jest | ||
.spyOn(service, 'getWorkspaceFixedStoragePerUser') | ||
.mockResolvedValueOnce(1024); | ||
|
||
jest.spyOn(configService, 'get').mockResolvedValueOnce('secret' as never); | ||
jest | ||
.spyOn(mailerService, 'sendWorkspaceUserExternalInvitation') | ||
|
@@ -171,7 +176,6 @@ describe('WorkspacesUsecases', () => { | |
await expect( | ||
service.inviteUserToWorkspace(user, 'workspace-id', { | ||
invitedUser: '[email protected]', | ||
spaceLimit: 1024, | ||
encryptionKey: '', | ||
encryptionAlgorithm: '', | ||
}), | ||
|
@@ -202,6 +206,10 @@ describe('WorkspacesUsecases', () => { | |
jest | ||
.spyOn(service, 'getAssignableSpaceInWorkspace') | ||
.mockResolvedValueOnce(6000000); | ||
jest | ||
.spyOn(service, 'getWorkspaceFixedStoragePerUser') | ||
.mockResolvedValueOnce(1024); | ||
|
||
jest | ||
.spyOn(mailerService, 'sendWorkspaceUserInvitation') | ||
.mockResolvedValueOnce(undefined); | ||
|
@@ -210,7 +218,6 @@ describe('WorkspacesUsecases', () => { | |
await expect( | ||
service.inviteUserToWorkspace(user, 'workspace-id', { | ||
invitedUser: '[email protected]', | ||
spaceLimit: 1024, | ||
encryptionKey: '', | ||
encryptionAlgorithm: '', | ||
}), | ||
|
@@ -401,6 +408,10 @@ describe('WorkspacesUsecases', () => { | |
.spyOn(workspaceRepository, 'findWorkspaceUser') | ||
.mockResolvedValueOnce(null); | ||
|
||
jest | ||
.spyOn(service, 'getWorkspaceFixedStoragePerUser') | ||
.mockResolvedValueOnce(50000); | ||
|
||
await service.setupWorkspace(owner, 'workspace-id', { | ||
name: 'Test Workspace', | ||
encryptedMnemonic: 'encryptedMnemonic', | ||
|
@@ -568,27 +579,34 @@ describe('WorkspacesUsecases', () => { | |
}); | ||
|
||
describe('isWorkspaceFull', () => { | ||
const workspaceId = 'workspace-id'; | ||
it('When workspace has slots left, then workspace is not full', async () => { | ||
const notFullWorkspace = newWorkspace({ | ||
attributes: { numberOfSeats: 10 }, | ||
}); | ||
|
||
jest | ||
.spyOn(workspaceRepository, 'getWorkspaceUsersCount') | ||
.mockResolvedValue(5); | ||
jest | ||
.spyOn(workspaceRepository, 'getWorkspaceInvitationsCount') | ||
.mockResolvedValue(4); | ||
|
||
const isFull = await service.isWorkspaceFull(workspaceId); | ||
const isFull = await service.isWorkspaceFull(notFullWorkspace); | ||
expect(isFull).toBe(false); | ||
}); | ||
it('When workspace does not have slots left, then workspace is full', async () => { | ||
const fullWorkspace = newWorkspace({ | ||
attributes: { numberOfSeats: 10 }, | ||
}); | ||
|
||
jest | ||
.spyOn(workspaceRepository, 'getWorkspaceUsersCount') | ||
.mockResolvedValue(10); | ||
jest | ||
.spyOn(workspaceRepository, 'getWorkspaceInvitationsCount') | ||
.mockResolvedValue(0); | ||
|
||
const isFull = await service.isWorkspaceFull(workspaceId); | ||
const isFull = await service.isWorkspaceFull(fullWorkspace); | ||
expect(isFull).toBe(true); | ||
}); | ||
}); | ||
|
@@ -1347,15 +1365,15 @@ describe('WorkspacesUsecases', () => { | |
jest | ||
.spyOn(workspaceRepository, 'getTotalSpaceLimitInWorkspaceUsers') | ||
.mockResolvedValue(500000); | ||
jest | ||
/* jest | ||
.spyOn(workspaceRepository, 'getSpaceLimitInInvitations') | ||
.mockResolvedValue(200000); | ||
.mockResolvedValue(200000); */ | ||
|
||
const assignableSpace = await service.getAssignableSpaceInWorkspace( | ||
workspace, | ||
workspaceDefaultUser, | ||
); | ||
expect(assignableSpace).toBe(300000); | ||
expect(assignableSpace).toBe(500000); | ||
}); | ||
}); | ||
|
||
|
@@ -3188,7 +3206,7 @@ describe('WorkspacesUsecases', () => { | |
describe('initiateWorkspace', () => { | ||
const owner = newUser(); | ||
const maxSpaceBytes = 1000000; | ||
const workspaceData = { address: '123 Main St' }; | ||
const workspaceData = { address: '123 Main St', numberOfSeats: 20 }; | ||
|
||
it('When owner does not exist, then it should throw', async () => { | ||
jest.spyOn(userRepository, 'findByUuid').mockResolvedValueOnce(null); | ||
|
Oops, something went wrong.