Files
memind/mindspace-index-policy.test.mjs
T
john fde6503bdf
Memind CI / Test, build, and release guards (push) Has been cancelled
feat(mindspace): add SEO/GEO delivery, page template catalog, and admin hooks
Enable optional SEO/GEO injection and discovery routes for confirmed public pages while keeping private pages noindex. Add premium page template skills, portal catalog API, template shop UI, and Baidu push gated by memind_adm config.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-10 08:06:12 +08:00

69 lines
2.0 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import {
isPublicationIndexable,
resolveIndexPolicy,
} from './mindspace-index-policy.mjs';
const indexablePublication = {
status: 'online',
accessMode: 'public',
userConfirmedAt: Date.now() - 1000,
expiresAt: null,
publicUrl: '/u/john/pages/demo',
};
test('isPublicationIndexable accepts confirmed public online publications', () => {
assert.equal(isPublicationIndexable(indexablePublication), true);
});
test('isPublicationIndexable rejects private access modes', () => {
for (const accessMode of ['password', 'private_link', 'login_required', 'owner_only']) {
assert.equal(
isPublicationIndexable({ ...indexablePublication, accessMode }),
false,
);
}
});
test('resolveIndexPolicy stays off when master switch disabled', () => {
const policy = resolveIndexPolicy({
seoGeoConfig: { enabled: false },
publication: indexablePublication,
});
assert.equal(policy.mode, 'off');
assert.equal(policy.injectNoindex, false);
});
test('resolveIndexPolicy noindexes non-public publications when enabled', () => {
const policy = resolveIndexPolicy({
seoGeoConfig: { enabled: true, seo: { enabled: true }, geo: { enabled: true } },
publication: { ...indexablePublication, accessMode: 'password' },
});
assert.equal(policy.mode, 'noindex');
assert.equal(policy.injectNoindex, true);
});
test('resolveIndexPolicy marks confirmed public pages indexable', () => {
const policy = resolveIndexPolicy({
seoGeoConfig: {
enabled: true,
seo: { enabled: true, canonical: true },
geo: { enabled: true, jsonLd: true },
},
publication: indexablePublication,
});
assert.equal(policy.mode, 'indexable');
assert.equal(policy.seoEnabled, true);
assert.equal(policy.geoEnabled, true);
});
test('resolveIndexPolicy skips embed delivery', () => {
const policy = resolveIndexPolicy({
seoGeoConfig: { enabled: true },
publication: indexablePublication,
embed: true,
});
assert.equal(policy.mode, 'off');
});