allow for sections and components in any order on pages

This commit is contained in:
2025-09-09 22:30:00 -06:00
parent 88d757546a
commit b82e22c38d
11 changed files with 1179 additions and 848 deletions

View File

@ -30,24 +30,13 @@ func pageEqual(got, want Page) bool {
}
}
// Compare sections (unified model)
if len(got.Sections) != len(want.Sections) {
// Compare elements (unified model)
if len(got.Elements) != len(want.Elements) {
return false
}
for i, section := range got.Sections {
if !sectionEqual(section, want.Sections[i]) {
return false
}
}
// Compare components
if len(got.Components) != len(want.Components) {
return false
}
for i, component := range got.Components {
if !componentEqual(component, want.Components[i]) {
for i, element := range got.Elements {
if !pageElementEqual(element, want.Elements[i]) {
return false
}
}
@ -55,6 +44,28 @@ func pageEqual(got, want Page) bool {
return true
}
func pageElementEqual(got, want PageElement) bool {
// Both should have either a Section or Component, but not both
if (got.Section == nil) != (want.Section == nil) {
return false
}
if (got.Component == nil) != (want.Component == nil) {
return false
}
// Compare sections if present
if got.Section != nil && want.Section != nil {
return sectionEqual(*got.Section, *want.Section)
}
// Compare components if present
if got.Component != nil && want.Component != nil {
return componentEqual(*got.Component, *want.Component)
}
return false
}
func metaTagEqual(got, want MetaTag) bool {
return got.Name == want.Name && got.Content == want.Content
}