NavStylePanel (Navbar/Menu/Logo/Footer):
- LinkPicker: dropdown of the site's pages (read-only via usePages()) plus
manual URL / #anchor / tel: / mailto: entry, wired into every link-href
field (standalone Logo href, Navbar logoUrl, Navbar/Menu link items).
- "Sync links with Pages" button in the Links section: repopulates the
links array from the current pages list (label = page name, href = '/'
for the landing page else '/{slug}'), preserving any existing CTA link.
Regression-fix vs the legacy GrapesJS builder, which had this.
- `download` checkbox per link (Navbar/Menu links, standalone Logo href)
emits the `download` attribute on export for links to files.
- Links/Colors sections now gate on the component actually carrying a
`links`/color prop, so Footer (no links array) no longer shows a dead
"Add Link" editor.
- Box-model (Margin/Padding via SpacingControl, Border & Effects via
BorderControl + box-shadow presets + opacity), AnimationControl, and
VisibilityControl added for all four owned components, backed by new
animation/animationDelay/hideOnDesktop/hideOnTablet/hideOnMobile props
(with blank/default values in each component's .craft.props).
Tests: NavStylePanel.test.tsx (new, 17 tests: LinkPicker modes, sync
preserves CTA, download toggle, box-model/animation/visibility wiring) +
extended Navbar/Menu/Logo/Footer .toHtml.test.ts (download attribute,
craft.props defaults). Full suite: 683/683 passing. `npm run build` green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
34 lines
1.5 KiB
TypeScript
34 lines
1.5 KiB
TypeScript
import { describe, test, expect } from 'vitest';
|
|
import { Footer } from './Footer';
|
|
|
|
const toHtml = (Footer as any).toHtml;
|
|
|
|
describe('Footer.toHtml text escaping (attacker-controlled `text` prop)', () => {
|
|
test('a tag-breakout attempt in text is neutralized (no injected element)', () => {
|
|
const { html } = toHtml({ text: '</footer><img src=x onerror=alert(1)>' }, '');
|
|
expect(html).not.toContain('<img');
|
|
expect(html).toContain('<img');
|
|
});
|
|
|
|
test('ampersand is escaped for well-formed text content (consistency with escapeHtml)', () => {
|
|
const { html } = toHtml({ text: 'Terms & Conditions' }, '');
|
|
expect(html).toContain('Terms & Conditions');
|
|
});
|
|
|
|
test('a normal copyright text value still renders unchanged', () => {
|
|
const { html } = toHtml({ text: '© 2026 MySite. All rights reserved.' }, '');
|
|
expect(html).toContain('© 2026 MySite. All rights reserved.');
|
|
});
|
|
});
|
|
|
|
describe('Footer (F4: box-model + animation + visibility props on craft.props)', () => {
|
|
test('craft.props includes animation/visibility defaults so the panel controls always render', () => {
|
|
const craftProps = (Footer as any).craft.props;
|
|
expect(craftProps).toHaveProperty('animation', 'none');
|
|
expect(craftProps).toHaveProperty('animationDelay', '0');
|
|
expect(craftProps).toHaveProperty('hideOnDesktop', false);
|
|
expect(craftProps).toHaveProperty('hideOnTablet', false);
|
|
expect(craftProps).toHaveProperty('hideOnMobile', false);
|
|
});
|
|
});
|