package topdata import ( "encoding/json" "os" "path/filepath" "strings" "testing" "time" "gitea.westgate.pw/ShadowsOverWestgate/sow-tools/internal/project" ) func TestBuildNativeGeneratesAndSkipsWikiPages(t *testing.T) { root := testProjectRoot(t) mkdirAll(t, filepath.Join(root, "topdata", "data", "skills")) writeFile(t, filepath.Join(root, "topdata", "base_dialog.json"), "{}\n") writeFile(t, filepath.Join(root, "topdata", "data", "skills", "base.json"), `{ "output": "skills.2da", "columns": ["Label", "Name", "Description", "HideFromLevelUp", "Untrained", "KeyAbility", "ArmorCheckPenalty", "Constant"], "rows": [ { "id": 0, "key": "skills:athletics", "Label": "Athletics", "Name": {"tlk": {"key": "skills:athletics.name", "text": "Athletics"}}, "Description": {"tlk": {"key": "skills:athletics.description", "text": "Ability: Strength.\n\nUses:\n- Climb\n- Swim"}}, "HideFromLevelUp": "0", "Untrained": "1", "KeyAbility": "STR", "ArmorCheckPenalty": "1", "Constant": "SKILL_ATHLETICS" } ] }`+"\n") writeFile(t, filepath.Join(root, "topdata", "data", "skills", "lock.json"), `{"skills:athletics":0}`+"\n") proj := testProject(root) proj.Config.TopData.ReferenceBuilder = "" result, err := BuildNative(proj, nil) if err != nil { t.Fatalf("BuildNative failed: %v", err) } generatedHTMLCount := countGeneratedWikiHTMLFiles(t, filepath.Join(root, ".cache", "wiki", "pages")) if result.WikiPages != generatedHTMLCount { t.Fatalf("expected wiki page count to match generated HTML files, got result=%d files=%d", result.WikiPages, generatedHTMLCount) } pagePath := filepath.Join(root, ".cache", "wiki", "pages", "skills", "Athletics.html") got, err := os.ReadFile(pagePath) if err != nil { t.Fatalf("read generated page: %v", err) } text := string(got) if !strings.Contains(text, "
This is generated.
Generated description.
| Hit Die | d6 |
|---|
| Lvl | BAB | HP |
|---|---|---|
| {{Level|ordinal}} | {{BAB}} | {{HPMin}}-{{HPMax}} |
| 1st | +1 | 1-10 | ||
| 2nd | +2 | 2-20 |
Ability Adjustments | +2 Wisdom, +2 Charisma | `,
`Favored Class | [[Classes/Paladin|Paladin]] | `,
`{{DESCRIPTION|text|paragraph:first}} `,
want: `Type of Feat: General `,
reject: `Prerequisite`,
},
{
name: "specifics after marker as html",
template: `You gain a +2 dodge bonus. {{DESCRIPTION|text|paragraphs:"first,last"|html}} `,
want: `Type of Feat: General Use: Automatic. {{title}}{{table:ClassProgression}}`, page) if err != nil { t.Fatalf("render table template: %v", err) } for _, expected := range []string{ `
|