feat(mindspace): add SEO/GEO delivery, page template catalog, and admin hooks
Memind CI / Test, build, and release guards (push) Has been cancelled
Memind CI / Test, build, and release guards (push) Has been cancelled
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>
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
buildPublicationAbsoluteUrl,
|
||||
createMindspaceSeoNotifyService,
|
||||
resolveMindspaceBaiduSite,
|
||||
} from './mindspace-seo-notify.mjs';
|
||||
|
||||
const indexablePublication = {
|
||||
status: 'online',
|
||||
accessMode: 'public',
|
||||
userConfirmedAt: Date.now(),
|
||||
publicUrl: '/u/john/pages/demo',
|
||||
};
|
||||
|
||||
test('buildPublicationAbsoluteUrl resolves relative publication urls', () => {
|
||||
assert.equal(
|
||||
buildPublicationAbsoluteUrl('/u/john/pages/demo', {
|
||||
H5_PUBLIC_BASE_URL: 'https://m.tkmind.cn',
|
||||
}),
|
||||
'https://m.tkmind.cn/u/john/pages/demo',
|
||||
);
|
||||
});
|
||||
|
||||
test('resolveMindspaceBaiduSite prefers explicit env', () => {
|
||||
assert.equal(
|
||||
resolveMindspaceBaiduSite({ MINDSPACE_BAIDU_SITE: 'm.tkmind.cn' }),
|
||||
'm.tkmind.cn',
|
||||
);
|
||||
});
|
||||
|
||||
test('notifyPublicationSearchEngines skips when baidu push disabled', async () => {
|
||||
const service = createMindspaceSeoNotifyService(
|
||||
{},
|
||||
{
|
||||
env: { H5_PUBLIC_BASE_URL: 'https://m.tkmind.cn' },
|
||||
loadMindSpaceConfigFn: async () => ({
|
||||
seoGeo: { enabled: true, seo: { baiduPush: false } },
|
||||
}),
|
||||
},
|
||||
);
|
||||
const result = await service.notifyPublicationSearchEngines(indexablePublication);
|
||||
assert.equal(result.reason, 'disabled');
|
||||
});
|
||||
|
||||
test('notifyPublicationSearchEngines skips non-indexable publications', async () => {
|
||||
const service = createMindspaceSeoNotifyService(
|
||||
{},
|
||||
{
|
||||
loadMindSpaceConfigFn: async () => ({
|
||||
seoGeo: { enabled: true, seo: { baiduPush: true } },
|
||||
}),
|
||||
},
|
||||
);
|
||||
const result = await service.notifyPublicationSearchEngines({
|
||||
...indexablePublication,
|
||||
accessMode: 'password',
|
||||
});
|
||||
assert.equal(result.reason, 'not_indexable');
|
||||
});
|
||||
|
||||
test('notifyPublicationSearchEngines pings baidu for indexable publications', async () => {
|
||||
const calls = [];
|
||||
const service = createMindspaceSeoNotifyService(
|
||||
{},
|
||||
{
|
||||
env: {
|
||||
H5_PUBLIC_BASE_URL: 'https://m.tkmind.cn',
|
||||
MINDSPACE_BAIDU_PUSH_TOKEN: 'token',
|
||||
MINDSPACE_BAIDU_SITE: 'm.tkmind.cn',
|
||||
},
|
||||
loadMindSpaceConfigFn: async () => ({
|
||||
seoGeo: { enabled: true, seo: { baiduPush: true } },
|
||||
}),
|
||||
plazaSeoFactory: () => ({
|
||||
pingBaidu: async (urls) => {
|
||||
calls.push(urls);
|
||||
return { pushed: true, result: { success: 1 } };
|
||||
},
|
||||
}),
|
||||
},
|
||||
);
|
||||
const result = await service.notifyPublicationSearchEngines(indexablePublication);
|
||||
assert.equal(result.pushed, true);
|
||||
assert.deepEqual(calls[0], ['https://m.tkmind.cn/u/john/pages/demo']);
|
||||
});
|
||||
Reference in New Issue
Block a user