chore: tree shake unused API methods from CLI (#6973)

This commit is contained in:
Ben McCann
2024-02-09 12:53:37 -08:00
committed by GitHub
parent 954c1c2ef4
commit aff71a10e5
200 changed files with 3337 additions and 22416 deletions

View File

@@ -1,6 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import { ImmichApi } from '../src/services/api.service';
import { ImmichApi } from 'src/services/api.service';
export const TEST_CONFIG_DIR = '/tmp/immich/';
export const TEST_AUTH_FILE = path.join(TEST_CONFIG_DIR, 'auth.yml');
@@ -11,14 +11,10 @@ export const CLI_BASE_OPTIONS = { configDirectory: TEST_CONFIG_DIR };
export const setup = async () => {
const api = new ImmichApi(process.env.IMMICH_INSTANCE_URL as string, '');
await api.authenticationApi.signUpAdmin({
signUpDto: { email: 'cli@immich.app', password: 'password', name: 'Administrator' },
});
const admin = await api.authenticationApi.login({
loginCredentialDto: { email: 'cli@immich.app', password: 'password' },
});
const apiKey = await api.keyApi.createApiKey(
{ aPIKeyCreateDto: { name: 'CLI Test' } },
await api.signUpAdmin({ email: 'cli@immich.app', password: 'password', name: 'Administrator' });
const admin = await api.login({ email: 'cli@immich.app', password: 'password' });
const apiKey = await api.createApiKey(
{ name: 'CLI Test' },
{ headers: { Authorization: `Bearer ${admin.accessToken}` } },
);

View File

@@ -37,7 +37,7 @@ describe(`login-key (e2e)`, () => {
it('should error when providing an invalid API key', async () => {
await expect(new LoginCommand(CLI_BASE_OPTIONS).run(instanceUrl, 'invalid')).rejects.toThrow(
`Failed to connect to server ${instanceUrl}: Response returned an error code`,
`Failed to connect to server ${instanceUrl}: Error: 401`,
);
});

View File

@@ -1,7 +1,7 @@
import { IMMICH_TEST_ASSET_PATH, restoreTempFolder, testApp } from '@test-utils';
import { CLI_BASE_OPTIONS, setup, spyOnConsole } from 'test/cli-test-utils';
import { UploadCommand } from '../../src/commands/upload.command';
import { ImmichApi } from '../../src/services/api.service';
import { ImmichApi } from 'src/services/api.service';
describe(`upload (e2e)`, () => {
let api: ImmichApi;
@@ -26,13 +26,13 @@ describe(`upload (e2e)`, () => {
it('should upload a folder recursively', async () => {
await new UploadCommand(CLI_BASE_OPTIONS).run([`${IMMICH_TEST_ASSET_PATH}/albums/nature/`], { recursive: true });
const assets = await api.assetApi.getAllAssets({}, { headers: { 'x-api-key': api.apiKey } });
const assets = await api.getAllAssets();
expect(assets.length).toBeGreaterThan(4);
});
it('should not create a new album', async () => {
await new UploadCommand(CLI_BASE_OPTIONS).run([`${IMMICH_TEST_ASSET_PATH}/albums/nature/`], { recursive: true });
const albums = await api.albumApi.getAllAlbums({}, { headers: { 'x-api-key': api.apiKey } });
const albums = await api.getAllAlbums();
expect(albums.length).toEqual(0);
});
@@ -42,7 +42,7 @@ describe(`upload (e2e)`, () => {
album: true,
});
const albums = await api.albumApi.getAllAlbums({}, { headers: { 'x-api-key': api.apiKey } });
const albums = await api.getAllAlbums();
expect(albums.length).toEqual(1);
const natureAlbum = albums[0];
expect(natureAlbum.albumName).toEqual('nature');
@@ -59,7 +59,7 @@ describe(`upload (e2e)`, () => {
album: true,
});
const albums = await api.albumApi.getAllAlbums({}, { headers: { 'x-api-key': api.apiKey } });
const albums = await api.getAllAlbums();
expect(albums.length).toEqual(1);
const natureAlbum = albums[0];
expect(natureAlbum.albumName).toEqual('nature');
@@ -71,7 +71,7 @@ describe(`upload (e2e)`, () => {
albumName: 'testAlbum',
});
const albums = await api.albumApi.getAllAlbums({}, { headers: { 'x-api-key': api.apiKey } });
const albums = await api.getAllAlbums();
expect(albums.length).toEqual(1);
const testAlbum = albums[0];
expect(testAlbum.albumName).toEqual('testAlbum');