Skip to content

Commit 9060016

Browse files
committed
chore(release): merge staging into the v0.9.43 release
2 parents d887612 + f0a3432 commit 9060016

2 files changed

Lines changed: 31 additions & 19 deletions

File tree

‎apps/sim/app/api/v2/files/[fileId]/route.test.ts‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -187,23 +187,6 @@ describe('v2 single-file routes', () => {
187187
expect(response.headers.get('X-Content-Type-Options')).toBe('nosniff')
188188
})
189189

190-
it('downloads a file named by its files/ VFS path', async () => {
191-
const vfsPath = 'files/Docs/data.csv'
192-
const response = await GET(
193-
new NextRequest(
194-
`http://localhost:3000/api/v2/files/${encodeURIComponent(vfsPath)}?workspaceId=${WORKSPACE_ID}`
195-
),
196-
{ params: Promise.resolve({ fileId: vfsPath }) }
197-
)
198-
199-
expect(response.status).toBe(200)
200-
expect(mocks.download).toHaveBeenCalledWith(
201-
expect.objectContaining({
202-
input: { fileId: vfsPath, acceptVfsPath: true, assertedWorkspaceId: WORKSPACE_ID },
203-
})
204-
)
205-
})
206-
207190
it('conceals cross-workspace download authorization', async () => {
208191
mocks.download.mockRejectedValue(new NoWorkspaceAccessError())
209192

‎apps/sim/scripts/test-file-delivery-e2e.ts‎

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,15 @@ async function create(
8181
owner: 'workspace' | 'project',
8282
name: string,
8383
contentType: string,
84-
content: string
84+
content: string,
85+
folderId?: string
8586
) {
8687
const response = await request(
8788
`/api/${owner === 'workspace' ? `workspaces/${workspaceId}` : `projects/${projectId}`}/files`,
88-
{ method: 'POST', body: JSON.stringify({ name, contentType, content, encoding: 'utf-8' }) }
89+
{
90+
method: 'POST',
91+
body: JSON.stringify({ name, contentType, content, encoding: 'utf-8', folderId }),
92+
}
8993
)
9094
assert.ok(response.ok, `Create returned ${response.status}: ${await response.clone().text()}`)
9195
return toRecord(toRecord(await response.json()).file)
@@ -204,6 +208,31 @@ await check(
204208
}
205209
}
206210
)
211+
await check('v2 workspace download routes a %2F-encoded files/ VFS path to its file', async () => {
212+
const folderResponse = await request(`/api/workspaces/${workspaceId}/files/folders`, {
213+
method: 'POST',
214+
body: JSON.stringify({ name: 'VfsDocs' }),
215+
})
216+
assert.ok(folderResponse.ok, `Folder create returned ${folderResponse.status}`)
217+
const folderId = required(toRecord(toRecord(await folderResponse.json()).folder).id)
218+
await create('workspace', 'vfs-report.csv', 'text/csv', 'root copy')
219+
await create('workspace', 'vfs-report.csv', 'text/csv', 'folder copy', folderId)
220+
const download = (path: string) =>
221+
request(
222+
`/api/v2/files/${encodeURIComponent(path)}?workspaceId=${workspaceId}`,
223+
{ headers: { 'X-API-Key': personalKey } },
224+
true
225+
)
226+
for (const [path, content] of [
227+
['files/VfsDocs/vfs-report.csv', 'folder copy'],
228+
['files/vfs-report.csv', 'root copy'],
229+
]) {
230+
const response = await download(path)
231+
assert.equal(response.status, 200, `${path} returned ${response.status}`)
232+
assert.equal(await response.text(), content)
233+
}
234+
assert.equal((await download('files/VfsDocs/missing.csv')).status, 404)
235+
})
207236
await check('Workspace immutable URLs, authorized 304 and browser cache reuse', async () => {
208237
const file = await create('workspace', 'cache.txt', 'text/plain', 'workspace cache bytes')
209238
const path = `/api/files/serve/${required(file.key)}`

0 commit comments

Comments
 (0)