mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
feat(server/web): album description (#3558)
* feat(server): add album description * chore: open api * fix: tests * show and edit description on the web * fix test * remove unused code * type event * format fix --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
parent
deaf81e2a4
commit
2f26a7edae
28 changed files with 287 additions and 41 deletions
|
|
@ -4,7 +4,7 @@ import { SharedLinkType } from '@app/infra/entities';
|
|||
import { INestApplication } from '@nestjs/common';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import request from 'supertest';
|
||||
import { errorStub } from '../fixtures';
|
||||
import { errorStub, uuidStub } from '../fixtures';
|
||||
import { api, db } from '../test-utils';
|
||||
|
||||
const user1SharedUser = 'user1SharedUser';
|
||||
|
|
@ -193,6 +193,7 @@ describe(`${AlbumController.name} (e2e)`, () => {
|
|||
updatedAt: expect.any(String),
|
||||
ownerId: user1.userId,
|
||||
albumName: 'New album',
|
||||
description: '',
|
||||
albumThumbnailAssetId: null,
|
||||
shared: false,
|
||||
sharedUsers: [],
|
||||
|
|
@ -202,4 +203,32 @@ describe(`${AlbumController.name} (e2e)`, () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('PATCH /album/:id', () => {
|
||||
it('should require authentication', async () => {
|
||||
const { status, body } = await request(server)
|
||||
.patch(`/album/${uuidStub.notFound}`)
|
||||
.send({ albumName: 'New album name' });
|
||||
expect(status).toBe(401);
|
||||
expect(body).toEqual(errorStub.unauthorized);
|
||||
});
|
||||
|
||||
it('should update an album', async () => {
|
||||
const album = await api.albumApi.create(server, user1.accessToken, { albumName: 'New album' });
|
||||
const { status, body } = await request(server)
|
||||
.patch(`/album/${album.id}`)
|
||||
.set('Authorization', `Bearer ${user1.accessToken}`)
|
||||
.send({
|
||||
albumName: 'New album name',
|
||||
description: 'An album description',
|
||||
});
|
||||
expect(status).toBe(200);
|
||||
expect(body).toEqual({
|
||||
...album,
|
||||
updatedAt: expect.any(String),
|
||||
albumName: 'New album name',
|
||||
description: 'An album description',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
10
server/test/fixtures/album.stub.ts
vendored
10
server/test/fixtures/album.stub.ts
vendored
|
|
@ -7,6 +7,7 @@ export const albumStub = {
|
|||
empty: Object.freeze<AlbumEntity>({
|
||||
id: 'album-1',
|
||||
albumName: 'Empty album',
|
||||
description: '',
|
||||
ownerId: authStub.admin.id,
|
||||
owner: userStub.admin,
|
||||
assets: [],
|
||||
|
|
@ -20,6 +21,7 @@ export const albumStub = {
|
|||
sharedWithUser: Object.freeze<AlbumEntity>({
|
||||
id: 'album-2',
|
||||
albumName: 'Empty album shared with user',
|
||||
description: '',
|
||||
ownerId: authStub.admin.id,
|
||||
owner: userStub.admin,
|
||||
assets: [],
|
||||
|
|
@ -33,6 +35,7 @@ export const albumStub = {
|
|||
sharedWithMultiple: Object.freeze<AlbumEntity>({
|
||||
id: 'album-3',
|
||||
albumName: 'Empty album shared with users',
|
||||
description: '',
|
||||
ownerId: authStub.admin.id,
|
||||
owner: userStub.admin,
|
||||
assets: [],
|
||||
|
|
@ -46,6 +49,7 @@ export const albumStub = {
|
|||
sharedWithAdmin: Object.freeze<AlbumEntity>({
|
||||
id: 'album-3',
|
||||
albumName: 'Empty album shared with admin',
|
||||
description: '',
|
||||
ownerId: authStub.user1.id,
|
||||
owner: userStub.user1,
|
||||
assets: [],
|
||||
|
|
@ -59,6 +63,7 @@ export const albumStub = {
|
|||
oneAsset: Object.freeze<AlbumEntity>({
|
||||
id: 'album-4',
|
||||
albumName: 'Album with one asset',
|
||||
description: '',
|
||||
ownerId: authStub.admin.id,
|
||||
owner: userStub.admin,
|
||||
assets: [assetStub.image],
|
||||
|
|
@ -72,6 +77,7 @@ export const albumStub = {
|
|||
twoAssets: Object.freeze<AlbumEntity>({
|
||||
id: 'album-4a',
|
||||
albumName: 'Album with two assets',
|
||||
description: '',
|
||||
ownerId: authStub.admin.id,
|
||||
owner: userStub.admin,
|
||||
assets: [assetStub.image, assetStub.withLocation],
|
||||
|
|
@ -85,6 +91,7 @@ export const albumStub = {
|
|||
emptyWithInvalidThumbnail: Object.freeze<AlbumEntity>({
|
||||
id: 'album-5',
|
||||
albumName: 'Empty album with invalid thumbnail',
|
||||
description: '',
|
||||
ownerId: authStub.admin.id,
|
||||
owner: userStub.admin,
|
||||
assets: [],
|
||||
|
|
@ -98,6 +105,7 @@ export const albumStub = {
|
|||
emptyWithValidThumbnail: Object.freeze<AlbumEntity>({
|
||||
id: 'album-5',
|
||||
albumName: 'Empty album with invalid thumbnail',
|
||||
description: '',
|
||||
ownerId: authStub.admin.id,
|
||||
owner: userStub.admin,
|
||||
assets: [],
|
||||
|
|
@ -111,6 +119,7 @@ export const albumStub = {
|
|||
oneAssetInvalidThumbnail: Object.freeze<AlbumEntity>({
|
||||
id: 'album-6',
|
||||
albumName: 'Album with one asset and invalid thumbnail',
|
||||
description: '',
|
||||
ownerId: authStub.admin.id,
|
||||
owner: userStub.admin,
|
||||
assets: [assetStub.image],
|
||||
|
|
@ -124,6 +133,7 @@ export const albumStub = {
|
|||
oneAssetValidThumbnail: Object.freeze<AlbumEntity>({
|
||||
id: 'album-6',
|
||||
albumName: 'Album with one asset and invalid thumbnail',
|
||||
description: '',
|
||||
ownerId: authStub.admin.id,
|
||||
owner: userStub.admin,
|
||||
assets: [assetStub.image],
|
||||
|
|
|
|||
2
server/test/fixtures/shared-link.stub.ts
vendored
2
server/test/fixtures/shared-link.stub.ts
vendored
|
|
@ -68,6 +68,7 @@ const assetResponse: AssetResponseDto = {
|
|||
|
||||
const albumResponse: AlbumResponseDto = {
|
||||
albumName: 'Test Album',
|
||||
description: '',
|
||||
albumThumbnailAssetId: null,
|
||||
createdAt: today,
|
||||
updatedAt: today,
|
||||
|
|
@ -146,6 +147,7 @@ export const sharedLinkStub = {
|
|||
ownerId: authStub.admin.id,
|
||||
owner: userStub.admin,
|
||||
albumName: 'Test Album',
|
||||
description: '',
|
||||
createdAt: today,
|
||||
updatedAt: today,
|
||||
albumThumbnailAsset: null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue