Classes
- Tester
- ResponseAssert
- AnyResponseAssert
- ConversationTester
Automated Conversation tests runner
Typedefs
- TestSource :
object - TestCase :
object - TextCase :
object - TextTest :
object - TestCaseStep :
object - TestsGroup :
object - List :
object - TestsDefinition :
object - testerFactory ⇒
Tester Callback for getting a tester
- TestsOutput :
object - Logger :
object
Tester
Kind: global class
- Tester
- new Tester()
- instance
- .processor :
Processor - .prompts :
Array.<PromptInfo> - .testData
- .allowEmptyResponse
- .senderLogger
- .features
- .ATTACHMENT_MOCK_URL
- .setExpandRandomTexts([fixedIndex])
- .cleanup()
- .setFeatures([features])
- .processMessage(message, senderId, pageId, [data]) ⇒
Promise.<any> - .res([index]) ⇒
ResponseAssert - .any() ⇒
AnyResponseAssert - .lastRes() ⇒
ResponseAssert - .passedAction(path, [matchRequestActions]) ⇒
this - .respondedWithBlock(blockName) ⇒
this - .getState() ⇒
object - .setState([state])
- .anyPrompt() ⇒
PromptAssert - .lastPrompt() ⇒
PromptAssert - .getLastPromptResult() ⇒
LLMMessage - .stateContains(object, [deep])
- .text(text) ⇒
Promise - .attachment(type, [url]) ⇒
Promise - .intent(intent, [text], [score]) ⇒
Promise - .intentWithEntity(intent, entity, [value], [text], [score], [entityScore]) ⇒
Promise - .entity(entity, [value], [text], [score]) ⇒
Promise - .optin(action, [data], [userRef]) ⇒
Promise - .quickReply(action, [data]) ⇒
Promise - .quickReplyText(text) ⇒
Promise.<boolean> - .postBack(action, [data], [refAction], [refData]) ⇒
Promise - .debug([full], [showPrivateKeys])
- .processor :
- static
new Tester()
Utility for testing requests
tester.processor : Processor
Kind: instance property of Tester
tester.prompts : Array.<PromptInfo>
Kind: instance property of Tester
tester.testData
Kind: instance property of Tester
Properties
| Name | Type | Description |
|---|---|---|
| predefined | object | test data to use |
tester.allowEmptyResponse
Kind: instance property of Tester
Properties
| Name | Type | Description |
|---|---|---|
| allow | boolean | tester to process empty responses |
tester.senderLogger
Kind: instance property of Tester
Properties
| Name | Type | Description |
|---|---|---|
| use | console | own loggger |
tester.features
Kind: instance property of Tester
Properties
| Type |
|---|
Array.<string> |
tester.ATTACHMENT_MOCK_URL
Kind: instance property of Tester
Properties
| Type |
|---|
string |
tester.setExpandRandomTexts([fixedIndex])
Enable tester to expand random texts It joins them into a single sting
Kind: instance method of Tester
| Param | Type |
|---|---|
| [fixedIndex] | boolean |
tester.cleanup()
Clear acquired responses and data
Kind: instance method of Tester
tester.setFeatures([features])
Set features for all messages
Kind: instance method of Tester
| Param | Type |
|---|---|
| [features] | Array.<string> |
tester.processMessage(message, senderId, pageId, [data]) ⇒ Promise.<any>
Use tester as a connector :)
Kind: instance method of Tester
| Param | Type | Description |
|---|---|---|
| message | object | wingbot chat event |
| senderId | string | chat event sender identifier |
| pageId | string | channel/page identifier |
| [data] | object | additional data |
tester.res([index]) ⇒ ResponseAssert
Returns single response asserter
Kind: instance method of Tester
| Param | Type | Default | Description |
|---|---|---|---|
| [index] | number | 0 | response index |
tester.any() ⇒ AnyResponseAssert
Returns any response asserter
Kind: instance method of Tester
tester.lastRes() ⇒ ResponseAssert
Returns last response asserter
Kind: instance method of Tester
tester.passedAction(path, [matchRequestActions]) ⇒ this
Checks, that request passed an interaction
Kind: instance method of Tester
| Param | Type | Default |
|---|---|---|
| path | string | |
| [matchRequestActions] | boolean | false |
tester.respondedWithBlock(blockName) ⇒ this
Checks, that a plugin used a block as a response
Kind: instance method of Tester
| Param | Type |
|---|---|
| blockName | string |
tester.getState() ⇒ object
Returns state
Kind: instance method of Tester
tester.setState([state])
Sets state with Object.assign()
Kind: instance method of Tester
| Param | Type | Default |
|---|---|---|
| [state] | object | {} |
tester.anyPrompt() ⇒ PromptAssert
Kind: instance method of Tester
tester.lastPrompt() ⇒ PromptAssert
Kind: instance method of Tester
tester.getLastPromptResult() ⇒ LLMMessage
Kind: instance method of Tester
tester.stateContains(object, [deep])
Assert, that state contains a subset of provided value
Kind: instance method of Tester
| Param | Type | Default |
|---|---|---|
| object | object | |
| [deep] | boolean | false |
Example
t.stateContains({ value: true });
tester.text(text) ⇒ Promise
Makes text request
Kind: instance method of Tester
| Param | Type |
|---|---|
| text | string |
tester.attachment(type, [url]) ⇒ Promise
Sends attachment
Kind: instance method of Tester
| Param | Type | Default |
|---|---|---|
| type | 'image' | 'audio' | 'video' | 'file' | file |
| [url] | string |
tester.intent(intent, [text], [score]) ⇒ Promise
Makes recognised AI intent request
Kind: instance method of Tester
| Param | Type | Default |
|---|---|---|
| intent | string | Array.<string> | |
| [text] | string | null |
| [score] | number |
tester.intentWithEntity(intent, entity, [value], [text], [score], [entityScore]) ⇒ Promise
Makes recognised AI intent request with entity
Kind: instance method of Tester
| Param | Type | Default |
|---|---|---|
| intent | string | |
| entity | string | |
| [value] | string | |
| [text] | string | |
| [score] | number | 1 |
| [entityScore] | number |
tester.entity(entity, [value], [text], [score]) ⇒ Promise
Makes recognised AI request with entity
Kind: instance method of Tester
| Param | Type | Default |
|---|---|---|
| entity | string | |
| [value] | string | |
| [text] | string | |
| [score] | number | 1 |
tester.optin(action, [data], [userRef]) ⇒ Promise
Make optin call
Kind: instance method of Tester
| Param | Type | Default | Description |
|---|---|---|---|
| action | string | ||
| [data] | object | {} | |
| [userRef] | string | null | specific ref string |
tester.quickReply(action, [data]) ⇒ Promise
Send quick reply
Kind: instance method of Tester
| Param | Type | Default |
|---|---|---|
| action | string | |
| [data] | object | {} |
tester.quickReplyText(text) ⇒ Promise.<boolean>
Send quick reply if text exactly matches, otherwise throws exception
Kind: instance method of Tester
| Param | Type |
|---|---|
| text | string |
tester.postBack(action, [data], [refAction], [refData]) ⇒ Promise
Sends postback, optionally with referrer action
Kind: instance method of Tester
| Param | Type | Default | Description |
|---|---|---|---|
| action | string | ||
| [data] | object | {} | |
| [refAction] | string | null | referred action |
| [refData] | object | {} | referred action data |
tester.debug([full], [showPrivateKeys])
Prints last conversation turnaround
Kind: instance method of Tester
| Param | Type | Default |
|---|---|---|
| [full] | boolean | false |
| [showPrivateKeys] | boolean | false |
Tester.Tester
Kind: static class of Tester
new Tester(reducer, [senderId], [pageId], [processorOptions], [storage])
Creates an instance of Tester.
| Param | Type | Default | Description |
|---|---|---|---|
| reducer | Router | ReducerWrapper | ||
| [senderId] | string | null | |
| [pageId] | string | null | |
| [processorOptions] | ProcessorOptions | {} | options for Processor |
| [storage] | MemoryStateStorage | place to override the storage |
ResponseAssert
Kind: global class
- ResponseAssert
- new ResponseAssert()
- instance
- .contains(search) ⇒
this - .quickReplyAction(action) ⇒
this - .templateType(type) ⇒
this - .passThread([appId]) ⇒
this - .attachmentType(type) ⇒
this
- .contains(search) ⇒
- static
- .AnyResponseAssert#contains(search) ⇒
this - .AnyResponseAssert#notContains(search) ⇒
this - .AnyResponseAssert#quickReplyAction(action) ⇒
this - .AnyResponseAssert#quickReplyTextContains(search) ⇒
this - .AnyResponseAssert#quickReplyTextNotContains(search) ⇒
this - .AnyResponseAssert#templateType(type) ⇒
this - .AnyResponseAssert#genericTemplate(itemCount)
- .AnyResponseAssert#buttonTemplate(search, buttonCount)
- .AnyResponseAssert#passThread([appId]) ⇒
this - .AnyResponseAssert#attachmentType(type) ⇒
this
- .AnyResponseAssert#contains(search) ⇒
new ResponseAssert()
Utility for asserting single response
responseAssert.contains(search) ⇒ this
Checks, that response contains text
Kind: instance method of ResponseAssert
| Param | Type |
|---|---|
| search | string | object |
responseAssert.quickReplyAction(action) ⇒ this
Checks quick response action
Kind: instance method of ResponseAssert
| Param | Type |
|---|---|
| action | string |
responseAssert.templateType(type) ⇒ this
Checks template type
Kind: instance method of ResponseAssert
| Param | Type |
|---|---|
| type | string |
responseAssert.passThread([appId]) ⇒ this
Checks pass thread control
Kind: instance method of ResponseAssert
| Param | Type | Default |
|---|---|---|
| [appId] | string | null |
responseAssert.attachmentType(type) ⇒ this
Checks attachment type
Kind: instance method of ResponseAssert
| Param | Type |
|---|---|
| type | string |
ResponseAssert.AnyResponseAssert#contains(search) ⇒ this
Checks, that response contains a text
Kind: static method of ResponseAssert
| Param | Type |
|---|---|
| search | string | object |
ResponseAssert.AnyResponseAssert#notContains(search) ⇒ this
Checks, that response does NOT contain a text
Kind: static method of ResponseAssert
| Param | Type |
|---|---|
| search | string |
ResponseAssert.AnyResponseAssert#quickReplyAction(action) ⇒ this
Checks quick response action
Kind: static method of ResponseAssert
| Param | Type |
|---|---|
| action | string |
ResponseAssert.AnyResponseAssert#quickReplyTextContains(search) ⇒ this
Checks quick response text
Kind: static method of ResponseAssert
| Param | Type |
|---|---|
| search | string |
ResponseAssert.AnyResponseAssert#quickReplyTextNotContains(search) ⇒ this
Checks for missing quick response text
Kind: static method of ResponseAssert
| Param | Type |
|---|---|
| search | string |
ResponseAssert.AnyResponseAssert#templateType(type) ⇒ this
Checks template type
Kind: static method of ResponseAssert
| Param | Type |
|---|---|
| type | string |
ResponseAssert.AnyResponseAssert#genericTemplate(itemCount)
Checks for generic template
Kind: static method of ResponseAssert
| Param | Type | Default | Description |
|---|---|---|---|
| itemCount | number | | specified item count |
ResponseAssert.AnyResponseAssert#buttonTemplate(search, buttonCount)
Checks for button template
Kind: static method of ResponseAssert
| Param | Type | Default | Description |
|---|---|---|---|
| search | string | ||
| buttonCount | number | | specified button count |
ResponseAssert.AnyResponseAssert#passThread([appId]) ⇒ this
Checks pass thread control
Kind: static method of ResponseAssert
| Param | Type | Default |
|---|---|---|
| [appId] | string | null |
ResponseAssert.AnyResponseAssert#attachmentType(type) ⇒ this
Checks attachment type
Kind: static method of ResponseAssert
| Param | Type |
|---|---|
| type | string |
AnyResponseAssert
Kind: global class
new AnyResponseAssert()
Utility for searching among responses
ConversationTester
Automated Conversation tests runner
Kind: global class
- ConversationTester
- new ConversationTester(testsSource, botFactory, [options])
- ._getTestCases(lang) ⇒
Promise.<TestsDefinition> - .test(validationRequestBody, [step], [lang], [snapshot]) ⇒
Promise.<TestsOutput> - ._getLists(testCases) ⇒
Array.<List> - ._getListCases(testCases) ⇒
Map.<string, (Array.<TestCase>|Array.<TextCase>)> - ._getPagingForStepCases(testCases, lim)
- ._getGroups(testCases) ⇒
Array.<TestsGroup> - ._getTestsGroups(testsGroups, step)
- ._createTester(testsGroup, [botconfig], [lang], [snapshot]) ⇒
Promise.<Tester> - ._runTextCaseTests(testsGroup, botconfig, [lang], [snapshot])
- ._runStepCaseTests(testsGroup, botconfig, [lang], [snapshot])
- .executeTextCase(testsGroup, t, textCase, botconfig, longestText, [lang], [snapshot])
- .executeStep(t, step)
new ConversationTester(testsSource, botFactory, [options])
| Param | Type | Description |
|---|---|---|
| testsSource | TestSource | Object.<string, TestSource> | single source or localized list |
| botFactory | function | |
| [options] | object | |
| [options.disableAssertActions] | boolean | |
| [options.disableAssertTexts] | boolean | |
| [options.disableAssertQuickReplies] | boolean | |
| [options.useConversationForTextTestCases] | boolean | |
| [options.textThreshold] | number | |
| [options.stepCasesPerStep] | number | |
| [options.textCasesPerStep] | number | |
| [options.textCaseParallel] | number | |
| [options.allowEmptyResponse] | boolean | |
| [options.log] | Logger | |
| [options.testerFactory] | testerFactory |
conversationTester._getTestCases(lang) ⇒ Promise.<TestsDefinition>
Kind: instance method of ConversationTester
| Param | Type |
|---|---|
| lang | string |
conversationTester.test(validationRequestBody, [step], [lang], [snapshot]) ⇒ Promise.<TestsOutput>
Runs the conversation test
Kind: instance method of ConversationTester
| Param | Type | Default |
|---|---|---|
| validationRequestBody | object | |
| [step] | number | |
| [lang] | string | null |
| [snapshot] | string | null |
conversationTester._getLists(testCases) ⇒ Array.<List>
Kind: instance method of ConversationTester
| Param | Type |
|---|---|
| testCases | Array.<TestCase> | Array.<TextCase> |
conversationTester._getListCases(testCases) ⇒ Map.<string, (Array.<TestCase>|Array.<TextCase>)>
Kind: instance method of ConversationTester
| Param | Type |
|---|---|
| testCases | Array.<TestCase> | Array.<TextCase> |
conversationTester._getPagingForStepCases(testCases, lim)
Kind: instance method of ConversationTester
| Param | Type |
|---|---|
| testCases | Array.<TestCase> |
| lim | number |
conversationTester._getGroups(testCases) ⇒ Array.<TestsGroup>
Kind: instance method of ConversationTester
| Param | Type |
|---|---|
| testCases | * |
conversationTester._getTestsGroups(testsGroups, step)
Kind: instance method of ConversationTester
| Param | Type |
|---|---|
| testsGroups | Array.<TestsGroup> |
| step | number |
conversationTester._createTester(testsGroup, [botconfig], [lang], [snapshot]) ⇒ Promise.<Tester>
Kind: instance method of ConversationTester
| Param | Type | Default |
|---|---|---|
| testsGroup | TestsGroup | |
| [botconfig] | object | |
| [lang] | string | null |
| [snapshot] | string | null |
conversationTester._runTextCaseTests(testsGroup, botconfig, [lang], [snapshot])
Kind: instance method of ConversationTester
| Param | Type | Default |
|---|---|---|
| testsGroup | TestsGroup | |
| botconfig | object | |
| [lang] | string | null |
| [snapshot] | string | null |
conversationTester._runStepCaseTests(testsGroup, botconfig, [lang], [snapshot])
Kind: instance method of ConversationTester
| Param | Type | Default |
|---|---|---|
| testsGroup | TestsGroup | |
| botconfig | object | |
| [lang] | string | null |
| [snapshot] | string | null |
conversationTester.executeTextCase(testsGroup, t, textCase, botconfig, longestText, [lang], [snapshot])
Kind: instance method of ConversationTester
| Param | Type | Default |
|---|---|---|
| testsGroup | TestsGroup | |
| t | Tester | |
| textCase | TextTest | |
| botconfig | * | |
| longestText | number | |
| [lang] | string | null |
| [snapshot] | string | null |
conversationTester.executeStep(t, step)
Kind: instance method of ConversationTester
| Param | Type |
|---|---|
| t | Tester |
| step | TestCaseStep |
TestSource : object
Kind: global typedef
Properties
| Name | Type |
|---|---|
| getTestCases | function |
TestCase : object
Kind: global typedef
Properties
| Name | Type |
|---|---|
| list | string |
| name | string |
| steps | Array.<TestCaseStep> |
TextCase : object
Kind: global typedef
Properties
| Name | Type |
|---|---|
| list | string |
| name | string |
| texts | Array.<TextTest> |
TextTest : object
Kind: global typedef
Properties
| Name | Type |
|---|---|
| appId | string |
| text | string |
| action | string |
| intent | string |
| [rowNum] | number |
TestCaseStep : object
Kind: global typedef
Properties
| Name | Type |
|---|---|
| step | number |
| rowNum | number |
| action | string |
| passedAction | string |
| textContains | string |
| quickRepliesContains | string |
| stepDescription | string |
TestsGroup : object
Kind: global typedef
Properties
| Name | Type |
|---|---|
| listId | number |
| list | string |
| type | string |
| testCases | Array.<TestCase> | Array.<TextTest> |
List : object
Kind: global typedef
Properties
| Name | Type |
|---|---|
| id | number |
| name | string |
| type | string |
| testCases | Array.<TestCase> | Array.<TextTest> |
TestsDefinition : object
Kind: global typedef
Properties
| Name | Type |
|---|---|
| lists | Array.<List> |
testerFactory ⇒ Tester
Callback for getting a tester
Kind: global typedef
| Param | Type | Description |
|---|---|---|
| bot | Router | ReducerWrapper | BuildRouter | the chatbot itself |
| test | TestsGroup | the chatbot itself |
TestsOutput : object
Kind: global typedef
Properties
| Name | Type |
|---|---|
| total | number |
| passed | number |
| failed | number |
| skipped | number |
| output | string |
| summaryOutput | string |
| step | number |
| stepCount | number |
Logger : object
Kind: global typedef
Properties
| Name | Type |
|---|---|
| log | function |
| error | function |