Merge pull request #30418 from overleaf/mfb-improve-handling-of-debug-copies-of-user-projects

Add isDebugCopyOf property to project, add Debug tag to debug project.

GitOrigin-RevId: e3d17de05c6f31db16b861d1adae333211dff018
This commit is contained in:
Maria Florencia Besteiro Gonzalez
2026-02-03 09:05:40 +00:00
committed by Copybot
parent 5829a7fe43
commit a591f2eb7a
11 changed files with 190 additions and 24 deletions
@@ -20,10 +20,13 @@ describe('ProjectGetter', function () {
ctx.Project = {
find: sinon.stub().returns({
exec: sinon.stub().resolves(),
populate: sinon.stub().returnsThis(),
limit: sinon.stub().returnsThis(),
}),
findOne: sinon.stub().returns({
exec: sinon.stub().resolves(ctx.project),
}),
exists: sinon.stub().returns({ exec: sinon.stub().resolves(true) }),
}
ctx.CollaboratorsGetter = {
promises: {
@@ -458,4 +461,39 @@ describe('ProjectGetter', function () {
expect(docs).to.deep.equal([ctx.deletedProject])
})
})
describe('findAllDebugProjects', function () {
it('should find all projects with overleaf.isDebugCopyOf of type objectId', async function (ctx) {
await ctx.ProjectGetter.promises.findAllDebugProjects('fields')
sinon.assert.calledWith(ctx.Project.find, {
'overleaf.isDebugCopyOf': { $type: 'objectId' },
})
sinon.assert.calledWith(ctx.Project.find().populate, 'owner_ref', [
'email',
'name',
])
sinon.assert.calledOnce(ctx.Project.find().exec)
})
})
describe('existUsersDebugProjectsOlderThan', function () {
it('should check for existence of debug projects older than given days', async function (ctx) {
const days = 10
const cutoffDate = new Date(Date.now() - days * 24 * 60 * 60 * 1000)
const exists =
await ctx.ProjectGetter.promises.existUsersDebugProjectsOlderThan(
ctx.userId,
days
)
sinon.assert.calledWith(ctx.Project.exists, {
owner_ref: ctx.userId,
'overleaf.isDebugCopyOf': { $type: 'objectId' },
lastUpdated: { $lt: cutoffDate },
})
expect(exists).to.equal(true)
})
})
})