[api] adjust to match images v5 derived shape

This commit is contained in:
Devin Zuczek
2026-10-22 13:08:29 -04:00
parent 76db89c30c
commit 1d0e71d651
4 changed files with 86 additions and 18 deletions
+25 -8
View File
@@ -7106,20 +7106,37 @@ describe('images', () => {
// Request order, not id order — the client lines the answers up with what it asked for.
const both = await bulk(`?ids=${two.Id}&ids=${one.Id}`)
expect(both.map((i) => i.Id)).toEqual([two.Id, one.Id])
// The RAW SavedImage: `Id`/`Type`, and TaggedPlayerIds present — not the
// SavedImageId/SavedImageType projection the player photo lists serve.
expect(both.map((i) => i.SavedImageId)).toEqual([two.Id, one.Id])
// The ImagesPlayer projection plus ClubId — not the raw SavedImage (`Id`/`Type`,
// `TaggedPlayerIds`).
expect(Object.keys(both[0]).sort()).toEqual(
[
'SavedImageId',
'ImageName',
'PlayerId',
'RoomId',
'PlayerEventId',
'ClubId',
'Description',
'Accessibility',
'AccessibilityLocked',
'SavedImageType',
'CreatedAt',
'CheerCount',
'CommentCount',
].sort()
)
expect(both[0]).toMatchObject({
Id: two.Id,
Type: two.Type,
SavedImageId: two.Id,
SavedImageType: two.Type,
ImageName: 'bulktwo.jpg',
PlayerId: 7102,
TaggedPlayerIds: [],
ClubId: null,
})
// An unknown id and a non-public one are absent rather than errors or holes, so the
// answer can be shorter than the request.
expect((await bulk(`?ids=${one.Id}&ids=999999&ids=${hidden.Id}`)).map((i) => i.Id)).toEqual([
expect((await bulk(`?ids=${one.Id}&ids=999999&ids=${hidden.Id}`)).map((i) => i.SavedImageId)).toEqual([
one.Id,
])
@@ -7128,7 +7145,7 @@ describe('images', () => {
// More ids than D1 will bind in one query (100) — the lookup has to split.
const many = [...Array.from({ length: 130 }, (_, i) => 800000 + i), one.Id, two.Id]
expect((await bulk(`?${many.map((id) => `ids=${id}`).join('&')}`)).map((i) => i.Id)).toEqual([
expect((await bulk(`?${many.map((id) => `ids=${id}`).join('&')}`)).map((i) => i.SavedImageId)).toEqual([
one.Id,
two.Id,
])