Presence fixes

This commit is contained in:
Adhiraj Singh
2020-11-24 18:56:07 +05:30
parent cd90d66c5e
commit 242328abdc
7 changed files with 74 additions and 38 deletions

View File

@@ -11,6 +11,17 @@ WAConnectionTest('Messages', conn => {
const message = await sendAndRetreiveMessage(conn, 'hello fren', MessageType.text)
assert.strictEqual(message.message.conversation || message.message.extendedTextMessage?.text, 'hello fren')
})
it('should send a pending message', async () => {
const message = await sendAndRetreiveMessage(conn, 'hello fren', MessageType.text, { waitForAck: false })
await new Promise(resolve => conn.once('message-status-update', update => {
if (update.ids.includes(message.key.id)) {
assert.strictEqual(update.type, WA_MESSAGE_STATUS_TYPE.SERVER_ACK)
resolve()
}
}))
})
it('should forward a message', async () => {
let {messages} = await conn.loadMessages (testJid, 1)
await conn.forwardMessage (testJid, messages[0], true)

View File

@@ -136,14 +136,17 @@ WAConnectionTest('Misc', (conn) => {
await delay (500)
}
})
// open the other phone and look at the updates to really verify stuff
it('should send presence updates', async () => {
conn.shouldLogMessages = true
conn.requestPresenceUpdate(testJid)
it('should update presence', async () => {
const presences = Object.values(Presence)
for (const i in presences) {
const response = await conn.updatePresence(testJid, presences[i])
assert.strictEqual(response.status, 200)
await delay(1500)
const sequence = [ Presence.available, Presence.composing, Presence.paused, Presence.recording, Presence.paused, Presence.unavailable ]
for (const presence of sequence) {
await delay(5000)
await conn.updatePresence(presence !== Presence.unavailable ? testJid : null, presence)
//console.log(conn.messageLog.slice(-1))
console.log('sent update ', presence)
}
})
it('should generate link previews correctly', async () => {