Files
memind/release-gate/canary-routing.test.mjs
john b1577a16e9
Memind CI / Test, build, and release guards (push) Failing after 12m3s
fix: harden release gate and page delivery
2026-07-26 14:32:01 +08:00

45 lines
1.4 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import {
createCanaryPolicy,
describeCanaryMatch,
resolveCanaryTarget,
} from './canary-routing.mjs';
const policy = createCanaryPolicy({
usernames: ['john'],
wechatUserIds: ['wx_ul610et8'],
});
test('canary routes the configured john identity to candidate', () => {
assert.equal(resolveCanaryTarget({ id: 'a6fb1e97', username: 'john' }, policy), 'candidate');
});
test('canary routes the exact 唐 WeChat identity by immutable user id', () => {
assert.equal(
resolveCanaryTarget({ id: 'a70ff537', displayName: '唐', wechatUserId: 'wx_ul610et8' }, policy),
'candidate',
);
});
test('same nickname without the configured immutable identity stays on stable', () => {
assert.equal(
resolveCanaryTarget({ id: 'other-user', displayName: '唐', wechatUserId: 'wx_other' }, policy),
'stable',
);
});
test('unrecognized, missing, and malformed identities fail closed to stable', () => {
for (const identity of [null, {}, { username: 'admin' }, { id: 'wx_ul610et8' }]) {
assert.equal(resolveCanaryTarget(identity, policy), 'stable');
}
});
test('match description never exposes display-name routing', () => {
const result = describeCanaryMatch({ id: 'other', displayName: '唐' }, policy);
assert.equal(result.target, 'stable');
assert.equal(result.matched, false);
assert.equal(result.identity.username, '');
});