Skip to content

Commit 8e82431

Browse files
committed
test(project-files): follow canonical inline cache policy
1 parent 4e2b29d commit 8e82431

1 file changed

Lines changed: 24 additions & 16 deletions

File tree

‎apps/sim/scripts/test-project-file-inline-source-e2e.ts‎

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,31 @@ await check(
6161
assert.ok((await response.arrayBuffer()).byteLength > 0)
6262
}
6363
)
64-
await check('Private Project inline responses disable browser cache reuse', async () => {
65-
const metadata = await request(
66-
`/api/projects/${owner.entityId}/files/${required(doc.imageId)}`,
67-
true
68-
)
69-
assert.equal(metadata.status, 200)
70-
const key = required(toRecord(toRecord(await metadata.json()).file).key)
71-
for (const query of [
72-
`key=${encodeURIComponent(key)}`,
73-
`fileId=${encodeURIComponent(required(doc.imageId))}`,
74-
]) {
75-
const response = await request(`/api/projects/${owner.entityId}/files/inline?${query}`, true)
76-
assert.equal(response.status, 200)
77-
assert.equal(response.headers.get('cache-control'), 'private, no-store')
78-
assert.ok((await response.arrayBuffer()).byteLength > 0)
64+
await check(
65+
'Private Project inline caching distinguishes immutable keys from live file IDs',
66+
async () => {
67+
const metadata = await request(
68+
`/api/projects/${owner.entityId}/files/${required(doc.imageId)}`,
69+
true
70+
)
71+
assert.equal(metadata.status, 200)
72+
const key = required(toRecord(toRecord(await metadata.json()).file).key)
73+
for (const query of [
74+
`key=${encodeURIComponent(key)}`,
75+
`fileId=${encodeURIComponent(required(doc.imageId))}`,
76+
]) {
77+
const response = await request(`/api/projects/${owner.entityId}/files/inline?${query}`, true)
78+
assert.equal(response.status, 200)
79+
assert.equal(
80+
response.headers.get('cache-control'),
81+
query.startsWith('key=')
82+
? 'private, max-age=31536000, immutable'
83+
: 'private, no-cache, must-revalidate'
84+
)
85+
assert.ok((await response.arrayBuffer()).byteLength > 0)
86+
}
7987
}
80-
})
88+
)
8189
await check(
8290
'The document token grants its own image and conceals the foreign Project image',
8391
async () => {

0 commit comments

Comments
 (0)