From 11d8c51e8ac72ea517c7d4e262a827eecf5b0778 Mon Sep 17 00:00:00 2001 From: Kpa-clawbot Date: Sat, 27 Jun 2026 23:55:48 +0000 Subject: [PATCH] =?UTF-8?q?test(#1792):=20RED=20=E2=80=94=20GRP=5FDATA=20d?= =?UTF-8?q?etail=20preview=20parity=20with=20GRP=5FTXT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds failing assertions to test-packets.js getDetailPreview suite for GRP_DATA payloads: - no_key envelope → render channel hash hex + 'no key' - decryption_failed → render hash hex + 'decryption failed' - decrypted → render hash hex + data_type hex + data_len + blob hex - decrypted long blob → truncated with ellipsis These currently fail because getDetailPreview has no GRP_DATA branch. --- test-packets.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/test-packets.js b/test-packets.js index e52b44b6..296e0eef 100644 --- a/test-packets.js +++ b/test-packets.js @@ -280,6 +280,54 @@ console.log('\n=== packets.js: getDetailPreview ==='); assert(result.includes('0xFF')); }); + // #1792: GRP_DATA detail preview parity with GRP_TXT. + test('getDetailPreview handles GRP_DATA with channelHash (no_key)', () => { + const result = api.getDetailPreview({ + type: 'GRP_DATA', channelHash: 0xAB, channelHashHex: 'AB', decryptionStatus: 'no_key' + }); + assert(result.includes('0xAB'), 'should render channel hash hex'); + assert(result.includes('no key'), 'should render no key status'); + }); + + test('getDetailPreview handles GRP_DATA decryption_failed', () => { + const result = api.getDetailPreview({ + type: 'GRP_DATA', channelHash: 5, channelHashHex: '05', decryptionStatus: 'decryption_failed' + }); + assert(result.includes('0x05'), 'should render channel hash hex'); + assert(result.includes('decryption failed'), 'should render failure status'); + }); + + test('getDetailPreview handles GRP_DATA decrypted with data_type and blob', () => { + const result = api.getDetailPreview({ + type: 'GRP_DATA', + channelHash: 0x12, + channelHashHex: '12', + decryptionStatus: 'decrypted', + dataType: 0x0001, + dataLen: 4, + decryptedBlob: 'deadbeef' + }); + assert(result.includes('0x12'), 'should render channel hash hex'); + assert(result.includes('0x0001'), 'should render data_type as hex'); + assert(result.includes('4'), 'should render data_len'); + assert(result.includes('deadbeef'), 'should render blob hex'); + }); + + test('getDetailPreview handles GRP_DATA decrypted truncates long blob', () => { + const longBlob = 'ab'.repeat(64); // 128 hex chars = 64 bytes + const result = api.getDetailPreview({ + type: 'GRP_DATA', + channelHash: 0x12, + channelHashHex: '12', + decryptionStatus: 'decrypted', + dataType: 0, + dataLen: 64, + decryptedBlob: longBlob + }); + assert(result.includes('…'), 'should truncate long blob with ellipsis'); + assert(!result.includes(longBlob), 'should not render full long blob'); + }); + test('getDetailPreview handles TXT_MSG', () => { const result = api.getDetailPreview({ type: 'TXT_MSG', srcHash: 'abcdef01', destHash: '12345678'