예약 명령 mutation 응답에도 autorunLimit을 포함해 입력 직후 색상과 상태가 사라지지 않게 한다. Ref getBrief 계약에 맞춰 명령 인자를 요약하고 자율 행동 종료 연월과 현재 시각을 표시한다.
42 lines
1.9 KiB
TypeScript
42 lines
1.9 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
|
|
import {
|
|
formatLocalDateTime,
|
|
formatLocalTimeSeconds,
|
|
formatSeoulDateTime,
|
|
formatSeoulHourMinute,
|
|
formatSeoulTimeSeconds,
|
|
} from '../src/utils/legacyDateTime.ts';
|
|
|
|
void test('formats API UTC timestamps in the server Seoul timezone', () => {
|
|
assert.equal(formatSeoulDateTime('2026-08-13T00:07:06.713Z'), '2026-08-13 09:07:06');
|
|
assert.equal(formatSeoulHourMinute('2026-08-13T00:07:06.713Z'), '09:07');
|
|
assert.equal(formatSeoulTimeSeconds('2026-08-13T00:07:06.713Z'), '09:07:06');
|
|
});
|
|
|
|
void test('keeps legacy timezone-less server timestamps unchanged', () => {
|
|
assert.equal(formatSeoulDateTime('2026-08-13 09:07:06'), '2026-08-13 09:07:06');
|
|
assert.equal(formatSeoulHourMinute('2026-08-13 09:07:06'), '09:07');
|
|
assert.equal(formatSeoulTimeSeconds('2026-08-13 09:07:06'), '09:07:06');
|
|
});
|
|
|
|
void test('formats an ISO instant with the client local clock', () => {
|
|
const instant = new Date('2026-08-13T00:07:06.713Z');
|
|
const expected = [instant.getHours(), instant.getMinutes(), instant.getSeconds()]
|
|
.map((part) => String(part).padStart(2, '0'))
|
|
.join(':');
|
|
assert.equal(formatLocalTimeSeconds(instant), expected);
|
|
assert.equal(formatLocalTimeSeconds(instant.toISOString()), expected);
|
|
assert.equal(formatLocalTimeSeconds('invalid'), '-');
|
|
});
|
|
|
|
void test('formats an autorun expiry instant with the client local date and seconds', () => {
|
|
const instant = new Date('2026-08-13T00:07:06.713Z');
|
|
const expectedDate = [instant.getFullYear(), instant.getMonth() + 1, instant.getDate()]
|
|
.map((part, index) => String(part).padStart(index === 0 ? 4 : 2, '0'))
|
|
.join('-');
|
|
assert.equal(formatLocalDateTime(instant), `${expectedDate} ${formatLocalTimeSeconds(instant)}`);
|
|
assert.equal(formatLocalDateTime('invalid'), '-');
|
|
});
|