|
|
@@ -85,6 +85,13 @@ describe('OwnershipTransferHandler', function () {
|
|
|
canAddXEditCollaborators: sinon.stub().resolves(true),
|
|
|
},
|
|
|
}
|
|
|
+ ctx.Modules = {
|
|
|
+ promises: {
|
|
|
+ hooks: {
|
|
|
+ fire: sinon.stub().resolves(),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
|
|
|
vi.mock('../../../../app/src/Features/Errors/Errors.js', () =>
|
|
|
vi.importActual('../../../../app/src/Features/Errors/Errors.js')
|
|
|
@@ -148,6 +155,10 @@ describe('OwnershipTransferHandler', function () {
|
|
|
})
|
|
|
)
|
|
|
|
|
|
+ vi.doMock('../../../../app/src/infrastructure/Modules.mjs', () => ({
|
|
|
+ default: ctx.Modules,
|
|
|
+ }))
|
|
|
+
|
|
|
ctx.handler = (await import(MODULE_PATH)).default
|
|
|
})
|
|
|
|
|
|
@@ -510,6 +521,19 @@ describe('OwnershipTransferHandler', function () {
|
|
|
)
|
|
|
})
|
|
|
|
|
|
+ it('should fire the ownershipTransferred hook', async function (ctx) {
|
|
|
+ await ctx.handler.promises.transferOwnership(
|
|
|
+ ctx.project._id,
|
|
|
+ ctx.collaborator._id
|
|
|
+ )
|
|
|
+ expect(ctx.Modules.promises.hooks.fire).to.have.been.calledWith(
|
|
|
+ 'projectOwnershipTransferred',
|
|
|
+ ctx.project._id,
|
|
|
+ ctx.user._id,
|
|
|
+ ctx.collaborator._id
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
it('should decline to transfer ownership to a non-collaborator', async function (ctx) {
|
|
|
ctx.project.collaberator_refs = []
|
|
|
ctx.project.readOnly_refs = []
|