23 lines
882 B
JavaScript
23 lines
882 B
JavaScript
const assert = require('node:assert/strict');
|
|
const { execFileSync } = require('node:child_process');
|
|
const path = require('node:path');
|
|
const test = require('node:test');
|
|
|
|
const result = JSON.parse(execFileSync('php', [path.join(__dirname, 'topics-harness.php')], { encoding: 'utf8' }));
|
|
|
|
test('topic whitelist includes descendants and preserves a selected child without its parent', () => {
|
|
assert.deepEqual(result.root_tree, [
|
|
{ id: 1, depth: 0 },
|
|
{ id: 2, depth: 1 },
|
|
{ id: 3, depth: 1 },
|
|
]);
|
|
assert.deepEqual(result.child_tree, [{ id: 2, depth: 0 }]);
|
|
assert.match(result.orphan_html, /name="topics\[\]" value="2"/);
|
|
});
|
|
|
|
test('topic submissions accept only existing terms within the configured whitelist', () => {
|
|
assert.deepEqual(result.filtered, [2]);
|
|
assert.deepEqual(result.disabled_tree, []);
|
|
assert.deepEqual(result.disabled_filtered, []);
|
|
});
|