immich/e2e/src/api/specs/server-info.e2e-spec.ts

166 lines
5 KiB
TypeScript
Raw Normal View History

import { LoginResponseDto } from '@immich/sdk';
import { createUserDto } from 'src/fixtures';
import { errorDto } from 'src/responses';
import { app, utils } from 'src/utils';
2023-09-01 22:01:54 -04:00
import request from 'supertest';
import { beforeAll, describe, expect, it } from 'vitest';
2023-09-01 22:01:54 -04:00
describe('/server-info', () => {
let admin: LoginResponseDto;
let nonAdmin: LoginResponseDto;
2023-09-01 22:01:54 -04:00
beforeAll(async () => {
await utils.resetDatabase();
admin = await utils.adminSetup({ onboarding: false });
nonAdmin = await utils.userSetup(admin.accessToken, createUserDto.user1);
2023-09-01 22:01:54 -04:00
});
describe('GET /server-info', () => {
it('should require authentication', async () => {
const { status, body } = await request(app).get('/server-info');
2023-09-01 22:01:54 -04:00
expect(status).toBe(401);
expect(body).toEqual(errorDto.unauthorized);
2023-09-01 22:01:54 -04:00
});
it('should return the disk information', async () => {
const { status, body } = await request(app)
.get('/server-info')
.set('Authorization', `Bearer ${admin.accessToken}`);
2023-09-01 22:01:54 -04:00
expect(status).toBe(200);
expect(body).toEqual({
diskAvailable: expect.any(String),
diskAvailableRaw: expect.any(Number),
diskSize: expect.any(String),
diskSizeRaw: expect.any(Number),
diskUsagePercentage: expect.any(Number),
diskUse: expect.any(String),
diskUseRaw: expect.any(Number),
});
});
});
describe('GET /server-info/ping', () => {
it('should respond with pong', async () => {
const { status, body } = await request(app).get('/server-info/ping');
2023-09-01 22:01:54 -04:00
expect(status).toBe(200);
expect(body).toEqual({ res: 'pong' });
});
});
describe('GET /server-info/version', () => {
it('should respond with the server version', async () => {
const { status, body } = await request(app).get('/server-info/version');
2023-09-01 22:01:54 -04:00
expect(status).toBe(200);
expect(body).toEqual({
major: expect.any(Number),
minor: expect.any(Number),
patch: expect.any(Number),
});
});
});
describe('GET /server-info/features', () => {
it('should respond with the server features', async () => {
const { status, body } = await request(app).get('/server-info/features');
2023-09-01 22:01:54 -04:00
expect(status).toBe(200);
expect(body).toEqual({
smartSearch: false,
configFile: false,
facialRecognition: false,
map: true,
reverseGeocoding: true,
2023-09-01 22:01:54 -04:00
oauth: false,
oauthAutoLaunch: false,
passwordLogin: true,
2023-12-08 11:15:46 -05:00
search: true,
2023-09-01 22:01:54 -04:00
sidecar: true,
feat(server): trash asset (#4015) * refactor(server): delete assets endpoint * fix: formatting * chore: cleanup * chore: open api * chore(mobile): replace DeleteAssetDTO with BulkIdsDTOs * feat: trash an asset * chore(server): formatting * chore: open api * chore: wording * chore: open-api * feat(server): add withDeleted to getAssets queries * WIP: mobile-recycle-bin * feat(server): recycle-bin to system config * feat(web): use recycle-bin system config * chore(server): domain assetcore removed * chore(server): rename recycle-bin to trash * chore(web): rename recycle-bin to trash * chore(server): always send soft deleted assets for getAllByUserId * chore(web): formatting * feat(server): permanent delete assets older than trashed period * feat(web): trash empty placeholder image * feat(server): empty trash * feat(web): empty trash * WIP: mobile-recycle-bin * refactor(server): empty / restore trash to separate endpoint * test(server): handle failures * test(server): fix e2e server-info test * test(server): deletion test refactor * feat(mobile): use map settings from server-config to enable / disable map * feat(mobile): trash asset * fix(server): operations on assets in trash * feat(web): show trash statistics * fix(web): handle trash enabled * fix(mobile): restore updates from trash * fix(server): ignore trashed assets for person * fix(server): add / remove search index when trashed / restored * chore(web): format * fix(server): asset service test * fix(server): include trashed assts for duplicates from uploads * feat(mobile): no dialog for trash, always dialog for permanent delete * refactor(mobile): use isar where instead of dart filter * refactor(mobile): asset provide - handle deletes in single db txn * chore(mobile): review changes * feat(web): confirmation before empty trash * server: review changes * fix(server): handle library changes * fix: filter external assets from getting trashed / deleted * fix(server): empty-bin * feat: broadcast config update events through ws * change order of trash button on mobile * styling * fix(mobile): do not show trashed toast for local only assets --------- Co-authored-by: Jason Rasmussen <jrasm91@gmail.com> Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
2023-10-06 07:01:14 +00:00
trash: true,
2023-09-01 22:01:54 -04:00
});
});
});
describe('GET /server-info/config', () => {
it('should respond with the server configuration', async () => {
const { status, body } = await request(app).get('/server-info/config');
expect(status).toBe(200);
expect(body).toEqual({
loginPageMessage: '',
oauthButtonText: 'Login with OAuth',
feat(server): trash asset (#4015) * refactor(server): delete assets endpoint * fix: formatting * chore: cleanup * chore: open api * chore(mobile): replace DeleteAssetDTO with BulkIdsDTOs * feat: trash an asset * chore(server): formatting * chore: open api * chore: wording * chore: open-api * feat(server): add withDeleted to getAssets queries * WIP: mobile-recycle-bin * feat(server): recycle-bin to system config * feat(web): use recycle-bin system config * chore(server): domain assetcore removed * chore(server): rename recycle-bin to trash * chore(web): rename recycle-bin to trash * chore(server): always send soft deleted assets for getAllByUserId * chore(web): formatting * feat(server): permanent delete assets older than trashed period * feat(web): trash empty placeholder image * feat(server): empty trash * feat(web): empty trash * WIP: mobile-recycle-bin * refactor(server): empty / restore trash to separate endpoint * test(server): handle failures * test(server): fix e2e server-info test * test(server): deletion test refactor * feat(mobile): use map settings from server-config to enable / disable map * feat(mobile): trash asset * fix(server): operations on assets in trash * feat(web): show trash statistics * fix(web): handle trash enabled * fix(mobile): restore updates from trash * fix(server): ignore trashed assets for person * fix(server): add / remove search index when trashed / restored * chore(web): format * fix(server): asset service test * fix(server): include trashed assts for duplicates from uploads * feat(mobile): no dialog for trash, always dialog for permanent delete * refactor(mobile): use isar where instead of dart filter * refactor(mobile): asset provide - handle deletes in single db txn * chore(mobile): review changes * feat(web): confirmation before empty trash * server: review changes * fix(server): handle library changes * fix: filter external assets from getting trashed / deleted * fix(server): empty-bin * feat: broadcast config update events through ws * change order of trash button on mobile * styling * fix(mobile): do not show trashed toast for local only assets --------- Co-authored-by: Jason Rasmussen <jrasm91@gmail.com> Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
2023-10-06 07:01:14 +00:00
trashDays: 30,
userDeleteDelay: 7,
isInitialized: true,
externalDomain: '',
isOnboarded: false,
});
});
});
describe('GET /server-info/statistics', () => {
2023-09-01 22:01:54 -04:00
it('should require authentication', async () => {
const { status, body } = await request(app).get('/server-info/statistics');
2023-09-01 22:01:54 -04:00
expect(status).toBe(401);
expect(body).toEqual(errorDto.unauthorized);
2023-09-01 22:01:54 -04:00
});
it('should only work for admins', async () => {
const { status, body } = await request(app)
.get('/server-info/statistics')
.set('Authorization', `Bearer ${nonAdmin.accessToken}`);
2023-09-01 22:01:54 -04:00
expect(status).toBe(403);
expect(body).toEqual(errorDto.forbidden);
2023-09-01 22:01:54 -04:00
});
it('should return the server stats', async () => {
const { status, body } = await request(app)
.get('/server-info/statistics')
.set('Authorization', `Bearer ${admin.accessToken}`);
2023-09-01 22:01:54 -04:00
expect(status).toBe(200);
expect(body).toEqual({
photos: 0,
usage: 0,
usageByUser: [
{
quotaSizeInBytes: null,
2023-09-01 22:01:54 -04:00
photos: 0,
usage: 0,
userName: 'Immich Admin',
userId: admin.userId,
videos: 0,
},
{
quotaSizeInBytes: null,
photos: 0,
usage: 0,
userName: 'User 1',
userId: nonAdmin.userId,
2023-09-01 22:01:54 -04:00
videos: 0,
},
],
videos: 0,
});
});
});
describe('GET /server-info/media-types', () => {
it('should return accepted media types', async () => {
const { status, body } = await request(app).get('/server-info/media-types');
2023-09-01 22:01:54 -04:00
expect(status).toBe(200);
expect(body).toEqual({
sidecar: ['.xmp'],
image: expect.any(Array),
video: expect.any(Array),
});
});
});
describe('GET /server-info/theme', () => {
it('should respond with the server theme', async () => {
const { status, body } = await request(app).get('/server-info/theme');
expect(status).toBe(200);
expect(body).toEqual({
customCss: '',
});
});
});
2023-09-01 22:01:54 -04:00
});