Zotero Integration (#164)

This commit is contained in:
David Rotermund
2026-07-07 14:42:58 +02:00
committed by yu-i-i
parent b1cf1f3c4b
commit 7ae7736a8c
22 changed files with 1117 additions and 14 deletions
@@ -1,5 +1,6 @@
import { expect, vi } from 'vitest'
import sinon from 'sinon'
import LinkedFilesErrors from '../../../../app/src/Features/LinkedFiles/LinkedFilesErrors.mjs'
const modulePath =
'../../../../app/src/Features/LinkedFiles/LinkedFilesController.mjs'
@@ -224,6 +225,37 @@ describe('LinkedFilesController', function () {
)
})
})
it('returns error 400 if user is not original importer', async function (ctx) {
ctx.Agent.promises.refreshLinkedFile = sinon
.stub()
.rejects(
new LinkedFilesErrors.NotOriginalImporterError(
'Only the user who created the Zotero-linked file can refresh this file'
)
)
await new Promise(resolve => {
ctx.next = sinon.stub().callsFake(() => resolve('unexpected error'))
ctx.res = {
status: sinon.stub().callsFake(code => {
expect(code).to.equal(400)
return ctx.res
}),
contentType: sinon.stub(),
setHeader: sinon.stub(),
send: sinon.stub(msg => {
expect(msg).to.equal('You are not the user who originally imported this file')
resolve()
}),
}
ctx.LinkedFilesController.refreshLinkedFile(ctx.req, ctx.res, ctx.next)
})
})
})
expect(ctx.Agent.promises.refreshLinkedFile).to.not.have.been.called
})
})
})