mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-08-09 10:13:02 +02:00
Fix clock sync command
This commit is contained in:
@@ -451,7 +451,7 @@ async def send_repeater_command(public_key: str, request: CommandRequest) -> Com
|
|||||||
- get radio, set radio <freq,bw,sf,cr>
|
- get radio, set radio <freq,bw,sf,cr>
|
||||||
- tempradio <freq,bw,sf,cr,minutes>
|
- tempradio <freq,bw,sf,cr,minutes>
|
||||||
- setperm <pubkey> <permission> (0=guest, 1=read-only, 2=read-write, 3=admin)
|
- setperm <pubkey> <permission> (0=guest, 1=read-only, 2=read-write, 3=admin)
|
||||||
- clock, clock sync
|
- clock, clock sync, time <epoch_seconds>
|
||||||
- reboot
|
- reboot
|
||||||
- ver
|
- ver
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -379,8 +379,8 @@ export function useRepeaterDashboard(
|
|||||||
}, [sendConsoleCommand]);
|
}, [sendConsoleCommand]);
|
||||||
|
|
||||||
const syncClock = useCallback(async () => {
|
const syncClock = useCallback(async () => {
|
||||||
const epoch = Math.floor(Date.now() / 1000);
|
const epochSeconds = Math.floor(Date.now() / 1000);
|
||||||
await sendConsoleCommand(`clock ${epoch}`);
|
await sendConsoleCommand(`time ${epochSeconds}`);
|
||||||
}, [sendConsoleCommand]);
|
}, [sendConsoleCommand]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -248,12 +248,10 @@ describe('useRepeaterDashboard', () => {
|
|||||||
expect(mockApi.sendRepeaterCommand).toHaveBeenCalledWith(REPEATER_KEY, 'reboot');
|
expect(mockApi.sendRepeaterCommand).toHaveBeenCalledWith(REPEATER_KEY, 'reboot');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('syncClock sends "clock <epoch>" command', async () => {
|
it('syncClock sends "time <epoch>" command', async () => {
|
||||||
const fakeNow = 1700000000000;
|
const dateNowSpy = vi.spyOn(Date, 'now').mockReturnValue(1_700_000_000_000);
|
||||||
vi.spyOn(Date, 'now').mockReturnValue(fakeNow);
|
|
||||||
|
|
||||||
mockApi.sendRepeaterCommand.mockResolvedValueOnce({
|
mockApi.sendRepeaterCommand.mockResolvedValueOnce({
|
||||||
command: 'clock 1700000000',
|
command: 'time 1700000000',
|
||||||
response: 'ok',
|
response: 'ok',
|
||||||
sender_timestamp: 1000,
|
sender_timestamp: 1000,
|
||||||
});
|
});
|
||||||
@@ -264,9 +262,8 @@ describe('useRepeaterDashboard', () => {
|
|||||||
await result.current.syncClock();
|
await result.current.syncClock();
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(mockApi.sendRepeaterCommand).toHaveBeenCalledWith(REPEATER_KEY, 'clock 1700000000');
|
expect(mockApi.sendRepeaterCommand).toHaveBeenCalledWith(REPEATER_KEY, 'time 1700000000');
|
||||||
|
dateNowSpy.mockRestore();
|
||||||
vi.restoreAllMocks();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('loadAll calls refreshPane for all panes serially', async () => {
|
it('loadAll calls refreshPane for all panes serially', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user