fix: MindSpace remote sync, thumbnail fallback, and Plaza URL guards

Ensure page sync runs via pageSyncService in remote mode, fall back to
workspace HTML when storage assets are missing, and prevent production
Portal from linking to loopback Plaza URLs baked in at build time.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-07-05 07:57:04 +08:00
parent 4781bbc156
commit d3239ff292
20 changed files with 646 additions and 58 deletions
+64
View File
@@ -0,0 +1,64 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import {
DEFAULT_PLAZA_PUBLIC_BASE,
DEFAULT_LOCAL_PLAZA_PUBLIC_BASE,
resolvePlazaHomePath,
resolvePlazaPostPath,
resolvePlazaPublicBase,
} from './src/utils/public-site-bases.mjs';
test('resolvePlazaPublicBase uses local default on localhost without configured base', () => {
assert.equal(
resolvePlazaPublicBase({ hostname: '127.0.0.1', dev: false }),
DEFAULT_LOCAL_PLAZA_PUBLIC_BASE,
);
});
test('resolvePlazaPublicBase uses plaza.tkmind.cn on production host without configured base', () => {
assert.equal(
resolvePlazaPublicBase({ hostname: 'm.tkmind.cn', dev: false }),
DEFAULT_PLAZA_PUBLIC_BASE,
);
});
test('resolvePlazaPublicBase ignores loopback configured base on production host', () => {
assert.equal(
resolvePlazaPublicBase({
configuredBase: 'http://127.0.0.1:3001',
hostname: 'm.tkmind.cn',
dev: false,
}),
DEFAULT_PLAZA_PUBLIC_BASE,
);
});
test('resolvePlazaPublicBase keeps loopback configured base on local host', () => {
assert.equal(
resolvePlazaPublicBase({
configuredBase: 'http://127.0.0.1:3001',
hostname: '127.0.0.1',
dev: false,
}),
'http://127.0.0.1:3001',
);
});
test('resolvePlazaPublicBase respects explicit production configured base', () => {
assert.equal(
resolvePlazaPublicBase({
configuredBase: 'https://plaza.tkmind.cn',
hostname: 'm.tkmind.cn',
dev: false,
}),
'https://plaza.tkmind.cn',
);
});
test('resolvePlazaHomePath and resolvePlazaPostPath append plaza routes', () => {
assert.equal(resolvePlazaHomePath('https://plaza.tkmind.cn'), 'https://plaza.tkmind.cn/plaza');
assert.equal(
resolvePlazaPostPath('https://plaza.tkmind.cn', 'post-1'),
'https://plaza.tkmind.cn/plaza/p/post-1',
);
});