Files
BetterDesk/web-nodejs/tests/billingClockConfigService.docker.test.js
T
UNITRONIX 9d7a08e7ab feat(commercialization): group packages, billing periods, and RD reports
Modernize Commercialization on packages/sessions IA: Settings Time tab with
BILLING_TIMEZONE, group-only packages, monthly period history with midnight
split, Web Remote report overlay, pending_report in Sessions, and package
preview as a centered modal. Includes panel form polish and desktop-client
API notes.

Refs #456

Thanks: INSOLVE (Honorary); Marco Jakobs (@jacotec); MyNameisStitch (@MyNameisStitch); Redspin (@playerumpknow); muopc (@muopc)
2026-10-18 22:45:17 +02:00

79 lines
2.6 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', expect.objectContaining({
ntp_servers: 'time.example.com',
max_skew_ms: 3500,
require_synced_clock: false,
trust_os_ntp: false,
billing_timezone: expect.any(String),
}));
expect(result.dockerMode).toBe(true);
expect(result.restart).toBeNull();
expect(sanitizeGoServerServiceConfig).not.toHaveBeenCalled();
});
});