mirror of
https://github.com/UNITRONIX/BetterDesk.git
synced 2026-10-26 22:37:07 +00:00
e1bd92a7e4
Persist panel-managed NTP settings in the Go server database and apply them without requiring systemd or host Docker access in split image deployments. Keep native restart behavior and make failed restart transactions dismissible in the UI. Refs #431 Thanks: INSOLVE (Honorary); Marco Jakobs (@jacotec); MyNameisStitch (@MyNameisStitch); Redspin (@playerumpknow)
78 lines
2.5 KiB
JavaScript
78 lines
2.5 KiB
JavaScript
'use strict';
|
|
|
|
describe('billingClockConfigService Docker split mode', () => {
|
|
let service;
|
|
let apiClient;
|
|
let sanitizeGoServerServiceConfig;
|
|
|
|
beforeEach(() => {
|
|
jest.resetModules();
|
|
process.env.DOCKER = 'true';
|
|
process.env.BETTERDESK_DOCKER_LAYOUT = 'split';
|
|
|
|
apiClient = {
|
|
get: jest.fn().mockResolvedValue({
|
|
data: {
|
|
ntp_servers: 'pool.ntp.org',
|
|
max_skew_ms: 2000,
|
|
require_synced_clock: true,
|
|
trust_os_ntp: true,
|
|
},
|
|
}),
|
|
put: jest.fn().mockResolvedValue({
|
|
data: {
|
|
config: {
|
|
ntp_servers: 'time.example.com',
|
|
max_skew_ms: 3500,
|
|
require_synced_clock: false,
|
|
trust_os_ntp: false,
|
|
},
|
|
status: { synced: true },
|
|
},
|
|
}),
|
|
};
|
|
sanitizeGoServerServiceConfig = jest.fn();
|
|
|
|
jest.doMock('../config/config', () => ({ isDocker: true }));
|
|
jest.doMock('../services/betterdeskApi', () => ({ apiClient }));
|
|
jest.doMock('../services/updateService', () => ({
|
|
sanitizeGoServerServiceConfig,
|
|
}));
|
|
jest.doMock('../services/serverConnectionConfigService', () => ({
|
|
restartServer: jest.fn(),
|
|
}));
|
|
|
|
service = require('../services/billingClockConfigService');
|
|
});
|
|
|
|
afterEach(() => {
|
|
delete process.env.DOCKER;
|
|
delete process.env.BETTERDESK_DOCKER_LAYOUT;
|
|
jest.resetModules();
|
|
});
|
|
|
|
test('reads and writes the Go server configuration without native restart', async () => {
|
|
expect(service.isDockerSplitDeployment()).toBe(true);
|
|
|
|
const current = await service.getRuntimeClockSettings();
|
|
expect(current.ntp_servers).toBe('pool.ntp.org');
|
|
|
|
const result = await service.saveClockSettings({
|
|
ntp_servers: 'time.example.com',
|
|
max_skew_ms: 3500,
|
|
require_synced_clock: false,
|
|
trust_os_ntp: false,
|
|
}, { restart: false });
|
|
|
|
expect(apiClient.put).toHaveBeenCalledWith('/timesync/config', {
|
|
ntp_servers: 'time.example.com',
|
|
max_skew_ms: 3500,
|
|
require_synced_clock: false,
|
|
trust_os_ntp: false,
|
|
});
|
|
expect(result.dockerMode).toBe(true);
|
|
expect(result.restart).toBeNull();
|
|
expect(sanitizeGoServerServiceConfig).not.toHaveBeenCalled();
|
|
});
|
|
});
|