DEFAULT_HEADER_STATE's Navbar linked Home/About/Services/Contact, but a brand new site only has a Home page — About/Services/Contact were dead links on first click. Simplified the default to Home + an inert "Get Started" CTA (href: '#') rather than seeding placeholder pages nobody asked for. Updated default-header.test.ts's HTML-export assertions to match the new default (and assert the removed links are gone). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
37 lines
1.6 KiB
TypeScript
37 lines
1.6 KiB
TypeScript
import { describe, test, expect } from 'vitest';
|
|
import { DEFAULT_HEADER_STATE } from './PageContext';
|
|
import { exportBodyHtml } from '../utils/html-export';
|
|
|
|
/**
|
|
* The default header is seeded as a hand-authored serialized Craft state. A
|
|
* malformed node map would not fail typecheck but would break the header on
|
|
* every new site at runtime, so we validate it deserializes + exports through
|
|
* the same path the editor preview and the WHP publish step use.
|
|
*/
|
|
describe('DEFAULT_HEADER_STATE seed', () => {
|
|
test('is valid JSON with a ROOT header + a Navbar child', () => {
|
|
const parsed = JSON.parse(DEFAULT_HEADER_STATE);
|
|
expect(parsed.ROOT).toBeDefined();
|
|
expect(parsed.ROOT.type.resolvedName).toBe('Container');
|
|
expect(parsed.ROOT.props.tag).toBe('header');
|
|
expect(parsed.ROOT.nodes).toContain('header-navbar');
|
|
expect(parsed['header-navbar'].type.resolvedName).toBe('Navbar');
|
|
expect(parsed['header-navbar'].parent).toBe('ROOT');
|
|
});
|
|
|
|
test('exports to header HTML containing the nav and its default links', () => {
|
|
const { html } = exportBodyHtml(DEFAULT_HEADER_STATE);
|
|
expect(html).toContain('<nav');
|
|
expect(html).toContain('MySite');
|
|
// Item 15: the default nav only links pages/anchors that actually exist
|
|
// on a brand new site (just "Home") plus an inert CTA -- no dead links
|
|
// to About/Services/Contact pages that were never seeded.
|
|
for (const link of ['Home', 'Get Started']) {
|
|
expect(html).toContain(link);
|
|
}
|
|
expect(html).not.toContain('About');
|
|
expect(html).not.toContain('Services');
|
|
expect(html).not.toContain('Contact');
|
|
});
|
|
});
|