|
|
@@ -239,6 +239,81 @@ describe('Deleting a project', function() {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
+ describe('when the project has deleted files', function() {
|
|
|
+ beforeEach('get rootFolder id', function(done) {
|
|
|
+ this.user.getProject(this.projectId, (error, project) => {
|
|
|
+ if (error) return done(error)
|
|
|
+ this.rootFolder = project.rootFolder[0]._id
|
|
|
+ done()
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ let allFileIds
|
|
|
+ beforeEach('reset allFileIds', function() {
|
|
|
+ allFileIds = []
|
|
|
+ })
|
|
|
+ function createAndDeleteFile(name) {
|
|
|
+ let fileId
|
|
|
+ beforeEach(`create file ${name}`, function(done) {
|
|
|
+ this.user.uploadExampleFileInProject(
|
|
|
+ this.projectId,
|
|
|
+ this.rootFolder,
|
|
|
+ name,
|
|
|
+ (error, theFileId) => {
|
|
|
+ fileId = theFileId
|
|
|
+ allFileIds.push(theFileId)
|
|
|
+ done(error)
|
|
|
+ }
|
|
|
+ )
|
|
|
+ })
|
|
|
+ beforeEach(`delete file ${name}`, function(done) {
|
|
|
+ this.user.deleteItemInProject(this.projectId, 'file', fileId, done)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ for (const name of ['a.png', 'another.png']) {
|
|
|
+ createAndDeleteFile(name)
|
|
|
+ }
|
|
|
+
|
|
|
+ it('should have two deleteFiles entries', async function() {
|
|
|
+ const files = await db.deletedFiles
|
|
|
+ .find({}, { sort: { _id: 1 } })
|
|
|
+ .toArray()
|
|
|
+ expect(files).to.have.length(2)
|
|
|
+ expect(files.map(file => file._id.toString())).to.deep.equal(allFileIds)
|
|
|
+ })
|
|
|
+
|
|
|
+ describe('When the deleted project is expired', function() {
|
|
|
+ beforeEach('soft delete the project', function(done) {
|
|
|
+ this.user.deleteProject(this.projectId, done)
|
|
|
+ })
|
|
|
+ beforeEach('hard delete the project', function(done) {
|
|
|
+ request.post(
|
|
|
+ `/internal/project/${this.projectId}/expire-deleted-project`,
|
|
|
+ {
|
|
|
+ auth: {
|
|
|
+ user: settings.apis.web.user,
|
|
|
+ pass: settings.apis.web.pass,
|
|
|
+ sendImmediately: true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ (error, res) => {
|
|
|
+ expect(error).not.to.exist
|
|
|
+ expect(res.statusCode).to.equal(200)
|
|
|
+
|
|
|
+ done()
|
|
|
+ }
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
+ it('should cleanup the deleteFiles', async function() {
|
|
|
+ const files = await db.deletedFiles
|
|
|
+ .find({}, { sort: { _id: 1 } })
|
|
|
+ .toArray()
|
|
|
+ expect(files).to.deep.equal([])
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
describe('When the project has docs', function() {
|
|
|
beforeEach(function(done) {
|
|
|
this.user.getProject(this.projectId, (error, project) => {
|