feat: add legal pages for Terms of Service and Privacy Policy with localization support

This commit is contained in:
mlogclub
2026-05-30 20:38:14 +08:00
parent b44bb666c9
commit c2b6d595aa
7 changed files with 298 additions and 2 deletions
+29
View File
@@ -0,0 +1,29 @@
import assert from "node:assert/strict"
import test from "node:test"
import { readFile } from "node:fs/promises"
async function loadMessages(locale) {
const source = await readFile(new URL(`../messages/${locale}.json`, import.meta.url), "utf8")
return JSON.parse(source)
}
test("legal pages have localized document content", async () => {
for (const locale of ["zh-CN", "en-US"]) {
const messages = await loadMessages(locale)
assert.equal(typeof messages.legal.terms.title, "string")
assert.equal(typeof messages.legal.privacy.title, "string")
assert.ok(messages.legal.terms.sections.length >= 6)
assert.ok(messages.legal.privacy.sections.length >= 6)
for (const page of [messages.legal.terms, messages.legal.privacy]) {
assert.equal(typeof page.updatedAt, "string")
assert.equal(typeof page.relatedLabel, "string")
assert.equal(typeof page.relatedLink, "string")
for (const section of page.sections) {
assert.equal(typeof section.title, "string")
assert.equal(typeof section.body, "string")
}
}
}
})