Skip to content

Commit f79afbf

Browse files
committed
test(db): update workspace file size fixtures
1 parent c3960be commit f79afbf

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

apps/sim/lib/uploads/contexts/workspace/workspace-file-query.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ function buildRow(overrides: Record<string, unknown> = {}) {
6666
originalName: 'data.csv',
6767
contentType: 'text/csv',
6868
size: 1024,
69+
sizeBytes: 1024,
6970
deletedAt: null,
7071
uploadedAt: new Date('2024-01-01T00:00:00Z'),
7172
updatedAt: new Date('2024-01-02T00:00:00Z'),

apps/sim/lib/uploads/contexts/workspace/workspace-file-storage-accounting.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ const FILE_ROW = {
141141
displayName: 'note.txt',
142142
contentType: 'text/plain',
143143
size: 5,
144+
sizeBytes: 5,
144145
deletedAt: null,
145146
uploadedAt: new Date('2026-07-01T00:00:00.000Z'),
146147
updatedAt: new Date('2026-07-01T00:00:00.000Z'),
@@ -666,12 +667,13 @@ describe('workspace file metadata and storage accounting', () => {
666667
})
667668

668669
it('uploads an overwrite before atomically swapping the locked row and exact delta', async () => {
669-
const concurrentFile = { ...FILE_ROW, size: 7 }
670+
const concurrentFile = { ...FILE_ROW, size: 7, sizeBytes: 7 }
670671
const replacementKey = `${FILE_ROW.key}-replacement`
671672
const updatedFile = {
672673
...concurrentFile,
673674
key: replacementKey,
674675
size: 10,
676+
sizeBytes: 10,
675677
updatedAt: new Date('2026-07-03T00:00:00.000Z'),
676678
}
677679
dbChainMockFns.limit.mockResolvedValueOnce([FILE_ROW]).mockResolvedValueOnce([concurrentFile])
@@ -715,7 +717,7 @@ describe('workspace file metadata and storage accounting', () => {
715717

716718
it('cleans up only the new overwrite object when atomic finalization fails', async () => {
717719
const replacementKey = `${FILE_ROW.key}-replacement`
718-
const updatedFile = { ...FILE_ROW, key: replacementKey, size: 10 }
720+
const updatedFile = { ...FILE_ROW, key: replacementKey, size: 10, sizeBytes: 10 }
719721
dbChainMockFns.limit.mockResolvedValueOnce([FILE_ROW]).mockResolvedValueOnce([FILE_ROW])
720722
dbChainMockFns.returning.mockResolvedValueOnce([updatedFile])
721723
mockUploadFile.mockResolvedValueOnce({ key: replacementKey })
@@ -744,6 +746,7 @@ describe('workspace file metadata and storage accounting', () => {
744746
const updatedFile = {
745747
...MD_ROW,
746748
size: 12,
749+
sizeBytes: 12,
747750
updatedAt: new Date('2026-07-05T00:00:00.000Z'),
748751
contentUpdatedAt: new Date('2026-07-04T00:00:00.000Z'),
749752
}
@@ -764,7 +767,7 @@ describe('workspace file metadata and storage accounting', () => {
764767
})
765768

766769
it('does NOT merge when syncLiveDoc is false (the relay persist / empty-shell opt-out)', async () => {
767-
const updatedFile = { ...MD_ROW, size: 12 }
770+
const updatedFile = { ...MD_ROW, size: 12, sizeBytes: 12 }
768771
dbChainMockFns.limit.mockResolvedValueOnce([MD_ROW]).mockResolvedValueOnce([MD_ROW])
769772
dbChainMockFns.returning.mockResolvedValueOnce([updatedFile])
770773
mockUploadFile.mockResolvedValueOnce({ key: MD_ROW.key })
@@ -782,7 +785,7 @@ describe('workspace file metadata and storage accounting', () => {
782785
})
783786

784787
it('does NOT merge a non-markdown write (the collaborative editor only renders markdown)', async () => {
785-
const updatedFile = { ...FILE_ROW, size: 10 }
788+
const updatedFile = { ...FILE_ROW, size: 10, sizeBytes: 10 }
786789
dbChainMockFns.limit.mockResolvedValueOnce([FILE_ROW]).mockResolvedValueOnce([FILE_ROW])
787790
dbChainMockFns.returning.mockResolvedValueOnce([updatedFile])
788791
mockUploadFile.mockResolvedValueOnce({ key: FILE_ROW.key })
@@ -799,7 +802,7 @@ describe('workspace file metadata and storage accounting', () => {
799802
})
800803

801804
it('writes when the expectedUpdatedAt optimistic-concurrency guard matches', async () => {
802-
const updatedFile = { ...FILE_ROW, size: 12 }
805+
const updatedFile = { ...FILE_ROW, size: 12, sizeBytes: 12 }
803806
dbChainMockFns.limit.mockResolvedValueOnce([FILE_ROW]).mockResolvedValueOnce([FILE_ROW])
804807
dbChainMockFns.returning.mockResolvedValueOnce([updatedFile])
805808
mockUploadFile.mockResolvedValueOnce({ key: FILE_ROW.key })

apps/sim/lib/uploads/contexts/workspace/workspace-file-storage-billing.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ describe('workspace file storage attribution', () => {
8888
displayName: 'note.txt',
8989
contentType: 'text/plain',
9090
size: 5,
91+
sizeBytes: 5,
9192
deletedAt: null,
9293
uploadedAt: new Date(),
9394
updatedAt: new Date(),

0 commit comments

Comments
 (0)