botium-core 1.13.6 → 1.13.7

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.13.6",
3
+ "version": "1.13.7",
4
4
  "description": "The Selenium for Chatbots",
5
5
  "main": "index.js",
6
6
  "module": "dist/botium-es.js",
@@ -111,19 +111,19 @@ module.exports = class LogicHookUtils {
111
111
 
112
112
  // 1 gives possibility to use default asserter as global asserter
113
113
  if (hookType === 'asserter') {
114
- const asserter = DEFAULT_ASSERTERS.find(asserter => src === asserter.className)
114
+ const asserter = DEFAULT_ASSERTERS.find(asserter => src === asserter.className || src === asserter.name)
115
115
  if (asserter) {
116
116
  return new (asserter.Class)({ ref, ...this.buildScriptContext }, this.caps, args)
117
117
  }
118
118
  }
119
119
  if (hookType === 'logichook') {
120
- const lh = DEFAULT_LOGIC_HOOKS.find(lh => src === lh.className)
120
+ const lh = DEFAULT_LOGIC_HOOKS.find(lh => src === lh.className || src === lh.name)
121
121
  if (lh) {
122
122
  return new (lh.Class)({ ref, ...this.buildScriptContext }, this.caps, args)
123
123
  }
124
124
  }
125
125
  if (hookType === 'userinput') {
126
- const ui = DEFAULT_USER_INPUTS.find(ui => src === ui.className)
126
+ const ui = DEFAULT_USER_INPUTS.find(ui => src === ui.className || src === ui.name)
127
127
  if (ui) {
128
128
  return new (ui.Class)({ ref, ...this.buildScriptContext }, this.caps, args)
129
129
  }
@@ -126,7 +126,8 @@ module.exports = class JsonPathAsserter {
126
126
  ))
127
127
  }
128
128
  }
129
- if (assert) {
129
+
130
+ if (!_.isNil(assert)) {
130
131
  const actual = (_.isArray(jsonPathValues) && jsonPathValues.length === 1) ? jsonPathValues[0] : jsonPathValues
131
132
 
132
133
  let matchFn = this.context.Match
@@ -137,7 +138,7 @@ module.exports = class JsonPathAsserter {
137
138
  const match = jsonPathValues.find(a => matchFn(a, assert))
138
139
 
139
140
  if (not && match) {
140
- return Promise.reject(new BotiumError(`${convoStep.stepTag}: Not expected: ${toString(actual)} in jsonPath ${path}"`,
141
+ return Promise.reject(new BotiumError(`${convoStep.stepTag}: Not expected: "${toString(actual)}" in jsonPath ${path}"`,
141
142
  {
142
143
  type: 'asserter',
143
144
  source: this.name,
@@ -158,7 +159,7 @@ module.exports = class JsonPathAsserter {
158
159
  ))
159
160
  }
160
161
  if (!not && !match) {
161
- return Promise.reject(new BotiumError(`${convoStep.stepTag}: Expected: ${assert} in jsonPath ${path}: Actual: ${toString(actual)}`,
162
+ return Promise.reject(new BotiumError(`${convoStep.stepTag}: Expected: "${assert}" in jsonPath ${path}, actual: ${toString(actual)}`,
162
163
  {
163
164
  type: 'asserter',
164
165
  source: this.name,
@@ -63,7 +63,7 @@ describe('scripting.asserters.jsonPathAsserter', function () {
63
63
  })
64
64
  } catch (err) {
65
65
  console.log(err.message)
66
- assert.isTrue(err.message.includes('Expected: message4 in jsonPath $.messages[*].label: Actual: message1,message2,message3'))
66
+ assert.isTrue(err.message.includes('Expected: "message4" in jsonPath $.messages[*].label, actual: message1,message2,message3'))
67
67
  }
68
68
  })
69
69
  it('should fail on not existing jsonpath', async function () {
@@ -133,7 +133,7 @@ describe('scripting.asserters.jsonPathAsserter', function () {
133
133
  }
134
134
  })
135
135
  } catch (err) {
136
- assert.isTrue(err.message.indexOf('Expected: {"label":"message2"} in jsonPath $.messages[0]: Actual: {"label":"message1"}') > 0)
136
+ assert.isTrue(err.message.indexOf('Expected: "{"label":"message2"}" in jsonPath $.messages[0], actual: {"label":"message1"}') > 0)
137
137
  assert.isNotNull(err.context)
138
138
  assert.isNotNull(err.context.cause)
139
139
  assert.isNotTrue(err.context.cause.not)
@@ -155,7 +155,7 @@ describe('scripting.asserters.jsonPathAsserter', function () {
155
155
  })
156
156
  assert.fail('should have failed')
157
157
  } catch (err) {
158
- assert.isTrue(err.message.indexOf('Expected: test2 in jsonPath $.test') > 0)
158
+ assert.isTrue(err.message.indexOf('Expected: "test2" in jsonPath $.test') > 0)
159
159
  assert.isNotNull(err.context)
160
160
  assert.isNotNull(err.context.cause)
161
161
  assert.isNotTrue(err.context.cause.not)
@@ -196,7 +196,7 @@ describe('scripting.asserters.jsonPathAsserter', function () {
196
196
  })
197
197
  assert.fail('should have failed')
198
198
  } catch (err) {
199
- assert.isTrue(err.message.indexOf('Not expected: test1 in jsonPath $.test') > 0)
199
+ assert.isTrue(err.message.indexOf('Not expected: "test1" in jsonPath $.test') > 0)
200
200
  assert.isNotNull(err.context)
201
201
  assert.isNotNull(err.context.cause)
202
202
  assert.isTrue(err.context.cause.not)
@@ -252,7 +252,7 @@ describe('scripting.asserters.jsonPathAsserter', function () {
252
252
  })
253
253
  assert.fail('should have failed')
254
254
  } catch (err) {
255
- assert.isTrue(err.message.indexOf('Expected: test2 in jsonPath $.test') > 0)
255
+ assert.isTrue(err.message.indexOf('Expected: "test2" in jsonPath $.test') > 0)
256
256
  assert.isNotNull(err.context)
257
257
  assert.isNotNull(err.context.cause)
258
258
  assert.isNotTrue(err.context.cause.not)
@@ -332,7 +332,7 @@ describe('scripting.asserters.jsonPathAsserter', function () {
332
332
  })
333
333
  assert.fail('should have failed')
334
334
  } catch (err) {
335
- assert.isTrue(err.message.indexOf('Expected: value in jsonPath $.test') > 0)
335
+ assert.isTrue(err.message.indexOf('Expected: "value" in jsonPath $.test') > 0)
336
336
  }
337
337
  })
338
338
  it('should succeed on setting matching mode in global args', async function () {
@@ -373,7 +373,7 @@ describe('scripting.asserters.jsonPathAsserter', function () {
373
373
  })
374
374
  assert.fail('should have failed')
375
375
  } catch (err) {
376
- assert.isTrue(err.message.indexOf('Expected: value1 in jsonPath $.test') > 0)
376
+ assert.isTrue(err.message.indexOf('Expected: "value1" in jsonPath $.test') > 0)
377
377
  }
378
378
  })
379
379
  })