mirror of
https://github.com/immich-app/immich.git
synced 2025-11-02 02:27:09 -05:00
* Multi add to album picker: - update modal for multi select - Update add-to-album and add-to-album-action to work with new array return from AlbumPickerModal - Add asset-utils.addAssetsToAlbums (incomplete) * initial addToAlbums endpoint * - fix endpoint - add test * - update return type - make open-api * - simplify return dto - handle notification * - fix returns - clean up * - update i18n - format & check * - checks * - correct successId count - fix assets_cannot_be_added language call * tests * foromat * refactor * - update successful add message to included total attempted * - fix web test - format i18n * - fix open-api * - fix imports to resolve checks * - PR suggestions * open-api * refactor addAssetsToAlbums * refactor it again * - fix error returns and tests * - swap icon for IconButton - don't nest the buttons * open-api * - Cleanup multi-select button to match Thumbnail * merge and openapi * - remove onclick from icon element * - fix double onClose call with keyboard shortcuts * - spelling and formatting - apply new api permission * - open-api * chore: styling * translation --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
96 lines
3.3 KiB
TypeScript
96 lines
3.3 KiB
TypeScript
import { AlbumController } from 'src/controllers/album.controller';
|
|
import { AlbumService } from 'src/services/album.service';
|
|
import request from 'supertest';
|
|
import { factory } from 'test/small.factory';
|
|
import { ControllerContext, controllerSetup, mockBaseService } from 'test/utils';
|
|
|
|
describe(AlbumController.name, () => {
|
|
let ctx: ControllerContext;
|
|
const service = mockBaseService(AlbumService);
|
|
|
|
beforeAll(async () => {
|
|
ctx = await controllerSetup(AlbumController, [{ provide: AlbumService, useValue: service }]);
|
|
return () => ctx.close();
|
|
});
|
|
|
|
beforeEach(() => {
|
|
service.resetAllMocks();
|
|
ctx.reset();
|
|
});
|
|
|
|
describe('GET /albums', () => {
|
|
it('should be an authenticated route', async () => {
|
|
await request(ctx.getHttpServer()).post('/albums');
|
|
expect(ctx.authenticate).toHaveBeenCalled();
|
|
});
|
|
|
|
it('should reject an invalid shared param', async () => {
|
|
const { status, body } = await request(ctx.getHttpServer()).get('/albums?shared=invalid');
|
|
expect(status).toEqual(400);
|
|
expect(body).toEqual(factory.responses.badRequest(['shared must be a boolean value']));
|
|
});
|
|
|
|
it('should reject an invalid assetId param', async () => {
|
|
const { status, body } = await request(ctx.getHttpServer()).get('/albums?assetId=invalid');
|
|
expect(status).toEqual(400);
|
|
expect(body).toEqual(factory.responses.badRequest(['assetId must be a UUID']));
|
|
});
|
|
});
|
|
|
|
describe('GET /albums/:id', () => {
|
|
it('should be an authenticated route', async () => {
|
|
await request(ctx.getHttpServer()).get(`/albums/${factory.uuid()}`);
|
|
expect(ctx.authenticate).toHaveBeenCalled();
|
|
});
|
|
});
|
|
|
|
describe('GET /albums/statistics', () => {
|
|
it('should be an authenticated route', async () => {
|
|
await request(ctx.getHttpServer()).get('/albums/statistics');
|
|
expect(ctx.authenticate).toHaveBeenCalled();
|
|
});
|
|
});
|
|
|
|
describe('POST /albums', () => {
|
|
it('should be an authenticated route', async () => {
|
|
await request(ctx.getHttpServer()).post('/albums').send({ albumName: 'New album' });
|
|
expect(ctx.authenticate).toHaveBeenCalled();
|
|
});
|
|
});
|
|
|
|
describe('PUT /albums/:id/assets', () => {
|
|
it('should be an authenticated route', async () => {
|
|
await request(ctx.getHttpServer()).put(`/albums/${factory.uuid()}/assets`);
|
|
expect(ctx.authenticate).toHaveBeenCalled();
|
|
});
|
|
});
|
|
|
|
describe('PUT /albums/assets', () => {
|
|
it('should be an authenticated route', async () => {
|
|
await request(ctx.getHttpServer()).put(`/albums/assets`);
|
|
expect(ctx.authenticate).toHaveBeenCalled();
|
|
});
|
|
});
|
|
|
|
describe('PATCH /albums/:id', () => {
|
|
it('should be an authenticated route', async () => {
|
|
await request(ctx.getHttpServer()).patch(`/albums/${factory.uuid()}`).send({ albumName: 'New album name' });
|
|
expect(ctx.authenticate).toHaveBeenCalled();
|
|
});
|
|
});
|
|
|
|
describe('DELETE /albums/:id/assets', () => {
|
|
it('should be an authenticated route', async () => {
|
|
await request(ctx.getHttpServer()).delete(`/albums/${factory.uuid()}/assets`);
|
|
expect(ctx.authenticate).toHaveBeenCalled();
|
|
});
|
|
});
|
|
|
|
describe('PUT :id/users', () => {
|
|
it('should be an authenticated route', async () => {
|
|
await request(ctx.getHttpServer()).put(`/albums/${factory.uuid()}/users`);
|
|
expect(ctx.authenticate).toHaveBeenCalled();
|
|
});
|
|
});
|
|
});
|