mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-14 20:40:17 -05:00
Merge pull request #21051 from overleaf/msm-esm-migration-history-v1
[web] Migrate `modules/history-v1` to ESM GitOrigin-RevId: db1f5485ea268a6a9f62efd3183e16920505bfda
This commit is contained in:
parent
3f0cf84318
commit
cc0ce638b7
5 changed files with 108 additions and 142 deletions
|
@ -3,4 +3,4 @@
|
||||||
/** @type {WebModule} */
|
/** @type {WebModule} */
|
||||||
const HistoryModule = {}
|
const HistoryModule = {}
|
||||||
|
|
||||||
module.exports = HistoryModule
|
export default HistoryModule
|
|
@ -1,24 +1,9 @@
|
||||||
/* eslint-disable
|
import { expect } from 'chai'
|
||||||
max-len,
|
|
||||||
no-unused-vars,
|
|
||||||
*/
|
|
||||||
// TODO: This file was created by bulk-decaffeinate.
|
|
||||||
// Fix any style issues and re-enable lint.
|
|
||||||
/*
|
|
||||||
* decaffeinate suggestions:
|
|
||||||
* DS102: Remove unnecessary code created because of implicit returns
|
|
||||||
* DS207: Consider shorter variations of null checks
|
|
||||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
||||||
*/
|
|
||||||
const { expect } = require('chai')
|
|
||||||
const _ = require('lodash')
|
|
||||||
|
|
||||||
const {
|
import _ from 'lodash'
|
||||||
db,
|
import { db, ObjectId } from '../../../../../app/src/infrastructure/mongodb.js'
|
||||||
ObjectId,
|
import User from '../../../../../test/acceptance/src/helpers/User.js'
|
||||||
} = require('../../../../../app/src/infrastructure/mongodb')
|
import MockV1HistoryApiClass from '../../../../../test/acceptance/src/mocks/MockV1HistoryApi.js'
|
||||||
const User = require('../../../../../test/acceptance/src/helpers/User')
|
|
||||||
const MockV1HistoryApiClass = require('../../../../../test/acceptance/src/mocks/MockV1HistoryApi')
|
|
||||||
|
|
||||||
let MockV1HistoryApi
|
let MockV1HistoryApi
|
||||||
|
|
||||||
|
@ -29,18 +14,18 @@ before(function () {
|
||||||
describe('History', function () {
|
describe('History', function () {
|
||||||
beforeEach(function (done) {
|
beforeEach(function (done) {
|
||||||
this.owner = new User()
|
this.owner = new User()
|
||||||
return this.owner.login(done)
|
this.owner.login(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('zip download of version', function () {
|
describe('zip download of version', function () {
|
||||||
it('should stream the zip file of a version', function (done) {
|
it('should stream the zip file of a version', function (done) {
|
||||||
return this.owner.createProject('example-project', (error, projectId) => {
|
this.owner.createProject('example-project', (error, projectId) => {
|
||||||
this.project_id = projectId
|
this.project_id = projectId
|
||||||
if (error != null) {
|
if (error) {
|
||||||
return done(error)
|
return done(error)
|
||||||
}
|
}
|
||||||
this.v1_history_id = 42
|
this.v1_history_id = 42
|
||||||
return db.projects.updateOne(
|
db.projects.updateOne(
|
||||||
{
|
{
|
||||||
_id: new ObjectId(this.project_id),
|
_id: new ObjectId(this.project_id),
|
||||||
},
|
},
|
||||||
|
@ -50,13 +35,13 @@ describe('History', function () {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
return done(error)
|
return done(error)
|
||||||
}
|
}
|
||||||
return this.owner.request(
|
this.owner.request(
|
||||||
`/project/${this.project_id}/version/42/zip`,
|
`/project/${this.project_id}/version/42/zip`,
|
||||||
(error, response, body) => {
|
(error, response, body) => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
return done(error)
|
return done(error)
|
||||||
}
|
}
|
||||||
expect(response.statusCode).to.equal(200)
|
expect(response.statusCode).to.equal(200)
|
||||||
|
@ -69,7 +54,7 @@ describe('History', function () {
|
||||||
expect(body).to.equal(
|
expect(body).to.equal(
|
||||||
`Mock zip for ${this.v1_history_id} at version 42`
|
`Mock zip for ${this.v1_history_id} at version 42`
|
||||||
)
|
)
|
||||||
return done()
|
done()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -195,12 +180,12 @@ describe('History', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return 402 for non-v2-history project', function (done) {
|
it('should return 402 for non-v2-history project', function (done) {
|
||||||
return this.owner.createProject('non-v2-project', (error, projectId) => {
|
this.owner.createProject('non-v2-project', (error, projectId) => {
|
||||||
this.project_id = projectId
|
this.project_id = projectId
|
||||||
if (error != null) {
|
if (error) {
|
||||||
return done(error)
|
return done(error)
|
||||||
}
|
}
|
||||||
return db.projects.updateOne(
|
db.projects.updateOne(
|
||||||
{
|
{
|
||||||
_id: new ObjectId(this.project_id),
|
_id: new ObjectId(this.project_id),
|
||||||
},
|
},
|
||||||
|
@ -210,17 +195,17 @@ describe('History', function () {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
return done(error)
|
return done(error)
|
||||||
}
|
}
|
||||||
return this.owner.request(
|
this.owner.request(
|
||||||
`/project/${this.project_id}/version/42/zip`,
|
`/project/${this.project_id}/version/42/zip`,
|
||||||
(error, response, body) => {
|
(error, response, body) => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
return done(error)
|
return done(error)
|
||||||
}
|
}
|
||||||
expect(response.statusCode).to.equal(402)
|
expect(response.statusCode).to.equal(402)
|
||||||
return done()
|
done()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -234,7 +219,7 @@ describe('History', function () {
|
||||||
_.remove(
|
_.remove(
|
||||||
MockV1HistoryApi.app._router.stack,
|
MockV1HistoryApi.app._router.stack,
|
||||||
appRoute =>
|
appRoute =>
|
||||||
(appRoute.route != null ? appRoute.route.path : undefined) ===
|
appRoute.route?.path ===
|
||||||
'/api/projects/:project_id/version/:version/zip'
|
'/api/projects/:project_id/version/:version/zip'
|
||||||
)
|
)
|
||||||
MockV1HistoryApi.app.post(
|
MockV1HistoryApi.app.post(
|
||||||
|
@ -258,7 +243,7 @@ describe('History', function () {
|
||||||
}
|
}
|
||||||
this.project_id = projectId
|
this.project_id = projectId
|
||||||
this.v1_history_id = 42
|
this.v1_history_id = 42
|
||||||
return db.projects.updateOne(
|
db.projects.updateOne(
|
||||||
{
|
{
|
||||||
_id: new ObjectId(this.project_id),
|
_id: new ObjectId(this.project_id),
|
||||||
},
|
},
|
||||||
|
@ -274,11 +259,11 @@ describe('History', function () {
|
||||||
this.owner.request(
|
this.owner.request(
|
||||||
`/project/${this.project_id}/version/42/zip`,
|
`/project/${this.project_id}/version/42/zip`,
|
||||||
(error, response, body) => {
|
(error, response, body) => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
return done(error)
|
return done(error)
|
||||||
}
|
}
|
||||||
expect(response.statusCode).to.equal(404)
|
expect(response.statusCode).to.equal(404)
|
||||||
return done()
|
done()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -292,7 +277,7 @@ describe('History', function () {
|
||||||
_.remove(
|
_.remove(
|
||||||
MockV1HistoryApi.app._router.stack,
|
MockV1HistoryApi.app._router.stack,
|
||||||
appRoute =>
|
appRoute =>
|
||||||
(appRoute.route != null ? appRoute.route.path : undefined) ===
|
appRoute.route?.path ===
|
||||||
'/api/projects/:project_id/version/:version/zip'
|
'/api/projects/:project_id/version/:version/zip'
|
||||||
)
|
)
|
||||||
MockV1HistoryApi.app.get(
|
MockV1HistoryApi.app.get(
|
||||||
|
@ -322,7 +307,7 @@ describe('History', function () {
|
||||||
}
|
}
|
||||||
this.project_id = projectId
|
this.project_id = projectId
|
||||||
this.v1_history_id = 42
|
this.v1_history_id = 42
|
||||||
return db.projects.updateOne(
|
db.projects.updateOne(
|
||||||
{
|
{
|
||||||
_id: new ObjectId(this.project_id),
|
_id: new ObjectId(this.project_id),
|
||||||
},
|
},
|
||||||
|
@ -338,11 +323,11 @@ describe('History', function () {
|
||||||
this.owner.request(
|
this.owner.request(
|
||||||
`/project/${this.project_id}/version/42/zip`,
|
`/project/${this.project_id}/version/42/zip`,
|
||||||
(error, response, body) => {
|
(error, response, body) => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
return done(error)
|
return done(error)
|
||||||
}
|
}
|
||||||
expect(response.statusCode).to.equal(500)
|
expect(response.statusCode).to.equal(500)
|
||||||
return done()
|
done()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -1,21 +1,9 @@
|
||||||
/* eslint-disable
|
import { expect } from 'chai'
|
||||||
max-len,
|
import mongodb from 'mongodb-legacy'
|
||||||
no-unused-vars,
|
import User from '../../../../../test/acceptance/src/helpers/User.js'
|
||||||
*/
|
import MockProjectHistoryApiClass from '../../../../../test/acceptance/src/mocks/MockProjectHistoryApi.js'
|
||||||
// TODO: This file was created by bulk-decaffeinate.
|
|
||||||
// Fix any style issues and re-enable lint.
|
|
||||||
/*
|
|
||||||
* decaffeinate suggestions:
|
|
||||||
* DS102: Remove unnecessary code created because of implicit returns
|
|
||||||
* DS207: Consider shorter variations of null checks
|
|
||||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
||||||
*/
|
|
||||||
const _ = require('lodash')
|
|
||||||
const { expect } = require('chai')
|
|
||||||
const { ObjectId } = require('mongodb-legacy')
|
|
||||||
|
|
||||||
const User = require('../../../../../test/acceptance/src/helpers/User')
|
const { ObjectId } = mongodb
|
||||||
const MockProjectHistoryApiClass = require('../../../../../test/acceptance/src/mocks/MockProjectHistoryApi')
|
|
||||||
|
|
||||||
let MockProjectHistoryApi
|
let MockProjectHistoryApi
|
||||||
|
|
||||||
|
@ -26,19 +14,19 @@ before(function () {
|
||||||
describe('Labels', function () {
|
describe('Labels', function () {
|
||||||
beforeEach(function (done) {
|
beforeEach(function (done) {
|
||||||
this.owner = new User()
|
this.owner = new User()
|
||||||
return this.owner.login(error => {
|
this.owner.login(error => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
return this.owner.createProject(
|
this.owner.createProject(
|
||||||
'example-project',
|
'example-project',
|
||||||
{ template: 'example' },
|
{ template: 'example' },
|
||||||
(error, projectId) => {
|
(error, projectId) => {
|
||||||
this.project_id = projectId
|
this.project_id = projectId
|
||||||
if (error != null) {
|
if (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
return done()
|
done()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -54,19 +42,19 @@ describe('Labels', function () {
|
||||||
version,
|
version,
|
||||||
})
|
})
|
||||||
|
|
||||||
return this.owner.request(
|
this.owner.request(
|
||||||
{
|
{
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: `/project/${this.project_id}/labels`,
|
url: `/project/${this.project_id}/labels`,
|
||||||
json: true,
|
json: true,
|
||||||
},
|
},
|
||||||
(error, response, body) => {
|
(error, response, body) => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
expect(response.statusCode).to.equal(200)
|
expect(response.statusCode).to.equal(200)
|
||||||
expect(body).to.deep.equal([{ id: labelId, comment, version }])
|
expect(body).to.deep.equal([{ id: labelId, comment, version }])
|
||||||
return done()
|
done()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -75,14 +63,14 @@ describe('Labels', function () {
|
||||||
const comment = 'a label comment'
|
const comment = 'a label comment'
|
||||||
const version = 3
|
const version = 3
|
||||||
|
|
||||||
return this.owner.request(
|
this.owner.request(
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: `/project/${this.project_id}/labels`,
|
url: `/project/${this.project_id}/labels`,
|
||||||
json: { comment, version },
|
json: { comment, version },
|
||||||
},
|
},
|
||||||
(error, response, body) => {
|
(error, response, body) => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
expect(response.statusCode).to.equal(200)
|
expect(response.statusCode).to.equal(200)
|
||||||
|
@ -90,7 +78,7 @@ describe('Labels', function () {
|
||||||
expect(MockProjectHistoryApi.getLabels(this.project_id)).to.deep.equal([
|
expect(MockProjectHistoryApi.getLabels(this.project_id)).to.deep.equal([
|
||||||
{ id: labelId, comment, version },
|
{ id: labelId, comment, version },
|
||||||
])
|
])
|
||||||
return done()
|
done()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -105,21 +93,21 @@ describe('Labels', function () {
|
||||||
version,
|
version,
|
||||||
})
|
})
|
||||||
|
|
||||||
return this.owner.request(
|
this.owner.request(
|
||||||
{
|
{
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
url: `/project/${this.project_id}/labels/${labelId}`,
|
url: `/project/${this.project_id}/labels/${labelId}`,
|
||||||
json: true,
|
json: true,
|
||||||
},
|
},
|
||||||
(error, response, body) => {
|
(error, response, body) => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
expect(response.statusCode).to.equal(204)
|
expect(response.statusCode).to.equal(204)
|
||||||
expect(MockProjectHistoryApi.getLabels(this.project_id)).to.deep.equal(
|
expect(MockProjectHistoryApi.getLabels(this.project_id)).to.deep.equal(
|
||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
return done()
|
done()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
|
@ -1,15 +1,17 @@
|
||||||
const { expect } = require('chai')
|
import { expect } from 'chai'
|
||||||
const { ObjectId } = require('mongodb-legacy')
|
import mongodb from 'mongodb-legacy'
|
||||||
const Path = require('path')
|
import Path from 'node:path'
|
||||||
const fs = require('fs')
|
import { fileURLToPath } from 'node:url'
|
||||||
const Settings = require('@overleaf/settings')
|
import fs from 'node:fs'
|
||||||
const _ = require('lodash')
|
import Settings from '@overleaf/settings'
|
||||||
|
import _ from 'lodash'
|
||||||
|
import ProjectGetter from '../../../../../app/src/Features/Project/ProjectGetter.js'
|
||||||
|
import User from '../../../../../test/acceptance/src/helpers/User.js'
|
||||||
|
import MockDocUpdaterApiClass from '../../../../../test/acceptance/src/mocks/MockDocUpdaterApi.js'
|
||||||
|
|
||||||
const ProjectGetter = require('../../../../../app/src/Features/Project/ProjectGetter')
|
const { ObjectId } = mongodb
|
||||||
|
|
||||||
const User = require('../../../../../test/acceptance/src/helpers/User')
|
|
||||||
const MockDocUpdaterApiClass = require('../../../../../test/acceptance/src/mocks/MockDocUpdaterApi')
|
|
||||||
|
|
||||||
|
const __dirname = fileURLToPath(new URL('.', import.meta.url))
|
||||||
const FILES_PATH = Path.join(__dirname, '../../../../../test/acceptance/files')
|
const FILES_PATH = Path.join(__dirname, '../../../../../test/acceptance/files')
|
||||||
|
|
||||||
let MockDocUpdaterApi
|
let MockDocUpdaterApi
|
|
@ -1,27 +1,18 @@
|
||||||
/* eslint-disable
|
import { expect } from 'chai'
|
||||||
max-len,
|
|
||||||
no-unused-vars,
|
|
||||||
*/
|
|
||||||
// TODO: This file was created by bulk-decaffeinate.
|
|
||||||
// Fix any style issues and re-enable lint.
|
|
||||||
/*
|
|
||||||
* decaffeinate suggestions:
|
|
||||||
* DS102: Remove unnecessary code created because of implicit returns
|
|
||||||
* DS207: Consider shorter variations of null checks
|
|
||||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
||||||
*/
|
|
||||||
const { expect } = require('chai')
|
|
||||||
const _ = require('lodash')
|
|
||||||
const fs = require('fs')
|
|
||||||
const Path = require('path')
|
|
||||||
|
|
||||||
const User = require('../../../../../test/acceptance/src/helpers/User')
|
import _ from 'lodash'
|
||||||
const MockProjectHistoryApiClass = require('../../../../../test/acceptance/src/mocks/MockProjectHistoryApi')
|
import fs from 'node:fs'
|
||||||
const MockDocstoreApiClass = require('../../../../../test/acceptance/src/mocks/MockDocstoreApi')
|
import { fileURLToPath } from 'node:url'
|
||||||
const MockFilestoreApiClass = require('../../../../../test/acceptance/src/mocks/MockFilestoreApi')
|
import Path from 'node:path'
|
||||||
|
import User from '../../../../../test/acceptance/src/helpers/User.js'
|
||||||
|
import MockProjectHistoryApiClass from '../../../../../test/acceptance/src/mocks/MockProjectHistoryApi.js'
|
||||||
|
import MockDocstoreApiClass from '../../../../../test/acceptance/src/mocks/MockDocstoreApi.js'
|
||||||
|
import MockFilestoreApiClass from '../../../../../test/acceptance/src/mocks/MockFilestoreApi.js'
|
||||||
|
|
||||||
let MockProjectHistoryApi, MockDocstoreApi, MockFilestoreApi
|
let MockProjectHistoryApi, MockDocstoreApi, MockFilestoreApi
|
||||||
|
|
||||||
|
const __dirname = fileURLToPath(new URL('.', import.meta.url))
|
||||||
|
|
||||||
before(function () {
|
before(function () {
|
||||||
MockProjectHistoryApi = MockProjectHistoryApiClass.instance()
|
MockProjectHistoryApi = MockProjectHistoryApiClass.instance()
|
||||||
MockDocstoreApi = MockDocstoreApiClass.instance()
|
MockDocstoreApi = MockDocstoreApiClass.instance()
|
||||||
|
@ -31,19 +22,19 @@ before(function () {
|
||||||
describe('RestoringFiles', function () {
|
describe('RestoringFiles', function () {
|
||||||
beforeEach(function (done) {
|
beforeEach(function (done) {
|
||||||
this.owner = new User()
|
this.owner = new User()
|
||||||
return this.owner.login(error => {
|
this.owner.login(error => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
return this.owner.createProject(
|
this.owner.createProject(
|
||||||
'example-project',
|
'example-project',
|
||||||
{ template: 'example' },
|
{ template: 'example' },
|
||||||
(error, projectId) => {
|
(error, projectId) => {
|
||||||
this.project_id = projectId
|
this.project_id = projectId
|
||||||
if (error != null) {
|
if (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
return done()
|
done()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -58,7 +49,7 @@ describe('RestoringFiles', function () {
|
||||||
'foo.tex',
|
'foo.tex',
|
||||||
'hello world, this is foo.tex!'
|
'hello world, this is foo.tex!'
|
||||||
)
|
)
|
||||||
return this.owner.request(
|
this.owner.request(
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: `/project/${this.project_id}/restore_file`,
|
url: `/project/${this.project_id}/restore_file`,
|
||||||
|
@ -68,18 +59,18 @@ describe('RestoringFiles', function () {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
(error, response, body) => {
|
(error, response, body) => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
expect(response.statusCode).to.equal(200)
|
expect(response.statusCode).to.equal(200)
|
||||||
return done()
|
done()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should have created a doc', function (done) {
|
it('should have created a doc', function (done) {
|
||||||
return this.owner.getProject(this.project_id, (error, project) => {
|
this.owner.getProject(this.project_id, (error, project) => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
let doc = _.find(
|
let doc = _.find(
|
||||||
|
@ -88,7 +79,7 @@ describe('RestoringFiles', function () {
|
||||||
)
|
)
|
||||||
doc = MockDocstoreApi.docs[this.project_id][doc._id]
|
doc = MockDocstoreApi.docs[this.project_id][doc._id]
|
||||||
expect(doc.lines).to.deep.equal(['hello world, this is foo.tex!'])
|
expect(doc.lines).to.deep.equal(['hello world, this is foo.tex!'])
|
||||||
return done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -108,7 +99,7 @@ describe('RestoringFiles', function () {
|
||||||
'image.png',
|
'image.png',
|
||||||
this.pngData
|
this.pngData
|
||||||
)
|
)
|
||||||
return this.owner.request(
|
this.owner.request(
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: `/project/${this.project_id}/restore_file`,
|
url: `/project/${this.project_id}/restore_file`,
|
||||||
|
@ -118,18 +109,18 @@ describe('RestoringFiles', function () {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
(error, response, body) => {
|
(error, response, body) => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
expect(response.statusCode).to.equal(200)
|
expect(response.statusCode).to.equal(200)
|
||||||
return done()
|
done()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should have created a file', function (done) {
|
it('should have created a file', function (done) {
|
||||||
return this.owner.getProject(this.project_id, (error, project) => {
|
this.owner.getProject(this.project_id, (error, project) => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
let file = _.find(
|
let file = _.find(
|
||||||
|
@ -138,7 +129,7 @@ describe('RestoringFiles', function () {
|
||||||
)
|
)
|
||||||
file = MockFilestoreApi.files[this.project_id][file._id]
|
file = MockFilestoreApi.files[this.project_id][file._id]
|
||||||
expect(file.content).to.equal(this.pngData)
|
expect(file.content).to.equal(this.pngData)
|
||||||
return done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -151,7 +142,7 @@ describe('RestoringFiles', function () {
|
||||||
'foldername/foo2.tex',
|
'foldername/foo2.tex',
|
||||||
'hello world, this is foo-2.tex!'
|
'hello world, this is foo-2.tex!'
|
||||||
)
|
)
|
||||||
return this.owner.request.post(
|
this.owner.request.post(
|
||||||
{
|
{
|
||||||
uri: `project/${this.project_id}/folder`,
|
uri: `project/${this.project_id}/folder`,
|
||||||
json: {
|
json: {
|
||||||
|
@ -159,11 +150,11 @@ describe('RestoringFiles', function () {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
(error, response, body) => {
|
(error, response, body) => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
expect(response.statusCode).to.equal(200)
|
expect(response.statusCode).to.equal(200)
|
||||||
return this.owner.request(
|
this.owner.request(
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: `/project/${this.project_id}/restore_file`,
|
url: `/project/${this.project_id}/restore_file`,
|
||||||
|
@ -173,11 +164,11 @@ describe('RestoringFiles', function () {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
(error, response, body) => {
|
(error, response, body) => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
expect(response.statusCode).to.equal(200)
|
expect(response.statusCode).to.equal(200)
|
||||||
return done()
|
done()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -185,8 +176,8 @@ describe('RestoringFiles', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should have created the doc in the named folder', function (done) {
|
it('should have created the doc in the named folder', function (done) {
|
||||||
return this.owner.getProject(this.project_id, (error, project) => {
|
this.owner.getProject(this.project_id, (error, project) => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
const folder = _.find(
|
const folder = _.find(
|
||||||
|
@ -196,7 +187,7 @@ describe('RestoringFiles', function () {
|
||||||
let doc = _.find(folder.docs, doc => doc.name === 'foo2.tex')
|
let doc = _.find(folder.docs, doc => doc.name === 'foo2.tex')
|
||||||
doc = MockDocstoreApi.docs[this.project_id][doc._id]
|
doc = MockDocstoreApi.docs[this.project_id][doc._id]
|
||||||
expect(doc.lines).to.deep.equal(['hello world, this is foo-2.tex!'])
|
expect(doc.lines).to.deep.equal(['hello world, this is foo-2.tex!'])
|
||||||
return done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -209,7 +200,7 @@ describe('RestoringFiles', function () {
|
||||||
'nothere/foo3.tex',
|
'nothere/foo3.tex',
|
||||||
'hello world, this is foo-3.tex!'
|
'hello world, this is foo-3.tex!'
|
||||||
)
|
)
|
||||||
return this.owner.request(
|
this.owner.request(
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: `/project/${this.project_id}/restore_file`,
|
url: `/project/${this.project_id}/restore_file`,
|
||||||
|
@ -219,18 +210,18 @@ describe('RestoringFiles', function () {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
(error, response, body) => {
|
(error, response, body) => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
expect(response.statusCode).to.equal(200)
|
expect(response.statusCode).to.equal(200)
|
||||||
return done()
|
done()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should have created the folder and restored the doc to it', function (done) {
|
it('should have created the folder and restored the doc to it', function (done) {
|
||||||
return this.owner.getProject(this.project_id, (error, project) => {
|
this.owner.getProject(this.project_id, (error, project) => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
const folder = _.find(
|
const folder = _.find(
|
||||||
|
@ -241,7 +232,7 @@ describe('RestoringFiles', function () {
|
||||||
let doc = _.find(folder.docs, doc => doc.name === 'foo3.tex')
|
let doc = _.find(folder.docs, doc => doc.name === 'foo3.tex')
|
||||||
doc = MockDocstoreApi.docs[this.project_id][doc._id]
|
doc = MockDocstoreApi.docs[this.project_id][doc._id]
|
||||||
expect(doc.lines).to.deep.equal(['hello world, this is foo-3.tex!'])
|
expect(doc.lines).to.deep.equal(['hello world, this is foo-3.tex!'])
|
||||||
return done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -254,7 +245,7 @@ describe('RestoringFiles', function () {
|
||||||
'main.tex',
|
'main.tex',
|
||||||
'hello world, this is main.tex!'
|
'hello world, this is main.tex!'
|
||||||
)
|
)
|
||||||
return this.owner.request(
|
this.owner.request(
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: `/project/${this.project_id}/restore_file`,
|
url: `/project/${this.project_id}/restore_file`,
|
||||||
|
@ -264,18 +255,18 @@ describe('RestoringFiles', function () {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
(error, response, body) => {
|
(error, response, body) => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
expect(response.statusCode).to.equal(200)
|
expect(response.statusCode).to.equal(200)
|
||||||
return done()
|
done()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should have created the doc in the root folder', function (done) {
|
it('should have created the doc in the root folder', function (done) {
|
||||||
return this.owner.getProject(this.project_id, (error, project) => {
|
this.owner.getProject(this.project_id, (error, project) => {
|
||||||
if (error != null) {
|
if (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
let doc = _.find(project.rootFolder[0].docs, doc =>
|
let doc = _.find(project.rootFolder[0].docs, doc =>
|
||||||
|
@ -284,7 +275,7 @@ describe('RestoringFiles', function () {
|
||||||
expect(doc).to.exist
|
expect(doc).to.exist
|
||||||
doc = MockDocstoreApi.docs[this.project_id][doc._id]
|
doc = MockDocstoreApi.docs[this.project_id][doc._id]
|
||||||
expect(doc.lines).to.deep.equal(['hello world, this is main.tex!'])
|
expect(doc.lines).to.deep.equal(['hello world, this is main.tex!'])
|
||||||
return done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
Loading…
Reference in a new issue