fix(ui): показывать неизвестные поля сертификатов явно
This commit is contained in:
1 parent
bb74eae64c
commit
17f03e7af1
6 files changed
+101
-36
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import assert from "node:assert/strict"
|
||||
import { test } from "node:test"
|
||||
import { renderToStaticMarkup } from "react-dom/server"
|
||||
import type { CertificateObserved } from "@mmapp/contracts/certificates"
|
||||
import { CertificateExpandedDetail } from "./certificate-expanded-detail"
|
||||
import { CertDaysCell } from "./certificate-days-cell"
|
||||
|
||||
const cert: CertificateObserved = {
|
||||
id: "1:*A", rosId: "*A", name: "unknown-cert", serverId: "1", commonName: "test.example",
|
||||
sans: [], issuedBy: "—", validFrom: null, validUntil: null, rawValidFrom: null,
|
||||
rawValidUntil: null, daysLeft: null, keySize: null, trusted: null, status: "unknown", usage: [],
|
||||
}
|
||||
|
||||
test("unknown observed fields are explicit and do not become zero or untrusted", () => {
|
||||
const details = renderToStaticMarkup(<CertificateExpandedDetail cert={cert} />)
|
||||
const days = renderToStaticMarkup(<CertDaysCell cert={cert} />)
|
||||
assert.match(details, /Неизвестен/)
|
||||
assert.match(details, /Дата неизвестна/)
|
||||
assert.match(details, /Неизвестно/)
|
||||
assert.ok(!details.includes("0 бит"))
|
||||
assert.ok(!details.includes("Нет (не доверенный)"))
|
||||
assert.match(days, /Срок неизвестен/)
|
||||
assert.match(days, /Дата окончания неизвестна/)
|
||||
assert.doesNotMatch(days, /0д осталось/)
|
||||
})
|
||||
|
||||
test("known false trust and zero remaining days are preserved", () => {
|
||||
const known = { ...cert, trusted: false, keySize: 2048, daysLeft: 0, validUntil: "2026-10-01T00:00:00Z" }
|
||||
const details = renderToStaticMarkup(<CertificateExpandedDetail cert={known} />)
|
||||
assert.ok(details.includes("Нет (не доверенный)"))
|
||||
assert.match(details, /2048 бит/)
|
||||
const days = renderToStaticMarkup(<CertDaysCell cert={known} />)
|
||||
assert.match(days, /0д осталось/)
|
||||
assert.match(days, /2026-10-01T00:00:00Z/)
|
||||
})
|
||||
|
||||
test("expired and positive observed days stay distinct", () => {
|
||||
assert.match(renderToStaticMarkup(<CertDaysCell cert={{ ...cert, daysLeft: -3 }} />), /Истёк 3д назад/)
|
||||
assert.match(renderToStaticMarkup(<CertDaysCell cert={{ ...cert, daysLeft: 40 }} />), /40д осталось/)
|
||||
})
|
||||
Reference in new issue
Block a user