@sprucelabs/spruce-conversation-plugin 62.2.24 → 62.2.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -17
- package/build/__tests__/behavioral/CheckingHealth.test.d.ts +0 -10
- package/build/__tests__/behavioral/CheckingHealth.test.js +0 -87
- package/build/__tests__/behavioral/KillingASkill.test.d.ts +0 -4
- package/build/__tests__/behavioral/KillingASkill.test.js +0 -29
- package/build/__tests__/behavioral/RegisteringConversationsOnBoot.test.d.ts +0 -13
- package/build/__tests__/behavioral/RegisteringConversationsOnBoot.test.js +0 -147
- package/build/__tests__/behavioral/RespondingToMessages.test.d.ts +0 -13
- package/build/__tests__/behavioral/RespondingToMessages.test.js +0 -134
- package/build/__tests__/behavioral/TestingAConversation.test.d.ts +0 -14
- package/build/__tests__/behavioral/TestingAConversation.test.js +0 -110
- package/build/__tests__/implementation/ConversationCoordinator.test.d.ts +0 -18
- package/build/__tests__/implementation/ConversationCoordinator.test.js +0 -185
- package/build/__tests__/implementation/MessageGraphicsInterface/EmailField.test.d.ts +0 -7
- package/build/__tests__/implementation/MessageGraphicsInterface/EmailField.test.js +0 -73
- package/build/__tests__/implementation/MessageGraphicsInterface/MessageGraphicsInterface.test.d.ts +0 -4
- package/build/__tests__/implementation/MessageGraphicsInterface/MessageGraphicsInterface.test.js +0 -42
- package/build/__tests__/implementation/MessageGraphicsInterface/MockMessageBeforeAndAfterEach.test.d.ts +0 -5
- package/build/__tests__/implementation/MessageGraphicsInterface/MockMessageBeforeAndAfterEach.test.js +0 -62
- package/build/__tests__/implementation/MessageGraphicsInterface/MockMessageInterface.test.d.ts +0 -18
- package/build/__tests__/implementation/MessageGraphicsInterface/MockMessageInterface.test.js +0 -168
- package/build/__tests__/implementation/MessageGraphicsInterface/SelectField.test.d.ts +0 -7
- package/build/__tests__/implementation/MessageGraphicsInterface/SelectField.test.js +0 -71
- package/build/__tests__/implementation/MessageGraphicsInterface/TextField.test.d.ts +0 -6
- package/build/__tests__/implementation/MessageGraphicsInterface/TextField.test.js +0 -48
- package/build/__tests__/implementation/ScriptTester.test.d.ts +0 -19
- package/build/__tests__/implementation/ScriptTester.test.js +0 -461
- package/build/__tests__/implementation/SuggesterUtil.test.d.ts +0 -7
- package/build/__tests__/implementation/SuggesterUtil.test.js +0 -63
- package/build/__tests__/implementation/TopicLoader.test.d.ts +0 -8
- package/build/__tests__/implementation/TopicLoader.test.js +0 -66
- package/build/__tests__/implementation/TopicScriptPlayer.test.d.ts +0 -23
- package/build/__tests__/implementation/TopicScriptPlayer.test.js +0 -436
- package/build/__tests__/implementation/TopicSuggester.test.d.ts +0 -8
- package/build/__tests__/implementation/TopicSuggester.test.js +0 -137
- package/build/__tests__/testDirsAndFiles/bad-empty/conversations/bookAppointment.topic.d.ts +0 -0
- package/build/__tests__/testDirsAndFiles/bad-empty/conversations/bookAppointment.topic.js +0 -1
- package/build/__tests__/testDirsAndFiles/bad-missing-params/conversations/bookAppointment.topic.d.ts +0 -2
- package/build/__tests__/testDirsAndFiles/bad-missing-params/conversations/bookAppointment.topic.js +0 -4
- package/build/__tests__/testDirsAndFiles/bad-skill/build/.spruce/events/listeners.d.ts +0 -2
- package/build/__tests__/testDirsAndFiles/bad-skill/build/.spruce/events/listeners.js +0 -3
- package/build/__tests__/testDirsAndFiles/bad-skill/build/conversations/bookAppointment.topic.d.ts +0 -2
- package/build/__tests__/testDirsAndFiles/bad-skill/build/conversations/bookAppointment.topic.js +0 -4
- package/build/__tests__/testDirsAndFiles/empty-skill/build/.spruce/events/listeners.d.ts +0 -2
- package/build/__tests__/testDirsAndFiles/empty-skill/build/.spruce/events/listeners.js +0 -3
- package/build/__tests__/testDirsAndFiles/good/conversations/bookAppointment.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/good/conversations/bookAppointment.topic.js +0 -8
- package/build/__tests__/testDirsAndFiles/good/conversations/cancelAppointment.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/good/conversations/cancelAppointment.topic.js +0 -12
- package/build/__tests__/testDirsAndFiles/skill/build/.spruce/events/listeners.d.ts +0 -2
- package/build/__tests__/testDirsAndFiles/skill/build/.spruce/events/listeners.js +0 -3
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/bookAppointment.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/bookAppointment.topic.js +0 -8
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/cancelAppointment.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/cancelAppointment.topic.js +0 -12
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColor.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColor.topic.js +0 -21
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColorTopicChanger.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColorTopicChanger.topic.js +0 -21
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/mixedStringsAndCallbacks.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/mixedStringsAndCallbacks.topic.js +0 -29
- package/build/__tests__/testDirsAndFiles/skill-assertions/build/.spruce/events/listeners.d.ts +0 -2
- package/build/__tests__/testDirsAndFiles/skill-assertions/build/.spruce/events/listeners.js +0 -3
- package/build/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptCallbackOptions.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptCallbackOptions.topic.js +0 -22
- package/build/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptOnlyCalledOnce.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptOnlyCalledOnce.topic.js +0 -14
- package/build/__tests__/testDirsAndFiles/skill-with-one-topic/build/.spruce/events/listeners.d.ts +0 -2
- package/build/__tests__/testDirsAndFiles/skill-with-one-topic/build/.spruce/events/listeners.js +0 -3
- package/build/__tests__/testDirsAndFiles/skill-with-one-topic/build/conversations/bookAppointment.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/skill-with-one-topic/build/conversations/bookAppointment.topic.js +0 -8
- package/build/__tests__/testDirsAndFiles/skill-with-script-that-throws/build/.spruce/events/listeners.d.ts +0 -2
- package/build/__tests__/testDirsAndFiles/skill-with-script-that-throws/build/.spruce/events/listeners.js +0 -3
- package/build/__tests__/testDirsAndFiles/skill-with-script-that-throws/build/conversations/cancelAppointment.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/skill-with-script-that-throws/build/conversations/cancelAppointment.topic.js +0 -16
- package/build/esm/__tests__/behavioral/CheckingHealth.test.d.ts +0 -10
- package/build/esm/__tests__/behavioral/CheckingHealth.test.js +0 -104
- package/build/esm/__tests__/behavioral/KillingASkill.test.d.ts +0 -4
- package/build/esm/__tests__/behavioral/KillingASkill.test.js +0 -34
- package/build/esm/__tests__/behavioral/RegisteringConversationsOnBoot.test.d.ts +0 -13
- package/build/esm/__tests__/behavioral/RegisteringConversationsOnBoot.test.js +0 -171
- package/build/esm/__tests__/behavioral/RespondingToMessages.test.d.ts +0 -13
- package/build/esm/__tests__/behavioral/RespondingToMessages.test.js +0 -158
- package/build/esm/__tests__/behavioral/TestingAConversation.test.d.ts +0 -14
- package/build/esm/__tests__/behavioral/TestingAConversation.test.js +0 -137
- package/build/esm/__tests__/implementation/ConversationCoordinator.test.d.ts +0 -18
- package/build/esm/__tests__/implementation/ConversationCoordinator.test.js +0 -214
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/EmailField.test.d.ts +0 -7
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/EmailField.test.js +0 -84
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/MessageGraphicsInterface.test.d.ts +0 -4
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/MessageGraphicsInterface.test.js +0 -47
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/MockMessageBeforeAndAfterEach.test.d.ts +0 -5
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/MockMessageBeforeAndAfterEach.test.js +0 -47
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/MockMessageInterface.test.d.ts +0 -18
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/MockMessageInterface.test.js +0 -172
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/SelectField.test.d.ts +0 -7
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/SelectField.test.js +0 -80
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/TextField.test.d.ts +0 -6
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/TextField.test.js +0 -57
- package/build/esm/__tests__/implementation/ScriptTester.test.d.ts +0 -19
- package/build/esm/__tests__/implementation/ScriptTester.test.js +0 -470
- package/build/esm/__tests__/implementation/SuggesterUtil.test.d.ts +0 -7
- package/build/esm/__tests__/implementation/SuggesterUtil.test.js +0 -74
- package/build/esm/__tests__/implementation/TopicLoader.test.d.ts +0 -8
- package/build/esm/__tests__/implementation/TopicLoader.test.js +0 -79
- package/build/esm/__tests__/implementation/TopicScriptPlayer.test.d.ts +0 -23
- package/build/esm/__tests__/implementation/TopicScriptPlayer.test.js +0 -477
- package/build/esm/__tests__/implementation/TopicSuggester.test.d.ts +0 -8
- package/build/esm/__tests__/implementation/TopicSuggester.test.js +0 -130
- package/build/esm/__tests__/testDirsAndFiles/bad-empty/conversations/bookAppointment.topic.d.ts +0 -0
- package/build/esm/__tests__/testDirsAndFiles/bad-empty/conversations/bookAppointment.topic.js +0 -1
- package/build/esm/__tests__/testDirsAndFiles/bad-missing-params/conversations/bookAppointment.topic.d.ts +0 -2
- package/build/esm/__tests__/testDirsAndFiles/bad-missing-params/conversations/bookAppointment.topic.js +0 -2
- package/build/esm/__tests__/testDirsAndFiles/bad-skill/build/conversations/bookAppointment.topic.d.ts +0 -2
- package/build/esm/__tests__/testDirsAndFiles/bad-skill/build/conversations/bookAppointment.topic.js +0 -2
- package/build/esm/__tests__/testDirsAndFiles/good/conversations/bookAppointment.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/good/conversations/bookAppointment.topic.js +0 -6
- package/build/esm/__tests__/testDirsAndFiles/good/conversations/cancelAppointment.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/good/conversations/cancelAppointment.topic.js +0 -10
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/bookAppointment.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/bookAppointment.topic.js +0 -6
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/cancelAppointment.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/cancelAppointment.topic.js +0 -10
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColor.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColor.topic.js +0 -28
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColorTopicChanger.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColorTopicChanger.topic.js +0 -28
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/mixedStringsAndCallbacks.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/mixedStringsAndCallbacks.topic.js +0 -36
- package/build/esm/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptCallbackOptions.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptCallbackOptions.topic.js +0 -29
- package/build/esm/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptOnlyCalledOnce.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptOnlyCalledOnce.topic.js +0 -21
- package/build/esm/__tests__/testDirsAndFiles/skill-with-one-topic/build/conversations/bookAppointment.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/skill-with-one-topic/build/conversations/bookAppointment.topic.js +0 -6
- package/build/esm/__tests__/testDirsAndFiles/skill-with-script-that-throws/build/conversations/cancelAppointment.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/skill-with-script-that-throws/build/conversations/cancelAppointment.topic.js +0 -14
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { SkillContext } from '@sprucelabs/spruce-skill-utils';
|
|
2
|
-
import AbstractConversationTest from '../../tests/AbstractConversationTest';
|
|
3
|
-
export default class TopicScriptPlayerTest extends AbstractConversationTest {
|
|
4
|
-
protected static throwsWhenRequiredOptionsNotSent(): Promise<void>;
|
|
5
|
-
protected static respondsToMessageWithOnlyLineInScript(): Promise<void>;
|
|
6
|
-
protected static respondsToMessagesWithAllLinesInScript(): Promise<void>;
|
|
7
|
-
protected static multipleTextLinesWaitsForDelay(): Promise<void>;
|
|
8
|
-
protected static restartsScriptNextMessage(): Promise<void>;
|
|
9
|
-
protected static respondsWithRandomLine(): Promise<void>;
|
|
10
|
-
protected static renderLineSendsMessage(): Promise<void>;
|
|
11
|
-
protected static scriptCanAskToConfirm(confirmBody: string, expectedConfirmResults: boolean): Promise<void>;
|
|
12
|
-
protected static scriptCanRespondWithTransition(): Promise<void>;
|
|
13
|
-
protected static scriptCanRespondWithTransitionAInLaterLines(): Promise<void>;
|
|
14
|
-
protected static scriptCanRespondWithTransitionAInLaterLinesAfterAskingForInput(): Promise<void>;
|
|
15
|
-
protected static randomOnOptions(): Promise<void>;
|
|
16
|
-
protected static randomOptionsRandomOnNotString(): Promise<void>;
|
|
17
|
-
protected static retainsStateBetweenScriptLines(): Promise<void>;
|
|
18
|
-
protected static retainsStateBetweenMessages(): Promise<void>;
|
|
19
|
-
protected static alwaysEndsWithRedirectToDiscovery(): Promise<void>;
|
|
20
|
-
protected static skillContextAvailableOnScriptLine(context: SkillContext): Promise<void>;
|
|
21
|
-
private static Player;
|
|
22
|
-
private static sendMessage;
|
|
23
|
-
}
|
|
@@ -1,436 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
13
|
-
const test_utils_2 = require("@sprucelabs/test-utils");
|
|
14
|
-
const AbstractConversationTest_1 = __importDefault(require("../../tests/AbstractConversationTest"));
|
|
15
|
-
const TopicScriptPlayer_1 = require("../../topics/TopicScriptPlayer");
|
|
16
|
-
class TopicScriptPlayerTest extends AbstractConversationTest_1.default {
|
|
17
|
-
static async throwsWhenRequiredOptionsNotSent() {
|
|
18
|
-
//@ts-ignore
|
|
19
|
-
const err = test_utils_1.assert.doesThrow(() => new TopicScriptPlayer_1.TopicScriptPlayer());
|
|
20
|
-
test_utils_2.errorAssert.assertError(err, 'MISSING_PARAMETERS', {
|
|
21
|
-
parameters: [
|
|
22
|
-
'script',
|
|
23
|
-
'sendMessageHandler',
|
|
24
|
-
'target.personId',
|
|
25
|
-
'getContext',
|
|
26
|
-
],
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
static async respondsToMessageWithOnlyLineInScript() {
|
|
30
|
-
const messages = [];
|
|
31
|
-
const player = this.Player({
|
|
32
|
-
script: ['It all started on a cold, dark night.'],
|
|
33
|
-
target: { personId: '12345' },
|
|
34
|
-
sendMessageHandler: async (message) => {
|
|
35
|
-
messages.push(message);
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
await this.sendMessage(player, {
|
|
39
|
-
body: 'how are you today?',
|
|
40
|
-
});
|
|
41
|
-
test_utils_1.assert.isLength(messages, 1);
|
|
42
|
-
test_utils_1.assert.isEqual(messages[0].body, 'It all started on a cold, dark night.');
|
|
43
|
-
test_utils_1.assert.isEqualDeep(messages[0].target.personId, '12345');
|
|
44
|
-
}
|
|
45
|
-
static async respondsToMessagesWithAllLinesInScript() {
|
|
46
|
-
const messages = [];
|
|
47
|
-
const player = this.Player({
|
|
48
|
-
script: [
|
|
49
|
-
'It all started on a cold, dark night.',
|
|
50
|
-
'Before the sun went down',
|
|
51
|
-
],
|
|
52
|
-
sendMessageHandler: async (message) => {
|
|
53
|
-
messages.push(message);
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
await this.sendMessage(player, {
|
|
57
|
-
body: 'how are you today?',
|
|
58
|
-
});
|
|
59
|
-
test_utils_1.assert.isLength(messages, 2);
|
|
60
|
-
test_utils_1.assert.isEqual(messages[0].body, 'It all started on a cold, dark night.');
|
|
61
|
-
test_utils_1.assert.isEqual(messages[1].body, 'Before the sun went down');
|
|
62
|
-
}
|
|
63
|
-
static async multipleTextLinesWaitsForDelay() {
|
|
64
|
-
const messages = [];
|
|
65
|
-
const player = this.Player({
|
|
66
|
-
lineDelay: 50,
|
|
67
|
-
script: [
|
|
68
|
-
'It all started on a cold, dark night.',
|
|
69
|
-
'Before the sun went down',
|
|
70
|
-
],
|
|
71
|
-
sendMessageHandler: async (message) => {
|
|
72
|
-
messages.push(message);
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
void this.sendMessage(player, {
|
|
76
|
-
body: 'how are you today?',
|
|
77
|
-
});
|
|
78
|
-
test_utils_1.assert.isLength(messages, 1);
|
|
79
|
-
await this.wait(100);
|
|
80
|
-
test_utils_1.assert.isLength(messages, 2);
|
|
81
|
-
test_utils_1.assert.isEqual(messages[0].body, 'It all started on a cold, dark night.');
|
|
82
|
-
test_utils_1.assert.isEqual(messages[1].body, 'Before the sun went down');
|
|
83
|
-
}
|
|
84
|
-
static async restartsScriptNextMessage() {
|
|
85
|
-
const messages = [];
|
|
86
|
-
const player = this.Player({
|
|
87
|
-
script: [
|
|
88
|
-
'It all started on a cold, dark night.',
|
|
89
|
-
'Before the sun went down',
|
|
90
|
-
],
|
|
91
|
-
sendMessageHandler: async (message) => {
|
|
92
|
-
messages.push(message);
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
await this.sendMessage(player, {
|
|
96
|
-
body: 'how are you today?',
|
|
97
|
-
});
|
|
98
|
-
await this.sendMessage(player, {
|
|
99
|
-
body: 'how are you today?',
|
|
100
|
-
});
|
|
101
|
-
test_utils_1.assert.isLength(messages, 4);
|
|
102
|
-
}
|
|
103
|
-
static async respondsWithRandomLine() {
|
|
104
|
-
const messages = [];
|
|
105
|
-
const player = this.Player({
|
|
106
|
-
script: [['one', 'two', 'three']],
|
|
107
|
-
sendMessageHandler: async (message) => {
|
|
108
|
-
messages.push(message);
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
const remaining = { one: 1, two: 1, three: 1 };
|
|
112
|
-
do {
|
|
113
|
-
await this.sendMessage(player, {
|
|
114
|
-
body: 'how are you today?',
|
|
115
|
-
});
|
|
116
|
-
if (messages.length === 0) {
|
|
117
|
-
test_utils_1.assert.fail("Didn't send any message.");
|
|
118
|
-
}
|
|
119
|
-
//@ts-ignore
|
|
120
|
-
delete remaining[messages.pop().body];
|
|
121
|
-
} while (Object.keys(remaining).length > 0);
|
|
122
|
-
}
|
|
123
|
-
static async renderLineSendsMessage() {
|
|
124
|
-
const messages = [];
|
|
125
|
-
const player = this.Player({
|
|
126
|
-
script: [
|
|
127
|
-
async (options) => {
|
|
128
|
-
options.ui.renderLine('What is up?');
|
|
129
|
-
},
|
|
130
|
-
],
|
|
131
|
-
sendMessageHandler: async (message) => {
|
|
132
|
-
messages.push(message);
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
|
-
await this.sendMessage(player, {
|
|
136
|
-
body: 'What the?',
|
|
137
|
-
});
|
|
138
|
-
test_utils_1.assert.isLength(messages, 1);
|
|
139
|
-
test_utils_1.assert.isEqual(messages[0].body, 'What is up?');
|
|
140
|
-
//@ts-ignore
|
|
141
|
-
test_utils_1.assert.isFalsy(messages[0].target.isCore);
|
|
142
|
-
}
|
|
143
|
-
static async scriptCanAskToConfirm(confirmBody, expectedConfirmResults) {
|
|
144
|
-
let confirmStarted = false;
|
|
145
|
-
let confirmResponse;
|
|
146
|
-
let confirmFinished = false;
|
|
147
|
-
const messages = [];
|
|
148
|
-
const player = this.Player({
|
|
149
|
-
sendMessageHandler: async (message) => {
|
|
150
|
-
messages.push(message);
|
|
151
|
-
},
|
|
152
|
-
script: [
|
|
153
|
-
'It all started on a cold, dark night.',
|
|
154
|
-
'Before the sun went down',
|
|
155
|
-
async (options) => {
|
|
156
|
-
confirmStarted = true;
|
|
157
|
-
const confirm = await options.ui.confirm('Are you sure?');
|
|
158
|
-
confirmResponse = confirm;
|
|
159
|
-
confirmFinished = true;
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
});
|
|
163
|
-
void this.sendMessage(player, {
|
|
164
|
-
body: 'tell me a story!',
|
|
165
|
-
});
|
|
166
|
-
await this.wait(100);
|
|
167
|
-
test_utils_1.assert.isTrue(confirmStarted);
|
|
168
|
-
test_utils_1.assert.isUndefined(confirmResponse);
|
|
169
|
-
test_utils_1.assert.isFalse(confirmFinished);
|
|
170
|
-
await this.sendMessage(player, {
|
|
171
|
-
body: confirmBody,
|
|
172
|
-
});
|
|
173
|
-
await this.wait(100);
|
|
174
|
-
test_utils_1.assert.isTrue(confirmStarted);
|
|
175
|
-
test_utils_1.assert.isEqual(confirmResponse, expectedConfirmResults);
|
|
176
|
-
test_utils_1.assert.isTrue(confirmFinished);
|
|
177
|
-
test_utils_1.assert.doesInclude(messages, { body: 'Are you sure?' });
|
|
178
|
-
}
|
|
179
|
-
static async scriptCanRespondWithTransition() {
|
|
180
|
-
const player = this.Player({
|
|
181
|
-
script: [
|
|
182
|
-
async () => {
|
|
183
|
-
return { transitionConversationTo: 'greeting' };
|
|
184
|
-
},
|
|
185
|
-
],
|
|
186
|
-
});
|
|
187
|
-
const results = await this.sendMessage(player, {
|
|
188
|
-
body: 'tell me a story!',
|
|
189
|
-
});
|
|
190
|
-
test_utils_1.assert.isTruthy(results);
|
|
191
|
-
test_utils_1.assert.isTruthy(results.transitionConversationTo);
|
|
192
|
-
test_utils_1.assert.isEqual(results.transitionConversationTo, 'greeting');
|
|
193
|
-
}
|
|
194
|
-
static async scriptCanRespondWithTransitionAInLaterLines() {
|
|
195
|
-
const player = this.Player({
|
|
196
|
-
script: [
|
|
197
|
-
'Hey there!',
|
|
198
|
-
async () => { },
|
|
199
|
-
async () => {
|
|
200
|
-
return { transitionConversationTo: 'greeting' };
|
|
201
|
-
},
|
|
202
|
-
],
|
|
203
|
-
});
|
|
204
|
-
const results = await this.sendMessage(player, {
|
|
205
|
-
body: 'tell me a story!',
|
|
206
|
-
});
|
|
207
|
-
test_utils_1.assert.isTruthy(results);
|
|
208
|
-
test_utils_1.assert.isTruthy(results.transitionConversationTo);
|
|
209
|
-
test_utils_1.assert.isEqual(results.transitionConversationTo, 'greeting');
|
|
210
|
-
}
|
|
211
|
-
static async scriptCanRespondWithTransitionAInLaterLinesAfterAskingForInput() {
|
|
212
|
-
const player = this.Player({
|
|
213
|
-
script: [
|
|
214
|
-
'Hey there!',
|
|
215
|
-
async (options) => {
|
|
216
|
-
await options.ui.prompt({ type: 'text', isRequired: true });
|
|
217
|
-
},
|
|
218
|
-
async () => {
|
|
219
|
-
return { transitionConversationTo: 'greeting' };
|
|
220
|
-
},
|
|
221
|
-
],
|
|
222
|
-
});
|
|
223
|
-
await this.sendMessage(player, {
|
|
224
|
-
body: 'tell me a story!',
|
|
225
|
-
});
|
|
226
|
-
const results = await this.sendMessage(player, {
|
|
227
|
-
body: 'Yes!',
|
|
228
|
-
});
|
|
229
|
-
test_utils_1.assert.isTruthy(results);
|
|
230
|
-
test_utils_1.assert.isTruthy(results.transitionConversationTo);
|
|
231
|
-
test_utils_1.assert.isEqual(results.transitionConversationTo, 'greeting');
|
|
232
|
-
}
|
|
233
|
-
static async randomOnOptions() {
|
|
234
|
-
const messages = [];
|
|
235
|
-
const remaining = { one: true, two: true, three: true };
|
|
236
|
-
const possibilities = [
|
|
237
|
-
'one',
|
|
238
|
-
'two',
|
|
239
|
-
'three',
|
|
240
|
-
];
|
|
241
|
-
const player = this.Player({
|
|
242
|
-
sendMessageHandler: async (message) => {
|
|
243
|
-
messages.push(message.body);
|
|
244
|
-
},
|
|
245
|
-
script: [
|
|
246
|
-
async (options) => {
|
|
247
|
-
test_utils_1.assert.isFunction(options.rand);
|
|
248
|
-
const answer = options.rand(possibilities);
|
|
249
|
-
//@ts-ignore
|
|
250
|
-
delete remaining[answer];
|
|
251
|
-
},
|
|
252
|
-
],
|
|
253
|
-
});
|
|
254
|
-
do {
|
|
255
|
-
await this.sendMessage(player, {
|
|
256
|
-
body: 'tell me a story!',
|
|
257
|
-
});
|
|
258
|
-
} while (Object.keys(remaining).length > 0);
|
|
259
|
-
}
|
|
260
|
-
static async randomOptionsRandomOnNotString() {
|
|
261
|
-
const possibilities = [true, false];
|
|
262
|
-
let answer;
|
|
263
|
-
const player = this.Player({
|
|
264
|
-
script: [
|
|
265
|
-
async (options) => {
|
|
266
|
-
test_utils_1.assert.isFunction(options.rand);
|
|
267
|
-
answer = options.rand(possibilities);
|
|
268
|
-
},
|
|
269
|
-
],
|
|
270
|
-
});
|
|
271
|
-
await this.sendMessage(player, {
|
|
272
|
-
body: 'go',
|
|
273
|
-
});
|
|
274
|
-
test_utils_1.assert.isTrue(possibilities.includes(answer));
|
|
275
|
-
}
|
|
276
|
-
static async retainsStateBetweenScriptLines() {
|
|
277
|
-
const player = this.Player({
|
|
278
|
-
script: [
|
|
279
|
-
async (options) => {
|
|
280
|
-
options.state.goTeam = true;
|
|
281
|
-
},
|
|
282
|
-
async (options) => {
|
|
283
|
-
test_utils_1.assert.isTrue(options.state.goTeam);
|
|
284
|
-
},
|
|
285
|
-
],
|
|
286
|
-
});
|
|
287
|
-
await this.sendMessage(player, {
|
|
288
|
-
body: 'tell me a story!',
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
static async retainsStateBetweenMessages() {
|
|
292
|
-
let stateCount = 0;
|
|
293
|
-
const player = this.Player({
|
|
294
|
-
script: [
|
|
295
|
-
async (options) => {
|
|
296
|
-
if (!options.state.count) {
|
|
297
|
-
options.state.count = 1;
|
|
298
|
-
}
|
|
299
|
-
else {
|
|
300
|
-
options.state.count++;
|
|
301
|
-
}
|
|
302
|
-
},
|
|
303
|
-
async (options) => {
|
|
304
|
-
options.state.count++;
|
|
305
|
-
stateCount = options.state.count;
|
|
306
|
-
},
|
|
307
|
-
],
|
|
308
|
-
});
|
|
309
|
-
await this.sendMessage(player, {
|
|
310
|
-
body: 'tell me a story!',
|
|
311
|
-
});
|
|
312
|
-
test_utils_1.assert.isEqual(stateCount, 2);
|
|
313
|
-
await this.sendMessage(player, { body: 'again, again!' });
|
|
314
|
-
test_utils_1.assert.isEqual(stateCount, 4);
|
|
315
|
-
}
|
|
316
|
-
static async alwaysEndsWithRedirectToDiscovery() {
|
|
317
|
-
let stateCount = 0;
|
|
318
|
-
const player = this.Player({
|
|
319
|
-
script: [
|
|
320
|
-
async (options) => {
|
|
321
|
-
if (!options.state.count) {
|
|
322
|
-
options.state.count = 1;
|
|
323
|
-
}
|
|
324
|
-
else {
|
|
325
|
-
options.state.count++;
|
|
326
|
-
}
|
|
327
|
-
},
|
|
328
|
-
async (options) => {
|
|
329
|
-
options.state.count++;
|
|
330
|
-
stateCount = options.state.count;
|
|
331
|
-
},
|
|
332
|
-
],
|
|
333
|
-
});
|
|
334
|
-
let results = await this.sendMessage(player, {
|
|
335
|
-
body: 'tell me a story!',
|
|
336
|
-
});
|
|
337
|
-
test_utils_1.assert.isEqual(results === null || results === void 0 ? void 0 : results.transitionConversationTo, 'discovery');
|
|
338
|
-
test_utils_1.assert.isEqual(stateCount, 2);
|
|
339
|
-
results = await this.sendMessage(player, { body: 'again, again!' });
|
|
340
|
-
test_utils_1.assert.isEqual(results === null || results === void 0 ? void 0 : results.transitionConversationTo, 'discovery');
|
|
341
|
-
test_utils_1.assert.isEqual(stateCount, 4);
|
|
342
|
-
}
|
|
343
|
-
static async skillContextAvailableOnScriptLine(context) {
|
|
344
|
-
let passedContext;
|
|
345
|
-
const player = this.Player({
|
|
346
|
-
getContext: () => context,
|
|
347
|
-
script: [
|
|
348
|
-
async (options) => {
|
|
349
|
-
passedContext = options.context;
|
|
350
|
-
},
|
|
351
|
-
],
|
|
352
|
-
});
|
|
353
|
-
await this.sendMessage(player, {
|
|
354
|
-
body: (0, test_utils_1.generateId)(),
|
|
355
|
-
});
|
|
356
|
-
test_utils_1.assert.isEqualDeep(passedContext, context);
|
|
357
|
-
}
|
|
358
|
-
static Player(options) {
|
|
359
|
-
var _a, _b;
|
|
360
|
-
return new TopicScriptPlayer_1.TopicScriptPlayer(Object.assign({ target: (_a = options.target) !== null && _a !== void 0 ? _a : { personId: '12345' }, lineDelay: 0, sendMessageHandler: (_b = options.sendMessageHandler) !== null && _b !== void 0 ? _b : async function () { }, getContext: () => ({}) }, options));
|
|
361
|
-
}
|
|
362
|
-
static async sendMessage(player, message) {
|
|
363
|
-
return player.handleMessage(this.buildMessage(Object.assign({ source: { personId: '1234' } }, message)));
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
exports.default = TopicScriptPlayerTest;
|
|
367
|
-
__decorate([
|
|
368
|
-
(0, test_utils_1.test)()
|
|
369
|
-
], TopicScriptPlayerTest, "throwsWhenRequiredOptionsNotSent", null);
|
|
370
|
-
__decorate([
|
|
371
|
-
(0, test_utils_1.test)()
|
|
372
|
-
], TopicScriptPlayerTest, "respondsToMessageWithOnlyLineInScript", null);
|
|
373
|
-
__decorate([
|
|
374
|
-
(0, test_utils_1.test)()
|
|
375
|
-
], TopicScriptPlayerTest, "respondsToMessagesWithAllLinesInScript", null);
|
|
376
|
-
__decorate([
|
|
377
|
-
(0, test_utils_1.test)()
|
|
378
|
-
], TopicScriptPlayerTest, "multipleTextLinesWaitsForDelay", null);
|
|
379
|
-
__decorate([
|
|
380
|
-
(0, test_utils_1.test)()
|
|
381
|
-
], TopicScriptPlayerTest, "restartsScriptNextMessage", null);
|
|
382
|
-
__decorate([
|
|
383
|
-
(0, test_utils_1.test)()
|
|
384
|
-
], TopicScriptPlayerTest, "respondsWithRandomLine", null);
|
|
385
|
-
__decorate([
|
|
386
|
-
(0, test_utils_1.test)()
|
|
387
|
-
], TopicScriptPlayerTest, "renderLineSendsMessage", null);
|
|
388
|
-
__decorate([
|
|
389
|
-
(0, test_utils_1.test)('Passes confirm when sent "Y"', 'Y', true),
|
|
390
|
-
(0, test_utils_1.test)('Passes confirm when sent "y"', 'y', true),
|
|
391
|
-
(0, test_utils_1.test)('Passes confirm when sent "yes"', 'yes', true),
|
|
392
|
-
(0, test_utils_1.test)('Passes confirm when sent "yup"', 'yup', true),
|
|
393
|
-
(0, test_utils_1.test)('Passes confirm when sent "yes please"', 'yes please', true),
|
|
394
|
-
(0, test_utils_1.test)('Passes confirm when sent "yeah"', 'yeah', true),
|
|
395
|
-
(0, test_utils_1.test)('Passes confirm when sent "yeah!!!"', 'yeah!!!', true),
|
|
396
|
-
(0, test_utils_1.test)('Passes confirm when sent "oh heck ya"', 'oh heck ya', true),
|
|
397
|
-
(0, test_utils_1.test)('Passes confirm when sent "oh heck yeah"', 'oh heck yeah', true),
|
|
398
|
-
(0, test_utils_1.test)('Passes confirm when sent "👍"', '👍', true),
|
|
399
|
-
(0, test_utils_1.test)('Fails confirm when sent "negative"', 'negative', false),
|
|
400
|
-
(0, test_utils_1.test)('Fails confirm when sent "nope"', 'nope', false),
|
|
401
|
-
(0, test_utils_1.test)('Fails confirm when sent "nope!!"', 'nope!!', false),
|
|
402
|
-
(0, test_utils_1.test)('Fails confirm when sent "no"', 'no', false),
|
|
403
|
-
(0, test_utils_1.test)('Fails confirm when sent "no thanks"', 'no thanks', false),
|
|
404
|
-
(0, test_utils_1.test)('Fails confirm when sent "no thank you"', 'no thank you', false),
|
|
405
|
-
(0, test_utils_1.test)('Fails confirm when sent "nah"', 'nah', false),
|
|
406
|
-
(0, test_utils_1.test)('Fails confirm when sent "No thanks!!!"', 'No thanks!!!', false),
|
|
407
|
-
(0, test_utils_1.test)('Fails confirm when sent "👎"', '👎', true)
|
|
408
|
-
], TopicScriptPlayerTest, "scriptCanAskToConfirm", null);
|
|
409
|
-
__decorate([
|
|
410
|
-
(0, test_utils_1.test)()
|
|
411
|
-
], TopicScriptPlayerTest, "scriptCanRespondWithTransition", null);
|
|
412
|
-
__decorate([
|
|
413
|
-
(0, test_utils_1.test)()
|
|
414
|
-
], TopicScriptPlayerTest, "scriptCanRespondWithTransitionAInLaterLines", null);
|
|
415
|
-
__decorate([
|
|
416
|
-
(0, test_utils_1.test)()
|
|
417
|
-
], TopicScriptPlayerTest, "scriptCanRespondWithTransitionAInLaterLinesAfterAskingForInput", null);
|
|
418
|
-
__decorate([
|
|
419
|
-
(0, test_utils_1.test)()
|
|
420
|
-
], TopicScriptPlayerTest, "randomOnOptions", null);
|
|
421
|
-
__decorate([
|
|
422
|
-
(0, test_utils_1.test)()
|
|
423
|
-
], TopicScriptPlayerTest, "randomOptionsRandomOnNotString", null);
|
|
424
|
-
__decorate([
|
|
425
|
-
(0, test_utils_1.test)()
|
|
426
|
-
], TopicScriptPlayerTest, "retainsStateBetweenScriptLines", null);
|
|
427
|
-
__decorate([
|
|
428
|
-
(0, test_utils_1.test)()
|
|
429
|
-
], TopicScriptPlayerTest, "retainsStateBetweenMessages", null);
|
|
430
|
-
__decorate([
|
|
431
|
-
(0, test_utils_1.test)()
|
|
432
|
-
], TopicScriptPlayerTest, "alwaysEndsWithRedirectToDiscovery", null);
|
|
433
|
-
__decorate([
|
|
434
|
-
(0, test_utils_1.test)('can passe context 1', { skill: 'test' }),
|
|
435
|
-
(0, test_utils_1.test)('can passe context 2', { hello: 'world' })
|
|
436
|
-
], TopicScriptPlayerTest, "skillContextAvailableOnScriptLine", null);
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import AbstractSpruceTest from '@sprucelabs/test-utils';
|
|
2
|
-
export default class TopicSuggesterTest extends AbstractSpruceTest {
|
|
3
|
-
protected static canCreateTopicSuggester(): Promise<void>;
|
|
4
|
-
protected static canReturnOnlyTopic(): Promise<void>;
|
|
5
|
-
protected static makeSureTopicsAreReturnedInOrderOfConfidence(): Promise<void>;
|
|
6
|
-
protected static matchTests(phrase: string, expectedSuggestionKey: string): Promise<void>;
|
|
7
|
-
private static Suggester;
|
|
8
|
-
}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
const test_utils_1 = __importStar(require("@sprucelabs/test-utils"));
|
|
33
|
-
const TopicSuggester_1 = require("../../topics/TopicSuggester");
|
|
34
|
-
class TopicSuggesterTest extends test_utils_1.default {
|
|
35
|
-
static async canCreateTopicSuggester() {
|
|
36
|
-
const topicSuggester = await TopicSuggester_1.TopicSuggester.Suggester({ topics: [] });
|
|
37
|
-
test_utils_1.assert.isTruthy(topicSuggester);
|
|
38
|
-
}
|
|
39
|
-
static async canReturnOnlyTopic() {
|
|
40
|
-
const topics = [
|
|
41
|
-
{
|
|
42
|
-
key: 'bookAppointment',
|
|
43
|
-
label: 'Book an appointment',
|
|
44
|
-
utterances: ['book an appointment'],
|
|
45
|
-
},
|
|
46
|
-
];
|
|
47
|
-
const messageBody = 'book';
|
|
48
|
-
const suggestions = await this.Suggester(topics, messageBody);
|
|
49
|
-
test_utils_1.assert.doesInclude(suggestions[0], {
|
|
50
|
-
key: 'bookAppointment',
|
|
51
|
-
label: 'Book an appointment',
|
|
52
|
-
});
|
|
53
|
-
test_utils_1.assert.isAbove(suggestions[0].confidence, 0);
|
|
54
|
-
}
|
|
55
|
-
static async makeSureTopicsAreReturnedInOrderOfConfidence() {
|
|
56
|
-
const suggestions = await this.Suggester([
|
|
57
|
-
{
|
|
58
|
-
key: 'scheduleShft',
|
|
59
|
-
label: 'Shift',
|
|
60
|
-
utterances: [
|
|
61
|
-
'shift',
|
|
62
|
-
'block my time',
|
|
63
|
-
'break',
|
|
64
|
-
'hours',
|
|
65
|
-
'schedule',
|
|
66
|
-
],
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
key: 'bookAppointment',
|
|
70
|
-
label: 'Book',
|
|
71
|
-
utterances: [
|
|
72
|
-
'book appointment',
|
|
73
|
-
'schedule an appointment',
|
|
74
|
-
'book',
|
|
75
|
-
'schedule',
|
|
76
|
-
],
|
|
77
|
-
},
|
|
78
|
-
], "I'd like to schedule a haircut");
|
|
79
|
-
test_utils_1.assert.isLength(suggestions, 2);
|
|
80
|
-
test_utils_1.assert.isEqualDeep(suggestions[0].key, 'bookAppointment');
|
|
81
|
-
}
|
|
82
|
-
static async matchTests(phrase, expectedSuggestionKey) {
|
|
83
|
-
const suggestions = await this.Suggester([
|
|
84
|
-
{
|
|
85
|
-
key: 'contactUs',
|
|
86
|
-
label: 'Contact',
|
|
87
|
-
utterances: [
|
|
88
|
-
'tell me more',
|
|
89
|
-
'experience',
|
|
90
|
-
'experience management',
|
|
91
|
-
'tell me about experience',
|
|
92
|
-
'I want to know more',
|
|
93
|
-
],
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
key: 'jokes',
|
|
97
|
-
label: 'Jokes',
|
|
98
|
-
utterances: [
|
|
99
|
-
'be funny',
|
|
100
|
-
'tell me a joke',
|
|
101
|
-
'tell me something funny',
|
|
102
|
-
'laugh',
|
|
103
|
-
'funny',
|
|
104
|
-
'make me laugh',
|
|
105
|
-
'robot jokes',
|
|
106
|
-
],
|
|
107
|
-
},
|
|
108
|
-
], phrase);
|
|
109
|
-
test_utils_1.assert.isLength(suggestions, 2);
|
|
110
|
-
test_utils_1.assert.isEqualDeep(suggestions[0].key, expectedSuggestionKey);
|
|
111
|
-
test_utils_1.assert.isAbove(suggestions[0].confidence, 0.8);
|
|
112
|
-
}
|
|
113
|
-
static async Suggester(topics, messageBody) {
|
|
114
|
-
const topicSuggester = await TopicSuggester_1.TopicSuggester.Suggester({
|
|
115
|
-
topics,
|
|
116
|
-
});
|
|
117
|
-
const suggestions = await topicSuggester.suggest(messageBody);
|
|
118
|
-
return suggestions;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
exports.default = TopicSuggesterTest;
|
|
122
|
-
__decorate([
|
|
123
|
-
(0, test_utils_1.test)()
|
|
124
|
-
], TopicSuggesterTest, "canCreateTopicSuggester", null);
|
|
125
|
-
__decorate([
|
|
126
|
-
(0, test_utils_1.test)()
|
|
127
|
-
], TopicSuggesterTest, "canReturnOnlyTopic", null);
|
|
128
|
-
__decorate([
|
|
129
|
-
(0, test_utils_1.test)()
|
|
130
|
-
], TopicSuggesterTest, "makeSureTopicsAreReturnedInOrderOfConfidence", null);
|
|
131
|
-
__decorate([
|
|
132
|
-
(0, test_utils_1.test)('matches regardless "Experience "', 'Experience ', 'contactUs'),
|
|
133
|
-
(0, test_utils_1.test)('matches regardless "Tell me about experience"', 'Tell me about experience ', 'contactUs'),
|
|
134
|
-
(0, test_utils_1.test)('matches "Tell me something funny"', 'Tell me something funny', 'jokes'),
|
|
135
|
-
(0, test_utils_1.test)('matches "Joke me"', 'Joke me', 'jokes'),
|
|
136
|
-
(0, test_utils_1.test)('matches "Joke me"', 'Joke me', 'jokes')
|
|
137
|
-
], TopicSuggesterTest, "matchTests", null);
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const topicDefinition = {
|
|
4
|
-
label: 'book appointment',
|
|
5
|
-
utterances: ['book appointment', 'Can i book my appointment?', 'book'],
|
|
6
|
-
script: ['Sweet, lets book!', 'Lemme find your appointment!'],
|
|
7
|
-
};
|
|
8
|
-
exports.default = topicDefinition;
|