2baf29b3ae
Deliver encrypted health zone, observation API, baseline maturity pipeline, page-data bindings, and H5/WeChat channel integration for health P0. Co-authored-by: Cursor <cursoragent@cursor.com>
48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import {
|
|
filterAccessModesForCategory,
|
|
filterPageDataDatasetsForCategory,
|
|
defaultAccessModeForCategory,
|
|
assertHealthCategoryPageDataBind,
|
|
} from './health-mindspace.mjs';
|
|
|
|
test('health category removes public access mode', () => {
|
|
const labels = {
|
|
public: '完全公开',
|
|
password: '密码访问',
|
|
login_required: '仅登录用户',
|
|
private_link: '私密链接',
|
|
};
|
|
const filtered = filterAccessModesForCategory('health', labels);
|
|
assert.equal(filtered.public, undefined);
|
|
assert.equal(filtered.password, '密码访问');
|
|
});
|
|
|
|
test('health category defaults access mode to password', () => {
|
|
assert.equal(defaultAccessModeForCategory('health', 'public'), 'password');
|
|
assert.equal(defaultAccessModeForCategory('public', 'public'), 'public');
|
|
});
|
|
|
|
test('health category filters forbidden page data datasets', () => {
|
|
const datasets = [
|
|
{ name: 'health_observations' },
|
|
{ name: 'health_share_snapshots' },
|
|
{ name: 'signups' },
|
|
];
|
|
const filtered = filterPageDataDatasetsForCategory('health', datasets);
|
|
assert.deepEqual(filtered.map((item) => item.name), ['health_share_snapshots', 'signups']);
|
|
});
|
|
|
|
test('health page data bind rejects raw observation dataset', () => {
|
|
assert.throws(
|
|
() =>
|
|
assertHealthCategoryPageDataBind({
|
|
categoryCode: 'health',
|
|
datasetName: 'health_observations',
|
|
columns: { read: ['id'] },
|
|
}),
|
|
(error) => error.code === 'health_share_raw_dataset_forbidden',
|
|
);
|
|
});
|