diff --git a/packages/genesys-web-messaging-tester-cli/package.json b/packages/genesys-web-messaging-tester-cli/package.json index 657d038..bc44014 100644 --- a/packages/genesys-web-messaging-tester-cli/package.json +++ b/packages/genesys-web-messaging-tester-cli/package.json @@ -27,7 +27,7 @@ "web-messaging-tester": "lib/index.js" }, "dependencies": { - "@ovotech/genesys-web-messaging-tester": "2.0.5-beta.2", + "@ovotech/genesys-web-messaging-tester": "2.0.5-beta.3", "chalk": "^4.1.2", "ci-info": "^3.5.0", "commander": "^11.0.0", diff --git a/packages/genesys-web-messaging-tester/package.json b/packages/genesys-web-messaging-tester/package.json index c57d07b..3a4b0f4 100644 --- a/packages/genesys-web-messaging-tester/package.json +++ b/packages/genesys-web-messaging-tester/package.json @@ -1,6 +1,6 @@ { "name": "@ovotech/genesys-web-messaging-tester", - "version": "2.0.5-beta.2", + "version": "2.0.5-beta.3", "main": "lib/index.js", "types": "lib/index.d.ts", "license": "Apache-2.0", diff --git a/packages/genesys-web-messaging-tester/src/Conversation.ts b/packages/genesys-web-messaging-tester/src/Conversation.ts index c06fe75..b80dcc2 100644 --- a/packages/genesys-web-messaging-tester/src/Conversation.ts +++ b/packages/genesys-web-messaging-tester/src/Conversation.ts @@ -271,7 +271,7 @@ export class Conversation { return text; }, }, - timeoutInSeconds + this.timeoutCompensation, + timeoutInSeconds, ); } @@ -296,7 +296,7 @@ export class Conversation { return pattern.toString(); }, }, - timeoutInSeconds + this.timeoutCompensation, + timeoutInSeconds, ); } diff --git a/packages/genesys-web-messaging-tester/src/genesys/message-delayer/ReorderedMessageDelayer.ts b/packages/genesys-web-messaging-tester/src/genesys/message-delayer/ReorderedMessageDelayer.ts index 4b004b1..c08b0f5 100644 --- a/packages/genesys-web-messaging-tester/src/genesys/message-delayer/ReorderedMessageDelayer.ts +++ b/packages/genesys-web-messaging-tester/src/genesys/message-delayer/ReorderedMessageDelayer.ts @@ -67,6 +67,7 @@ export class ReorderedMessageDelayer extends EventEmitter implements MessageDela () => this.emitMessagesAfterSilence(), ReorderedMessageDelayer.INTERVAL, ); + ReorderedMessageDelayer.debugger('Interval started'); } } @@ -74,15 +75,11 @@ export class ReorderedMessageDelayer extends EventEmitter implements MessageDela if (this.intervalReference) { this.intervalClear(this.intervalReference); this.intervalReference = undefined; + ReorderedMessageDelayer.debugger('Interval stopped'); } } private emitMessagesAfterSilence(): void { - if (this.messages.length === 0) { - this.stopInterval(); - return; - } - const result = orderByTimestamp(this.messages); if (result.wasRearranged) { ReorderedMessageDelayer.debugger( @@ -101,19 +98,27 @@ export class ReorderedMessageDelayer extends EventEmitter implements MessageDela if (isStructuredMessage(this.messages[0].response)) { const ageOfMessageInMs = now - this.messages[0].received.getTime(); if (ageOfMessageInMs >= ReorderedMessageDelayer.SILENCE_TO_WAIT_IN_MS) { - this.emit('message', this.messages.shift()?.response); + const message = this.messages.shift()?.response; + this.emit('message', message); ReorderedMessageDelayer.debugger('Emitted message with timestamp: %O', { msDelayed: ageOfMessageInMs, + message, }); } else { finished = true; } } else { + const message = this.messages.shift()?.response; // No timestamp so just emit - this.emit('message', this.messages.shift()?.response); - ReorderedMessageDelayer.debugger('Emitted message without timestamp'); + this.emit('message', message); + ReorderedMessageDelayer.debugger('Emitted message without timestamp %O', message); } } while (!finished && this.messages.length > 0); + + if (this.messages.length === 0) { + this.stopInterval(); + return; + } } public get delay(): number { diff --git a/yarn.lock b/yarn.lock index 0421bc7..f8613a2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -916,7 +916,7 @@ __metadata: version: 0.0.0-use.local resolution: "@ovotech/genesys-web-messaging-tester-cli@workspace:packages/genesys-web-messaging-tester-cli" dependencies: - "@ovotech/genesys-web-messaging-tester": 2.0.5-beta.2 + "@ovotech/genesys-web-messaging-tester": 2.0.5-beta.3 "@types/humanize-duration": ^3.27.1 "@types/jest": ^29.0.3 "@types/jest-when": ^3.5.2 @@ -959,7 +959,7 @@ __metadata: languageName: unknown linkType: soft -"@ovotech/genesys-web-messaging-tester@2.0.5-beta.2, @ovotech/genesys-web-messaging-tester@workspace:packages/genesys-web-messaging-tester": +"@ovotech/genesys-web-messaging-tester@2.0.5-beta.3, @ovotech/genesys-web-messaging-tester@workspace:packages/genesys-web-messaging-tester": version: 0.0.0-use.local resolution: "@ovotech/genesys-web-messaging-tester@workspace:packages/genesys-web-messaging-tester" dependencies: @@ -987,6 +987,17 @@ __metadata: languageName: unknown linkType: soft +"@ovotech/genesys-web-messaging-tester@npm:2.0.5-beta.2": + version: 2.0.5-beta.2 + resolution: "@ovotech/genesys-web-messaging-tester@npm:2.0.5-beta.2" + dependencies: + debug: ^4.3.3 + uuid: ^9.0.0 + ws: ^8.13.0 + checksum: ec64ae96df500021dafcc963557ce944cbdcc069ab5b746ca51cc5d79fe241e2dcc3a526b713b20f84208b143cfc0e86f67472d1e66e4e878a20997de2364e86 + languageName: node + linkType: hard + "@sideway/address@npm:^4.1.3": version: 4.1.4 resolution: "@sideway/address@npm:4.1.4"