diff --git a/docs/api/README.md b/docs/api/README.md index 18e810c..2143bc1 100644 --- a/docs/api/README.md +++ b/docs/api/README.md @@ -11,6 +11,8 @@ Genesys Web Messaging Tester - [ReorderedMessageDelayer](classes/ReorderedMessageDelayer.md) - [SessionTranscriber](classes/SessionTranscriber.md) - [TimeoutWaitingForResponseError](classes/TimeoutWaitingForResponseError.md) +- [WebMessageServerConnectionFixture](classes/WebMessageServerConnectionFixture.md) +- [WebMessageServerFixture](classes/WebMessageServerFixture.md) - [WebMessengerGuestSession](classes/WebMessengerGuestSession.md) ### Interfaces @@ -21,3 +23,48 @@ Genesys Web Messaging Tester - [StructuredMessage](interfaces/StructuredMessage.md) - [TranscribedMessage](interfaces/TranscribedMessage.md) - [WebMessengerSession](interfaces/WebMessengerSession.md) + +### Type Aliases + +- [Response](README.md#response) + +### Variables + +- [webMessagePayloads](README.md#webmessagepayloads) + +## Type Aliases + +### Response + +Ƭ **Response**<`T`\>: `SuccessResponse`<`T`\> \| `FailureResponse` + +#### Type parameters + +| Name | +| :------ | +| `T` | + +#### Defined in + +[packages/genesys-web-messaging-tester/src/genesys/Response.ts:19](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/genesys/Response.ts#L19) + +## Variables + +### webMessagePayloads + +• `Const` **webMessagePayloads**: `Object` + +Payloads taken from real interactions + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `inboundStructuredMessage` | (`text`: `string`, `date`: `Date`) => [`StructuredMessage`](interfaces/StructuredMessage.md) | +| `outboundDisconnectEventStructuredMessage` | (`date`: `Date`) => [`StructuredMessage`](interfaces/StructuredMessage.md) | +| `outboundTextStructuredMessage` | (`text`: `string`, `date`: `Date`) => [`StructuredMessage`](interfaces/StructuredMessage.md) | +| `sessionResponse` | () => [`SessionResponse`](interfaces/SessionResponse.md) | + +#### Defined in + +[packages/genesys-web-messaging-tester/src/testFixtures/webMessagePayloads.ts:6](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/testFixtures/webMessagePayloads.ts#L6) diff --git a/docs/api/classes/ReorderedMessageDelayer.md b/docs/api/classes/ReorderedMessageDelayer.md index 5c70a39..6666a3f 100644 --- a/docs/api/classes/ReorderedMessageDelayer.md +++ b/docs/api/classes/ReorderedMessageDelayer.md @@ -35,6 +35,7 @@ timestamps. ### Accessors - [delay](ReorderedMessageDelayer.md#delay) +- [unorderdMessageDetected](ReorderedMessageDelayer.md#unorderdmessagedetected) ### Methods @@ -68,7 +69,7 @@ timestamps. | Name | Type | Default value | | :------ | :------ | :------ | -| `delayBeforeEmittingInMs` | `number` | `5000` | +| `delayBeforeEmittingInMs` | `number` | `1000` | | `intervalInMs` | `number` | `1000` | | `intervalSet` | (`callback`: (...`args`: `any`[]) => `void`, `ms?`: `number`, ...`args`: `any`[]) => `NodeJS.Timeout` | `setInterval` | | `intervalClear` | (`intervalId`: `undefined` \| `string` \| `number` \| `Timeout`) => `void` | `clearInterval` | @@ -79,7 +80,7 @@ EventEmitter.constructor #### Defined in -[packages/genesys-web-messaging-tester/src/genesys/message-delayer/ReorderedMessageDelayer.ts:32](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/genesys/message-delayer/ReorderedMessageDelayer.ts#L32) +[packages/genesys-web-messaging-tester/src/genesys/message-delayer/ReorderedMessageDelayer.ts:34](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/genesys/message-delayer/ReorderedMessageDelayer.ts#L34) ## Properties @@ -163,7 +164,21 @@ MessageDelayer.delay #### Defined in -[packages/genesys-web-messaging-tester/src/genesys/message-delayer/ReorderedMessageDelayer.ts:137](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/genesys/message-delayer/ReorderedMessageDelayer.ts#L137) +[packages/genesys-web-messaging-tester/src/genesys/message-delayer/ReorderedMessageDelayer.ts:142](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/genesys/message-delayer/ReorderedMessageDelayer.ts#L142) + +___ + +### unorderdMessageDetected + +• `get` **unorderdMessageDetected**(): `boolean` + +#### Returns + +`boolean` + +#### Defined in + +[packages/genesys-web-messaging-tester/src/genesys/message-delayer/ReorderedMessageDelayer.ts:69](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/genesys/message-delayer/ReorderedMessageDelayer.ts#L69) ## Methods @@ -178,7 +193,7 @@ before releasing the oldest message. | Name | Type | | :------ | :------ | -| `message` | `Response`<`unknown`\> | +| `message` | [`Response`](../README.md#response)<`unknown`\> | | `received` | `Date` | #### Returns @@ -191,7 +206,7 @@ before releasing the oldest message. #### Defined in -[packages/genesys-web-messaging-tester/src/genesys/message-delayer/ReorderedMessageDelayer.ts:67](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/genesys/message-delayer/ReorderedMessageDelayer.ts#L67) +[packages/genesys-web-messaging-tester/src/genesys/message-delayer/ReorderedMessageDelayer.ts:77](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/genesys/message-delayer/ReorderedMessageDelayer.ts#L77) ___ diff --git a/docs/api/classes/WebMessageServerConnectionFixture.md b/docs/api/classes/WebMessageServerConnectionFixture.md new file mode 100644 index 0000000..8cd37e9 --- /dev/null +++ b/docs/api/classes/WebMessageServerConnectionFixture.md @@ -0,0 +1,138 @@ +[Genesys Web Messaging Tester](../README.md) / WebMessageServerConnectionFixture + +# Class: WebMessageServerConnectionFixture + +## Table of contents + +### Constructors + +- [constructor](WebMessageServerConnectionFixture.md#constructor) + +### Methods + +- [simulateInboundTextStructuredMessage](WebMessageServerConnectionFixture.md#simulateinboundtextstructuredmessage) +- [simulateOutboundDisconnectEventStructuredMessage](WebMessageServerConnectionFixture.md#simulateoutbounddisconnecteventstructuredmessage) +- [simulateOutboundTextStructuredMessage](WebMessageServerConnectionFixture.md#simulateoutboundtextstructuredmessage) +- [simulateSessionResponseMessage](WebMessageServerConnectionFixture.md#simulatesessionresponsemessage) +- [waitForConnectionToClose](WebMessageServerConnectionFixture.md#waitforconnectiontoclose) +- [waitForMessage](WebMessageServerConnectionFixture.md#waitformessage) + +## Constructors + +### constructor + +• **new WebMessageServerConnectionFixture**(`ws`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `ws` | `WebSocket` | + +#### Defined in + +[packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerConnectionFixture.ts:5](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerConnectionFixture.ts#L5) + +## Methods + +### simulateInboundTextStructuredMessage + +▸ **simulateInboundTextStructuredMessage**(`text`, `date?`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `text` | `string` | +| `date` | `Date` | + +#### Returns + +`void` + +#### Defined in + +[packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerConnectionFixture.ts:42](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerConnectionFixture.ts#L42) + +___ + +### simulateOutboundDisconnectEventStructuredMessage + +▸ **simulateOutboundDisconnectEventStructuredMessage**(`date?`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `date` | `Date` | + +#### Returns + +`void` + +#### Defined in + +[packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerConnectionFixture.ts:37](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerConnectionFixture.ts#L37) + +___ + +### simulateOutboundTextStructuredMessage + +▸ **simulateOutboundTextStructuredMessage**(`text`, `date?`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `text` | `string` | +| `date` | `Date` | + +#### Returns + +`void` + +#### Defined in + +[packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerConnectionFixture.ts:32](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerConnectionFixture.ts#L32) + +___ + +### simulateSessionResponseMessage + +▸ **simulateSessionResponseMessage**(): `void` + +#### Returns + +`void` + +#### Defined in + +[packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerConnectionFixture.ts:27](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerConnectionFixture.ts#L27) + +___ + +### waitForConnectionToClose + +▸ **waitForConnectionToClose**(): `Promise`<`void`\> + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerConnectionFixture.ts:23](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerConnectionFixture.ts#L23) + +___ + +### waitForMessage + +▸ **waitForMessage**(): `Promise`<`any`\> + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerConnectionFixture.ts:7](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerConnectionFixture.ts#L7) diff --git a/docs/api/classes/WebMessageServerFixture.md b/docs/api/classes/WebMessageServerFixture.md new file mode 100644 index 0000000..0ec37f5 --- /dev/null +++ b/docs/api/classes/WebMessageServerFixture.md @@ -0,0 +1,72 @@ +[Genesys Web Messaging Tester](../README.md) / WebMessageServerFixture + +# Class: WebMessageServerFixture + +## Table of contents + +### Constructors + +- [constructor](WebMessageServerFixture.md#constructor) + +### Properties + +- [port](WebMessageServerFixture.md#port) + +### Methods + +- [close](WebMessageServerFixture.md#close) +- [waitForConnection](WebMessageServerFixture.md#waitforconnection) + +## Constructors + +### constructor + +• **new WebMessageServerFixture**(`port`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `port` | `number` | + +#### Defined in + +[packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerFixture.ts:8](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerFixture.ts#L8) + +## Properties + +### port + +• `Readonly` **port**: `number` + +#### Defined in + +[packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerFixture.ts:8](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerFixture.ts#L8) + +## Methods + +### close + +▸ **close**(): `void` + +#### Returns + +`void` + +#### Defined in + +[packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerFixture.ts:23](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerFixture.ts#L23) + +___ + +### waitForConnection + +▸ **waitForConnection**(): `Promise`<[`WebMessageServerConnectionFixture`](WebMessageServerConnectionFixture.md)\> + +#### Returns + +`Promise`<[`WebMessageServerConnectionFixture`](WebMessageServerConnectionFixture.md)\> + +#### Defined in + +[packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerFixture.ts:17](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/testFixtures/WebMessageServerFixture.ts#L17) diff --git a/docs/api/classes/WebMessengerGuestSession.md b/docs/api/classes/WebMessengerGuestSession.md index e429218..1a40f9b 100644 --- a/docs/api/classes/WebMessengerGuestSession.md +++ b/docs/api/classes/WebMessengerGuestSession.md @@ -57,7 +57,7 @@ https://developer.genesys.cloud/api/digital/webmessaging/websocketapi#configure- ### constructor -• **new WebMessengerGuestSession**(`config`, `participantData?`, `wsFactory?`, `messageDelayer?`) +• **new WebMessengerGuestSession**(`config`, `participantData?`, `messageDelayer?`, `wsFactory?`) #### Parameters @@ -65,8 +65,8 @@ https://developer.genesys.cloud/api/digital/webmessaging/websocketapi#configure- | :------ | :------ | | `config` | [`SessionConfig`](../interfaces/SessionConfig.md) | | `participantData` | `Record`<`string`, `string`\> | -| `wsFactory` | (`url`: `string`, `options?`: `ClientRequestArgs` \| `ClientOptions`) => `WebSocket` | | `messageDelayer` | [`MessageDelayer`](../interfaces/MessageDelayer.md) | +| `wsFactory` | (`url`: `string`, `options?`: `ClientRequestArgs` \| `ClientOptions`) => `WebSocket` | #### Overrides @@ -99,7 +99,7 @@ EventEmitter.constructor #### Defined in -[packages/genesys-web-messaging-tester/src/genesys/WebMessengerGuestSession.ts:54](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/genesys/WebMessengerGuestSession.ts#L54) +[packages/genesys-web-messaging-tester/src/genesys/WebMessengerGuestSession.ts:55](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/genesys/WebMessengerGuestSession.ts#L55) ___ diff --git a/docs/api/interfaces/MessageDelayer.md b/docs/api/interfaces/MessageDelayer.md index 87d44af..3183059 100644 --- a/docs/api/interfaces/MessageDelayer.md +++ b/docs/api/interfaces/MessageDelayer.md @@ -65,7 +65,7 @@ due to it being async and not guaranteeing order. | Name | Type | | :------ | :------ | -| `message` | `Response`<`unknown`\> | +| `message` | [`Response`](../README.md#response)<`unknown`\> | | `whenReceived` | `Date` | #### Returns diff --git a/docs/release-strategy.md b/docs/release-strategy.md index c0883cf..e5468c7 100644 --- a/docs/release-strategy.md +++ b/docs/release-strategy.md @@ -18,7 +18,7 @@ tag created last._ ## Beta releases -1. Suffix the versions with `-beta.0`, increase the number for subsequent publishes +1. Suffix the versions with `-beta.0` (increase the number for subsequent publishes) 2. Publish the beta version ``` npm publish --tag beta diff --git a/docs/unordered-messages.md b/docs/unordered-messages.md index f418ac8..f28c32c 100644 --- a/docs/unordered-messages.md +++ b/docs/unordered-messages.md @@ -1,9 +1,8 @@ -# Handling Unordered Messages +# Handling unordered messages -The Web Messenger server can sometimes return responses out of order, as mentioned in the documentation: +The Web Messenger server can sometimes return responses out of order, as [mentioned in the documentation](https://developer.genesys.cloud/commdigital/digital/webmessaging/websocketapi#messaging): > All messaging follows a request/response pattern. However, web messaging is an asynchronous > channel and therefore no guarantee to ordering is provided. -> Source: https://developer.genesys.cloud/commdigital/digital/webmessaging/websocketapi#messaging I suspect the official embeddable client deals with this by re-ordering the messages on the fly in the UI. However, this approach is problematic for this tool, as it asserts on the order of messages being received: @@ -11,20 +10,21 @@ this approach is problematic for this tool, as it asserts on the order of messag ```yaml #... scenarios: - "Accept Survey": - - waitForReplyContaining: Welcome to our company's chatbot # Expected to come first + "Convo starts with welcome message": + - say: Hi + - waitForReplyContaining: Welcome to our company's chatbot - waitForReplyContaining: How can I help you? ``` This tool handles out-of-order messages by delaying their propagation into the rest of the tool. During this delay messages can then be re-reordered. -The delay, detection and re-ordering of messages all happens in the [`ReorderedMessageDelayer`](./api/classes/ReorderedMessageDelayer.md) class +The delay, detection and re-ordering of messages all happens in the [`ReorderedMessageDelayer`](./api/classes/ReorderedMessageDelayer.md) class. ## How the CLI handles out-of-order messages The approach guaranteed to address the issue of out-of-order messages is to configure a long delay when instantiating [`ReorderedMessageDelayer`](./api/classes/ReorderedMessageDelayer.md). -However, a longer delay between messages results in longer tests, at OVO this meant a suite of tests that usually took 14 mins taking 54 mins. +However, a longer delay between messages results in longer tests - at OVO this meant a suite of tests that usually took 14 mins taking 54 mins. The CLI addresses this problem by starting all tests with a very short delay. Should a test fail then it will check to see if the conversation contained any unordered messages and if so will retry the test with a long delay. This means the majority of tests