botium-core 1.14.0 → 1.14.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "botium-core",
3
- "version": "1.14.0",
3
+ "version": "1.14.1",
4
4
  "description": "The Selenium for Chatbots",
5
5
  "main": "index.js",
6
6
  "module": "dist/botium-es.js",
@@ -31,12 +31,12 @@
31
31
  },
32
32
  "homepage": "https://www.botium.ai",
33
33
  "dependencies": {
34
- "@babel/runtime": "^7.22.15",
35
- "async": "^3.2.4",
34
+ "@babel/runtime": "^7.23.2",
35
+ "async": "^3.2.5",
36
36
  "body-parser": "^1.20.2",
37
37
  "boolean": "^3.2.0",
38
38
  "bottleneck": "^2.19.5",
39
- "csv-parse": "^5.5.0",
39
+ "csv-parse": "^5.5.2",
40
40
  "debug": "^4.3.4",
41
41
  "express": "^4.18.2",
42
42
  "globby": "11.0.4",
@@ -45,7 +45,7 @@
45
45
  "is-json": "^2.0.1",
46
46
  "jsonpath": "^1.1.1",
47
47
  "lodash": "^4.17.21",
48
- "markdown-it": "^13.0.1",
48
+ "markdown-it": "^13.0.2",
49
49
  "mime-types": "^2.1.35",
50
50
  "mkdirp": "^3.0.1",
51
51
  "moment": "^2.29.4",
@@ -55,7 +55,7 @@
55
55
  "promise.allsettled": "^1.0.7",
56
56
  "randomatic": "^3.1.1",
57
57
  "request": "^2.88.2",
58
- "rimraf": "^5.0.1",
58
+ "rimraf": "^5.0.5",
59
59
  "sanitize-filename": "^1.6.3",
60
60
  "slugify": "^1.6.6",
61
61
  "socket.io": "^4.7.2",
@@ -63,31 +63,31 @@
63
63
  "socketio-auth": "^0.1.1",
64
64
  "swagger-jsdoc": "^6.2.8",
65
65
  "swagger-ui-express": "^5.0.0",
66
- "uuid": "^9.0.0",
66
+ "uuid": "^9.0.1",
67
67
  "word-error-rate": "0.0.7",
68
68
  "write-yaml": "^1.0.0",
69
69
  "xlsx": "^0.18.5",
70
70
  "xregexp": "^5.1.1",
71
- "yaml": "^2.3.2"
71
+ "yaml": "^2.3.4"
72
72
  },
73
73
  "devDependencies": {
74
- "@babel/core": "^7.22.17",
75
- "@babel/node": "^7.22.15",
76
- "@babel/plugin-transform-runtime": "^7.22.15",
77
- "@babel/preset-env": "^7.22.15",
78
- "chai": "^4.3.8",
74
+ "@babel/core": "^7.23.3",
75
+ "@babel/node": "^7.22.19",
76
+ "@babel/plugin-transform-runtime": "^7.23.3",
77
+ "@babel/preset-env": "^7.23.3",
78
+ "chai": "^4.3.10",
79
79
  "chai-as-promised": "^7.1.1",
80
80
  "cross-env": "^7.0.3",
81
- "eslint": "^8.49.0",
81
+ "eslint": "^8.53.0",
82
82
  "eslint-config-standard": "^17.1.0",
83
- "eslint-plugin-import": "^2.28.1",
84
- "eslint-plugin-mocha": "^10.1.0",
85
- "eslint-plugin-n": "^16.1.0",
83
+ "eslint-plugin-import": "^2.29.0",
84
+ "eslint-plugin-mocha": "^10.2.0",
85
+ "eslint-plugin-n": "^16.3.1",
86
86
  "eslint-plugin-promise": "^6.1.1",
87
87
  "eslint-plugin-standard": "^4.1.0",
88
88
  "mocha": "^10.2.0",
89
- "nock": "^13.3.3",
90
- "npm-check-updates": "^16.13.3",
89
+ "nock": "^13.3.8",
90
+ "npm-check-updates": "^16.14.6",
91
91
  "nyc": "^15.1.0",
92
92
  "rollup": "2.79.1",
93
93
  "rollup-plugin-babel": "^4.4.0",
@@ -275,6 +275,8 @@ class Convo {
275
275
  let botMsg = null
276
276
  let waitForBotSays = true
277
277
  let skipTranscriptStep = false
278
+ let conditionalGroupId = null
279
+ let conditionMetInGroup = false
278
280
  for (let i = 0; i < this.conversation.length; i++) {
279
281
  const convoStep = this.conversation[i]
280
282
  const currentStepIndex = i
@@ -356,7 +358,6 @@ class Convo {
356
358
  throw failErr
357
359
  }
358
360
  } else if (convoStep.sender === 'bot') {
359
- const previousWaitForBotSays = waitForBotSays
360
361
  if (waitForBotSays) {
361
362
  botMsg = null
362
363
  } else {
@@ -406,22 +407,38 @@ class Convo {
406
407
  }
407
408
 
408
409
  if (convoStep.conditional) {
410
+ waitForBotSays = false
411
+ let endOfConditionalGroup = false
412
+ conditionalGroupId = convoStep.logicHooks.find(lh => lh.name.startsWith('CONDITIONAL_STEP')).args[1]
409
413
  const nextConvoStep = this.conversation[i + 1]
410
414
 
411
- if (!previousWaitForBotSays) {
412
- skipTranscriptStep = true
413
- }
414
- waitForBotSays = false
415
415
  if (!nextConvoStep || nextConvoStep.sender !== 'bot' || !nextConvoStep.logicHooks || !nextConvoStep.logicHooks.some(lh => lh.name.toUpperCase().startsWith('CONDITIONAL_STEP'))) {
416
- waitForBotSays = true
416
+ endOfConditionalGroup = true
417
417
  } else {
418
- const conditionalLogicHook = convoStep.logicHooks.find(lh => lh.name.startsWith('CONDITIONAL_STEP'))
419
418
  const nextConditionalLogicHook = nextConvoStep.logicHooks.find(lh => lh.name.startsWith('CONDITIONAL_STEP'))
420
- waitForBotSays = conditionalLogicHook.args[1] !== nextConditionalLogicHook.args[1]
419
+ endOfConditionalGroup = conditionalGroupId !== nextConditionalLogicHook.args[1]
421
420
  }
422
421
 
423
- if (convoStep.conditional.skip) {
422
+ if (convoStep.conditional.skip || conditionMetInGroup) {
423
+ skipTranscriptStep = true
424
+ if (endOfConditionalGroup && !conditionMetInGroup && !convoStep.optional) {
425
+ const failErr = new BotiumError(`${this.header.name}/${convoStep.stepTag}: Non of the conditions are met in ${conditionalGroupId ? `'${conditionalGroupId}' ` : ''}condition group`)
426
+ debug(failErr)
427
+ throw failErr
428
+ }
429
+ if (endOfConditionalGroup) {
430
+ waitForBotSays = !convoStep.optional
431
+ conditionalGroupId = undefined
432
+ conditionMetInGroup = false
433
+ }
424
434
  continue
435
+ } else {
436
+ conditionMetInGroup = true
437
+ if (endOfConditionalGroup) {
438
+ waitForBotSays = !convoStep.optional
439
+ conditionalGroupId = undefined
440
+ conditionMetInGroup = false
441
+ }
425
442
  }
426
443
  }
427
444
 
@@ -51,6 +51,6 @@ module.exports = class ConditionalBusinessHoursLogicHook {
51
51
  }
52
52
  params.now = moment()
53
53
  convoStep.conditional.skip = !this._isBetween(params)
54
- debug(`ConditionalBusinessHoursLogicHook onBotPrepare ${convo.header.name}/${convoStep.stepTag}, args: ${util.inspect(args)}, convoStep.conditional: ${convoStep.conditional}`)
54
+ debug(`ConditionalBusinessHoursLogicHook onBotPrepare ${convo.header.name}/${convoStep.stepTag}, args: ${util.inspect(args)}, convoStep.conditional: ${util.inspect(convoStep.conditional)}`)
55
55
  }
56
56
  }
@@ -32,6 +32,6 @@ module.exports = class ConditionalCapabilityValueBasedLogicHook {
32
32
  conditionGroupId
33
33
  }
34
34
  convoStep.conditional.skip = !this._isCapabilityValueEqual(params)
35
- debug(`ConditionalCapabilityValueBasedLogicHook onBotPrepare ${convo.header.name}/${convoStep.stepTag}, args: ${util.inspect(args)}, convoStep.conditional: ${convoStep.conditional}`)
35
+ debug(`ConditionalCapabilityValueBasedLogicHook onBotPrepare ${convo.header.name}/${convoStep.stepTag}, args: ${util.inspect(args)}, convoStep.conditional: ${util.inspect(convoStep.conditional)}`)
36
36
  }
37
37
  }
@@ -26,6 +26,6 @@ module.exports = class ConditionalJsonPathBasedLogicHook {
26
26
  skip = !(values && values.length > 0 && values.includes(params.value))
27
27
  }
28
28
  convoStep.conditional.skip = skip
29
- debug(`ConditionalJsonPathBasedLogicHook onBotPrepare ${convo.header.name}/${convoStep.stepTag}, args: ${util.inspect(args)}, convoStep.conditional: ${convoStep.conditional}`)
29
+ debug(`ConditionalJsonPathBasedLogicHook onBotPrepare ${convo.header.name}/${convoStep.stepTag}, args: ${util.inspect(args)}, convoStep.conditional: ${util.inspect(convoStep.conditional)}`)
30
30
  }
31
31
  }
@@ -41,6 +41,6 @@ module.exports = class ConditionalTimeBasedLogicHook {
41
41
  }
42
42
  params.now = moment()
43
43
  convoStep.conditional.skip = !this._isBetween(params)
44
- debug(`ConditionalTimeBasedLogicHook onBotPrepare ${convo.header.name}/${convoStep.stepTag}, args: ${util.inspect(args)}, convoStep.conditional: ${convoStep.conditional}`)
44
+ debug(`ConditionalTimeBasedLogicHook onBotPrepare ${convo.header.name}/${convoStep.stepTag}, args: ${util.inspect(args)}, convoStep.conditional: ${util.inspect(convoStep.conditional)}`)
45
45
  }
46
46
  }
@@ -4,17 +4,17 @@ custom embedded
4
4
  hello
5
5
 
6
6
  #bot
7
- hello should not assert
8
- CONDITIONAL_STEP_LOGIC_HOOK { "skip":true }|G1
7
+ hello
8
+ CONDITIONAL_STEP_LOGIC_HOOK { "skip":false }|G1
9
9
 
10
10
  #bot
11
11
  hello should not assert
12
- CONDITIONAL_STEP_LOGIC_HOOK { "skip":true }|G1
12
+ CONDITIONAL_STEP_LOGIC_HOOK { "skip":false }|G1
13
13
 
14
14
  #bot
15
- hello should not assert
16
- CONDITIONAL_STEP_LOGIC_HOOK { "skip":true }|G2
15
+ hello
16
+ CONDITIONAL_STEP_LOGIC_HOOK { "skip":false }|G2
17
17
 
18
18
  #bot
19
19
  hello should not assert
20
- CONDITIONAL_STEP_LOGIC_HOOK { "skip":true }|G2
20
+ CONDITIONAL_STEP_LOGIC_HOOK { "skip":false }|G2
@@ -0,0 +1,20 @@
1
+ custom embedded
2
+
3
+ #me
4
+ hello
5
+
6
+ #bot
7
+ hello should not assert
8
+ CONDITIONAL_STEP_LOGIC_HOOK { "skip":true }|G1
9
+
10
+ #bot
11
+ hello
12
+ CONDITIONAL_STEP_LOGIC_HOOK { "skip":false }|G1
13
+
14
+ #bot
15
+ hello should not assert
16
+ CONDITIONAL_STEP_LOGIC_HOOK { "skip":true }|G2
17
+
18
+ #bot
19
+ hello should not assert
20
+ CONDITIONAL_STEP_LOGIC_HOOK { "skip":true }|G2
@@ -0,0 +1,20 @@
1
+ custom embedded
2
+
3
+ #me
4
+ hello
5
+
6
+ #bot
7
+ ?hello
8
+ CONDITIONAL_STEP_LOGIC_HOOK { "skip":false }|G1
9
+
10
+ #bot
11
+ ?hello should not assert
12
+ CONDITIONAL_STEP_LOGIC_HOOK { "skip":false }|G1
13
+
14
+ #bot
15
+ ?hello 2
16
+ CONDITIONAL_STEP_LOGIC_HOOK { "skip":false }|G2
17
+
18
+ #bot
19
+ ?hello should not assert
20
+ CONDITIONAL_STEP_LOGIC_HOOK { "skip":true }|G2
@@ -101,5 +101,21 @@ describe('convo with custom conditional logichook', function () {
101
101
  const transript = await this.compiler.convos[0].Run(this.container)
102
102
  assert.equal(transript.steps.length, 3)
103
103
  })
104
+
105
+ it('should fail mandatory condition group if no condition met', async function () {
106
+ try {
107
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'conditional_steps_multiple_mandatory_condition_groups.convo.txt')
108
+ await this.compiler.convos[0].Run(this.container)
109
+ assert.fail('it should have failed')
110
+ } catch (e) {
111
+ assert.equal(e.message, 'custom embedded/Line 18: Non of the conditions are met in \'G2\' condition group')
112
+ }
113
+ })
114
+
115
+ it('should not fail optional condition group if no condition met', async function () {
116
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'conditional_steps_multiple_optional_condition_groups.convo.txt')
117
+ const transript = await this.compiler.convos[0].Run(this.container)
118
+ assert.equal(transript.steps.length, 2)
119
+ })
104
120
  })
105
121
  })