Android chat read fix + debounceTimeout bug fix

This commit is contained in:
Adhiraj Singh
2020-11-03 13:24:56 +05:30
parent e0fd554aa0
commit 155df2bc4f
5 changed files with 33 additions and 25 deletions

View File

@@ -7,7 +7,7 @@ export const testJid = process.env.TEST_JID || '1234@s.whatsapp.net' // set TEST
export const makeConnection = () => {
const conn = new WAConnection()
conn.connectOptions.maxIdleTimeMs = 30_000
conn.connectOptions.maxIdleTimeMs = 45_000
conn.logger.level = 'debug'
let evCounts = {}

View File

@@ -71,21 +71,24 @@ WAConnectionTest('Misc', (conn) => {
assert.ok(response)
})
it('should change a chat read status', async () => {
const waitForEvent = new Promise (resolve => {
conn.on ('chat-update', ({jid, count}) => {
if (jid === testJid) {
assert.ok (count < 0)
conn.removeAllListeners ('chat-update')
resolve ()
}
const jids = conn.chats.all ().map (c => c.jid)
for (let jid of jids.slice(0, 5)) {
console.log (`changing read status for ${jid}`)
const waitForEvent = new Promise (resolve => {
conn.once ('chat-update', ({jid: tJid, count}) => {
if (jid === tJid) {
assert.ok (count < 0)
resolve ()
}
})
})
})
await conn.chatRead (testJid, 'unread')
await waitForEvent
await delay (5000)
await conn.chatRead (testJid, 'read')
await conn.chatRead (jid, 'unread')
await waitForEvent
await delay (5000)
await conn.chatRead (jid, 'read')
}
})
it('should archive & unarchive', async () => {
await conn.modifyChat (testJid, ChatModification.archive)