mirror of
https://github.com/immich-app/immich.git
synced 2024-11-16 10:28:54 -07:00
b3c7bebbd4
* add library validation api * chore: open api * show warning i UI * add flex row * fix e2e * tests * fix tests * enforce path validation * enforce validation on refresh * return 400 on bad import path * add limits to import paths * set response code to 200 * fix e2e * fix lint * fix test * restore e2e folder * fix import * use startsWith * icon color * notify user of failed validation * add parent div to validation * add docs to the import validation * improve library troubleshooting docs * fix button alignment --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
72 lines
2.6 KiB
TypeScript
72 lines
2.6 KiB
TypeScript
import {
|
|
CreateLibraryDto,
|
|
LibraryResponseDto,
|
|
LibraryStatsResponseDto,
|
|
ScanLibraryDto,
|
|
UpdateLibraryDto,
|
|
ValidateLibraryDto,
|
|
ValidateLibraryResponseDto,
|
|
} from '@app/domain';
|
|
import request from 'supertest';
|
|
|
|
export const libraryApi = {
|
|
getAll: async (server: any, accessToken: string) => {
|
|
const { body, status } = await request(server).get(`/library/`).set('Authorization', `Bearer ${accessToken}`);
|
|
expect(status).toBe(200);
|
|
return body as LibraryResponseDto[];
|
|
},
|
|
create: async (server: any, accessToken: string, dto: CreateLibraryDto) => {
|
|
const { body, status } = await request(server)
|
|
.post(`/library/`)
|
|
.set('Authorization', `Bearer ${accessToken}`)
|
|
.send(dto);
|
|
expect(status).toBe(201);
|
|
return body as LibraryResponseDto;
|
|
},
|
|
setImportPaths: async (server: any, accessToken: string, id: string, importPaths: string[]) => {
|
|
const { body, status } = await request(server)
|
|
.put(`/library/${id}`)
|
|
.set('Authorization', `Bearer ${accessToken}`)
|
|
.send({ importPaths });
|
|
expect(status).toBe(200);
|
|
return body as LibraryResponseDto;
|
|
},
|
|
scanLibrary: async (server: any, accessToken: string, id: string, dto: ScanLibraryDto = {}) => {
|
|
const { status } = await request(server)
|
|
.post(`/library/${id}/scan`)
|
|
.set('Authorization', `Bearer ${accessToken}`)
|
|
.send(dto);
|
|
expect(status).toBe(201);
|
|
},
|
|
removeOfflineFiles: async (server: any, accessToken: string, id: string) => {
|
|
const { status } = await request(server)
|
|
.post(`/library/${id}/removeOffline`)
|
|
.set('Authorization', `Bearer ${accessToken}`)
|
|
.send();
|
|
expect(status).toBe(201);
|
|
},
|
|
getLibraryStatistics: async (server: any, accessToken: string, id: string): Promise<LibraryStatsResponseDto> => {
|
|
const { body, status } = await request(server)
|
|
.get(`/library/${id}/statistics`)
|
|
.set('Authorization', `Bearer ${accessToken}`);
|
|
expect(status).toBe(200);
|
|
return body;
|
|
},
|
|
update: async (server: any, accessToken: string, id: string, data: UpdateLibraryDto) => {
|
|
const { body, status } = await request(server)
|
|
.put(`/library/${id}`)
|
|
.set('Authorization', `Bearer ${accessToken}`)
|
|
.send(data);
|
|
expect(status).toBe(200);
|
|
return body as LibraryResponseDto;
|
|
},
|
|
validate: async (server: any, accessToken: string, id: string, data: ValidateLibraryDto) => {
|
|
const { body, status } = await request(server)
|
|
.post(`/library/${id}/validate`)
|
|
.set('Authorization', `Bearer ${accessToken}`)
|
|
.send(data);
|
|
expect(status).toBe(200);
|
|
return body as ValidateLibraryResponseDto;
|
|
},
|
|
};
|