fix(server): allow an empty assetIds array when creating an album shared link (#31098)
This commit is contained in:
@@ -330,6 +330,16 @@ describe('/shared-links', () => {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should create an album shared link when the client sends an empty assetIds array', async () => {
|
||||||
|
const { status, body } = await request(app)
|
||||||
|
.post('/shared-links')
|
||||||
|
.set('Authorization', `Bearer ${user1.accessToken}`)
|
||||||
|
.send({ type: SharedLinkType.Album, albumId: album.id, assetIds: [] });
|
||||||
|
|
||||||
|
expect(status).toBe(201);
|
||||||
|
expect(body).toEqual(expect.objectContaining({ type: SharedLinkType.Album, userId: user1.userId }));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('PATCH /shared-links/:id', () => {
|
describe('PATCH /shared-links/:id', () => {
|
||||||
|
|||||||
@@ -77,6 +77,17 @@ describe(SharedLinkController.name, () => {
|
|||||||
);
|
);
|
||||||
expect(service.create).not.toHaveBeenCalled();
|
expect(service.create).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should allow an empty assetIds array for share type Album', async () => {
|
||||||
|
const albumId = newUuid();
|
||||||
|
await request(ctx.getHttpServer())
|
||||||
|
.post('/shared-links')
|
||||||
|
.send({ type: SharedLinkType.Album, albumId, assetIds: [] });
|
||||||
|
expect(service.create).toHaveBeenCalledWith(
|
||||||
|
undefined,
|
||||||
|
expect.objectContaining({ type: SharedLinkType.Album, albumId }),
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('DELETE /shared-links/:id/assets', () => {
|
describe('DELETE /shared-links/:id/assets', () => {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ const SharedLinkCreateSchema = z
|
|||||||
if (!albumId) {
|
if (!albumId) {
|
||||||
ctx.addIssue(`albumId is required for type ${SharedLinkType.Album}`);
|
ctx.addIssue(`albumId is required for type ${SharedLinkType.Album}`);
|
||||||
}
|
}
|
||||||
if (assetIds) {
|
if (assetIds && assetIds.length > 0) {
|
||||||
ctx.addIssue(`assetIds can only be used with type ${SharedLinkType.Individual}`);
|
ctx.addIssue(`assetIds can only be used with type ${SharedLinkType.Individual}`);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user