Files
pages/tools/design-export/main_test.go
T
Anya Tokugawa c1175d389f Implement Knowledge City platform, organizer and DAV integration
Capture accumulated application, UI, CLI, regression tests and design documentation changes, including task project mapping and default CalDAV list naming.

Keep deployment data, backups, local credentials and build artifacts out of Git. Move the Compose enrollment token to an ignored local environment file.
2026-09-27 14:44:43 +09:00

52 lines
1.2 KiB
Go

package main
import (
"encoding/json"
"os"
"path/filepath"
"strings"
"testing"
)
func TestExportHandbook(t *testing.T) {
dest := t.TempDir()
if err := export("../../docs/design/ja", dest); err != nil {
t.Fatal(err)
}
b, err := os.ReadFile(filepath.Join(dest, "manifest.json"))
if err != nil {
t.Fatal(err)
}
var manifest []entry
if err := json.Unmarshal(b, &manifest); err != nil {
t.Fatal(err)
}
if len(manifest) != 23 {
t.Fatalf("got %d chapters", len(manifest))
}
for _, e := range manifest {
b, err := os.ReadFile(filepath.Join(dest, e.File))
if err != nil {
t.Fatal(err)
}
if e.Language != "ja" || e.HTMLSHA256 != digest(b) || !strings.Contains(string(b), "<h1>") {
t.Fatalf("invalid payload: %s", e.Chapter)
}
if err := validateLinks(string(b)); err != nil {
t.Fatal(err)
}
if e.Chapter == "address-storage" && !strings.Contains(string(b), "<table>") {
t.Fatal("Markdown tables lost")
}
}
if err := export("../../docs/design/ja", dest); err == nil {
t.Fatal("must not overwrite staging artifacts")
}
}
func TestUnknownLink(t *testing.T) {
if validateLinks(`<a href="/lab/pageswiki-dev/missing">x</a>`) == nil {
t.Fatal("broken chapter link accepted")
}
}