allow for sections and components in any order on pages
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user