wingbot 3.31.5-alpha.2 → 3.31.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": "wingbot",
3
- "version": "3.31.5-alpha.2",
3
+ "version": "3.31.7",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -310,7 +310,8 @@ class BuildRouter extends Router {
310
310
  this._configTs = 0;
311
311
  }
312
312
  if (this._prebuiltGlobalIntents !== null) {
313
- this.globalIntents = new Map(this._prebuiltGlobalIntents);
313
+ this.globalIntents.clear();
314
+ this._prebuiltGlobalIntents.forEach(([k, v]) => this.globalIntents.set(k, v));
314
315
  }
315
316
  }
316
317
 
@@ -326,7 +327,8 @@ class BuildRouter extends Router {
326
327
  if (this._prebuiltGlobalIntents === null) {
327
328
  this._prebuiltGlobalIntents = Array.from(this.globalIntents.entries());
328
329
  } else {
329
- this.globalIntents = new Map(this._prebuiltGlobalIntents);
330
+ this.globalIntents.clear();
331
+ this._prebuiltGlobalIntents.forEach(([k, v]) => this.globalIntents.set(k, v));
330
332
  }
331
333
 
332
334
  if (this._prebuiltRoutesCount === null) {
@@ -524,7 +524,7 @@ class ConversationTester {
524
524
  await tester.text(textCase.text);
525
525
 
526
526
  if (textCase.action) {
527
- tester.passedAction(textCase.action);
527
+ tester.passedAction(textCase.action, true);
528
528
  }
529
529
 
530
530
  if (textCase.appId) {
@@ -623,7 +623,7 @@ class ConversationTester {
623
623
  if (!this._options.disableAssertActions) {
624
624
  passedAction.split('\n')
625
625
  .map((a) => (a.trim().match(/^[a-z\-0-9/_]+$/) ? a : tokenize(a)))
626
- .forEach((a) => a && t.passedAction(a));
626
+ .forEach((a) => a && t.passedAction(a, true));
627
627
  }
628
628
 
629
629
  const any = t.any();
package/src/Tester.js CHANGED
@@ -70,8 +70,15 @@ class Tester {
70
70
  };
71
71
 
72
72
  this._listener = (senderIdentifier, action, text, req, prevAction, doNotTrack) => {
73
+ const reqAction = req.action();
74
+ if (reqAction && !this._actionMatches(action, reqAction)) {
75
+ this._actionsCollector.push({
76
+ action: reqAction, text, prevAction, doNotTrack, isReqAction: true
77
+ });
78
+ }
79
+
73
80
  this._actionsCollector.push({
74
- action, text, prevAction, doNotTrack
81
+ action, text, prevAction, doNotTrack, isReqAction: false
75
82
  });
76
83
  };
77
84
 
@@ -255,22 +262,30 @@ class Tester {
255
262
  return new ResponseAssert(this.responses[this.responses.length - 1]);
256
263
  }
257
264
 
265
+ _actionMatches (botAction, path) {
266
+ return botAction === path
267
+ || (path === '*' && botAction === '/*')
268
+ || (!botAction.match(/\*/) && actionMatches(botAction, path));
269
+ }
270
+
258
271
  /**
259
- * Checks, that app past the action
272
+ * Checks, that request passed an interaction
260
273
  *
261
274
  * @param {string} path
275
+ * @param {boolean} [matchRequestActions]
262
276
  * @returns {this}
263
277
  *
264
278
  * @memberOf Tester
265
279
  */
266
- passedAction (path) {
280
+ passedAction (path, matchRequestActions = false) {
267
281
  const ok = this.actions
268
- .some((action) => (action.action === path
269
- || (!action.action.match(/\*/) && actionMatches(action.action, path))));
282
+ .some((action) => (!action.isReqAction || matchRequestActions)
283
+ && this._actionMatches(action.action, path));
270
284
  let actual;
271
285
  if (!ok) {
272
286
  const set = new Set();
273
287
  actual = this.actions
288
+ .filter((a) => !a.isReqAction || matchRequestActions)
274
289
  .map((a) => (a.doNotTrack ? `(system interaction) ${a.action}` : a.action))
275
290
  .filter((a) => !set.has(a) && set.add(a));
276
291
  assert.fail(asserts.ex('Interaction was not passed', path, actual));