fix(ui): использовать серверное время и не подменять отсутствующий Ping
This commit is contained in:
1 parent
7f18fcb6db
commit
30cc99c68e
9 files changed
+60
-11
No files matched your search
@@ -15,3 +15,11 @@ test("invalid or foreign receipts cannot publish measurements", () => {
|
||||
test("invalid post-test ping rejects the whole receipt", () => {
|
||||
assert.throws(() => parseSpeedRunResponse({ ...receipt(10, 0), result: { ...receipt(10, 0).result, afterBtPing: { rttMs: null, lossPct: 101, error: null } } }, "run-1"))
|
||||
})
|
||||
|
||||
test("server persistence time is validated while legacy receipt remains compatible", () => {
|
||||
const base = receipt(10, 0)
|
||||
const withTime = (createdAt: unknown) => ({ ...base, result: { ...base.result, createdAt } })
|
||||
assert.equal(parseSpeedRunResponse(withTime("2026-10-07T07:00:00+07:00"), "run-1").createdAt, "2026-10-07T07:00:00+07:00")
|
||||
assert.equal(parseSpeedRunResponse(base, "run-1").createdAt, undefined)
|
||||
for (const value of [null, "", "yesterday", 123, "2026-10-07"]) assert.throws(() => parseSpeedRunResponse(withTime(value), "run-1"), /Результат операции неизвестен/)
|
||||
})
|
||||
@@ -6,6 +6,7 @@ const response = z.object({
|
||||
ok: z.literal(true),
|
||||
result: z.object({
|
||||
runId: z.string().min(1),
|
||||
createdAt: z.string().datetime({ offset: true }).optional(),
|
||||
txAvgMbps: metric,
|
||||
rxAvgMbps: metric,
|
||||
raw: z.array(z.record(z.string(), z.unknown())).optional(),
|
||||
|
||||
Reference in new issue
Block a user