Feat improve testing coverage e2e (#1799)
* fix: ensure proper socket closure and await connection termination in tests * feat(tests): enhance E2E tests for image and video message handling, including downloads and group interactions
This commit is contained in:
committed by
GitHub
parent
0b3b2a88cd
commit
e53fa7b8e5
@@ -45,7 +45,14 @@ export class WebSocketClient extends AbstractSocketClient {
|
||||
return
|
||||
}
|
||||
|
||||
const closePromise = new Promise<void>(resolve => {
|
||||
this.socket?.once('close', resolve)
|
||||
})
|
||||
|
||||
this.socket.close()
|
||||
|
||||
await closePromise
|
||||
|
||||
this.socket = null
|
||||
}
|
||||
send(str: string | Uint8Array, cb?: (err?: Error) => void): boolean {
|
||||
|
||||
@@ -605,7 +605,7 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
})
|
||||
}
|
||||
|
||||
const end = (error: Error | undefined) => {
|
||||
const end = async (error: Error | undefined) => {
|
||||
if (closed) {
|
||||
logger.trace({ trace: error?.stack }, 'connection already closed')
|
||||
return
|
||||
@@ -623,7 +623,7 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
|
||||
if (!ws.isClosed && !ws.isClosing) {
|
||||
try {
|
||||
ws.close()
|
||||
await ws.close()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user