Files
memind/scripts/memind-runtime-profile.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

64 lines
2.5 KiB
JavaScript

import assert from 'node:assert/strict';
import path from 'node:path';
import test from 'node:test';
import {
applyMemindRuntimeProfile,
resolveMemindRuntimeProfile,
} from './memind-runtime-profile.mjs';
test('resolveMemindRuntimeProfile defaults to local for dev', () => {
assert.equal(resolveMemindRuntimeProfile({}), 'local');
assert.equal(resolveMemindRuntimeProfile({ NODE_ENV: 'development' }), 'local');
});
test('resolveMemindRuntimeProfile honors explicit profile and production NODE_ENV', () => {
assert.equal(resolveMemindRuntimeProfile({ MEMIND_RUNTIME_PROFILE: 'split-service' }), 'split-service');
assert.equal(resolveMemindRuntimeProfile({ NODE_ENV: 'production' }), 'production');
});
test('applyMemindRuntimeProfile local forces monolith adapter and repo storage', () => {
const env = {
MINDSPACE_SERVER_ADAPTER: 'remote',
MINDSPACE_REMOTE_BASE_URL: 'http://127.0.0.1:8082',
};
const result = applyMemindRuntimeProfile({
rootDir: '/tmp/memind',
env,
profile: 'local',
});
assert.equal(result.profile, 'local');
assert.equal(env.MINDSPACE_SERVER_ADAPTER, 'local');
assert.match(env.MINDSPACE_STORAGE_ROOT, /\/tmp\/memind\/data\/mindspace$/);
assert.equal(env.MEMIND_H5_HTML_FINISH_GUARD, '1');
});
test('applyMemindRuntimeProfile split-service expands auth token reference', () => {
const env = {
TKMIND_SERVER__SECRET_KEY: 'local-dev-secret',
MINDSPACE_REMOTE_AUTH_TOKEN: '${TKMIND_SERVER__SECRET_KEY}',
};
applyMemindRuntimeProfile({ env, profile: 'split-service' });
assert.equal(env.MINDSPACE_SERVER_ADAPTER, 'remote');
assert.equal(env.MINDSPACE_REMOTE_AUTH_TOKEN, 'local-dev-secret');
assert.equal(env.MEMIND_H5_HTML_FINISH_GUARD, '1');
});
test('applyMemindRuntimeProfile production does not override adapter', () => {
const env = {
MINDSPACE_SERVER_ADAPTER: 'remote',
MINDSPACE_REMOTE_BASE_URL: 'http://127.0.0.1:8082',
MINDSPACE_REMOTE_AUTH_TOKEN: 'prod-token',
};
const result = applyMemindRuntimeProfile({ env, profile: 'production' });
assert.equal(result.profile, 'production');
assert.equal(env.MINDSPACE_SERVER_ADAPTER, 'remote');
assert.equal(env.MINDSPACE_REMOTE_AUTH_TOKEN, 'prod-token');
assert.equal(env.MEMIND_H5_HTML_FINISH_GUARD, undefined);
});
test('applyMemindRuntimeProfile local respects explicit finish guard override', () => {
const env = { MEMIND_H5_HTML_FINISH_GUARD: '0' };
applyMemindRuntimeProfile({ rootDir: '/tmp/memind', env, profile: 'local' });
assert.equal(env.MEMIND_H5_HTML_FINISH_GUARD, '0');
});