Skip to content

Commit a0db7b8

Browse files
committed
test(plugin-flow-builder): update test to check that request.input.nluResult is set after a match
1 parent 5e87e5f commit a0db7b8

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

packages/botonic-plugin-flow-builder/tests/keyword.test.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,20 @@ describe('Check the contents returned by the plugin using keywords', () => {
1212
test.each(['reset', 'hola', 'HOLA'])(
1313
'The initial content is displayed when the user sends the %s text',
1414
async (inputData: string) => {
15-
const { contents } = await createFlowBuilderPluginAndGetContents({
16-
flowBuilderOptions: { flow: basicFlow },
17-
requestArgs: {
18-
input: { data: inputData, type: INPUT.TEXT },
19-
},
20-
})
15+
const { contents, request } = await createFlowBuilderPluginAndGetContents(
16+
{
17+
flowBuilderOptions: { flow: basicFlow },
18+
requestArgs: {
19+
input: { data: inputData, type: INPUT.TEXT },
20+
},
21+
}
22+
)
2123

2224
expect((contents[0] as FlowText).text).toBe('Welcome message')
25+
expect(request.input.nluResult).toEqual({
26+
type: 'keyword',
27+
match: inputData,
28+
})
2329
}
2430
)
2531
})

packages/botonic-plugin-flow-builder/tests/smart-intent.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ describe('Check the contents returned by the plugin when match a smart intent',
1313

1414
beforeEach(() => mockSmartIntent('Add a bag'))
1515

16-
test('When the smart intent inference returns the intent_name Add a Bag, the contents of the add a bag use case are displayed', async () => {
17-
const { contents } = await createFlowBuilderPluginAndGetContents({
16+
test('When the smart intent inference returns the intent_name Add a bag, the contents of the add a bag use case are displayed', async () => {
17+
const { contents, request } = await createFlowBuilderPluginAndGetContents({
1818
flowBuilderOptions: { flow: smartIntentsFlow },
1919
requestArgs: {
2020
input: {
@@ -27,6 +27,10 @@ describe('Check the contents returned by the plugin when match a smart intent',
2727
expect((contents[0] as FlowText).text).toBe(
2828
'Message explaining how to add a bag'
2929
)
30+
expect(request.input.nluResult).toEqual({
31+
type: 'smart-intent',
32+
match: 'Add a bag',
33+
})
3034
})
3135
})
3236

@@ -36,7 +40,7 @@ describe('Check the contents returned by the plugin when no match a smart intent
3640
beforeEach(() => mockSmartIntent('Other'))
3741

3842
test('When the smart intent inference returns the intent_name Other, fallback content are displayed', async () => {
39-
const { contents } = await createFlowBuilderPluginAndGetContents({
43+
const { contents, request } = await createFlowBuilderPluginAndGetContents({
4044
flowBuilderOptions: { flow: smartIntentsFlow },
4145
requestArgs: {
4246
input: {
@@ -47,5 +51,6 @@ describe('Check the contents returned by the plugin when no match a smart intent
4751
})
4852

4953
expect((contents[0] as FlowText).text).toBe('fallback 1st message')
54+
expect(request.input.nluResult).toEqual(undefined)
5055
})
5156
})

0 commit comments

Comments
 (0)