d3239ff292
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>
65 lines
1.8 KiB
JavaScript
65 lines
1.8 KiB
JavaScript
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',
|
|
);
|
|
});
|