mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-11 23:20:47 +02:00
Merge pull request #26575 from overleaf/jpa-archived-state
[web] remove runtime migration for project.archived/trashed state GitOrigin-RevId: 69064878f3dfdcde3727a4e3eb555deb75c70588
This commit is contained in:
@@ -95,10 +95,6 @@ describe('ProjectDeleter', function () {
|
||||
},
|
||||
}
|
||||
|
||||
this.ProjectHelper = {
|
||||
calculateArchivedArray: sinon.stub(),
|
||||
}
|
||||
|
||||
this.db = {
|
||||
projects: {
|
||||
insertOne: sinon.stub().resolves(),
|
||||
@@ -143,7 +139,6 @@ describe('ProjectDeleter', function () {
|
||||
'../../infrastructure/Features': this.Features,
|
||||
'../Editor/EditorRealTimeController': this.EditorRealTimeController,
|
||||
'../../models/Project': { Project },
|
||||
'./ProjectHelper': this.ProjectHelper,
|
||||
'../../models/DeletedProject': { DeletedProject },
|
||||
'../DocumentUpdater/DocumentUpdaterHandler':
|
||||
this.DocumentUpdaterHandler,
|
||||
@@ -559,19 +554,11 @@ describe('ProjectDeleter', function () {
|
||||
|
||||
describe('archiveProject', function () {
|
||||
beforeEach(function () {
|
||||
const archived = [new ObjectId(this.user._id)]
|
||||
this.ProjectHelper.calculateArchivedArray.returns(archived)
|
||||
|
||||
this.ProjectMock.expects('findOne')
|
||||
.withArgs({ _id: this.project._id })
|
||||
.chain('exec')
|
||||
.resolves(this.project)
|
||||
|
||||
this.ProjectMock.expects('updateOne')
|
||||
.withArgs(
|
||||
{ _id: this.project._id },
|
||||
{
|
||||
$set: { archived },
|
||||
$addToSet: { archived: new ObjectId(this.user._id) },
|
||||
$pull: { trashed: new ObjectId(this.user._id) },
|
||||
}
|
||||
)
|
||||
@@ -585,32 +572,15 @@ describe('ProjectDeleter', function () {
|
||||
)
|
||||
this.ProjectMock.verify()
|
||||
})
|
||||
|
||||
it('calculates the archived array', async function () {
|
||||
await this.ProjectDeleter.promises.archiveProject(
|
||||
this.project._id,
|
||||
this.user._id
|
||||
)
|
||||
expect(this.ProjectHelper.calculateArchivedArray).to.have.been.calledWith(
|
||||
this.project,
|
||||
this.user._id,
|
||||
'ARCHIVE'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('unarchiveProject', function () {
|
||||
beforeEach(function () {
|
||||
const archived = [new ObjectId(this.user._id)]
|
||||
this.ProjectHelper.calculateArchivedArray.returns(archived)
|
||||
|
||||
this.ProjectMock.expects('findOne')
|
||||
.withArgs({ _id: this.project._id })
|
||||
.chain('exec')
|
||||
.resolves(this.project)
|
||||
|
||||
this.ProjectMock.expects('updateOne')
|
||||
.withArgs({ _id: this.project._id }, { $set: { archived } })
|
||||
.withArgs(
|
||||
{ _id: this.project._id },
|
||||
{ $pull: { archived: new ObjectId(this.user._id) } }
|
||||
)
|
||||
.resolves()
|
||||
})
|
||||
|
||||
@@ -621,36 +591,16 @@ describe('ProjectDeleter', function () {
|
||||
)
|
||||
this.ProjectMock.verify()
|
||||
})
|
||||
|
||||
it('calculates the archived array', async function () {
|
||||
await this.ProjectDeleter.promises.unarchiveProject(
|
||||
this.project._id,
|
||||
this.user._id
|
||||
)
|
||||
expect(this.ProjectHelper.calculateArchivedArray).to.have.been.calledWith(
|
||||
this.project,
|
||||
this.user._id,
|
||||
'UNARCHIVE'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('trashProject', function () {
|
||||
beforeEach(function () {
|
||||
const archived = [new ObjectId(this.user._id)]
|
||||
this.ProjectHelper.calculateArchivedArray.returns(archived)
|
||||
|
||||
this.ProjectMock.expects('findOne')
|
||||
.withArgs({ _id: this.project._id })
|
||||
.chain('exec')
|
||||
.resolves(this.project)
|
||||
|
||||
this.ProjectMock.expects('updateOne')
|
||||
.withArgs(
|
||||
{ _id: this.project._id },
|
||||
{
|
||||
$addToSet: { trashed: new ObjectId(this.user._id) },
|
||||
$set: { archived },
|
||||
$pull: { archived: new ObjectId(this.user._id) },
|
||||
}
|
||||
)
|
||||
.resolves()
|
||||
@@ -663,27 +613,10 @@ describe('ProjectDeleter', function () {
|
||||
)
|
||||
this.ProjectMock.verify()
|
||||
})
|
||||
|
||||
it('unarchives the project', async function () {
|
||||
await this.ProjectDeleter.promises.trashProject(
|
||||
this.project._id,
|
||||
this.user._id
|
||||
)
|
||||
expect(this.ProjectHelper.calculateArchivedArray).to.have.been.calledWith(
|
||||
this.project,
|
||||
this.user._id,
|
||||
'UNARCHIVE'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('untrashProject', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectMock.expects('findOne')
|
||||
.withArgs({ _id: this.project._id })
|
||||
.chain('exec')
|
||||
.resolves(this.project)
|
||||
|
||||
this.ProjectMock.expects('updateOne')
|
||||
.withArgs(
|
||||
{ _id: this.project._id },
|
||||
|
||||
@@ -101,134 +101,6 @@ describe('ProjectHelper', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('calculateArchivedArray', function () {
|
||||
describe('project.archived being an array', function () {
|
||||
it('returns an array adding the current user id when archiving', function () {
|
||||
const project = { archived: [] }
|
||||
const result = this.ProjectHelper.calculateArchivedArray(
|
||||
project,
|
||||
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||
'ARCHIVE'
|
||||
)
|
||||
expect(result).to.deep.equal([new ObjectId('5c922599cdb09e014aa7d499')])
|
||||
})
|
||||
|
||||
it('returns an array without the current user id when unarchiving', function () {
|
||||
const project = { archived: [new ObjectId('5c922599cdb09e014aa7d499')] }
|
||||
const result = this.ProjectHelper.calculateArchivedArray(
|
||||
project,
|
||||
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||
'UNARCHIVE'
|
||||
)
|
||||
expect(result).to.deep.equal([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('project.archived being a boolean and being true', function () {
|
||||
it('returns an array of all associated user ids when archiving', function () {
|
||||
const project = {
|
||||
archived: true,
|
||||
owner_ref: this.user._id,
|
||||
collaberator_refs: [
|
||||
new ObjectId('4f2cfb341eb5855a5b000f8b'),
|
||||
new ObjectId('5c45f3bd425ead01488675aa'),
|
||||
],
|
||||
readOnly_refs: [new ObjectId('5c92243fcdb09e014aa7d487')],
|
||||
tokenAccessReadAndWrite_refs: [
|
||||
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||
],
|
||||
tokenAccessReadOnly_refs: [],
|
||||
}
|
||||
|
||||
const result = this.ProjectHelper.calculateArchivedArray(
|
||||
project,
|
||||
this.user._id,
|
||||
'ARCHIVE'
|
||||
)
|
||||
expect(result).to.deep.equal([
|
||||
this.user._id,
|
||||
new ObjectId('4f2cfb341eb5855a5b000f8b'),
|
||||
new ObjectId('5c45f3bd425ead01488675aa'),
|
||||
new ObjectId('5c92243fcdb09e014aa7d487'),
|
||||
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||
])
|
||||
})
|
||||
|
||||
it('returns an array of all associated users without the current user id when unarchived', function () {
|
||||
const project = {
|
||||
archived: true,
|
||||
owner_ref: this.user._id,
|
||||
collaberator_refs: [
|
||||
new ObjectId('4f2cfb341eb5855a5b000f8b'),
|
||||
new ObjectId('5c45f3bd425ead01488675aa'),
|
||||
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||
],
|
||||
readOnly_refs: [new ObjectId('5c92243fcdb09e014aa7d487')],
|
||||
tokenAccessReadAndWrite_refs: [
|
||||
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||
],
|
||||
tokenAccessReadOnly_refs: [],
|
||||
}
|
||||
|
||||
const result = this.ProjectHelper.calculateArchivedArray(
|
||||
project,
|
||||
this.user._id,
|
||||
'UNARCHIVE'
|
||||
)
|
||||
expect(result).to.deep.equal([
|
||||
new ObjectId('4f2cfb341eb5855a5b000f8b'),
|
||||
new ObjectId('5c45f3bd425ead01488675aa'),
|
||||
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||
new ObjectId('5c92243fcdb09e014aa7d487'),
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe('project.archived being a boolean and being false', function () {
|
||||
it('returns an array adding the current user id when archiving', function () {
|
||||
const project = { archived: false }
|
||||
const result = this.ProjectHelper.calculateArchivedArray(
|
||||
project,
|
||||
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||
'ARCHIVE'
|
||||
)
|
||||
expect(result).to.deep.equal([new ObjectId('5c922599cdb09e014aa7d499')])
|
||||
})
|
||||
|
||||
it('returns an empty array when unarchiving', function () {
|
||||
const project = { archived: false }
|
||||
const result = this.ProjectHelper.calculateArchivedArray(
|
||||
project,
|
||||
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||
'UNARCHIVE'
|
||||
)
|
||||
expect(result).to.deep.equal([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('project.archived not being set', function () {
|
||||
it('returns an array adding the current user id when archiving', function () {
|
||||
const project = { archived: undefined }
|
||||
const result = this.ProjectHelper.calculateArchivedArray(
|
||||
project,
|
||||
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||
'ARCHIVE'
|
||||
)
|
||||
expect(result).to.deep.equal([new ObjectId('5c922599cdb09e014aa7d499')])
|
||||
})
|
||||
|
||||
it('returns an empty array when unarchiving', function () {
|
||||
const project = { archived: undefined }
|
||||
const result = this.ProjectHelper.calculateArchivedArray(
|
||||
project,
|
||||
new ObjectId('5c922599cdb09e014aa7d499'),
|
||||
'UNARCHIVE'
|
||||
)
|
||||
expect(result).to.deep.equal([])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('compilerFromV1Engine', function () {
|
||||
it('returns the correct engine for latex_dvipdf', function () {
|
||||
expect(this.ProjectHelper.compilerFromV1Engine('latex_dvipdf')).to.equal(
|
||||
|
||||
Reference in New Issue
Block a user