|
@@ -22,6 +22,7 @@ describe('LinkedFiles', function () {
|
|
|
let projectOne, projectOneId, projectOneRootFolderId
|
|
let projectOne, projectOneId, projectOneRootFolderId
|
|
|
let projectTwo, projectTwoId, projectTwoRootFolderId
|
|
let projectTwo, projectTwoId, projectTwoRootFolderId
|
|
|
const sourceDocName = 'test.txt'
|
|
const sourceDocName = 'test.txt'
|
|
|
|
|
+ let sourceDocId
|
|
|
let owner
|
|
let owner
|
|
|
|
|
|
|
|
before(function (done) {
|
|
before(function (done) {
|
|
@@ -48,7 +49,7 @@ describe('LinkedFiles', function () {
|
|
|
projectTwo = await owner.getProject(projectTwoId)
|
|
projectTwo = await owner.getProject(projectTwoId)
|
|
|
projectTwoRootFolderId = projectTwo.rootFolder[0]._id.toString()
|
|
projectTwoRootFolderId = projectTwo.rootFolder[0]._id.toString()
|
|
|
|
|
|
|
|
- await owner.createDocInProject(
|
|
|
|
|
|
|
+ sourceDocId = await owner.createDocInProject(
|
|
|
projectTwoId,
|
|
projectTwoId,
|
|
|
projectTwoRootFolderId,
|
|
projectTwoRootFolderId,
|
|
|
sourceDocName
|
|
sourceDocName
|
|
@@ -154,6 +155,41 @@ describe('LinkedFiles', function () {
|
|
|
expect(response.statusCode).to.equal(403)
|
|
expect(response.statusCode).to.equal(403)
|
|
|
expect(body).to.equal('You do not have access to this project')
|
|
expect(body).to.equal('You do not have access to this project')
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ it('should generate a proper error message when the source file has been deleted', async function () {
|
|
|
|
|
+ // import the file from the source project
|
|
|
|
|
+ let { response, body } = await owner.doRequest('post', {
|
|
|
|
|
+ url: `/project/${projectOneId}/linked_file`,
|
|
|
|
|
+ json: {
|
|
|
|
|
+ name: 'test-link.txt',
|
|
|
|
|
+ parent_folder_id: projectOneRootFolderId,
|
|
|
|
|
+ provider: 'project_file',
|
|
|
|
|
+ data: {
|
|
|
|
|
+ source_project_id: projectTwoId,
|
|
|
|
|
+ source_entity_path: `/${sourceDocName}`,
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ })
|
|
|
|
|
+ expect(response.statusCode).to.equal(200)
|
|
|
|
|
+ const existingFileId = body.new_file_id
|
|
|
|
|
+ expect(existingFileId).to.exist
|
|
|
|
|
+
|
|
|
|
|
+ // rename the source file
|
|
|
|
|
+ await owner.renameItemInProject(
|
|
|
|
|
+ projectTwoId,
|
|
|
|
|
+ 'doc',
|
|
|
|
|
+ sourceDocId,
|
|
|
|
|
+ 'renamed-doc.txt'
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ // refresh the file
|
|
|
|
|
+ ;({ response, body } = await owner.doRequest('post', {
|
|
|
|
|
+ url: `/project/${projectOneId}/linked_file/${existingFileId}/refresh`,
|
|
|
|
|
+ json: true,
|
|
|
|
|
+ }))
|
|
|
|
|
+ expect(response.statusCode).to.equal(404)
|
|
|
|
|
+ expect(body).to.equal('Source file not found')
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('with a linked project_file from a v1 project that has not been imported', function () {
|
|
describe('with a linked project_file from a v1 project that has not been imported', function () {
|