mirror of
https://github.com/immich-app/immich.git
synced 2025-12-24 01:11:32 +03:00
test: update cli spec
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { jwtVerify } from 'jose';
|
import { jwtVerify } from 'jose';
|
||||||
import { SystemMetadataKey } from 'src/enum';
|
import { MaintenanceAction, SystemMetadataKey } from 'src/enum';
|
||||||
import { CliService } from 'src/services/cli.service';
|
import { CliService } from 'src/services/cli.service';
|
||||||
import { factory } from 'test/small.factory';
|
import { factory } from 'test/small.factory';
|
||||||
import { newTestService, ServiceMocks } from 'test/utils';
|
import { newTestService, ServiceMocks } from 'test/utils';
|
||||||
@@ -94,7 +94,14 @@ describe(CliService.name, () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should disable maintenance mode', async () => {
|
it('should disable maintenance mode', async () => {
|
||||||
mocks.systemMetadata.get.mockResolvedValue({ isMaintenanceMode: true, secret: 'secret' });
|
mocks.systemMetadata.get.mockResolvedValue({
|
||||||
|
isMaintenanceMode: true,
|
||||||
|
secret: 'secret',
|
||||||
|
action: {
|
||||||
|
action: MaintenanceAction.Start,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
await expect(sut.disableMaintenanceMode()).resolves.toEqual({
|
await expect(sut.disableMaintenanceMode()).resolves.toEqual({
|
||||||
alreadyDisabled: false,
|
alreadyDisabled: false,
|
||||||
});
|
});
|
||||||
@@ -107,7 +114,14 @@ describe(CliService.name, () => {
|
|||||||
|
|
||||||
describe('enableMaintenanceMode', () => {
|
describe('enableMaintenanceMode', () => {
|
||||||
it('should not do anything if in maintenance mode', async () => {
|
it('should not do anything if in maintenance mode', async () => {
|
||||||
mocks.systemMetadata.get.mockResolvedValue({ isMaintenanceMode: true, secret: 'secret' });
|
mocks.systemMetadata.get.mockResolvedValue({
|
||||||
|
isMaintenanceMode: true,
|
||||||
|
secret: 'secret',
|
||||||
|
action: {
|
||||||
|
action: MaintenanceAction.Start,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
await expect(sut.enableMaintenanceMode()).resolves.toEqual(
|
await expect(sut.enableMaintenanceMode()).resolves.toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
alreadyEnabled: true,
|
alreadyEnabled: true,
|
||||||
@@ -129,13 +143,22 @@ describe(CliService.name, () => {
|
|||||||
expect(mocks.systemMetadata.set).toHaveBeenCalledWith(SystemMetadataKey.MaintenanceMode, {
|
expect(mocks.systemMetadata.set).toHaveBeenCalledWith(SystemMetadataKey.MaintenanceMode, {
|
||||||
isMaintenanceMode: true,
|
isMaintenanceMode: true,
|
||||||
secret: expect.stringMatching(/^\w{128}$/),
|
secret: expect.stringMatching(/^\w{128}$/),
|
||||||
|
action: {
|
||||||
|
action: 'start',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const RE_LOGIN_URL = /https:\/\/my.immich.app\/maintenance\?token=([A-Za-z0-9-_]*\.[A-Za-z0-9-_]*\.[A-Za-z0-9-_]*)/;
|
const RE_LOGIN_URL = /https:\/\/my.immich.app\/maintenance\?token=([A-Za-z0-9-_]*\.[A-Za-z0-9-_]*\.[A-Za-z0-9-_]*)/;
|
||||||
|
|
||||||
it('should return a valid login URL', async () => {
|
it('should return a valid login URL', async () => {
|
||||||
mocks.systemMetadata.get.mockResolvedValue({ isMaintenanceMode: true, secret: 'secret' });
|
mocks.systemMetadata.get.mockResolvedValue({
|
||||||
|
isMaintenanceMode: true,
|
||||||
|
secret: 'secret',
|
||||||
|
action: {
|
||||||
|
action: MaintenanceAction.Start,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const result = await sut.enableMaintenanceMode();
|
const result = await sut.enableMaintenanceMode();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user