diff options
| author | Elvis Claros Castro <elvis@claros.ar> | 2026-09-26 19:26:33 -0300 |
|---|---|---|
| committer | Elvis Claros Castro <elvis@claros.ar> | 2026-09-26 19:26:33 -0300 |
| commit | d80640d01eeb84907e36ff4af33add9081eda17c (patch) | |
| tree | 27698b34e06e28d111c2196700015d9c82f78274 /test/compat.test.js | |
| download | wa-cli-main.tar.gz wa-cli-main.zip | |
Diffstat (limited to 'test/compat.test.js')
| -rw-r--r-- | test/compat.test.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/compat.test.js b/test/compat.test.js new file mode 100644 index 0000000..d5a3d65 --- /dev/null +++ b/test/compat.test.js @@ -0,0 +1,25 @@ +import assert from 'node:assert/strict'; +import { createRequire } from 'node:module'; +import test from 'node:test'; +import { patchStructures } from '../src/compat.js'; +import * as ser from '../src/serialize.js'; + +const require = createRequire(import.meta.url); + +test('MsgKey with $1 (WA Web 2.3000.104x) recovers _serialized in Message and Reaction', () => { + patchStructures(); + patchStructures(); // idempotent + const S = require('whatsapp-web.js/src/structures/index.js'); + const key = { fromMe: false, remote: '5491122334455@c.us', id: '3EB0AAA1', self: 'in', $1: 'false_5491122334455@c.us_3EB0AAA1' }; + + const m = new S.Message(null, { id: { ...key }, body: 'hola', t: 1789500000, type: 'chat', from: key.remote, to: 'yo@c.us' }); + assert.equal(m.id._serialized, key.$1); + assert.equal(ser.message(m).id, key.$1); + + const r = new S.Reaction(null, { msgKey: { ...key, $1: 'x' }, parentMsgKey: { ...key }, reactionText: '๐', timestamp: 1 }); + assert.equal(r.msgId._serialized, key.$1); + + // IDs that already have _serialized are left alone + const old = new S.Message(null, { id: { ...key, _serialized: 'old' }, body: '', t: 1, type: 'chat' }); + assert.equal(old.id._serialized, 'old'); +}); |