botium-core 1.12.3 → 1.12.6

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.
@@ -142,7 +142,8 @@ describe('connectors.simplerest.nock', function () {
142
142
  [Capabilities.SIMPLEREST_URL]: 'http://my-host.com/api/endpoint/{{msg.messageText}}',
143
143
  [Capabilities.SIMPLEREST_HEADERS_TEMPLATE]: { HEADER1: 'HEADER1VALUE', HEADER2: '{{msg.token}}' },
144
144
  [Capabilities.SIMPLEREST_RESPONSE_JSONPATH]: ['$'],
145
- [Capabilities.SIMPLEREST_PING_URL]: 'https://mock.com/pingget'
145
+ [Capabilities.SIMPLEREST_PING_URL]: 'https://mock.com/pingget',
146
+ [Capabilities.SIMPLEREST_COOKIE_REPLICATION]: false
146
147
  }
147
148
  const scope = nock('https://mock.com')
148
149
  .get('/pingget')
@@ -156,7 +157,7 @@ describe('connectors.simplerest.nock', function () {
156
157
  const pingConfig = {
157
158
  method: 'GET',
158
159
  uri: 'https://mock.com/pingget',
159
- body: body,
160
+ body,
160
161
  timeout: 10000
161
162
  }
162
163
  const responseBody = await container.pluginInstance._waitForUrlResponse(pingConfig, 2)
@@ -170,8 +171,8 @@ describe('connectors.simplerest.nock', function () {
170
171
  [Capabilities.SIMPLEREST_HEADERS_TEMPLATE]: { HEADER1: 'HEADER1VALUE', HEADER2: '{{msg.token}}' },
171
172
  [Capabilities.SIMPLEREST_RESPONSE_JSONPATH]: ['$'],
172
173
  [Capabilities.SIMPLEREST_PING_URL]: 'https://mock.com/pingpost',
173
- [Capabilities.SIMPLEREST_PING_RETRIES]: 2
174
-
174
+ [Capabilities.SIMPLEREST_PING_RETRIES]: 2,
175
+ [Capabilities.SIMPLEREST_COOKIE_REPLICATION]: false
175
176
  }
176
177
  const scope = nock('https://mock.com')
177
178
  .post('/pingpost', { status: 'ok?' }, null)
@@ -185,7 +186,7 @@ describe('connectors.simplerest.nock', function () {
185
186
  const pingConfig = {
186
187
  method: 'POST',
187
188
  uri: 'https://mock.com/pingpost',
188
- body: body,
189
+ body,
189
190
  timeout: 100
190
191
  }
191
192
  const responseBody = await container.pluginInstance._waitForUrlResponse(pingConfig, 2)
@@ -201,7 +202,8 @@ describe('connectors.simplerest.nock', function () {
201
202
  [Capabilities.SIMPLEREST_STOP_URL]: 'https://mock.com/stoppost',
202
203
  [Capabilities.SIMPLEREST_STOP_RETRIES]: 2,
203
204
  [Capabilities.SIMPLEREST_STOP_VERB]: 'POST',
204
- [Capabilities.SIMPLEREST_STOP_BODY]: { status: 'ok?' }
205
+ [Capabilities.SIMPLEREST_STOP_BODY]: { status: 'ok?' },
206
+ [Capabilities.SIMPLEREST_COOKIE_REPLICATION]: false
205
207
  }
206
208
  const scope = nock('https://mock.com')
207
209
  .post('/stoppost', { status: 'ok?' }, null)
@@ -222,7 +224,8 @@ describe('connectors.simplerest.nock', function () {
222
224
  [Capabilities.SIMPLEREST_HEADERS_TEMPLATE]: { HEADER1: 'HEADER1VALUE', HEADER2: '{{msg.token}}' },
223
225
  [Capabilities.SIMPLEREST_RESPONSE_JSONPATH]: ['$'],
224
226
  [Capabilities.SIMPLEREST_PING_URL]: 'https://mock.com/pingfail',
225
- [Capabilities.SIMPLEREST_PING_RETRIES]: 2
227
+ [Capabilities.SIMPLEREST_PING_RETRIES]: 2,
228
+ [Capabilities.SIMPLEREST_COOKIE_REPLICATION]: false
226
229
  }
227
230
  const scope = nock('https://mock.com')
228
231
  .get('/pingfail')
@@ -236,7 +239,7 @@ describe('connectors.simplerest.nock', function () {
236
239
  const pingConfig = {
237
240
  method: 'GET',
238
241
  uri: 'https://mock.com/pingfail',
239
- body: body,
242
+ body,
240
243
  timeout: 100
241
244
  }
242
245
  try {
@@ -246,6 +249,44 @@ describe('connectors.simplerest.nock', function () {
246
249
  }
247
250
  scope.persist(false)
248
251
  })
252
+ it('should store cookies from ping and use for user says request', async () => {
253
+ const caps = {
254
+ [Capabilities.CONTAINERMODE]: 'simplerest',
255
+ [Capabilities.SIMPLEREST_URL]: 'https://mock2.com/endpoint',
256
+ [Capabilities.SIMPLEREST_HEADERS_TEMPLATE]: { HEADER1: 'HEADER1VALUE', HEADER2: '{{msg.token}}' },
257
+ [Capabilities.SIMPLEREST_RESPONSE_JSONPATH]: ['$.text'],
258
+ [Capabilities.SIMPLEREST_PING_URL]: 'https://mock2.com/pingget'
259
+ }
260
+ const scope = nock('https://mock2.com')
261
+ .get('/pingget')
262
+ .reply(200, {
263
+ status: 'ok'
264
+ }, {
265
+ 'set-cookie': 'botium=test-cookie'
266
+ }).persist()
267
+
268
+ const scope2 = nock('https://mock2.com', {
269
+ reqheaders: {
270
+ cookie: 'botium=test-cookie'
271
+ }
272
+ })
273
+ .get('/endpoint')
274
+ .reply(200, {
275
+ text: 'you called me'
276
+ })
277
+ .persist()
278
+ const driver = new BotDriver(caps)
279
+ const container = await driver.Build()
280
+ await container.Start()
281
+
282
+ await container.UserSays({ text: 'hallo' })
283
+ await container.WaitBotSays()
284
+
285
+ await container.Stop()
286
+ await container.Clean()
287
+ scope.persist(false)
288
+ scope2.persist(false)
289
+ })
249
290
  })
250
291
 
251
292
  describe('connectors.simplerest.build', function () {
@@ -0,0 +1,16 @@
1
+ continuefailing
2
+
3
+ #me
4
+ Hello
5
+
6
+ #bot
7
+ Hello
8
+
9
+ #me
10
+ Hello again!
11
+
12
+ #bot
13
+ Hello again FAILING!
14
+
15
+ #bot
16
+ working again
@@ -47,7 +47,8 @@ describe('convo.transcript', function () {
47
47
  [Capabilities.PROJECTNAME]: 'convo.transcript',
48
48
  [Capabilities.CONTAINERMODE]: echoConnector,
49
49
  [Capabilities.SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS]: true,
50
- [Capabilities.SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS]: true
50
+ [Capabilities.SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS]: true,
51
+ [Capabilities.WAITFORBOTTIMEOUT]: 500
51
52
  }
52
53
  this.driverSkipAssertErrors = new BotDriver(myCapsSkipAssertErrors)
53
54
  this.compilerSkipAssertErrors = this.driverSkipAssertErrors.BuildCompiler()
@@ -381,4 +382,20 @@ describe('convo.transcript', function () {
381
382
  assert.isNull(err.transcript.steps[5].err)
382
383
  }
383
384
  })
385
+ it('should continue on failing assertion with timeout', async function () {
386
+ this.compilerSkipAssertErrors.ReadScript(path.resolve(__dirname, 'convos'), 'continuefailing_timeout.convo.txt')
387
+ assert.equal(this.compilerSkipAssertErrors.convos.length, 1)
388
+
389
+ try {
390
+ await this.compilerSkipAssertErrors.convos[0].Run(this.containerSkipAssertErrors)
391
+ assert.fail('expected error')
392
+ } catch (err) {
393
+ assert.isDefined(err.cause)
394
+ assert.equal(err.cause.message, 'continuefailing/Line 12: Bot response (on Line 9: #me - Hello again!) "Hello again!" expected to match "Hello again FAILING!",\ncontinuefailing/Line 15: error waiting for bot - Bot did not respond within 500ms')
395
+ assert.equal(err.cause.context.errors.length, 2)
396
+
397
+ assert.isDefined(err.transcript)
398
+ assert.equal(err.transcript.steps.length, 5)
399
+ }
400
+ })
384
401
  })
@@ -1,4 +1,4 @@
1
- WAITFORBOT INFINTE
1
+ WAITFORBOT INFINITE
2
2
 
3
3
  #me
4
4
  Hello
@@ -69,7 +69,7 @@ describe('logichooks.hookfromsrc', function () {
69
69
  await compiler.convos[0].Run(container)
70
70
  assert.fail('it should have failed')
71
71
  } catch (err) {
72
- assert.isTrue(err.message.includes('Line 6: assertion error - Unexpected token'))
72
+ assert.isTrue(err.message.includes('Line 6: assertion error - Unexpected end of input'))
73
73
  }
74
74
  })
75
75
  })
@@ -263,3 +263,50 @@ describe('scripting.asserters.buttonsCountAsserter', function () {
263
263
  })
264
264
  })
265
265
  })
266
+
267
+ describe('scripting.asserters.buttonsNormalizeAsserter', function () {
268
+ beforeEach(async function () {
269
+ this.cardsAsserter = new ButtonsAsserter({
270
+ Match: (botresponse, utterance) => botresponse.toLowerCase().indexOf(utterance.toLowerCase()) >= 0
271
+ }, { SCRIPTING_NORMALIZE_TEXT: true })
272
+ })
273
+
274
+ it('should succeed with normalized text', async function () {
275
+ await this.cardsAsserter.assertConvoStep({
276
+ convoStep: { stepTag: 'test' },
277
+ args: ['Test Html header test html text'],
278
+ botMsg: {
279
+ buttons: [
280
+ {
281
+ text: '<html><h1>test html header</h1><p>test html text</p>'
282
+ }
283
+ ]
284
+ }
285
+ })
286
+ })
287
+
288
+ it('should fail with normalized text', async function () {
289
+ try {
290
+ await this.cardsAsserter.assertConvoStep({
291
+ convoStep: { stepTag: 'test' },
292
+ args: ['Test Html header1 test html text'],
293
+ botMsg: {
294
+ buttons: [
295
+ {
296
+ text: '<html><h1>test html header</h1><p>test html text</p>'
297
+ }
298
+ ]
299
+ }
300
+ })
301
+ assert.fail('should have failed')
302
+ } catch (err) {
303
+ assert.isTrue(err.message.indexOf('Expected button(s) with text "Test Html header1 test html text"') > 0)
304
+ assert.isNotNull(err.context)
305
+ assert.isNotNull(err.context.cause)
306
+ assert.isArray(err.context.cause.expected)
307
+ assert.deepEqual(err.context.cause.expected, ['Test Html header1 test html text'])
308
+ assert.deepEqual(err.context.cause.actual, ['test html header test html text'])
309
+ assert.deepEqual(err.context.cause.diff, ['Test Html header1 test html text'])
310
+ }
311
+ })
312
+ })
@@ -243,3 +243,42 @@ describe('scripting.asserters.cardsCountAsserter', function () {
243
243
  })
244
244
  })
245
245
  })
246
+
247
+ describe('scripting.asserters.cardsNormalizeAsserter', function () {
248
+ beforeEach(async function () {
249
+ this.cardsAsserter = new CardsAsserter({
250
+ Match: (botresponse, utterance) => botresponse.toLowerCase().indexOf(utterance.toLowerCase()) >= 0
251
+ }, { SCRIPTING_NORMALIZE_TEXT: true })
252
+ })
253
+
254
+ it('should succeed with normalized text', async function () {
255
+ await this.cardsAsserter.assertConvoStep({
256
+ convoStep: { stepTag: 'test' },
257
+ args: ['Test Html header test html text'],
258
+ botMsg: {
259
+ cards: [{ text: '<html><h1>test html header</h1><p>test html text</p>' }]
260
+ }
261
+ })
262
+ })
263
+
264
+ it('should fail with normalized text', async function () {
265
+ try {
266
+ await this.cardsAsserter.assertConvoStep({
267
+ convoStep: { stepTag: 'test' },
268
+ args: ['Test Html header1 test html text'],
269
+ botMsg: {
270
+ cards: [{ text: '<html><h1>test html header</h1><p>test html text</p>' }]
271
+ }
272
+ })
273
+ assert.fail('should have failed')
274
+ } catch (err) {
275
+ assert.isTrue(err.message.indexOf('Expected card(s) with text "Test Html header1 test html text"') > 0)
276
+ assert.isNotNull(err.context)
277
+ assert.isNotNull(err.context.cause)
278
+ assert.isArray(err.context.cause.expected)
279
+ assert.deepEqual(err.context.cause.expected, ['Test Html header1 test html text'])
280
+ assert.deepEqual(err.context.cause.actual, ['test html header test html text'])
281
+ assert.deepEqual(err.context.cause.diff, ['Test Html header1 test html text'])
282
+ }
283
+ })
284
+ })
@@ -226,7 +226,7 @@ describe('scriptingProvider._tagAndCleanupUtterances', function () {
226
226
  it('positive case remove empty String from utterances', async function () {
227
227
  const scriptingProvider = new ScriptingProvider()
228
228
  const utterances = ['don\'t understand', 'sorry', '']
229
- const fileUtterances = [{ name: 'INCOMPREHENSION', utterances: utterances }]
229
+ const fileUtterances = [{ name: 'INCOMPREHENSION', utterances }]
230
230
  const actualResult = scriptingProvider._tagAndCleanupUtterances(fileUtterances, 'mydir', 'incomprehension.utterances.txt')
231
231
  expect(actualResult[0].utterances).to.eql(utterances.slice(0, 2))
232
232
  })
@@ -634,6 +634,30 @@ CARDS text of card2
634
634
  #me
635
635
  some text
636
636
  CUSTOMINPUT arg1|arg2
637
+ `
638
+ )
639
+ })
640
+ it('should escape pipe in args', async function () {
641
+ const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
642
+ await scriptingProvider.Build()
643
+
644
+ const convo = {
645
+ header: {
646
+ name: 'test convo'
647
+ },
648
+ conversation: [
649
+ {
650
+ sender: 'me',
651
+ userInputs: [{ name: 'CUSTOMINPUT', args: ['arg|1', 'arg|2'] }]
652
+ }
653
+ ]
654
+ }
655
+
656
+ const script = scriptingProvider.Decompile([convo], 'SCRIPTING_FORMAT_TXT')
657
+ assert.equal(script, `test convo
658
+
659
+ #me
660
+ CUSTOMINPUT arg\\|1|arg\\|2
637
661
  `
638
662
  )
639
663
  })