Fix race pages deploy

This commit is contained in:
2026-05-24 09:45:57 +02:00
parent 58b8955e07
commit 153f46fbc8
2 changed files with 114 additions and 7 deletions
+74
View File
@@ -364,6 +364,80 @@ func TestBuildNativeCanDisableWikiStatusPages(t *testing.T) {
}
}
func TestBuildNativeWikiGeneratesRacePagesFromCoreRacialtypes(t *testing.T) {
root := testProjectRoot(t)
mkdirAll(t, filepath.Join(root, "topdata", "data", "feat"))
mkdirAll(t, filepath.Join(root, "topdata", "data", "racialtypes", "core", "modules"))
mkdirAll(t, filepath.Join(root, "topdata", "data", "racialtypes", "00_feats"))
writeFile(t, filepath.Join(root, "topdata", "base_dialog.json"), "{}\n")
writeFile(t, filepath.Join(root, "topdata", "data", "feat", "base.json"), `{
"output": "feat.2da",
"columns": ["FEAT", "DESCRIPTION"],
"rows": [
{"id": 10, "key": "feat:darkvision", "FEAT": "Darkvision", "DESCRIPTION": "See in the dark."}
]
}`+"\n")
writeFile(t, filepath.Join(root, "topdata", "data", "feat", "lock.json"), `{"feat:darkvision":10}`+"\n")
writeFile(t, filepath.Join(root, "topdata", "data", "racialtypes", "core", "base.json"), `{
"output": "racialtypes.2da",
"columns": ["Label", "Name", "Description", "Appearance", "PlayerRace", "FeatsTable"],
"rows": [
{"id": 7, "key": "racialtypes:beast", "Label": "Beast", "Name": "Beast", "Description": "Creature category.", "Appearance": 174, "PlayerRace": 0, "FeatsTable": "****"}
]
}`+"\n")
writeFile(t, filepath.Join(root, "topdata", "data", "racialtypes", "core", "lock.json"), `{"racialtypes:beast":7,"racialtypes:goblin_dynamic":39}`+"\n")
writeFile(t, filepath.Join(root, "topdata", "data", "racialtypes", "core", "modules", "add_goblin.json"), `{
"entries": {
"racialtypes:goblin_dynamic": {
"Label": "Goblin_Dynamic",
"Name": {"tlk": {"text": "Goblin"}},
"Description": {"tlk": {"text": "A playable goblin race."}},
"Appearance": 15381,
"PlayerRace": 1,
"FeatsTable": {"table": "racialtypes/feats:goblin_dynamic"}
}
}
}`+"\n")
writeFile(t, filepath.Join(root, "topdata", "data", "racialtypes", "00_feats", "goblin.json"), `{
"key": "racialtypes/feats:goblin_dynamic",
"output": "race_feat_gobpc.2da",
"columns": ["FeatLabel", "FeatIndex"],
"rows": [
{"id": 0, "FeatIndex": {"id": "feat:darkvision"}}
]
}`+"\n")
writeFile(t, filepath.Join(root, "topdata", "data", "racialtypes", "00_feats", "lock.json"), "{}\n")
disabled := false
proj := testProject(root)
proj.Config.TopData.ReferenceBuilder = ""
proj.Config.TopData.Wiki.StatusPages = &disabled
result, err := BuildNative(proj, nil)
if err != nil {
t.Fatalf("BuildNative failed: %v", err)
}
if result.WikiPages != 2 {
t.Fatalf("expected one generated race page and its referenced feat page, got %d", result.WikiPages)
}
pagePath := filepath.Join(root, ".cache", "wiki", "pages", "races", "Goblin.html")
got, err := os.ReadFile(pagePath)
if err != nil {
t.Fatalf("read generated race page: %v", err)
}
if !strings.Contains(string(got), "A playable goblin race.") || !strings.Contains(string(got), "[[Feats/Darkvision|Darkvision]]") {
t.Fatalf("expected generated race page content, got:\n%s", got)
}
indexRaw, err := os.ReadFile(filepath.Join(root, ".cache", "wiki", "page-index.json"))
if err != nil {
t.Fatalf("read page index: %v", err)
}
indexText := string(indexRaw)
if !strings.Contains(indexText, `"page_id": "races:goblin_dynamic"`) || !strings.Contains(indexText, `"namespace": "races"`) || !strings.Contains(indexText, `"public_path": "Races/Goblin"`) {
t.Fatalf("expected generated race page-index entry, got:\n%s", indexText)
}
}
func countGeneratedWikiHTMLFiles(t *testing.T, root string) int {
t.Helper()
count := 0