mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-16 21:17:39 +00:00
Merge pull request #5277 from overleaf/jpa-handle-missing-file-during-refresh
[web] fix handling of missing source file when refreshing a linked file GitOrigin-RevId: 775bf08a37adb20e71a1492d27bce9a41b959d27
This commit is contained in:
parent
4b0e85f340
commit
b58ba2299a
2 changed files with 38 additions and 2 deletions
|
@ -197,7 +197,7 @@ module.exports = ProjectFileAgent = {
|
|||
},
|
||||
function (err, entity, type) {
|
||||
if (err != null) {
|
||||
if (/^not found.*/.test(err.toString())) {
|
||||
if (/^not found.*/.test(err.message)) {
|
||||
err = new SourceFileNotFoundError()
|
||||
}
|
||||
return callback(err)
|
||||
|
|
|
@ -22,6 +22,7 @@ describe('LinkedFiles', function () {
|
|||
let projectOne, projectOneId, projectOneRootFolderId
|
||||
let projectTwo, projectTwoId, projectTwoRootFolderId
|
||||
const sourceDocName = 'test.txt'
|
||||
let sourceDocId
|
||||
let owner
|
||||
|
||||
before(function (done) {
|
||||
|
@ -48,7 +49,7 @@ describe('LinkedFiles', function () {
|
|||
projectTwo = await owner.getProject(projectTwoId)
|
||||
projectTwoRootFolderId = projectTwo.rootFolder[0]._id.toString()
|
||||
|
||||
await owner.createDocInProject(
|
||||
sourceDocId = await owner.createDocInProject(
|
||||
projectTwoId,
|
||||
projectTwoRootFolderId,
|
||||
sourceDocName
|
||||
|
@ -154,6 +155,41 @@ describe('LinkedFiles', function () {
|
|||
expect(response.statusCode).to.equal(403)
|
||||
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 () {
|
||||
|
|
Loading…
Add table
Reference in a new issue