renamed the block for rendering

This commit is contained in:
2025-12-22 23:20:49 +01:00
parent 53bdca87d5
commit dd1901d173
11 changed files with 49 additions and 49 deletions
+6 -6
View File
@@ -162,8 +162,8 @@ func TestIntegration_TemplateMetadata(t *testing.T) {
}{
{"page_1.html", "skills_column1"},
{"page_2.html", "skills_learned"},
{"page_3.html", "spells_left"},
{"page_3.html", "spells_right"},
{"page_3.html", "spells_column1"},
{"page_3.html", "spells_column2"},
{"page_4.html", "equipment_worn"},
}
@@ -331,8 +331,8 @@ func TestIntegration_MultiPageSpellList(t *testing.T) {
}
}
spellsLeftBlock := GetBlockByName(page3Template.Metadata.Blocks, "spells_left")
spellsRightBlock := GetBlockByName(page3Template.Metadata.Blocks, "spells_right")
spellsLeftBlock := GetBlockByName(page3Template.Metadata.Blocks, "spells_column1")
spellsRightBlock := GetBlockByName(page3Template.Metadata.Blocks, "spells_column2")
expectedSpellCapacity := spellsLeftBlock.MaxItems + spellsRightBlock.MaxItems
// Arrange - Create 30 spells
@@ -365,8 +365,8 @@ func TestIntegration_MultiPageSpellList(t *testing.T) {
}
// Page 1 should have min(30, capacity) spells
leftPage1 := pages[0].Data["spells_left"].([]SpellViewModel)
rightPage1 := pages[0].Data["spells_right"].([]SpellViewModel)
leftPage1 := pages[0].Data["spells_column1"].([]SpellViewModel)
rightPage1 := pages[0].Data["spells_column2"].([]SpellViewModel)
totalPage1 := len(leftPage1) + len(rightPage1)
expectedPage1 := expectedSpellCapacity
+2 -2
View File
@@ -119,8 +119,8 @@ func PreparePaginatedPageData(viewModel *CharacterSheetViewModel, templateName s
pageData.Skills = viewModel.Skills // Keep for backward compatibility
} else if templateName == "page_3.html" {
// Get capacities from template
spellsLeftCapacity := GetBlockCapacity(&templateSet, templateName, "spells_left")
spellsRightCapacity := GetBlockCapacity(&templateSet, templateName, "spells_right")
spellsLeftCapacity := GetBlockCapacity(&templateSet, templateName, "spells_column1")
spellsRightCapacity := GetBlockCapacity(&templateSet, templateName, "spells_column2")
magicItemsCapacity := GetBlockCapacity(&templateSet, templateName, "magic_items")
// Split spells into left and right columns
+2 -2
View File
@@ -190,8 +190,8 @@ func TestPreparePaginatedPageData_Page2Play(t *testing.T) {
func TestPreparePaginatedPageData_Page3Spell(t *testing.T) {
// Get capacities from template
templateSet := DefaultA4QuerTemplateSet()
leftCap := GetBlockCapacity(&templateSet, "page_3.html", "spells_left")
rightCap := GetBlockCapacity(&templateSet, "page_3.html", "spells_right")
leftCap := GetBlockCapacity(&templateSet, "page_3.html", "spells_column1")
rightCap := GetBlockCapacity(&templateSet, "page_3.html", "spells_column2")
magicItemsCap := GetBlockCapacity(&templateSet, "page_3.html", "magic_items")
// Create test data exceeding capacities
+10 -10
View File
@@ -562,9 +562,9 @@ func TestPaginateSpells_TwoColumns(t *testing.T) {
}
var leftCapacity, rightCapacity int
for i := range page3Template.Metadata.Blocks {
if page3Template.Metadata.Blocks[i].Name == "spells_left" {
if page3Template.Metadata.Blocks[i].Name == "spells_column1" {
leftCapacity = page3Template.Metadata.Blocks[i].MaxItems
} else if page3Template.Metadata.Blocks[i].Name == "spells_right" {
} else if page3Template.Metadata.Blocks[i].Name == "spells_column2" {
rightCapacity = page3Template.Metadata.Blocks[i].MaxItems
}
}
@@ -593,7 +593,7 @@ func TestPaginateSpells_TwoColumns(t *testing.T) {
page := pages[0]
// Left column should be filled first
leftData := page.Data["spells_left"].([]SpellViewModel)
leftData := page.Data["spells_column1"].([]SpellViewModel)
expectedLeft := leftCapacity
if testCount < leftCapacity {
expectedLeft = testCount
@@ -603,7 +603,7 @@ func TestPaginateSpells_TwoColumns(t *testing.T) {
}
// Right column gets remainder
rightData := page.Data["spells_right"].([]SpellViewModel)
rightData := page.Data["spells_column2"].([]SpellViewModel)
expectedRight := testCount - expectedLeft
if len(rightData) != expectedRight {
t.Errorf("Expected %d spells in right column (remaining), got %d", expectedRight, len(rightData))
@@ -626,9 +626,9 @@ func TestPaginateSpells_MultiPage(t *testing.T) {
}
var leftCapacity, rightCapacity int
for i := range page3Template.Metadata.Blocks {
if page3Template.Metadata.Blocks[i].Name == "spells_left" {
if page3Template.Metadata.Blocks[i].Name == "spells_column1" {
leftCapacity = page3Template.Metadata.Blocks[i].MaxItems
} else if page3Template.Metadata.Blocks[i].Name == "spells_right" {
} else if page3Template.Metadata.Blocks[i].Name == "spells_column2" {
rightCapacity = page3Template.Metadata.Blocks[i].MaxItems
}
}
@@ -656,8 +656,8 @@ func TestPaginateSpells_MultiPage(t *testing.T) {
// Page 1 should have full capacity (left + right)
page1 := pages[0]
leftPage1 := page1.Data["spells_left"].([]SpellViewModel)
rightPage1 := page1.Data["spells_right"].([]SpellViewModel)
leftPage1 := page1.Data["spells_column1"].([]SpellViewModel)
rightPage1 := page1.Data["spells_column2"].([]SpellViewModel)
if len(leftPage1) != leftCapacity {
t.Errorf("Page 1 left: expected %d spells (template capacity), got %d", leftCapacity, len(leftPage1))
}
@@ -819,9 +819,9 @@ func TestCalculatePagesNeeded(t *testing.T) {
// Get spell capacity (col1 + col2)
var spellCol1, spellCol2 int
for i := range page3Template.Metadata.Blocks {
if page3Template.Metadata.Blocks[i].Name == "spells_left" {
if page3Template.Metadata.Blocks[i].Name == "spells_column1" {
spellCol1 = page3Template.Metadata.Blocks[i].MaxItems
} else if page3Template.Metadata.Blocks[i].Name == "spells_right" {
} else if page3Template.Metadata.Blocks[i].Name == "spells_column2" {
spellCol2 = page3Template.Metadata.Blocks[i].MaxItems
}
}
@@ -133,12 +133,12 @@ func populatePageDataFromDistribution(pageData *PageData, dist PageDistribution)
}
// Spells blocks
case "spells_left":
case "spells_column1":
if spells, ok := data.([]SpellViewModel); ok {
pageData.SpellsLeft = spells
pageData.Spells = append(pageData.Spells, spells...)
}
case "spells_right":
case "spells_column2":
if spells, ok := data.([]SpellViewModel); ok {
pageData.SpellsRight = spells
pageData.Spells = append(pageData.Spells, spells...)
+2 -2
View File
@@ -166,13 +166,13 @@ func getHardcodedTemplateSet() TemplateSet {
Description: "Zauberseite mit Zauberliste",
Blocks: []BlockMetadata{
{
Name: "spells_left",
Name: "spells_column1",
ListType: "spells",
MaxItems: 15,
Column: 1,
},
{
Name: "spells_right",
Name: "spells_column2",
ListType: "spells",
MaxItems: 10,
Column: 2,
@@ -93,14 +93,14 @@ func TestDefaultA4QuerTemplateSet_LoadsFromFiles(t *testing.T) {
expectedBlocks := ParseTemplateMetadata(string(templateContent))
var expectedSpellsLeft *BlockMetadata
for i := range expectedBlocks {
if expectedBlocks[i].Name == "spells_left" {
if expectedBlocks[i].Name == "spells_column1" {
expectedSpellsLeft = &expectedBlocks[i]
break
}
}
if expectedSpellsLeft == nil {
t.Fatal("spells_left block not found in template file")
t.Fatal("spells_column1 block not found in template file")
}
var page3 *TemplateWithMeta
@@ -117,18 +117,18 @@ func TestDefaultA4QuerTemplateSet_LoadsFromFiles(t *testing.T) {
var spellsLeft *BlockMetadata
for i := range page3.Metadata.Blocks {
if page3.Metadata.Blocks[i].Name == "spells_left" {
if page3.Metadata.Blocks[i].Name == "spells_column1" {
spellsLeft = &page3.Metadata.Blocks[i]
break
}
}
if spellsLeft == nil {
t.Error("spells_left block not found")
t.Error("spells_column1 block not found")
} else {
// Should match the value from the template file
if spellsLeft.MaxItems != expectedSpellsLeft.MaxItems {
t.Errorf("Expected spells_left MaxItems %d (from template file), got %d", expectedSpellsLeft.MaxItems, spellsLeft.MaxItems)
t.Errorf("Expected spells_column1 MaxItems %d (from template file), got %d", expectedSpellsLeft.MaxItems, spellsLeft.MaxItems)
}
}
}
+6 -6
View File
@@ -8,13 +8,13 @@ func TestParseTemplateMetadata(t *testing.T) {
<!DOCTYPE html>
<html>
<body>
<!-- BLOCK: spells_left, TYPE: spells, MAX: 12 -->
<!-- BLOCK: spells_column1, TYPE: spells, MAX: 12 -->
<table>
{{range .Spells}}
{{end}}
</table>
<!-- BLOCK: spells_right, TYPE: spells, MAX: 10 -->
<!-- BLOCK: spells_column2, TYPE: spells, MAX: 10 -->
<table>
{{range .Spells}}
{{end}}
@@ -38,8 +38,8 @@ func TestParseTemplateMetadata(t *testing.T) {
}
// Check first block
if blocks[0].Name != "spells_left" {
t.Errorf("Expected name 'spells_left', got '%s'", blocks[0].Name)
if blocks[0].Name != "spells_column1" {
t.Errorf("Expected name 'spells_column1', got '%s'", blocks[0].Name)
}
if blocks[0].ListType != "spells" {
t.Errorf("Expected type 'spells', got '%s'", blocks[0].ListType)
@@ -49,8 +49,8 @@ func TestParseTemplateMetadata(t *testing.T) {
}
// Check second block
if blocks[1].Name != "spells_right" {
t.Errorf("Expected name 'spells_right', got '%s'", blocks[1].Name)
if blocks[1].Name != "spells_column2" {
t.Errorf("Expected name 'spells_column2', got '%s'", blocks[1].Name)
}
if blocks[1].MaxItems != 10 {
t.Errorf("Expected max 10, got %d", blocks[1].MaxItems)
+10 -10
View File
@@ -98,30 +98,30 @@ func TestGetTemplateMetadata(t *testing.T) {
// Get expected values from template
var expectedLeftMax, expectedRightMax int
for i := range page3Template.Metadata.Blocks {
if page3Template.Metadata.Blocks[i].Name == "spells_left" {
if page3Template.Metadata.Blocks[i].Name == "spells_column1" {
expectedLeftMax = page3Template.Metadata.Blocks[i].MaxItems
} else if page3Template.Metadata.Blocks[i].Name == "spells_right" {
} else if page3Template.Metadata.Blocks[i].Name == "spells_column2" {
expectedRightMax = page3Template.Metadata.Blocks[i].MaxItems
}
}
// Check for spells_left block
leftBlock := GetBlockByName(metadata, "spells_left")
// Check for spells_column1 block
leftBlock := GetBlockByName(metadata, "spells_column1")
if leftBlock == nil {
t.Error("Expected to find 'spells_left' block")
t.Error("Expected to find 'spells_column1' block")
} else {
if leftBlock.MaxItems != expectedLeftMax {
t.Errorf("Expected spells_left max %d (from template), got %d", expectedLeftMax, leftBlock.MaxItems)
t.Errorf("Expected spells_column1 max %d (from template), got %d", expectedLeftMax, leftBlock.MaxItems)
}
}
// Check for spells_right block
rightBlock := GetBlockByName(metadata, "spells_right")
// Check for spells_column2 block
rightBlock := GetBlockByName(metadata, "spells_column2")
if rightBlock == nil {
t.Error("Expected to find 'spells_right' block")
t.Error("Expected to find 'spells_column2' block")
} else {
if rightBlock.MaxItems != expectedRightMax {
t.Errorf("Expected spells_right max %d (from template), got %d", expectedRightMax, rightBlock.MaxItems)
t.Errorf("Expected spells_column2 max %d (from template), got %d", expectedRightMax, rightBlock.MaxItems)
}
}
}
@@ -26,7 +26,7 @@
<div class="flex main-content">
<!-- Left spell table -->
<div class="left-section">
<!-- BLOCK: spells_left, TYPE: spells, MAX: 5 -->
<!-- BLOCK: spells_column1, TYPE: spells, MAX: 5 -->
<table class="spells-table">
<tr>
<th>AP<hr>Prozess *</th>
@@ -51,7 +51,7 @@
<!-- Right spell table -->
<div class="right-section">
<!-- BLOCK: spells_right, TYPE: spells, MAX: 2 -->
<!-- BLOCK: spells_column2, TYPE: spells, MAX: 2 -->
<table class="spells-table">
<tr>
<th>AP<br>Prozess *</th>
@@ -26,7 +26,7 @@
<div class="flex main-content">
<!-- Left spell table -->
<div class="left-section">
<!-- BLOCK: spells_left, TYPE: spells, MAX: 15 -->
<!-- BLOCK: spells_column1, TYPE: spells, MAX: 15 -->
<table class="spells-table">
<tr>
<th>AP<hr>Prozess *</th>
@@ -51,7 +51,7 @@
<!-- Right spell table -->
<div class="right-section">
<!-- BLOCK: spells_right, TYPE: spells, MAX: 10 -->
<!-- BLOCK: spells_column2, TYPE: spells, MAX: 10 -->
<table class="spells-table">
<tr>
<th>AP<br>Prozess *</th>