Files
memind/mindspace-seo-geo-delivery.test.mjs
T
john 4e789663a1
Memind CI / Test, build, and release guards (push) Failing after 5m19s
feat(seo): index public online pages without confirmation
Drop the user_confirmed_at gate so public, online, unexpired pages can enter sitemap/llms and receive SEO/GEO tags. Defaults now enable all discovery switches; stored all-off config is still preserved until admin saves.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-13 15:51:48 +08:00

48 lines
1.4 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import {
decorateMindSpaceSeoGeoHtml,
ROBOTS_NOINDEX_HEADER,
} from './mindspace-seo-geo-delivery.mjs';
const seoGeoEnabled = {
enabled: true,
seo: { enabled: true, canonical: true },
geo: { enabled: true, jsonLd: true },
};
test('decorateMindSpaceSeoGeoHtml noindexes private publications', () => {
const result = decorateMindSpaceSeoGeoHtml('<html><head></head><body></body></html>', {
seoGeoConfig: seoGeoEnabled,
publication: {
status: 'online',
accessMode: 'password',
userConfirmedAt: Date.now(),
},
});
assert.equal(result.robotsHeader, ROBOTS_NOINDEX_HEADER);
assert.match(result.html, /noindex, nofollow/);
});
test('decorateMindSpaceSeoGeoHtml injects seo and geo for unconfirmed public pages', () => {
const result = decorateMindSpaceSeoGeoHtml(
'<html><head><title>Demo</title><meta name="description" content="摘要"></head><body></body></html>',
{
seoGeoConfig: seoGeoEnabled,
publication: {
status: 'online',
accessMode: 'public',
userConfirmedAt: null,
publicUrl: '/u/john/pages/demo',
},
context: {
origin: 'https://m.tkmind.cn',
pageUrl: 'https://m.tkmind.cn/u/john/pages/demo',
},
},
);
assert.equal(result.robotsHeader, null);
assert.match(result.html, /rel="canonical"/);
assert.match(result.html, /application\/ld\+json/);
});