botium-core 1.15.3 → 1.15.5

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.15.3",
3
+ "version": "1.15.5",
4
4
  "description": "The Selenium for Chatbots",
5
5
  "main": "index.js",
6
6
  "module": "dist/botium-es.js",
@@ -262,9 +262,8 @@ module.exports = class SimpleRestContainer {
262
262
  if (requestOptions.body) {
263
263
  debug('Request.form and request.body are mutually exclusive')
264
264
  }
265
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded'
265
266
  requestOptions.body = new URLSearchParams(requestOptions.form).toString()
266
- // it is set automatically by fetch
267
- // requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded'
268
267
  delete requestOptions.form
269
268
  }
270
269
 
@@ -551,7 +550,8 @@ module.exports = class SimpleRestContainer {
551
550
  fetch(requestOptions.uri, requestOptions).then(async (bodyRaw) => {
552
551
  let body
553
552
  try {
554
- if (bodyRaw.headers.get('content-type').includes('application/json')) {
553
+ const contentType = bodyRaw.headers.get('content-type')
554
+ if (contentType && contentType.includes('application/json')) {
555
555
  try {
556
556
  body = await bodyRaw.json()
557
557
  } catch (err) {
@@ -710,9 +710,9 @@ module.exports = class SimpleRestContainer {
710
710
  }
711
711
  }
712
712
  this._addRequestOptions(requestOptions)
713
- this._fetchify(requestOptions)
714
713
  await executeHook(this.caps, this.requestHook, Object.assign({ requestOptions }, this.view))
715
714
  this._addRequestCookies(requestOptions)
715
+ this._fetchify(requestOptions)
716
716
 
717
717
  return requestOptions
718
718
  }
@@ -158,7 +158,8 @@ module.exports = class MediaInput {
158
158
  const baseDir = this._getBaseDir(convo)
159
159
  return args.reduce((e, arg) => {
160
160
  if (this._isWildcard(arg)) {
161
- const mediaFiles = globSync(arg, { cwd: baseDir })
161
+ // we need to escape brackets to find files
162
+ const mediaFiles = globSync(arg.replace(/[()[\]{}]/g, '\\$&'), { cwd: baseDir })
162
163
  mediaFiles.forEach(mf => {
163
164
  e.push({
164
165
  name: 'MEDIA',
@@ -139,8 +139,9 @@ const _assertHook = async (myCaps) => {
139
139
  const request = await container.pluginInstance._buildRequest(msg)
140
140
 
141
141
  assert.exists(request.body)
142
- assert.exists(request.body.bodyFieldRequestHook)
143
- assert.equal(request.body.bodyFieldRequestHook, 1)
142
+ const body = JSON.parse(request.body)
143
+ assert.exists(body.bodyFieldRequestHook)
144
+ assert.equal(body.bodyFieldRequestHook, 1)
144
145
 
145
146
  assert.exists(container.pluginInstance.view)
146
147
  assert.exists(container.pluginInstance.view.context)
@@ -382,9 +383,8 @@ describe('connectors.simplerest', function () {
382
383
  [Capabilities.SIMPLEREST_RESPONSE_JSONPATH]: ['$.status']
383
384
  }
384
385
  const scope = nock('https://mock2.com')
385
- .post('/endpointForm', (body) => {
386
- return body === 'formparam1=valueparam1%2B-%25'
387
- })
386
+ .post('/endpointForm', 'formparam1=valueparam1%2B-%25')
387
+ .matchHeader('Content-Type', 'application/x-www-form-urlencoded')
388
388
  .reply(200, {
389
389
  status: 'ok'
390
390
  })