archetecture security fix

This commit is contained in:
root
2026-06-11 03:22:12 -04:00
parent 6def9993da
commit 9483750161
3126 changed files with 177194 additions and 37211 deletions
@@ -0,0 +1,32 @@
import React, { isValidElement } from 'react'
import { describe, expect, it, vi } from 'vitest'
vi.mock('@/components/layout/PublicHeader', () => ({ default: function MockPublicHeader() { return React.createElement('mock-header') } }))
vi.mock('@/components/layout/PublicFooter', () => ({ default: function MockPublicFooter() { return React.createElement('mock-footer') } }))
import PublicShell from './PublicShell'
function childTypes(node: React.ReactElement): string[] {
return React.Children.toArray(node.props.children).filter(isValidElement).map((child) => {
const type = child.type as any
if (typeof type === 'string') return type
return type.displayName ?? type.name ?? 'anonymous'
})
}
describe('dashboard PublicShell', () => {
it('wraps public pages with header, content, and footer by default', () => {
const shell = PublicShell({ children: React.createElement('main', { id: 'content' }) })
expect(isValidElement(shell)).toBe(true)
expect(childTypes(shell)).toEqual(['MockPublicHeader', 'div', 'MockPublicFooter'])
})
it('omits chrome when embedded so partner surfaces do not get nested headers', () => {
const shell = PublicShell({ embedded: true, children: React.createElement('main', { id: 'content' }) })
expect(childTypes(shell)).toEqual(['div'])
const contentWrapper = React.Children.toArray(shell.props.children).find(isValidElement) as React.ReactElement
expect(contentWrapper.props.children).toEqual(React.createElement('main', { id: 'content' }))
})
})