operation-flags.test.ts (1886B)
1 import assert from 'node:assert/strict'; 2 import { test } from 'node:test'; 3 import { 4 readRelayPolicy, 5 validateRelayPolicy 6 } from '../../src/lib/config/relays.ts'; 7 import { 8 makeSetupFixture, 9 fixturePolicy, 10 setupInput, 11 reviewInboxSetup, 12 inboxSetupPreview 13 } from '../e2e/harness/inbox-setup.ts'; 14 15 void test('HCP126 posting off preserves genuine deliberate messaging-only preference review without signing', async () => { 16 const f = await makeSetupFixture(); 17 try { 18 const policy = validateRelayPolicy( 19 JSON.stringify({ 20 ...readRelayPolicy(fixturePolicy()), 21 postingEnabled: false, 22 messagingEnabled: true 23 }) 24 ); 25 if (!policy) throw Error('original messaging-only policy missing'); 26 const before = f.counts(); 27 const result = await reviewInboxSetup( 28 f.identity, 29 f.own.resolver, 30 policy, 31 setupInput(), 32 () => 101 33 ); 34 assert.equal(result.status, 'review'); 35 assert.match( 36 inboxSetupPreview(result.review)?.globalEffect ?? '', 37 /does not publish/ 38 ); 39 assert.deepEqual(f.counts(), before); 40 } finally { 41 f.close(); 42 } 43 }); 44 void test('HCP126 messaging off denies genuine preference preparation even when public posting is on', async () => { 45 const f = await makeSetupFixture(); 46 try { 47 const policy = validateRelayPolicy( 48 JSON.stringify({ 49 ...readRelayPolicy(fixturePolicy()), 50 postingEnabled: true, 51 messagingEnabled: false 52 }) 53 ); 54 if (!policy) throw Error('original posting-only policy missing'); 55 const before = f.counts(); 56 assert.deepEqual( 57 await reviewInboxSetup( 58 f.identity, 59 f.own.resolver, 60 policy, 61 setupInput(), 62 () => 101 63 ), 64 { status: 'blocked', reason: 'unavailable' } 65 ); 66 assert.deepEqual(f.counts(), before); 67 } finally { 68 f.close(); 69 } 70 });