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 accepts public online pages without confirmation', () => { assert.equal( isPublicationIndexable({ ...indexablePublication, userConfirmedAt: null }), 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 public online 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'); });