@sprucelabs/spruce-conversation-plugin 62.2.24 → 62.2.25
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
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"@types/inquirer"
|
|
13
13
|
]
|
|
14
14
|
},
|
|
15
|
-
"version": "62.2.
|
|
15
|
+
"version": "62.2.25",
|
|
16
16
|
"files": [
|
|
17
17
|
"build/**/*",
|
|
18
18
|
"!build/__tests__",
|
|
@@ -65,35 +65,35 @@
|
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@nlpjs/nlu": "^4.27.0",
|
|
68
|
-
"@sprucelabs/error": "^6.0.
|
|
69
|
-
"@sprucelabs/globby": "^2.0.
|
|
70
|
-
"@sprucelabs/mercury-core-events": "^24.0.
|
|
68
|
+
"@sprucelabs/error": "^6.0.67",
|
|
69
|
+
"@sprucelabs/globby": "^2.0.23",
|
|
70
|
+
"@sprucelabs/mercury-core-events": "^24.0.142",
|
|
71
71
|
"@sprucelabs/schema": "^30.0.109",
|
|
72
|
-
"@sprucelabs/spruce-core-schemas": "^40.1.
|
|
73
|
-
"@sprucelabs/spruce-event-plugin": "^62.2.
|
|
74
|
-
"@sprucelabs/spruce-event-utils": "^40.0.
|
|
75
|
-
"@sprucelabs/spruce-skill-booter": "^62.2.
|
|
76
|
-
"@sprucelabs/spruce-skill-utils": "^31.0.
|
|
77
|
-
"@sprucelabs/spruce-test-fixtures": "^62.2.
|
|
72
|
+
"@sprucelabs/spruce-core-schemas": "^40.1.55",
|
|
73
|
+
"@sprucelabs/spruce-event-plugin": "^62.2.25",
|
|
74
|
+
"@sprucelabs/spruce-event-utils": "^40.0.126",
|
|
75
|
+
"@sprucelabs/spruce-skill-booter": "^62.2.25",
|
|
76
|
+
"@sprucelabs/spruce-skill-utils": "^31.0.127",
|
|
77
|
+
"@sprucelabs/spruce-test-fixtures": "^62.2.25",
|
|
78
78
|
"fuzzyset": "^1.0.7",
|
|
79
79
|
"inquirer": "^8.2.4",
|
|
80
80
|
"node-nlp": "^4.27.0",
|
|
81
81
|
"random": "^4.1.0"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@sprucelabs/esm-postbuild": "^6.0.
|
|
85
|
-
"@sprucelabs/jest-json-reporter": "^8.0.
|
|
86
|
-
"@sprucelabs/mercury-client": "^42.0.
|
|
87
|
-
"@sprucelabs/resolve-path-aliases": "^2.0.
|
|
84
|
+
"@sprucelabs/esm-postbuild": "^6.0.51",
|
|
85
|
+
"@sprucelabs/jest-json-reporter": "^8.0.70",
|
|
86
|
+
"@sprucelabs/mercury-client": "^42.0.152",
|
|
87
|
+
"@sprucelabs/resolve-path-aliases": "^2.0.46",
|
|
88
88
|
"@sprucelabs/semantic-release": "^5.0.1",
|
|
89
|
-
"@sprucelabs/test": "^9.0.
|
|
89
|
+
"@sprucelabs/test": "^9.0.32",
|
|
90
90
|
"@sprucelabs/test-utils": "^5.1.2",
|
|
91
91
|
"@types/fuzzyset": "^1.0.7",
|
|
92
92
|
"@types/inquirer": "^8.2.1",
|
|
93
93
|
"@types/node": "17.0.5",
|
|
94
94
|
"chokidar-cli": "^3.0.0",
|
|
95
95
|
"eslint": "^9.5.0",
|
|
96
|
-
"eslint-config-spruce": "^11.2.
|
|
96
|
+
"eslint-config-spruce": "^11.2.25",
|
|
97
97
|
"jest": "^29.7.0",
|
|
98
98
|
"jest-circus": "^29.7.0",
|
|
99
99
|
"prettier": "^3.3.2",
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"^#spruce/(.*)$": "<rootDir>/build/.spruce/$1"
|
|
120
120
|
}
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "c477b55a1974aa716dcccea98b36d0fb8976317b"
|
|
123
123
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import AbstractConversationTest from '../../tests/AbstractConversationTest';
|
|
2
|
-
export default class CheckingHealthTest extends AbstractConversationTest {
|
|
3
|
-
protected static pluginReturnsInstance(): Promise<void>;
|
|
4
|
-
protected static registersWithSkill(): Promise<void>;
|
|
5
|
-
protected static throwsWhenExecutingIfEventPluginMissing(): Promise<void>;
|
|
6
|
-
protected static returnsZeroStateResponseFromHealthCheckWhenNoConversations(): Promise<void>;
|
|
7
|
-
private static checkHealth;
|
|
8
|
-
protected static returnsHelpfulErrorWHenPassedBadConvos(): Promise<void>;
|
|
9
|
-
protected static getsTopicsFromHealthCheck(): Promise<void>;
|
|
10
|
-
}
|
|
@@ -1,87 +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 conversation_plugin_1 = __importDefault(require("../../plugins/conversation.plugin"));
|
|
15
|
-
const AbstractConversationTest_1 = __importDefault(require("../../tests/AbstractConversationTest"));
|
|
16
|
-
class CheckingHealthTest extends AbstractConversationTest_1.default {
|
|
17
|
-
static async pluginReturnsInstance() {
|
|
18
|
-
test_utils_1.assert.isTrue(conversation_plugin_1.default instanceof Function);
|
|
19
|
-
}
|
|
20
|
-
static async registersWithSkill() {
|
|
21
|
-
const skill = await this.Skill();
|
|
22
|
-
const features = skill.getFeatures();
|
|
23
|
-
test_utils_1.assert.isLength(features, 2);
|
|
24
|
-
}
|
|
25
|
-
static async throwsWhenExecutingIfEventPluginMissing() {
|
|
26
|
-
var _a;
|
|
27
|
-
const health = await this.checkHealth({ plugins: [conversation_plugin_1.default] });
|
|
28
|
-
test_utils_1.assert.isTruthy(health.conversation);
|
|
29
|
-
test_utils_1.assert.isEqual(health.conversation.status, 'failed');
|
|
30
|
-
const err = (_a = health.conversation.errors) === null || _a === void 0 ? void 0 : _a[0];
|
|
31
|
-
test_utils_1.assert.isTruthy(err);
|
|
32
|
-
test_utils_2.errorAssert.assertError(err, 'MISSING_DEPENDENCIES', {
|
|
33
|
-
dependencies: ['event.plugin'],
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
static async returnsZeroStateResponseFromHealthCheckWhenNoConversations() {
|
|
37
|
-
const healthCheck = await this.checkHealth();
|
|
38
|
-
test_utils_1.assert.isTruthy(healthCheck.conversation);
|
|
39
|
-
test_utils_1.assert.isEqual(healthCheck.conversation.status, 'passed');
|
|
40
|
-
test_utils_1.assert.isEqualDeep(healthCheck.conversation.topics, []);
|
|
41
|
-
}
|
|
42
|
-
static async checkHealth(options) {
|
|
43
|
-
const skill = await this.Skill(options);
|
|
44
|
-
const healthCheck = await skill.checkHealth();
|
|
45
|
-
return healthCheck;
|
|
46
|
-
}
|
|
47
|
-
static async returnsHelpfulErrorWHenPassedBadConvos() {
|
|
48
|
-
var _a, _b;
|
|
49
|
-
const healthCheck = await this.checkHealth({
|
|
50
|
-
activeDir: this.resolvePath(__dirname, '..', 'testDirsAndFiles', 'bad-missing-params'),
|
|
51
|
-
});
|
|
52
|
-
test_utils_1.assert.isTruthy(healthCheck.conversation);
|
|
53
|
-
test_utils_1.assert.isEqual(healthCheck.conversation.status, 'failed');
|
|
54
|
-
test_utils_2.errorAssert.assertError((_a = healthCheck.conversation.errors) === null || _a === void 0 ? void 0 : _a[0], 'CONVERSATION_PLUGIN_ERROR');
|
|
55
|
-
test_utils_2.errorAssert.assertError((_b = healthCheck.conversation.errors) === null || _b === void 0 ? void 0 : _b[0].originalError, 'INVALID_TOPIC');
|
|
56
|
-
}
|
|
57
|
-
static async getsTopicsFromHealthCheck() {
|
|
58
|
-
const healthCheck = await this.checkHealth({
|
|
59
|
-
activeDir: this.resolvePath(__dirname, '..', 'testDirsAndFiles', 'good'),
|
|
60
|
-
});
|
|
61
|
-
test_utils_1.assert.isTruthy(healthCheck.conversation);
|
|
62
|
-
test_utils_1.assert.isLength(healthCheck.conversation.topics, 2);
|
|
63
|
-
test_utils_1.assert.isEqualDeep(healthCheck.conversation.topics, [
|
|
64
|
-
'bookAppointment',
|
|
65
|
-
'cancelAppointment',
|
|
66
|
-
]);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
exports.default = CheckingHealthTest;
|
|
70
|
-
__decorate([
|
|
71
|
-
(0, test_utils_1.test)()
|
|
72
|
-
], CheckingHealthTest, "pluginReturnsInstance", null);
|
|
73
|
-
__decorate([
|
|
74
|
-
(0, test_utils_1.test)()
|
|
75
|
-
], CheckingHealthTest, "registersWithSkill", null);
|
|
76
|
-
__decorate([
|
|
77
|
-
(0, test_utils_1.test)()
|
|
78
|
-
], CheckingHealthTest, "throwsWhenExecutingIfEventPluginMissing", null);
|
|
79
|
-
__decorate([
|
|
80
|
-
(0, test_utils_1.test)()
|
|
81
|
-
], CheckingHealthTest, "returnsZeroStateResponseFromHealthCheckWhenNoConversations", null);
|
|
82
|
-
__decorate([
|
|
83
|
-
(0, test_utils_1.test)()
|
|
84
|
-
], CheckingHealthTest, "returnsHelpfulErrorWHenPassedBadConvos", null);
|
|
85
|
-
__decorate([
|
|
86
|
-
(0, test_utils_1.test)()
|
|
87
|
-
], CheckingHealthTest, "getsTopicsFromHealthCheck", null);
|
|
@@ -1,29 +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 spruce_test_fixtures_1 = require("@sprucelabs/spruce-test-fixtures");
|
|
13
|
-
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
14
|
-
const AbstractConversationTest_1 = __importDefault(require("../../tests/AbstractConversationTest"));
|
|
15
|
-
spruce_test_fixtures_1.MercuryFixture.setShouldRequireLocalListeners(false);
|
|
16
|
-
class KillingASkillTest extends AbstractConversationTest_1.default {
|
|
17
|
-
static async killingASkillKillsConversation() {
|
|
18
|
-
this.cwd = this.resolveTestPath('empty-skill');
|
|
19
|
-
const { skill } = await this.bootAndRegisterNewSkill({
|
|
20
|
-
name: 'great skill dude!',
|
|
21
|
-
});
|
|
22
|
-
await skill.kill();
|
|
23
|
-
test_utils_1.assert.isFalse(skill.isRunning());
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.default = KillingASkillTest;
|
|
27
|
-
__decorate([
|
|
28
|
-
(0, test_utils_1.test)()
|
|
29
|
-
], KillingASkillTest, "killingASkillKillsConversation", null);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import AbstractConversationTest from '../../tests/AbstractConversationTest';
|
|
2
|
-
export default class RegisteringConversationsOnBootTest extends AbstractConversationTest {
|
|
3
|
-
protected static throwsWhenExecutingIfEventPluginMissing(): Promise<void>;
|
|
4
|
-
protected static noConvosToStart(): Promise<void>;
|
|
5
|
-
protected static registersConvosOnBoot(): Promise<void>;
|
|
6
|
-
protected static skillShutsDownWhenConvosFailToRegister(): Promise<void>;
|
|
7
|
-
protected static canBootASecondTime(): Promise<void>;
|
|
8
|
-
protected static skillCanBootASecondTime(): Promise<void>;
|
|
9
|
-
protected static coordinaterGetsSkillContext(): Promise<void>;
|
|
10
|
-
private static registerBootAndConnect;
|
|
11
|
-
private static assertExpectedTopics;
|
|
12
|
-
private static registerAndBoot;
|
|
13
|
-
}
|
|
@@ -1,147 +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 spruce_event_utils_1 = require("@sprucelabs/spruce-event-utils");
|
|
13
|
-
const spruce_test_fixtures_1 = require("@sprucelabs/spruce-test-fixtures");
|
|
14
|
-
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
15
|
-
const test_utils_2 = require("@sprucelabs/test-utils");
|
|
16
|
-
const conversation_plugin_1 = __importDefault(require("../../plugins/conversation.plugin"));
|
|
17
|
-
const AbstractConversationTest_1 = __importDefault(require("../../tests/AbstractConversationTest"));
|
|
18
|
-
spruce_test_fixtures_1.MercuryFixture.setShouldRequireLocalListeners(false);
|
|
19
|
-
class RegisteringConversationsOnBootTest extends AbstractConversationTest_1.default {
|
|
20
|
-
static async throwsWhenExecutingIfEventPluginMissing() {
|
|
21
|
-
const skill = await this.Skill({ plugins: [conversation_plugin_1.default] });
|
|
22
|
-
const err = await test_utils_1.assert.doesThrowAsync(() => skill.execute());
|
|
23
|
-
test_utils_2.errorAssert.assertError(err, 'MISSING_DEPENDENCIES', {
|
|
24
|
-
dependencies: ['event.plugin'],
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
static async noConvosToStart() {
|
|
28
|
-
this.cwd = this.resolveTestPath('empty-skill');
|
|
29
|
-
const { topics } = await this.registerAndBoot();
|
|
30
|
-
test_utils_1.assert.isLength(topics, 0);
|
|
31
|
-
}
|
|
32
|
-
static async registersConvosOnBoot() {
|
|
33
|
-
this.cwd = this.resolveTestPath('skill');
|
|
34
|
-
const { topics } = await this.registerAndBoot();
|
|
35
|
-
this.assertExpectedTopics(topics);
|
|
36
|
-
}
|
|
37
|
-
static async skillShutsDownWhenConvosFailToRegister() {
|
|
38
|
-
const { skill } = await super.bootSkill({
|
|
39
|
-
shouldSuppressBootErrors: true,
|
|
40
|
-
});
|
|
41
|
-
test_utils_1.assert.isFalse(skill.isRunning());
|
|
42
|
-
this.clearSkillBootErrors();
|
|
43
|
-
}
|
|
44
|
-
static async canBootASecondTime() {
|
|
45
|
-
this.cwd = this.resolveTestPath('skill');
|
|
46
|
-
const { topics } = await this.registerAndBoot();
|
|
47
|
-
this.assertExpectedTopics(topics);
|
|
48
|
-
const { topics: topics2 } = await this.registerAndBoot({
|
|
49
|
-
skillId: process.env.SKILL_ID,
|
|
50
|
-
apiKey: process.env.SKILL_API_KEY,
|
|
51
|
-
});
|
|
52
|
-
this.assertExpectedTopics(topics2);
|
|
53
|
-
}
|
|
54
|
-
static async skillCanBootASecondTime() {
|
|
55
|
-
this.cwd = this.resolveTestPath('skill');
|
|
56
|
-
await this.registerAndBoot();
|
|
57
|
-
await this.registerAndBoot({
|
|
58
|
-
skillId: process.env.SKILL_ID,
|
|
59
|
-
apiKey: process.env.SKILL_API_KEY,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
static async coordinaterGetsSkillContext() {
|
|
63
|
-
this.cwd = this.resolveTestPath('skill');
|
|
64
|
-
const { skill, client } = await this.registerBootAndConnect();
|
|
65
|
-
const id = (0, test_utils_1.generateId)();
|
|
66
|
-
await client.emitAndFlattenResponses('did-message::v2020_12_25', {
|
|
67
|
-
payload: {
|
|
68
|
-
message: this.buildMessage({
|
|
69
|
-
body: (0, test_utils_1.generateId)(),
|
|
70
|
-
source: {
|
|
71
|
-
personId: id,
|
|
72
|
-
},
|
|
73
|
-
}),
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
const conversations = skill.getFeatureByCode('conversation');
|
|
77
|
-
//@ts-ignore
|
|
78
|
-
const coordinator = await conversations.coordinatorsBySource[id];
|
|
79
|
-
test_utils_1.assert.isTruthy(coordinator);
|
|
80
|
-
//@ts-ignore
|
|
81
|
-
skill.updateContext('hello', 'world');
|
|
82
|
-
test_utils_1.assert.isEqualDeep(coordinator.getContext(), { hello: 'world' });
|
|
83
|
-
//@ts-ignore
|
|
84
|
-
skill.updateContext('hello2', 'world2');
|
|
85
|
-
test_utils_1.assert.isEqualDeep(coordinator.getContext(), {
|
|
86
|
-
hello: 'world',
|
|
87
|
-
hello2: 'world2',
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
static async registerBootAndConnect() {
|
|
91
|
-
const { skill } = await this.registerAndBoot();
|
|
92
|
-
const events = skill.getFeatureByCode('event');
|
|
93
|
-
const client = await events.connectToApi();
|
|
94
|
-
return { skill, client };
|
|
95
|
-
}
|
|
96
|
-
static assertExpectedTopics(topics) {
|
|
97
|
-
test_utils_1.assert.isLength(topics, 5);
|
|
98
|
-
test_utils_1.assert.doesInclude(topics, { key: 'bookAppointment' });
|
|
99
|
-
test_utils_1.assert.doesInclude(topics, { key: 'cancelAppointment' });
|
|
100
|
-
test_utils_1.assert.doesInclude(topics, { key: 'favoriteColor' });
|
|
101
|
-
test_utils_1.assert.doesInclude(topics, { key: 'favoriteColorTopicChanger' });
|
|
102
|
-
test_utils_1.assert.doesInclude(topics, { key: 'mixedStringsAndCallbacks' });
|
|
103
|
-
}
|
|
104
|
-
static async registerAndBoot(options) {
|
|
105
|
-
if (options === null || options === void 0 ? void 0 : options.skillId) {
|
|
106
|
-
process.env.SKILL_ID = options.skillId;
|
|
107
|
-
process.env.SKILL_API_KEY = options.apiKey;
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
const registeredSkill = await this.Fixture('skill').seedDemoSkill({
|
|
111
|
-
name: 'my great skill',
|
|
112
|
-
});
|
|
113
|
-
process.env.SKILL_ID = registeredSkill.id;
|
|
114
|
-
process.env.SKILL_API_KEY = registeredSkill.apiKey;
|
|
115
|
-
}
|
|
116
|
-
const { skill } = await this.bootSkill();
|
|
117
|
-
const eventFeature = skill.getFeatureByCode('event');
|
|
118
|
-
const client = await eventFeature.connectToApi();
|
|
119
|
-
let topics;
|
|
120
|
-
const results = await client.emit('get-conversation-topics::v2020_12_25');
|
|
121
|
-
const payload = spruce_event_utils_1.eventResponseUtil.getFirstResponseOrThrow(results);
|
|
122
|
-
topics = payload.topics;
|
|
123
|
-
return { topics, skill };
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
exports.default = RegisteringConversationsOnBootTest;
|
|
127
|
-
__decorate([
|
|
128
|
-
(0, test_utils_1.test)()
|
|
129
|
-
], RegisteringConversationsOnBootTest, "throwsWhenExecutingIfEventPluginMissing", null);
|
|
130
|
-
__decorate([
|
|
131
|
-
(0, test_utils_1.test)()
|
|
132
|
-
], RegisteringConversationsOnBootTest, "noConvosToStart", null);
|
|
133
|
-
__decorate([
|
|
134
|
-
(0, test_utils_1.test)()
|
|
135
|
-
], RegisteringConversationsOnBootTest, "registersConvosOnBoot", null);
|
|
136
|
-
__decorate([
|
|
137
|
-
(0, test_utils_1.test)()
|
|
138
|
-
], RegisteringConversationsOnBootTest, "skillShutsDownWhenConvosFailToRegister", null);
|
|
139
|
-
__decorate([
|
|
140
|
-
(0, test_utils_1.test)()
|
|
141
|
-
], RegisteringConversationsOnBootTest, "canBootASecondTime", null);
|
|
142
|
-
__decorate([
|
|
143
|
-
(0, test_utils_1.test)()
|
|
144
|
-
], RegisteringConversationsOnBootTest, "skillCanBootASecondTime", null);
|
|
145
|
-
__decorate([
|
|
146
|
-
(0, test_utils_1.test)()
|
|
147
|
-
], RegisteringConversationsOnBootTest, "coordinaterGetsSkillContext", null);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import AbstractConversationTest from '../../tests/AbstractConversationTest';
|
|
2
|
-
export default class RespondingToMessagesTest extends AbstractConversationTest {
|
|
3
|
-
private static client;
|
|
4
|
-
protected static beforeEach(): Promise<void>;
|
|
5
|
-
protected static respondsToFirstMessageWithSuggestedTopics(): Promise<void>;
|
|
6
|
-
protected static scriptSendsMessages(): Promise<void>;
|
|
7
|
-
protected static scriptCallbacksCanRespondToEventWithTransitionAndRepairs(): Promise<void>;
|
|
8
|
-
protected static scriptCallbacksCanRespondToEventWithTransitionAndTopicChangers(): Promise<void>;
|
|
9
|
-
protected static scriptCallbackGetsRandAndMessage(): Promise<void>;
|
|
10
|
-
protected static eachPersonGetsTheirOwnConversation(): Promise<void>;
|
|
11
|
-
private static sendMessage;
|
|
12
|
-
private static boot;
|
|
13
|
-
}
|
|
@@ -1,134 +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 spruce_event_utils_1 = require("@sprucelabs/spruce-event-utils");
|
|
13
|
-
const spruce_test_fixtures_1 = require("@sprucelabs/spruce-test-fixtures");
|
|
14
|
-
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
15
|
-
const AbstractConversationTest_1 = __importDefault(require("../../tests/AbstractConversationTest"));
|
|
16
|
-
spruce_test_fixtures_1.MercuryFixture.setShouldRequireLocalListeners(false);
|
|
17
|
-
class RespondingToMessagesTest extends AbstractConversationTest_1.default {
|
|
18
|
-
static async beforeEach() {
|
|
19
|
-
await super.beforeEach();
|
|
20
|
-
//@ts-ignore
|
|
21
|
-
this.client = undefined;
|
|
22
|
-
}
|
|
23
|
-
static async respondsToFirstMessageWithSuggestedTopics() {
|
|
24
|
-
this.cwd = this.resolveTestPath('skill');
|
|
25
|
-
const results = await this.sendMessage();
|
|
26
|
-
const { suggestedTopics } = spruce_event_utils_1.eventResponseUtil.getFirstResponseOrThrow(results);
|
|
27
|
-
test_utils_1.assert.isArray(suggestedTopics);
|
|
28
|
-
test_utils_1.assert.isLength(suggestedTopics, 1);
|
|
29
|
-
}
|
|
30
|
-
static async scriptSendsMessages() {
|
|
31
|
-
this.cwd = this.resolveTestPath('skill');
|
|
32
|
-
const sentMessages = [];
|
|
33
|
-
await this.boot();
|
|
34
|
-
await this.client.on('send-message::v2020_12_25', async (targetAndPayload) => {
|
|
35
|
-
const { payload } = targetAndPayload;
|
|
36
|
-
sentMessages.push(payload.message);
|
|
37
|
-
return { message: payload.message };
|
|
38
|
-
});
|
|
39
|
-
await this.sendMessage({ topic: 'bookAppointment' });
|
|
40
|
-
test_utils_1.assert.isLength(sentMessages, 2);
|
|
41
|
-
}
|
|
42
|
-
static async scriptCallbacksCanRespondToEventWithTransitionAndRepairs() {
|
|
43
|
-
this.cwd = this.resolveTestPath('skill');
|
|
44
|
-
await this.sendMessage({
|
|
45
|
-
topic: 'favoriteColor',
|
|
46
|
-
message: { body: 'favorite color' },
|
|
47
|
-
});
|
|
48
|
-
const results = await this.sendMessage({
|
|
49
|
-
topic: 'favoriteColor',
|
|
50
|
-
message: { body: 'blue' },
|
|
51
|
-
});
|
|
52
|
-
const { transitionConversationTo, repairs } = spruce_event_utils_1.eventResponseUtil.getFirstResponseOrThrow(results);
|
|
53
|
-
test_utils_1.assert.isEqual(transitionConversationTo, 'discovery');
|
|
54
|
-
test_utils_1.assert.isEqualDeep(repairs, ['go', 'team']);
|
|
55
|
-
}
|
|
56
|
-
static async scriptCallbacksCanRespondToEventWithTransitionAndTopicChangers() {
|
|
57
|
-
this.cwd = this.resolveTestPath('skill');
|
|
58
|
-
await this.sendMessage({
|
|
59
|
-
topic: 'favoriteColorTopicChanger',
|
|
60
|
-
message: { body: 'favorite color' },
|
|
61
|
-
});
|
|
62
|
-
const results = await this.sendMessage({
|
|
63
|
-
topic: 'favoriteColorTopicChanger',
|
|
64
|
-
message: { body: 'blue' },
|
|
65
|
-
});
|
|
66
|
-
const { transitionConversationTo, topicChangers } = spruce_event_utils_1.eventResponseUtil.getFirstResponseOrThrow(results);
|
|
67
|
-
test_utils_1.assert.isEqual(transitionConversationTo, 'discovery');
|
|
68
|
-
test_utils_1.assert.isEqualDeep(topicChangers, ['now', 'this']);
|
|
69
|
-
}
|
|
70
|
-
static async scriptCallbackGetsRandAndMessage() {
|
|
71
|
-
this.cwd = this.resolveTestPath('skill-assertions');
|
|
72
|
-
const results = await this.sendMessage({
|
|
73
|
-
topic: 'assertsScriptCallbackOptions',
|
|
74
|
-
message: { body: 'hello' },
|
|
75
|
-
});
|
|
76
|
-
spruce_event_utils_1.eventResponseUtil.getFirstResponseOrThrow(results);
|
|
77
|
-
}
|
|
78
|
-
static async eachPersonGetsTheirOwnConversation() {
|
|
79
|
-
this.cwd = this.resolveTestPath('skill-assertions');
|
|
80
|
-
await this.sendMessage({
|
|
81
|
-
topic: 'assertsScriptOnlyCalledOnce',
|
|
82
|
-
message: { body: 'hey hey', source: { personId: '234234234' } },
|
|
83
|
-
});
|
|
84
|
-
await this.sendMessage({
|
|
85
|
-
topic: 'assertsScriptOnlyCalledOnce',
|
|
86
|
-
message: { body: 'hey hey', source: { personId: '234234' } },
|
|
87
|
-
});
|
|
88
|
-
await this.sendMessage({
|
|
89
|
-
topic: 'assertsScriptOnlyCalledOnce',
|
|
90
|
-
message: { body: 'hey hey', source: { personId: '323' } },
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
static async sendMessage(options) {
|
|
94
|
-
const client = await this.boot();
|
|
95
|
-
const results = await client.emit('did-message::v2020_12_25', {
|
|
96
|
-
target: {},
|
|
97
|
-
payload: Object.assign(Object.assign({}, options), { message: this.buildMessage(Object.assign({ body: 'I wanna book an appointment!', source: {
|
|
98
|
-
isCore: null,
|
|
99
|
-
personId: '12345',
|
|
100
|
-
} }, options === null || options === void 0 ? void 0 : options.message)) }),
|
|
101
|
-
});
|
|
102
|
-
return results;
|
|
103
|
-
}
|
|
104
|
-
static async boot() {
|
|
105
|
-
if (!this.client) {
|
|
106
|
-
const { skill } = await this.bootAndRegisterNewSkill({
|
|
107
|
-
name: 'my skill yo',
|
|
108
|
-
});
|
|
109
|
-
const events = skill.getFeatureByCode('event');
|
|
110
|
-
const client = await events.connectToApi();
|
|
111
|
-
this.client = client;
|
|
112
|
-
}
|
|
113
|
-
return this.client;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
exports.default = RespondingToMessagesTest;
|
|
117
|
-
__decorate([
|
|
118
|
-
(0, test_utils_1.test)()
|
|
119
|
-
], RespondingToMessagesTest, "respondsToFirstMessageWithSuggestedTopics", null);
|
|
120
|
-
__decorate([
|
|
121
|
-
(0, test_utils_1.test)()
|
|
122
|
-
], RespondingToMessagesTest, "scriptSendsMessages", null);
|
|
123
|
-
__decorate([
|
|
124
|
-
(0, test_utils_1.test)()
|
|
125
|
-
], RespondingToMessagesTest, "scriptCallbacksCanRespondToEventWithTransitionAndRepairs", null);
|
|
126
|
-
__decorate([
|
|
127
|
-
(0, test_utils_1.test)()
|
|
128
|
-
], RespondingToMessagesTest, "scriptCallbacksCanRespondToEventWithTransitionAndTopicChangers", null);
|
|
129
|
-
__decorate([
|
|
130
|
-
(0, test_utils_1.test)()
|
|
131
|
-
], RespondingToMessagesTest, "scriptCallbackGetsRandAndMessage", null);
|
|
132
|
-
__decorate([
|
|
133
|
-
(0, test_utils_1.test)()
|
|
134
|
-
], RespondingToMessagesTest, "eachPersonGetsTheirOwnConversation", null);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { SkillContext } from '@sprucelabs/spruce-skill-utils';
|
|
2
|
-
import AbstractConversationTest from '../../tests/AbstractConversationTest';
|
|
3
|
-
export default class TestingAConversationTest extends AbstractConversationTest {
|
|
4
|
-
protected static afterEach(): Promise<void>;
|
|
5
|
-
protected static afterAll(): Promise<void>;
|
|
6
|
-
protected static bootingNormallyDoesNotGoToTestMode(): Promise<void>;
|
|
7
|
-
protected static bootsInTestModeWithProperAction(): Promise<void>;
|
|
8
|
-
protected static throwsWithBadScript(): Promise<void>;
|
|
9
|
-
protected static throwsWithThrowsInScript(): Promise<void>;
|
|
10
|
-
protected static scriptTesterGetsContext(context: SkillContext): Promise<void>;
|
|
11
|
-
private static getScriptTester;
|
|
12
|
-
private static bootAndGetConversationFeature;
|
|
13
|
-
private static getConversationFeature;
|
|
14
|
-
}
|
|
@@ -1,110 +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 mercury_client_1 = require("@sprucelabs/mercury-client");
|
|
13
|
-
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
14
|
-
const test_utils_2 = require("@sprucelabs/test-utils");
|
|
15
|
-
const AbstractConversationTest_1 = __importDefault(require("../../tests/AbstractConversationTest"));
|
|
16
|
-
class TestingAConversationTest extends AbstractConversationTest_1.default {
|
|
17
|
-
static async afterEach() {
|
|
18
|
-
await super.afterEach();
|
|
19
|
-
process.env.ACTION = undefined;
|
|
20
|
-
}
|
|
21
|
-
static async afterAll() {
|
|
22
|
-
await super.afterAll();
|
|
23
|
-
process.env.ACTION = undefined;
|
|
24
|
-
}
|
|
25
|
-
static async bootingNormallyDoesNotGoToTestMode() {
|
|
26
|
-
this.cwd = this.resolveTestPath('empty-skill');
|
|
27
|
-
const conversation = await this.bootAndGetConversationFeature({
|
|
28
|
-
shouldSuppressBootErrors: true,
|
|
29
|
-
});
|
|
30
|
-
test_utils_1.assert.isFalse(conversation.isTesting());
|
|
31
|
-
this.clearSkillBootErrors();
|
|
32
|
-
}
|
|
33
|
-
static async bootsInTestModeWithProperAction() {
|
|
34
|
-
process.env.ACTION = 'test.conversation';
|
|
35
|
-
const conversation = await this.bootAndGetConversationFeature();
|
|
36
|
-
test_utils_1.assert.isTrue(conversation.isTesting());
|
|
37
|
-
}
|
|
38
|
-
static async throwsWithBadScript() {
|
|
39
|
-
this.cwd = this.resolveTestPath('bad-skill');
|
|
40
|
-
process.env.ACTION = 'test.conversation';
|
|
41
|
-
const skill = await this.Skill();
|
|
42
|
-
const err = await test_utils_1.assert.doesThrowAsync(() => skill.execute());
|
|
43
|
-
test_utils_2.errorAssert.assertError(err, 'INVALID_TOPIC');
|
|
44
|
-
}
|
|
45
|
-
static async throwsWithThrowsInScript() {
|
|
46
|
-
this.cwd = this.resolveTestPath('skill-with-script-that-throws');
|
|
47
|
-
process.env.ACTION = 'test.conversation';
|
|
48
|
-
process.env.FIRST_MESSAGE = 'hey there!';
|
|
49
|
-
const skill = await this.Skill();
|
|
50
|
-
const err = await test_utils_1.assert.doesThrowAsync(() => skill.execute());
|
|
51
|
-
test_utils_2.errorAssert.assertError(err, 'CONVERSATION_ABORTED');
|
|
52
|
-
}
|
|
53
|
-
static async scriptTesterGetsContext(context) {
|
|
54
|
-
this.cwd = this.resolveTestPath('skill-with-one-topic');
|
|
55
|
-
mercury_client_1.MercuryClientFactory.setIsTestMode(true);
|
|
56
|
-
process.env.ACTION = 'test.conversation';
|
|
57
|
-
process.env.FIRST_MESSAGE = 'hey there!';
|
|
58
|
-
const skill = await this.Skill();
|
|
59
|
-
const getContext = () => context;
|
|
60
|
-
//@ts-ignore
|
|
61
|
-
skill.getContext = getContext;
|
|
62
|
-
void this.bootSkill({ skill });
|
|
63
|
-
await this.wait(100);
|
|
64
|
-
const scriptTester = await this.getScriptTester(skill);
|
|
65
|
-
//@ts-ignore
|
|
66
|
-
scriptTester.writeHandler = () => { };
|
|
67
|
-
//@ts-ignore
|
|
68
|
-
const player = scriptTester.player;
|
|
69
|
-
test_utils_1.assert.isTruthy(player);
|
|
70
|
-
//@ts-ignore
|
|
71
|
-
test_utils_1.assert.isEqualDeep(player.getContext(), context);
|
|
72
|
-
await skill.kill();
|
|
73
|
-
}
|
|
74
|
-
static async getScriptTester(skill) {
|
|
75
|
-
const conversation = this.getConversationFeature(skill);
|
|
76
|
-
//@ts-ignore
|
|
77
|
-
while (!conversation.tester) {
|
|
78
|
-
await this.wait(100);
|
|
79
|
-
}
|
|
80
|
-
//@ts-ignore
|
|
81
|
-
const scriptTester = conversation.tester;
|
|
82
|
-
test_utils_1.assert.isTruthy(scriptTester);
|
|
83
|
-
return scriptTester;
|
|
84
|
-
}
|
|
85
|
-
static async bootAndGetConversationFeature(options) {
|
|
86
|
-
const { skill } = await this.bootSkill(options);
|
|
87
|
-
const conversation = this.getConversationFeature(skill);
|
|
88
|
-
return conversation;
|
|
89
|
-
}
|
|
90
|
-
static getConversationFeature(skill) {
|
|
91
|
-
return skill.getFeatureByCode('conversation');
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
exports.default = TestingAConversationTest;
|
|
95
|
-
__decorate([
|
|
96
|
-
(0, test_utils_1.test)()
|
|
97
|
-
], TestingAConversationTest, "bootingNormallyDoesNotGoToTestMode", null);
|
|
98
|
-
__decorate([
|
|
99
|
-
(0, test_utils_1.test)()
|
|
100
|
-
], TestingAConversationTest, "bootsInTestModeWithProperAction", null);
|
|
101
|
-
__decorate([
|
|
102
|
-
(0, test_utils_1.test)()
|
|
103
|
-
], TestingAConversationTest, "throwsWithBadScript", null);
|
|
104
|
-
__decorate([
|
|
105
|
-
(0, test_utils_1.test)()
|
|
106
|
-
], TestingAConversationTest, "throwsWithThrowsInScript", null);
|
|
107
|
-
__decorate([
|
|
108
|
-
(0, test_utils_1.test)('can get context 1', { hello: 'world' }),
|
|
109
|
-
(0, test_utils_1.test)('can get context 2', { what: 'the!?' })
|
|
110
|
-
], TestingAConversationTest, "scriptTesterGetsContext", null);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { SkillContext } from '@sprucelabs/spruce-skill-utils';
|
|
2
|
-
import AbstractConversationTest from '../../tests/AbstractConversationTest';
|
|
3
|
-
export default class TopicCoordinatorTest extends AbstractConversationTest {
|
|
4
|
-
private static coordinator;
|
|
5
|
-
private static sentMessages;
|
|
6
|
-
private static skillContext;
|
|
7
|
-
protected static beforeEach(): Promise<void>;
|
|
8
|
-
protected static canCreateTopicCoordinator(): Promise<void>;
|
|
9
|
-
protected static hasHandleMessage(): Promise<void>;
|
|
10
|
-
protected static handledMessageMustHaveASource(): Promise<void>;
|
|
11
|
-
protected static respondsWithSuggestedTopicsToFirstMessage(): Promise<void>;
|
|
12
|
-
protected static handlesNoSkillWithTopics(): Promise<void>;
|
|
13
|
-
protected static throwsWhenSentBadTopic(): Promise<void>;
|
|
14
|
-
protected static playsScriptWhenTopicIsSelected(): Promise<void>;
|
|
15
|
-
protected static canHandlePromptsInScript(): Promise<void>;
|
|
16
|
-
protected static canPlaceMixedScriptsUntilTheEndAndStartsOver(): Promise<void>;
|
|
17
|
-
protected static passesThroughContextGetter(context: SkillContext): Promise<void>;
|
|
18
|
-
}
|