Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Commit 81e7df5

Browse files
Batta32darrenj
authored andcommitted
[TypeScript][Botskills] Refactor in Mocks folder (#1706)
* Fix typos for errors * Refactor mocks folder
1 parent e127744 commit 81e7df5

29 files changed

+94
-114
lines changed

tools/botskills/src/functionality/connectSkill.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ Make sure your Skill's .lu file's name matches your Skill's manifest id`);
133133
// Validate 'dispatch add' arguments
134134
if (!existsSync(configuration.dispatchFolder)) {
135135
throw new Error(`Path to the Dispatch folder (${configuration.dispatchFolder}) leads to a nonexistent folder.
136-
Remember to use the argument '--dispatchFOlder' for your Assistant's Dispatch folder.`);
136+
Remember to use the argument '--dispatchFolder' for your Assistant's Dispatch folder.`);
137137
} else if (!existsSync(dispatchFilePath)) {
138138
throw new Error(`Path to the ${dispatchFile} file leads to a nonexistent file.
139139
Make sure to use the argument '--dispatchName' for your Assistant's Dispatch file name.`);

tools/botskills/src/functionality/refreshSkill.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class RefreshSkill {
7878

7979
if (!existsSync(configuration.dispatchFolder)) {
8080
throw new Error(`Path to the Dispatch folder (${configuration.dispatchFolder}) leads to a nonexistent folder.
81-
Remember to use the argument '--dispatchFOlder' for your Assistant's Dispatch folder.`);
81+
Remember to use the argument '--dispatchFolder' for your Assistant's Dispatch folder.`);
8282
} else if (!existsSync(this.dispatchFilePath)) {
8383
throw new Error(`Path to the ${this.dispatchFile} file leads to a nonexistent file.
8484
Make sure to use the argument '--dispatchName' for your Assistant's Dispatch file name.`);

tools/botskills/test/connect.test.js

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const { join, resolve } = require("path");
99
const sandbox = require("sinon").createSandbox();
1010
const testLogger = require("./helpers/testLogger");
1111
const botskills = require("../lib/index");
12-
const filledSkillsArray = JSON.stringify(
12+
const filledSkills = JSON.stringify(
1313
{
1414
"skills": [
1515
{
@@ -25,16 +25,14 @@ const filledSkillsArray = JSON.stringify(
2525
describe("The connect command", function () {
2626

2727
beforeEach(function () {
28-
writeFileSync(resolve(__dirname, join("mocks", "resources", "filledSkillsArray.json")), filledSkillsArray);
29-
writeFileSync(resolve(__dirname, join("mocks", "resources", "successfulConnectFiles", "filledSkillsArray.json")), filledSkillsArray);
28+
writeFileSync(resolve(__dirname, join("mocks", "virtualAssistant", "filledSkills.json")), filledSkills);
3029

3130
this.logger = new testLogger.TestLogger();
3231
this.connector = new botskills.ConnectSkill(this.logger);
3332
})
3433

3534
after(function () {
36-
writeFileSync(resolve(__dirname, join("mocks", "resources", "filledSkillsArray.json")), filledSkillsArray);
37-
writeFileSync(resolve(__dirname, join("mocks", "resources", "successfulConnectFiles", "filledSkillsArray.json")), filledSkillsArray);
35+
writeFileSync(resolve(__dirname, join("mocks", "virtualAssistant", "filledSkills.json")), filledSkills);
3836
})
3937

4038
describe("should show an error", function () {
@@ -67,7 +65,7 @@ Error: Either the 'localManifest' or 'remoteManifest' argument should be passed.
6765
it("when the localManifest points to a nonexisting Skill manifest file", async function () {
6866
const config = {
6967
botName: "",
70-
localManifest: resolve(__dirname, join("mocks", "resources", "nonexistentSkill.json")),
68+
localManifest: resolve(__dirname, join("mocks", "skills", "nonexistentSkill.json")),
7169
remoteManifest: "",
7270
dispatchName: "",
7371
language: "",
@@ -94,7 +92,7 @@ Please make sure to provide a valid path to your Skill manifest using the '--loc
9492
it("when the Skill is missing all mandatory fields", async function () {
9593
const config = {
9694
botName: "",
97-
localManifest: resolve(__dirname, join("mocks", "resources", "invalidSkill.json")),
95+
localManifest: resolve(__dirname, join("mocks", "skills", "invalidManifest.json")),
9896
remoteManifest: "",
9997
dispatchName: "",
10098
language: "",
@@ -129,7 +127,7 @@ Please make sure to provide a valid path to your Skill manifest using the '--loc
129127
it("when the Skill has an invalid id field", async function () {
130128
const config = {
131129
botName: "",
132-
localManifest: resolve(__dirname, join("mocks", "resources", "invalidSkillid.json")),
130+
localManifest: resolve(__dirname, join("mocks", "skills", "invalidIdManifest.json")),
133131
remoteManifest: "",
134132
dispatchName: "",
135133
language: "",
@@ -180,15 +178,15 @@ RequestError: Error: getaddrinfo ENOTFOUND nonexistentskill.azurewebsites.net no
180178
it("when the luisFolder leads to a nonexistent folder", async function () {
181179
const config = {
182180
botName: "",
183-
localManifest: resolve(__dirname, join("mocks", "resources", "connectableSkill.json")),
181+
localManifest: resolve(__dirname, join("mocks", "skills", "connectableManifest.json")),
184182
remoteManifest: "",
185183
dispatchName: "",
186184
language: "",
187-
luisFolder: resolve(__dirname, join("mocks", "resources", "nonexistentLuisFolder")),
185+
luisFolder: resolve(__dirname, join("mocks", "fail", "nonexistentLuis")),
188186
dispatchFolder: "",
189187
outFolder: "",
190188
lgOutFolder: "",
191-
skillsFile: resolve(__dirname, join("mocks", "resources", "filledSkillsArray.json")),
189+
skillsFile: resolve(__dirname, join("mocks", "virtualAssistant", "filledSkills.json")),
192190
resourceGroup: "",
193191
appSettingsFile: "",
194192
cognitiveModelsFile: "",
@@ -208,15 +206,15 @@ Remember to use the argument '--luisFolder' for your Skill's LUIS folder.`);
208206
it("when the .lu file path leads to a nonexistent file", async function () {
209207
const config = {
210208
botName: "",
211-
localManifest: resolve(__dirname, join("mocks", "resources", "connectableSkill.json")),
209+
localManifest: resolve(__dirname, join("mocks", "skills", "connectableManifest.json")),
212210
remoteManifest: "",
213211
dispatchName: "",
214212
language: "",
215-
luisFolder: resolve(__dirname, join("mocks", "resources")),
213+
luisFolder: resolve(__dirname, join("mocks", "success")),
216214
dispatchFolder: "",
217215
outFolder: "",
218216
lgOutFolder: "",
219-
skillsFile: resolve(__dirname, join("mocks", "resources", "filledSkillsArray.json")),
217+
skillsFile: resolve(__dirname, join("mocks", "virtualAssistant", "filledSkills.json")),
220218
resourceGroup: "",
221219
appSettingsFile: "",
222220
cognitiveModelsFile: "",
@@ -236,15 +234,15 @@ Make sure your Skill's .lu file's name matches your Skill's manifest id`);
236234
it("when the dispatch folder path leads to a nonexistent folder", async function () {
237235
const config = {
238236
botName: "",
239-
localManifest: resolve(__dirname, join("mocks", "resources", "connectableSkill.json")),
237+
localManifest: resolve(__dirname, join("mocks", "skills", "connectableManifest.json")),
240238
remoteManifest: "",
241239
dispatchName: "",
242240
language: "",
243-
luisFolder: resolve(__dirname, join("mocks", "resources", "luisFolder")),
244-
dispatchFolder: resolve(__dirname, join("mocks", "resources", "nonexistentDispatchFolder")),
241+
luisFolder: resolve(__dirname, join("mocks", "success", "luis")),
242+
dispatchFolder: resolve(__dirname, join("mocks", "fail", "nonexistentDispatch")),
245243
outFolder: "",
246244
lgOutFolder: "",
247-
skillsFile: resolve(__dirname, join("mocks", "resources", "filledSkillsArray.json")),
245+
skillsFile: resolve(__dirname, join("mocks", "virtualAssistant", "filledSkills.json")),
248246
resourceGroup: "",
249247
appSettingsFile: "",
250248
cognitiveModelsFile: "",
@@ -258,21 +256,21 @@ Make sure your Skill's .lu file's name matches your Skill's manifest id`);
258256
strictEqual(errorList[errorList.length - 1], `There was an error while connecting the Skill to the Assistant:
259257
Error: An error ocurred while updating the Dispatch model:
260258
Error: Path to the Dispatch folder (${config.dispatchFolder}) leads to a nonexistent folder.
261-
Remember to use the argument '--dispatchFOlder' for your Assistant's Dispatch folder.`);
259+
Remember to use the argument '--dispatchFolder' for your Assistant's Dispatch folder.`);
262260
});
263261

264262
it("when the .dispatch file path leads to a nonexistent file", async function () {
265263
const config = {
266264
botName: "",
267-
localManifest: resolve(__dirname, join("mocks", "resources", "connectableSkill.json")),
265+
localManifest: resolve(__dirname, join("mocks", "skills", "connectableManifest.json")),
268266
remoteManifest: "",
269-
dispatchName: "nonexistentDispatchFile",
267+
dispatchName: "nonexistentDispatch",
270268
language: "",
271-
luisFolder: resolve(__dirname, join("mocks", "resources", "luisFolder")),
272-
dispatchFolder: resolve(__dirname, join("mocks", "resources", "dispatchFolder")),
269+
luisFolder: resolve(__dirname, join("mocks", "success", "luis")),
270+
dispatchFolder: resolve(__dirname, join("mocks", "success", "dispatch")),
273271
outFolder: "",
274272
lgOutFolder: "",
275-
skillsFile: resolve(__dirname, join("mocks", "resources", "filledSkillsArray.json")),
273+
skillsFile: resolve(__dirname, join("mocks", "virtualAssistant", "filledSkills.json")),
276274
resourceGroup: "",
277275
appSettingsFile: "",
278276
cognitiveModelsFile: "",
@@ -295,15 +293,15 @@ Make sure to use the argument '--dispatchName' for your Assistant's Dispatch fil
295293
});
296294
const config = {
297295
botName: "",
298-
localManifest: resolve(__dirname, join("mocks", "resources", "connectableSkill.json")),
296+
localManifest: resolve(__dirname, join("mocks", "skills", "connectableManifest.json")),
299297
remoteManifest: "",
300298
dispatchName: "connectableSkill",
301299
language: "en",
302-
luisFolder: resolve(__dirname, join("mocks", "resources", "luFolder")),
303-
dispatchFolder: resolve(__dirname, join("mocks", "resources", "dispatchFolder")),
300+
luisFolder: resolve(__dirname, join("mocks", "success", "lu")),
301+
dispatchFolder: resolve(__dirname, join("mocks", "success", "dispatch")),
304302
outFolder: "",
305303
lgOutFolder: "",
306-
skillsFile: resolve(__dirname, join("mocks", "resources", "filledSkillsArray.json")),
304+
skillsFile: resolve(__dirname, join("mocks", "virtualAssistant", "filledSkills.json")),
307305
resourceGroup: "",
308306
appSettingsFile: "",
309307
cognitiveModelsFile: "",
@@ -329,15 +327,15 @@ Command: ludown parse toluis --in ${join(config.luisFolder, config.dispatchName)
329327
});
330328
const config = {
331329
botName: "",
332-
localManifest: resolve(__dirname, join("mocks", "resources", "connectableSkill.json")),
330+
localManifest: resolve(__dirname, join("mocks", "skills", "connectableManifest.json")),
333331
remoteManifest: "",
334332
dispatchName: "connectableSkill",
335333
language: "",
336-
luisFolder: resolve(__dirname, join("mocks", "resources", "luisFolder")),
337-
dispatchFolder: resolve(__dirname, join("mocks", "resources", "dispatchFolder")),
334+
luisFolder: resolve(__dirname, join("mocks", "success", "luis")),
335+
dispatchFolder: resolve(__dirname, join("mocks", "success", "dispatch")),
338336
outFolder: "",
339337
lgOutFolder: "",
340-
skillsFile: resolve(__dirname, join("mocks", "resources", "filledSkillsArray.json")),
338+
skillsFile: resolve(__dirname, join("mocks", "virtualAssistant", "filledSkills.json")),
341339
resourceGroup: "",
342340
appSettingsFile: "",
343341
cognitiveModelsFile: "",
@@ -358,15 +356,15 @@ Error: There was an error while refreshing the Dispatch model.`);
358356
it("when the Skill is already connected", async function () {
359357
const config = {
360358
botName: "",
361-
localManifest: resolve(__dirname, join("mocks", "resources", "testSkill.json")),
359+
localManifest: resolve(__dirname, join("mocks", "skills", "repeatedManifest.json")),
362360
remoteManifest: "",
363361
dispatchName: "",
364362
language: "",
365363
luisFolder: "",
366364
dispatchFolder: "",
367365
outFolder: "",
368366
lgOutFolder: "",
369-
skillsFile: resolve(__dirname, join("mocks", "resources", "filledSkillsArray.json")),
367+
skillsFile: resolve(__dirname, join("mocks", "virtualAssistant", "filledSkills.json")),
370368
resourceGroup: "",
371369
appSettingsFile: "",
372370
cognitiveModelsFile: "",
@@ -392,16 +390,16 @@ Error: There was an error while refreshing the Dispatch model.`);
392390
});
393391
const config = {
394392
botName: "",
395-
localManifest: resolve(__dirname, join("mocks", "resources", "connectableSkill.json")),
393+
localManifest: resolve(__dirname, join("mocks", "skills", "connectableManifest.json")),
396394
remoteManifest: "",
397395
noRefresh: true,
398396
dispatchName: "connectableSkill",
399397
language: "",
400-
luisFolder: resolve(__dirname, join("mocks", "resources", "successfulConnectFiles")),
401-
dispatchFolder: resolve(__dirname, join("mocks", "resources", "successfulConnectFiles")),
398+
luisFolder: resolve(__dirname, join("mocks", "success", "luis")),
399+
dispatchFolder: resolve(__dirname, join("mocks", "success", "dispatch")),
402400
outFolder: "",
403401
lgOutFolder: "",
404-
skillsFile: resolve(__dirname, join("mocks", "resources", "filledSkillsArray.json")),
402+
skillsFile: resolve(__dirname, join("mocks", "virtualAssistant", "filledSkills.json")),
405403
resourceGroup: "",
406404
appSettingsFile: "",
407405
cognitiveModelsFile: "",
@@ -429,15 +427,15 @@ Error: There was an error while refreshing the Dispatch model.`);
429427
});
430428
const config = {
431429
botName: "",
432-
localManifest: resolve(__dirname, join("mocks", "resources", "successfulConnectFiles", "connectableSkill.json")),
430+
localManifest: resolve(__dirname, join("mocks", "skills", "connectableManifest.json")),
433431
remoteManifest: "",
434432
dispatchName: "connectableSkill",
435433
language: "",
436-
luisFolder: resolve(__dirname, join("mocks", "resources", "successfulConnectFiles")),
437-
dispatchFolder: resolve(__dirname, join("mocks", "resources", "successfulConnectFiles")),
434+
luisFolder: resolve(__dirname, join("mocks", "success", "luis")),
435+
dispatchFolder: resolve(__dirname, join("mocks", "success", "dispatch")),
438436
outFolder: "",
439437
lgOutFolder: "",
440-
skillsFile: resolve(__dirname, join("mocks", "resources", "successfulConnectFiles", "filledSkillsArray.json")),
438+
skillsFile: resolve(__dirname, join("mocks", "virtualAssistant", "filledSkills.json")),
441439
resourceGroup: "",
442440
appSettingsFile: "",
443441
cognitiveModelsFile: "",

0 commit comments

Comments
 (0)