mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Presence fixes
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user