[web] Add deletedReason parameter to project deletion methods (#32221)

* [web] Add deletedReason parameter to project deletion methods

* revert sinon.match.any in ProjectDuplicator negative assertion

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
GitOrigin-RevId: d1595eefe0e36150231ee9646fe5eba0786fd1f5
This commit is contained in:
Domagoj Kriskovic
2026-03-23 09:06:04 +00:00
committed by Copybot
co-authored by Copilot Autofix powered by AI
parent c9ba2ac025
commit 6486ef3e1e
13 changed files with 53 additions and 12 deletions
@@ -684,7 +684,7 @@ describe('EditorController', function () {
describe('deleteProject', function () {
beforeEach(function (ctx) {
ctx.err = 'errro'
ctx.ProjectDeleter.deleteProject.callsArgWith(1, ctx.err)
ctx.ProjectDeleter.deleteProject.callsArgWith(2, ctx.err)
})
it('should call the project handler', async function (ctx) {
@@ -692,7 +692,9 @@ describe('EditorController', function () {
ctx.EditorController.deleteProject(ctx.project_id, err => {
err.should.equal(ctx.err)
ctx.ProjectDeleter.deleteProject
.calledWith(ctx.project_id)
.calledWith(ctx.project_id, {
deletedReason: 'user',
})
.should.equal(true)
resolve()
})
@@ -710,6 +710,7 @@ describe('ProjectController', function () {
.calledWith(ctx.project_id, {
deleterUser: ctx.user,
ipAddress: ctx.req.ip,
deletedReason: 'user',
})
.should.equal(true)
code.should.equal(200)
@@ -288,7 +288,7 @@ describe('ProjectDeleter', function () {
{ 'deleterData.deletedProjectId': project._id },
{
project,
deleterData: sinon.match.object,
deleterData: sinon.match.has('deletedReason', 'account-deletion'),
},
{ upsert: true }
)
@@ -343,6 +343,7 @@ describe('ProjectDeleter', function () {
it('should save a DeletedProject with additional deleterData', async function (ctx) {
ctx.deleterData.deleterIpAddress = ctx.ip
ctx.deleterData.deleterId = ctx.user._id
ctx.deleterData.deletedReason = 'user'
ctx.ProjectMock.expects('deleteOne').chain('exec').resolves()
ctx.DeletedProjectMock.expects('updateOne')
@@ -359,6 +360,7 @@ describe('ProjectDeleter', function () {
await ctx.ProjectDeleter.promises.deleteProject(ctx.project._id, {
deleterUser: ctx.user,
ipAddress: ctx.ip,
deletedReason: 'user',
})
ctx.DeletedProjectMock.verify()
})
@@ -459,7 +459,8 @@ describe('ProjectDuplicator', function () {
it('should delete the broken cloned project', function (ctx) {
ctx.ProjectDeleter.promises.deleteProject.should.have.been.calledWith(
ctx.newBlankProject._id
ctx.newBlankProject._id,
{ deletedReason: 'clone-failure' }
)
})
@@ -445,7 +445,8 @@ describe('ProjectUploadManager', function () {
it('should cleanup the blank project created', async function (ctx) {
ctx.ProjectDeleter.promises.deleteProject.should.have.been.calledWith(
ctx.project._id
ctx.project._id,
{ deletedReason: 'zip-import-failure' }
)
})
@@ -471,7 +472,8 @@ describe('ProjectUploadManager', function () {
it('should cleanup the blank project created', function (ctx) {
ctx.ProjectDeleter.promises.deleteProject.should.have.been.calledWith(
ctx.project._id
ctx.project._id,
{ deletedReason: 'zip-import-failure' }
)
})