Merge pull request #22239 from overleaf/jpa-file-url-helper

[web] add helper for getting file URL from history w/ filestore fallback

GitOrigin-RevId: d77e6f1565fab407e1004a02c4bfdfe03a0214d7
This commit is contained in:
Jakob Ackermann
2024-12-02 09:05:26 +00:00
committed by Copybot
parent 8db1f2c9bc
commit b9a56afe4c
4 changed files with 89 additions and 21 deletions
@@ -116,6 +116,59 @@ describe('TpdsUpdateSender', function () {
})
it('queues a post the file with user and file id', async function () {
const fileId = '4545345'
const hash = undefined
const historyId = 91525
const path = '/some/path/here.jpg'
await this.TpdsUpdateSender.promises.addFile({
projectId,
historyId,
fileId,
hash,
path,
projectName,
})
expect(this.FetchUtils.fetchNothing).to.have.been.calledWithMatch(
this.enqueueUrl,
{
json: {
group: userId,
method: 'pipeStreamFrom',
job: {
method: 'post',
streamOrigin: `${filestoreUrl}/project/${projectId}/file/${fileId}`,
uri: `${thirdPartyDataStoreApiUrl}/user/${userId}/entity/${encodeURIComponent(
projectName
)}${encodeURIComponent(path)}`,
headers: {},
},
},
}
)
expect(this.FetchUtils.fetchNothing).to.have.been.calledWithMatch(
this.enqueueUrl,
{
json: {
group: collaberatorRef,
},
}
)
expect(this.FetchUtils.fetchNothing).to.have.been.calledWithMatch(
this.enqueueUrl,
{
json: {
group: readOnlyRef,
job: {},
},
}
)
})
it('queues a post the file with user and file id and hash', async function () {
const fileId = '4545345'
const hash = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
const historyId = 91525