// @vitest-environment node
/**
* landingSeo — SSR-lite render of the marketing landing (chat 3772, GEO pack
* docs 254978 §6 / 255025 §D.4). Pure render + host gate; no DB, no network
* (ADR-0009). The blog helper's DB import is mocked because landingSeo pulls
* its escaping/injection primitives from blogSeo.js.
*/
import { describe, it, expect, vi } from 'vitest';
import fs from 'fs';
import os from 'os';
import path from 'path';
vi.mock('../../routes/v3/public.js', () => ({ fetchPublicRows: vi.fn() }));
const {
loadLandingCopy, renderLandingBody, renderLandingPage,
isLandingRequest, registerLandingSeoRoutes, MARKETING_HOSTS,
} = await import('../landingSeo.js');
const TEMPLATE = [
'
',
'GOD CRM — Not that CRM. A substrate between any model and your business',
'',
'',
'',
'',
].join('\n');
const copy = loadLandingCopy();
describe('renderLandingPage — the acceptance criterion (curl -A GPTBot gets text)', () => {
const html = renderLandingPage(TEMPLATE, copy);
it('fills #root with H1, the enemy, the four cards, the story, the anchor and the FAQ', () => {
expect(html).toContain('
');
expect(html).toContain(`
${copy.hero.h1}
`);
expect(html).toContain("Every tool wants to be a tab you can't close.");
const h3s = [...html.matchAll(/
\d\d ([A-Z &]+?)<\/h3>/g)].map((m) => m[1]);
expect(h3s.slice(0, 4)).toEqual(['CONTEXT', 'RIGHTS', 'MEMORY', 'BUILD']);
expect(html).toContain('We changed the model about ten times while running a real company on GOD CRM: Claude, Grok');
expect(html).toContain(copy.underTheHood.anchor.replace(/'/g, '''));
const dts = [...html.matchAll(/
(.*?)<\/dt>/g)].map((m) => m[1]);
expect(dts).toEqual(copy.faq.items.map((i) => i.q.replace(/'/g, ''')));
expect(html).toContain('');
});
it('keeps the generic head (title/description/JSON-LD) and adds only a canonical', () => {
expect(html).toContain('GOD CRM — Not that CRM.');
expect(html).toContain('');
expect(html).toContain('{"@type":"FAQPage"}');
expect(html.match(/');
});
it('omits the enemy link while it is null and renders the MEMORY card link (v3.2)', () => {
expect(html).not.toContain('SEE WHICH');
expect(html).toContain('rcll.ai →');
const withLink = { ...copy, enemy: { ...copy.enemy, link: 'SEE →' } };
expect(renderLandingBody(withLink)).toContain('SEE →');
});
it('carries no team numbers and grounds "and life" (calendar, fitness module) for crawlers', () => {
expect(html).not.toContain('agents run');
expect(html).toContain('A substrate for business and life');
expect(html).toContain('Tables, documents, chats, calendar and people in one database.');
expect(html).toContain('A fitness module ships with it');
});
it('escapes every copy field (the JSON may become a table one day)', () => {
const hostile = {
...copy,
hero: { ...copy.hero, h1: '' },
faq: { ...copy.faq, items: [{ q: 'aalert');
expect(body).toContain('<script>alert(1)</script>');
expect(body).toContain('