@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,470 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
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;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
import { test, assert, errorAssert } from '@sprucelabs/test-utils';
|
|
17
|
-
import AbstractConversationTest from '../../tests/AbstractConversationTest.js';
|
|
18
|
-
import ScriptTester, { END_OF_LINE, generateTransitionMessage, } from '../../tests/ScriptTester.js';
|
|
19
|
-
class ScriptTesterTest extends AbstractConversationTest {
|
|
20
|
-
static throwsWithoutScript() {
|
|
21
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
//@ts-ignore
|
|
23
|
-
const err = yield assert.doesThrowAsync(() => ScriptTester.Tester());
|
|
24
|
-
errorAssert.assertError(err, 'MISSING_PARAMETERS', {
|
|
25
|
-
parameters: ['script'],
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
static acceptsSimpleScript() {
|
|
30
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
const tester = yield ScriptTesterTest.Tester({
|
|
32
|
-
topics: [
|
|
33
|
-
{
|
|
34
|
-
utterances: [],
|
|
35
|
-
key: 'bookAppointment',
|
|
36
|
-
label: 'Book appointment',
|
|
37
|
-
script: ['hey there!'],
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
});
|
|
41
|
-
assert.isTruthy(tester);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
static callingGoDoesntCrash() {
|
|
45
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
const tester = yield this.Tester({
|
|
47
|
-
topics: [
|
|
48
|
-
{
|
|
49
|
-
utterances: [],
|
|
50
|
-
key: 'bookAppointment',
|
|
51
|
-
label: 'Book appointment',
|
|
52
|
-
script: ['hey there!'],
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
writeHandler: () => { },
|
|
56
|
-
selectPromptHandler: () => __awaiter(this, void 0, void 0, function* () { return ''; }),
|
|
57
|
-
promptHandler: () => __awaiter(this, void 0, void 0, function* () { return yield new Promise(() => { }); }),
|
|
58
|
-
});
|
|
59
|
-
void tester.go();
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
static cantHandleMessageBeforeStartup() {
|
|
63
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
const tester = yield this.Tester({
|
|
65
|
-
topics: [
|
|
66
|
-
{
|
|
67
|
-
utterances: [],
|
|
68
|
-
key: 'bookAppointment',
|
|
69
|
-
label: 'Book appointment',
|
|
70
|
-
script: ['hey there!'],
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
writeHandler: () => { },
|
|
74
|
-
selectPromptHandler: () => __awaiter(this, void 0, void 0, function* () { return ''; }),
|
|
75
|
-
promptHandler: () => __awaiter(this, void 0, void 0, function* () { return ''; }),
|
|
76
|
-
});
|
|
77
|
-
const err = yield assert.doesThrowAsync(() => tester.handleInput('taco'));
|
|
78
|
-
errorAssert.assertError(err, 'TESTER_NOT_STARTED');
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
static selectingBadScriptToStartThrows() {
|
|
82
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
const tester = yield this.Tester({
|
|
84
|
-
topics: this.basicBookingScript,
|
|
85
|
-
selectPromptHandler: () => __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
return 'oeuou';
|
|
87
|
-
}),
|
|
88
|
-
writeHandler: () => { },
|
|
89
|
-
promptHandler: () => __awaiter(this, void 0, void 0, function* () { return ''; }),
|
|
90
|
-
});
|
|
91
|
-
const err = yield assert.doesThrowAsync(() => tester.go());
|
|
92
|
-
errorAssert.assertError(err, 'TOPIC_NOT_FOUND', {
|
|
93
|
-
suppliedTopic: 'oeuou',
|
|
94
|
-
validTopics: ['bookAppointment', 'cancelAppointment'],
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
static asksWhichScriptYouWantToStartWithWhenThereIsMoreThanOne() {
|
|
99
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
-
let choices;
|
|
101
|
-
const writes = [];
|
|
102
|
-
const tester = yield this.Tester({
|
|
103
|
-
topics: this.basicBookingScript,
|
|
104
|
-
selectPromptHandler: (message) => __awaiter(this, void 0, void 0, function* () {
|
|
105
|
-
var _a;
|
|
106
|
-
choices = (_a = message.choices) !== null && _a !== void 0 ? _a : [];
|
|
107
|
-
return 'cancelAppointment';
|
|
108
|
-
}),
|
|
109
|
-
writeHandler: (message) => {
|
|
110
|
-
writes.push(message.body);
|
|
111
|
-
},
|
|
112
|
-
promptHandler: () => __awaiter(this, void 0, void 0, function* () { return yield new Promise(() => { }); }),
|
|
113
|
-
});
|
|
114
|
-
void tester.go('go team');
|
|
115
|
-
assert.isEqualDeep(choices, [
|
|
116
|
-
{
|
|
117
|
-
value: 'bookAppointment',
|
|
118
|
-
label: 'Book appointment',
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
value: 'cancelAppointment',
|
|
122
|
-
label: 'Cancel appointment',
|
|
123
|
-
},
|
|
124
|
-
]);
|
|
125
|
-
yield this.wait(10);
|
|
126
|
-
assert.doesInclude(writes, 'Lets cancel');
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
static playsSimpleScript(script) {
|
|
130
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
-
const writes = [];
|
|
132
|
-
const tester = yield this.Tester({
|
|
133
|
-
shouldPlayReplayAfterFinish: false,
|
|
134
|
-
lineDelay: 0,
|
|
135
|
-
topics: [{ key: 'test', label: 'Testing', script, utterances: [] }],
|
|
136
|
-
writeHandler: (message) => {
|
|
137
|
-
writes.push(message.body);
|
|
138
|
-
},
|
|
139
|
-
selectPromptHandler: () => __awaiter(this, void 0, void 0, function* () { return ''; }),
|
|
140
|
-
promptHandler: () => __awaiter(this, void 0, void 0, function* () { return ''; }),
|
|
141
|
-
});
|
|
142
|
-
assert.isLength(writes, 0);
|
|
143
|
-
void tester.go('hey there!');
|
|
144
|
-
yield this.wait(10);
|
|
145
|
-
const expected = [
|
|
146
|
-
...script,
|
|
147
|
-
generateTransitionMessage('discovery'),
|
|
148
|
-
END_OF_LINE,
|
|
149
|
-
];
|
|
150
|
-
assert.isLength(writes, expected.length);
|
|
151
|
-
assert.isEqualDeep(writes, expected);
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
static canSendInputToThePlayer(answer) {
|
|
155
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
-
const writes = [];
|
|
157
|
-
const tester = yield this.Tester({
|
|
158
|
-
shouldPlayReplayAfterFinish: false,
|
|
159
|
-
topics: [
|
|
160
|
-
{
|
|
161
|
-
utterances: [],
|
|
162
|
-
key: 'test',
|
|
163
|
-
label: 'Test with prompt',
|
|
164
|
-
script: [
|
|
165
|
-
(options) => __awaiter(this, void 0, void 0, function* () {
|
|
166
|
-
const confirm = yield options.ui.confirm('Are you sure?');
|
|
167
|
-
if (confirm) {
|
|
168
|
-
options.ui.renderLine('yes');
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
options.ui.renderLine('no');
|
|
172
|
-
}
|
|
173
|
-
}),
|
|
174
|
-
],
|
|
175
|
-
},
|
|
176
|
-
],
|
|
177
|
-
writeHandler: (message) => {
|
|
178
|
-
writes.push(message.body);
|
|
179
|
-
},
|
|
180
|
-
promptHandler: () => __awaiter(this, void 0, void 0, function* () {
|
|
181
|
-
return answer;
|
|
182
|
-
}),
|
|
183
|
-
selectPromptHandler: () => __awaiter(this, void 0, void 0, function* () { return ''; }),
|
|
184
|
-
});
|
|
185
|
-
void tester.go('lets go!');
|
|
186
|
-
yield this.wait(20);
|
|
187
|
-
const expected = [
|
|
188
|
-
'Are you sure?',
|
|
189
|
-
answer,
|
|
190
|
-
generateTransitionMessage('discovery'),
|
|
191
|
-
END_OF_LINE,
|
|
192
|
-
];
|
|
193
|
-
assert.isEqualDeep(writes, expected);
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
static promptsForFirstMessageIfNoneSentToGo() {
|
|
197
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
198
|
-
const writes = [];
|
|
199
|
-
const promptWrites = [];
|
|
200
|
-
let promptResolve;
|
|
201
|
-
const tester = yield this.Tester({
|
|
202
|
-
lineDelay: 0,
|
|
203
|
-
topics: [
|
|
204
|
-
{
|
|
205
|
-
utterances: [],
|
|
206
|
-
key: 'test',
|
|
207
|
-
label: 'Test with prompt',
|
|
208
|
-
script: ['go', 'team'],
|
|
209
|
-
},
|
|
210
|
-
],
|
|
211
|
-
writeHandler: (message) => {
|
|
212
|
-
writes.push(message.body);
|
|
213
|
-
},
|
|
214
|
-
promptHandler: (message) => __awaiter(this, void 0, void 0, function* () {
|
|
215
|
-
promptWrites.push(message.body);
|
|
216
|
-
yield new Promise((resolve) => (promptResolve = resolve));
|
|
217
|
-
return 'go!';
|
|
218
|
-
}),
|
|
219
|
-
selectPromptHandler: () => __awaiter(this, void 0, void 0, function* () { return ''; }),
|
|
220
|
-
});
|
|
221
|
-
void tester.go();
|
|
222
|
-
yield this.wait(10);
|
|
223
|
-
assert.isLength(promptWrites, 1);
|
|
224
|
-
assert.isLength(writes, 0);
|
|
225
|
-
promptResolve();
|
|
226
|
-
yield this.wait(10);
|
|
227
|
-
const expected = [
|
|
228
|
-
'go',
|
|
229
|
-
'team',
|
|
230
|
-
generateTransitionMessage('discovery'),
|
|
231
|
-
END_OF_LINE,
|
|
232
|
-
];
|
|
233
|
-
assert.isEqualDeep(writes, expected);
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
static showsConfidenceRatingBasedOnFirstMesageSent() {
|
|
237
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
238
|
-
const writes = [];
|
|
239
|
-
const promptWrites = [];
|
|
240
|
-
const tester = yield this.Tester({
|
|
241
|
-
lineDelay: 0,
|
|
242
|
-
topics: [
|
|
243
|
-
{
|
|
244
|
-
utterances: ['go team', 'team'],
|
|
245
|
-
key: 'test',
|
|
246
|
-
label: 'Test with prompt',
|
|
247
|
-
script: ['go', 'team'],
|
|
248
|
-
},
|
|
249
|
-
],
|
|
250
|
-
writeHandler: (message) => {
|
|
251
|
-
writes.push(message.body);
|
|
252
|
-
},
|
|
253
|
-
promptHandler: (message) => __awaiter(this, void 0, void 0, function* () {
|
|
254
|
-
promptWrites.push(message.body);
|
|
255
|
-
return 'go!';
|
|
256
|
-
}),
|
|
257
|
-
selectPromptHandler: () => __awaiter(this, void 0, void 0, function* () { return ''; }),
|
|
258
|
-
});
|
|
259
|
-
void tester.go('team');
|
|
260
|
-
yield this.wait(10);
|
|
261
|
-
assert.doesInclude(writes, `%`);
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
static promptsToStartAgainAfterDone() {
|
|
265
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
266
|
-
const writes = [];
|
|
267
|
-
let promptHitCount = 0;
|
|
268
|
-
const tester = yield this.Tester({
|
|
269
|
-
lineDelay: 0,
|
|
270
|
-
topics: [
|
|
271
|
-
{
|
|
272
|
-
utterances: [],
|
|
273
|
-
key: 'test',
|
|
274
|
-
label: 'Test with prompt',
|
|
275
|
-
script: ['go', 'team'],
|
|
276
|
-
},
|
|
277
|
-
],
|
|
278
|
-
writeHandler: (message) => {
|
|
279
|
-
writes.push(message.body);
|
|
280
|
-
},
|
|
281
|
-
promptHandler: () => __awaiter(this, void 0, void 0, function* () {
|
|
282
|
-
promptHitCount++;
|
|
283
|
-
if (promptHitCount > 2) {
|
|
284
|
-
yield new Promise(() => { });
|
|
285
|
-
}
|
|
286
|
-
return 'go!';
|
|
287
|
-
}),
|
|
288
|
-
selectPromptHandler: () => __awaiter(this, void 0, void 0, function* () { return ''; }),
|
|
289
|
-
});
|
|
290
|
-
void tester.go();
|
|
291
|
-
yield this.wait(500);
|
|
292
|
-
assert.isEqual(promptHitCount, 3);
|
|
293
|
-
assert.isEqualDeep(writes, [
|
|
294
|
-
'go',
|
|
295
|
-
'team',
|
|
296
|
-
generateTransitionMessage('discovery'),
|
|
297
|
-
END_OF_LINE,
|
|
298
|
-
'go',
|
|
299
|
-
'team',
|
|
300
|
-
generateTransitionMessage('discovery'),
|
|
301
|
-
END_OF_LINE,
|
|
302
|
-
]);
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
static messagesAboutTransitionResponseTopicChanger() {
|
|
306
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
307
|
-
const writes = [];
|
|
308
|
-
let promptHitCount = 0;
|
|
309
|
-
const tester = yield this.Tester({
|
|
310
|
-
lineDelay: 0,
|
|
311
|
-
topics: [
|
|
312
|
-
{
|
|
313
|
-
key: 'test',
|
|
314
|
-
label: 'Test with prompt',
|
|
315
|
-
utterances: [],
|
|
316
|
-
script: [
|
|
317
|
-
'my',
|
|
318
|
-
'team',
|
|
319
|
-
() => __awaiter(this, void 0, void 0, function* () {
|
|
320
|
-
return {
|
|
321
|
-
transitionConversationTo: 'greeting',
|
|
322
|
-
topicChangers: ['topic_changer'],
|
|
323
|
-
};
|
|
324
|
-
}),
|
|
325
|
-
],
|
|
326
|
-
},
|
|
327
|
-
],
|
|
328
|
-
writeHandler: (message) => {
|
|
329
|
-
writes.push(message.body);
|
|
330
|
-
},
|
|
331
|
-
promptHandler: () => __awaiter(this, void 0, void 0, function* () {
|
|
332
|
-
promptHitCount++;
|
|
333
|
-
if (promptHitCount > 2) {
|
|
334
|
-
yield new Promise(() => { });
|
|
335
|
-
}
|
|
336
|
-
return 'go!';
|
|
337
|
-
}),
|
|
338
|
-
selectPromptHandler: () => __awaiter(this, void 0, void 0, function* () { return ''; }),
|
|
339
|
-
});
|
|
340
|
-
void tester.go();
|
|
341
|
-
yield this.wait(500);
|
|
342
|
-
assert.isEqual(promptHitCount, 3);
|
|
343
|
-
assert.isEqualDeep(writes, [
|
|
344
|
-
'my',
|
|
345
|
-
'team',
|
|
346
|
-
'topic_changer',
|
|
347
|
-
generateTransitionMessage('greeting'),
|
|
348
|
-
END_OF_LINE,
|
|
349
|
-
'my',
|
|
350
|
-
'team',
|
|
351
|
-
'topic_changer',
|
|
352
|
-
generateTransitionMessage('greeting'),
|
|
353
|
-
END_OF_LINE,
|
|
354
|
-
]);
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
static messagesAboutTransitionResponseWithRepairs() {
|
|
358
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
359
|
-
const writes = [];
|
|
360
|
-
let promptHitCount = 0;
|
|
361
|
-
const tester = yield this.Tester({
|
|
362
|
-
lineDelay: 0,
|
|
363
|
-
topics: [
|
|
364
|
-
{
|
|
365
|
-
key: 'test',
|
|
366
|
-
label: 'Test with prompt',
|
|
367
|
-
utterances: [],
|
|
368
|
-
script: [
|
|
369
|
-
'my',
|
|
370
|
-
'team',
|
|
371
|
-
() => __awaiter(this, void 0, void 0, function* () {
|
|
372
|
-
return {
|
|
373
|
-
transitionConversationTo: 'greeting',
|
|
374
|
-
repairs: ['repairs'],
|
|
375
|
-
};
|
|
376
|
-
}),
|
|
377
|
-
],
|
|
378
|
-
},
|
|
379
|
-
],
|
|
380
|
-
writeHandler: (message) => {
|
|
381
|
-
writes.push(message.body);
|
|
382
|
-
},
|
|
383
|
-
promptHandler: () => __awaiter(this, void 0, void 0, function* () {
|
|
384
|
-
promptHitCount++;
|
|
385
|
-
if (promptHitCount > 2) {
|
|
386
|
-
yield new Promise(() => { });
|
|
387
|
-
}
|
|
388
|
-
return 'go!';
|
|
389
|
-
}),
|
|
390
|
-
selectPromptHandler: () => __awaiter(this, void 0, void 0, function* () { return ''; }),
|
|
391
|
-
});
|
|
392
|
-
void tester.go();
|
|
393
|
-
yield this.wait(500);
|
|
394
|
-
assert.isEqual(promptHitCount, 3);
|
|
395
|
-
assert.isEqualDeep(writes, [
|
|
396
|
-
'my',
|
|
397
|
-
'team',
|
|
398
|
-
'repairs',
|
|
399
|
-
generateTransitionMessage('greeting'),
|
|
400
|
-
END_OF_LINE,
|
|
401
|
-
'my',
|
|
402
|
-
'team',
|
|
403
|
-
'repairs',
|
|
404
|
-
generateTransitionMessage('greeting'),
|
|
405
|
-
END_OF_LINE,
|
|
406
|
-
]);
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
static Tester(options) {
|
|
410
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
411
|
-
return yield ScriptTester.Tester(Object.assign({ getContext: () => ({}), topics: [] }, options));
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
ScriptTesterTest.basicBookingScript = [
|
|
416
|
-
{
|
|
417
|
-
utterances: [],
|
|
418
|
-
key: 'bookAppointment',
|
|
419
|
-
label: 'Book appointment',
|
|
420
|
-
script: ['you ready to book?'],
|
|
421
|
-
},
|
|
422
|
-
{
|
|
423
|
-
utterances: [],
|
|
424
|
-
key: 'cancelAppointment',
|
|
425
|
-
label: 'Cancel appointment',
|
|
426
|
-
script: ['Lets cancel'],
|
|
427
|
-
},
|
|
428
|
-
];
|
|
429
|
-
export default ScriptTesterTest;
|
|
430
|
-
__decorate([
|
|
431
|
-
test()
|
|
432
|
-
], ScriptTesterTest, "throwsWithoutScript", null);
|
|
433
|
-
__decorate([
|
|
434
|
-
test()
|
|
435
|
-
], ScriptTesterTest, "acceptsSimpleScript", null);
|
|
436
|
-
__decorate([
|
|
437
|
-
test()
|
|
438
|
-
], ScriptTesterTest, "callingGoDoesntCrash", null);
|
|
439
|
-
__decorate([
|
|
440
|
-
test()
|
|
441
|
-
], ScriptTesterTest, "cantHandleMessageBeforeStartup", null);
|
|
442
|
-
__decorate([
|
|
443
|
-
test()
|
|
444
|
-
], ScriptTesterTest, "selectingBadScriptToStartThrows", null);
|
|
445
|
-
__decorate([
|
|
446
|
-
test()
|
|
447
|
-
], ScriptTesterTest, "asksWhichScriptYouWantToStartWithWhenThereIsMoreThanOne", null);
|
|
448
|
-
__decorate([
|
|
449
|
-
test('plays single line script', ['hey there']),
|
|
450
|
-
test('plays multi line script', ['hey there', 'how are you?'])
|
|
451
|
-
], ScriptTesterTest, "playsSimpleScript", null);
|
|
452
|
-
__decorate([
|
|
453
|
-
test('passes the confirm', 'yes'),
|
|
454
|
-
test('fails the confirm', 'no')
|
|
455
|
-
], ScriptTesterTest, "canSendInputToThePlayer", null);
|
|
456
|
-
__decorate([
|
|
457
|
-
test()
|
|
458
|
-
], ScriptTesterTest, "promptsForFirstMessageIfNoneSentToGo", null);
|
|
459
|
-
__decorate([
|
|
460
|
-
test()
|
|
461
|
-
], ScriptTesterTest, "showsConfidenceRatingBasedOnFirstMesageSent", null);
|
|
462
|
-
__decorate([
|
|
463
|
-
test()
|
|
464
|
-
], ScriptTesterTest, "promptsToStartAgainAfterDone", null);
|
|
465
|
-
__decorate([
|
|
466
|
-
test()
|
|
467
|
-
], ScriptTesterTest, "messagesAboutTransitionResponseTopicChanger", null);
|
|
468
|
-
__decorate([
|
|
469
|
-
test()
|
|
470
|
-
], ScriptTesterTest, "messagesAboutTransitionResponseWithRepairs", null);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import AbstractConversationTest from '../../tests/AbstractConversationTest';
|
|
2
|
-
export default class SuggesterUtilTest extends AbstractConversationTest {
|
|
3
|
-
protected static suggesterExists(): Promise<void>;
|
|
4
|
-
protected static returnsOnlyPossibility(): Promise<void>;
|
|
5
|
-
protected static returnsSortedByBestGuess(): Promise<void>;
|
|
6
|
-
protected static matchesByReturningTopOptionsAboveThreshold(phrases: string[], utterance: string, expected: boolean): Promise<void>;
|
|
7
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
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;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
import { test, assert } from '@sprucelabs/test-utils';
|
|
17
|
-
import AbstractConversationTest from '../../tests/AbstractConversationTest.js';
|
|
18
|
-
import suggesterUtil from '../../utilities/suggester.utility.js';
|
|
19
|
-
export default class SuggesterUtilTest extends AbstractConversationTest {
|
|
20
|
-
static suggesterExists() {
|
|
21
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
assert.isTruthy(suggesterUtil);
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
static returnsOnlyPossibility() {
|
|
26
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
const results = yield suggesterUtil.rank([{ key: 'test', phrase: 'test' }], 'test');
|
|
28
|
-
assert.isArray(results);
|
|
29
|
-
assert.isEqualDeep(results, [
|
|
30
|
-
{
|
|
31
|
-
key: 'test',
|
|
32
|
-
score: 1,
|
|
33
|
-
},
|
|
34
|
-
]);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
static returnsSortedByBestGuess() {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
const results = yield suggesterUtil.rank([
|
|
40
|
-
{ key: 'wronge', phrase: 'wronge' },
|
|
41
|
-
{ key: 'test', phrase: 'test' },
|
|
42
|
-
], 'test');
|
|
43
|
-
assert.isArray(results);
|
|
44
|
-
assert.isEqualDeep(results[0], {
|
|
45
|
-
key: 'test',
|
|
46
|
-
score: 1,
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
static matchesByReturningTopOptionsAboveThreshold(phrases, utterance, expected) {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
const results = yield suggesterUtil.doesMatch(phrases, utterance);
|
|
53
|
-
assert.isEqual(results, expected);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
__decorate([
|
|
58
|
-
test()
|
|
59
|
-
], SuggesterUtilTest, "suggesterExists", null);
|
|
60
|
-
__decorate([
|
|
61
|
-
test()
|
|
62
|
-
], SuggesterUtilTest, "returnsOnlyPossibility", null);
|
|
63
|
-
__decorate([
|
|
64
|
-
test()
|
|
65
|
-
], SuggesterUtilTest, "returnsSortedByBestGuess", null);
|
|
66
|
-
__decorate([
|
|
67
|
-
test('doesMatch is false when way off', ['one', 'two', 'three', 'four'], 'miss', false),
|
|
68
|
-
test('doesMatch is true when perfect match', ['one', 'two', 'three', 'four'], 'one', true),
|
|
69
|
-
test('doesMatch is true with ha', ['ha', 'haha', 'lol', 'lolz', 'rofl', 'hahahah', 'haha'], 'haha!!!', true),
|
|
70
|
-
test('doesMatch is true with ha', ['ha', 'haha', 'lol', 'lolz', 'rofl', 'hahahah'], 'lol', true),
|
|
71
|
-
test('doesMatch is false with lame', ['ha', 'haha', 'lol', 'lolz', 'rofl', 'hahahah'], 'lame', false),
|
|
72
|
-
test('doesMatch is false with horrible', ['ha', 'haha', 'lol', 'lolz', 'rofl', 'hahahah'], 'horrible', false),
|
|
73
|
-
test('doesMatch is false with hey', ['ha', 'haha', 'lol', 'lolz', 'rofl', 'hahahah'], 'hey', false)
|
|
74
|
-
], SuggesterUtilTest, "matchesByReturningTopOptionsAboveThreshold", null);
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import AbstractConversationTest from '../../tests/AbstractConversationTest';
|
|
2
|
-
export default class TopicLoaderTest extends AbstractConversationTest {
|
|
3
|
-
protected static loadsNoTopicsWithBadDir(): Promise<void>;
|
|
4
|
-
protected static throwsWhenLoadingEmpty(): Promise<void>;
|
|
5
|
-
protected static throwsWhenMissingParameters(): Promise<void>;
|
|
6
|
-
protected static canLoadTopics(): Promise<void>;
|
|
7
|
-
protected static loadedTopicsSetKey(): Promise<void>;
|
|
8
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
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;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
import { test, assert } from '@sprucelabs/test-utils';
|
|
17
|
-
import { errorAssert } from '@sprucelabs/test-utils';
|
|
18
|
-
import AbstractConversationTest from '../../tests/AbstractConversationTest.js';
|
|
19
|
-
import TopicLoader from '../../topics/TopicLoader.js';
|
|
20
|
-
export default class TopicLoaderTest extends AbstractConversationTest {
|
|
21
|
-
static loadsNoTopicsWithBadDir() {
|
|
22
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const source = this.resolvePath('doesNotExist');
|
|
24
|
-
const topics = yield TopicLoader.loadTopics(source);
|
|
25
|
-
assert.isLength(topics, 0);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
static throwsWhenLoadingEmpty() {
|
|
29
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
const source = this.resolveTestPath('bad-empty');
|
|
31
|
-
const err = yield assert.doesThrowAsync(() => TopicLoader.loadTopics(source));
|
|
32
|
-
errorAssert.assertError(err, 'INVALID_TOPIC', {
|
|
33
|
-
topicScript: 'bookAppointment.topic',
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
static throwsWhenMissingParameters() {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
const source = this.resolveTestPath('bad-missing-params');
|
|
40
|
-
const err = yield assert.doesThrowAsync(() => TopicLoader.loadTopics(source));
|
|
41
|
-
errorAssert.assertError(err, 'INVALID_TOPIC', {
|
|
42
|
-
topicScript: 'bookAppointment.topic',
|
|
43
|
-
});
|
|
44
|
-
//@ts-ignore
|
|
45
|
-
const original = err.options.originalError;
|
|
46
|
-
errorAssert.assertError(original, 'MISSING_PARAMETERS', {
|
|
47
|
-
parameters: ['label', 'utterances', 'script'],
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
static canLoadTopics() {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
const scripts = yield TopicLoader.loadTopics(this.resolveTestPath('good'));
|
|
54
|
-
assert.isLength(scripts, 2);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
static loadedTopicsSetKey() {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
const scripts = yield TopicLoader.loadTopics(this.resolveTestPath('good'));
|
|
60
|
-
assert.doesInclude(scripts, { key: 'bookAppointment' });
|
|
61
|
-
assert.doesInclude(scripts, { key: 'cancelAppointment' });
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
__decorate([
|
|
66
|
-
test()
|
|
67
|
-
], TopicLoaderTest, "loadsNoTopicsWithBadDir", null);
|
|
68
|
-
__decorate([
|
|
69
|
-
test()
|
|
70
|
-
], TopicLoaderTest, "throwsWhenLoadingEmpty", null);
|
|
71
|
-
__decorate([
|
|
72
|
-
test()
|
|
73
|
-
], TopicLoaderTest, "throwsWhenMissingParameters", null);
|
|
74
|
-
__decorate([
|
|
75
|
-
test()
|
|
76
|
-
], TopicLoaderTest, "canLoadTopics", null);
|
|
77
|
-
__decorate([
|
|
78
|
-
test()
|
|
79
|
-
], TopicLoaderTest, "loadedTopicsSetKey", null);
|
|
@@ -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
|
-
}
|