mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
Merge pull request #2150 from overleaf/cmg-archiving-frontend
Frontend for new archiving and trashing GitOrigin-RevId: be8676ab6c2fea7f8fb23655772a008d067b2a78
This commit is contained in:
committed by
sharelatex
parent
1a456da017
commit
0abe99d98f
@@ -1223,6 +1223,8 @@ describe('ProjectController', function() {
|
||||
describe('_buildProjectViewModel', function() {
|
||||
beforeEach(function() {
|
||||
this.ProjectHelper.isArchived.returns(false)
|
||||
this.ProjectHelper.isTrashed.returns(false)
|
||||
|
||||
this.project = {
|
||||
_id: 'abcd',
|
||||
name: 'netsenits',
|
||||
@@ -1239,31 +1241,70 @@ describe('ProjectController', function() {
|
||||
}
|
||||
})
|
||||
|
||||
it('should produce a model of the project', function() {
|
||||
const result = this.ProjectController._buildProjectViewModel(
|
||||
this.project,
|
||||
'readAndWrite',
|
||||
'owner',
|
||||
this.user._id
|
||||
)
|
||||
expect(result).to.exist
|
||||
expect(result).to.be.an('object')
|
||||
expect(result).to.deep.equal({
|
||||
id: 'abcd',
|
||||
name: 'netsenits',
|
||||
lastUpdated: 1,
|
||||
lastUpdatedBy: 2,
|
||||
publicAccessLevel: 'private',
|
||||
accessLevel: 'readAndWrite',
|
||||
source: 'owner',
|
||||
archived: false,
|
||||
owner_ref: 'defg',
|
||||
tokens: {
|
||||
readAndWrite: '1abcd',
|
||||
readAndWritePrefix: '1',
|
||||
readOnly: 'neiotsranteoia'
|
||||
},
|
||||
isV1Project: false
|
||||
describe('project not being archived or trashed', function() {
|
||||
it('should produce a model of the project', function() {
|
||||
const result = this.ProjectController._buildProjectViewModel(
|
||||
this.project,
|
||||
'readAndWrite',
|
||||
'owner',
|
||||
this.user._id
|
||||
)
|
||||
expect(result).to.exist
|
||||
expect(result).to.be.an('object')
|
||||
expect(result).to.deep.equal({
|
||||
id: 'abcd',
|
||||
name: 'netsenits',
|
||||
lastUpdated: 1,
|
||||
lastUpdatedBy: 2,
|
||||
publicAccessLevel: 'private',
|
||||
accessLevel: 'readAndWrite',
|
||||
source: 'owner',
|
||||
archived: false,
|
||||
trashed: false,
|
||||
owner_ref: 'defg',
|
||||
tokens: {
|
||||
readAndWrite: '1abcd',
|
||||
readAndWritePrefix: '1',
|
||||
readOnly: 'neiotsranteoia'
|
||||
},
|
||||
isV1Project: false
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('project being simultaneously archived and trashed', function() {
|
||||
beforeEach(function() {
|
||||
this.ProjectHelper.isArchived.returns(true)
|
||||
this.ProjectHelper.isTrashed.returns(true)
|
||||
})
|
||||
|
||||
it('should produce a model of the project', function() {
|
||||
const result = this.ProjectController._buildProjectViewModel(
|
||||
this.project,
|
||||
'readAndWrite',
|
||||
'owner',
|
||||
this.user._id
|
||||
)
|
||||
expect(result).to.exist
|
||||
expect(result).to.be.an('object')
|
||||
expect(result).to.deep.equal({
|
||||
id: 'abcd',
|
||||
name: 'netsenits',
|
||||
lastUpdated: 1,
|
||||
lastUpdatedBy: 2,
|
||||
publicAccessLevel: 'private',
|
||||
accessLevel: 'readAndWrite',
|
||||
source: 'owner',
|
||||
archived: true,
|
||||
trashed: false,
|
||||
owner_ref: 'defg',
|
||||
tokens: {
|
||||
readAndWrite: '1abcd',
|
||||
readAndWritePrefix: '1',
|
||||
readOnly: 'neiotsranteoia'
|
||||
},
|
||||
isV1Project: false
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1286,6 +1327,7 @@ describe('ProjectController', function() {
|
||||
accessLevel: 'readOnly',
|
||||
source: 'token',
|
||||
archived: false,
|
||||
trashed: false,
|
||||
owner_ref: null,
|
||||
tokens: {
|
||||
readAndWrite: '1abcd',
|
||||
|
||||
@@ -158,7 +158,7 @@ describe('ProjectDeleter', function() {
|
||||
'../Collaborators/CollaboratorsGetter': this.CollaboratorsGetter,
|
||||
'../Docstore/DocstoreManager': this.DocstoreManager,
|
||||
'./ProjectDetailsHandler': this.ProjectDetailsHandler,
|
||||
'../../infrastructure/mongojs': { db: this.db },
|
||||
'../../infrastructure/mongojs': { db: this.db, ObjectId },
|
||||
'logger-sharelatex': this.logger
|
||||
},
|
||||
globals: {
|
||||
@@ -464,7 +464,13 @@ describe('ProjectDeleter', function() {
|
||||
.resolves(this.project)
|
||||
|
||||
this.ProjectMock.expects('update')
|
||||
.withArgs({ _id: this.project_id }, { $set: { archived: archived } })
|
||||
.withArgs(
|
||||
{ _id: this.project_id },
|
||||
{
|
||||
$set: { archived: archived },
|
||||
$pull: { trashed: ObjectId(this.user._id) }
|
||||
}
|
||||
)
|
||||
.resolves()
|
||||
})
|
||||
|
||||
@@ -501,6 +507,57 @@ describe('ProjectDeleter', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('trashProject', function() {
|
||||
beforeEach(function() {
|
||||
this.ProjectMock.expects('findOne')
|
||||
.withArgs({ _id: this.project_id })
|
||||
.chain('exec')
|
||||
.resolves(this.project)
|
||||
|
||||
this.ProjectMock.expects('update')
|
||||
.withArgs(
|
||||
{ _id: this.project_id },
|
||||
{
|
||||
$addToSet: { trashed: ObjectId(this.user._id) },
|
||||
$pull: { archived: ObjectId(this.user._id) }
|
||||
}
|
||||
)
|
||||
.resolves()
|
||||
})
|
||||
|
||||
it('should update the project', async function() {
|
||||
await this.ProjectDeleter.promises.trashProject(
|
||||
this.project_id,
|
||||
this.user._id
|
||||
)
|
||||
this.ProjectMock.verify()
|
||||
})
|
||||
})
|
||||
|
||||
describe('untrashProject', function() {
|
||||
beforeEach(function() {
|
||||
this.ProjectMock.expects('findOne')
|
||||
.withArgs({ _id: this.project_id })
|
||||
.chain('exec')
|
||||
.resolves(this.project)
|
||||
|
||||
this.ProjectMock.expects('update')
|
||||
.withArgs(
|
||||
{ _id: this.project_id },
|
||||
{ $pull: { trashed: ObjectId(this.user._id) } }
|
||||
)
|
||||
.resolves()
|
||||
})
|
||||
|
||||
it('should update the project', async function() {
|
||||
await this.ProjectDeleter.promises.untrashProject(
|
||||
this.project_id,
|
||||
this.user._id
|
||||
)
|
||||
this.ProjectMock.verify()
|
||||
})
|
||||
})
|
||||
|
||||
describe('restoreProject', function() {
|
||||
beforeEach(function() {
|
||||
this.ProjectMock.expects('update')
|
||||
|
||||
Reference in New Issue
Block a user