Remove repeated Plant, Financial and Workforce shortcut cards. Add site-scoped Plant and Financial sidebar attention status with automatic refresh. Include accumulated delivery processing, purchase order recovery, supplier reconciliation, plant data and user management changes and audit records.
29 lines
1.6 KiB
JavaScript
29 lines
1.6 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { buildKnowledge, equalJson } from './2026-09-30-add-supplier-reconciliation-rules.mjs';
|
|
|
|
const rule = { rule_key: 'common', version: 1, supplier_ids: [], status: 'draft', financially_active: false };
|
|
const pack = { schema_version: 1, prepared_on: '2026-09-30', rules: [rule,
|
|
{ ...rule, rule_key: 'specific', supplier_ids: ['a'] }], suppliers: [{ id: 'a' }, { id: 'b' }] };
|
|
|
|
test('common and supplier-specific rules stay on their own supplier', () => {
|
|
assert.deepEqual(buildKnowledge(null, pack, 'a').rules.map(r => r.rule_key), ['common', 'specific']);
|
|
assert.deepEqual(buildKnowledge(null, pack, 'b').rules.map(r => r.rule_key), ['common']);
|
|
});
|
|
test('repeat installation is unchanged, including reordered JSON keys', () => {
|
|
const initial = buildKnowledge(null, pack, 'a');
|
|
assert.ok(equalJson(initial, buildKnowledge(initial, pack, 'a')));
|
|
assert.ok(equalJson({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
});
|
|
test('existing unrelated knowledge and approvals are retained', () => {
|
|
const existing = { schema_version: 1, notes: 'Keep this', rules: [{ rule_key: 'other', status: 'active' }] };
|
|
const merged = buildKnowledge(existing, pack, 'a');
|
|
assert.equal(merged.notes, 'Keep this');
|
|
assert.deepEqual(merged.rules[0], existing.rules[0]);
|
|
});
|
|
test('changed or activated rules cannot be silently overwritten', () => {
|
|
const existing = buildKnowledge(null, pack, 'a');
|
|
existing.rules[0].status = 'active';
|
|
assert.throws(() => buildKnowledge(existing, pack, 'a'), /conflict/i);
|
|
assert.throws(() => buildKnowledge('old notes', pack, 'a'), /invalid/i);
|
|
});
|