botium-core 1.13.17 → 1.13.19

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.
Files changed (38) hide show
  1. package/README.md +0 -1
  2. package/dist/botium-cjs.js +118 -15
  3. package/dist/botium-cjs.js.map +1 -1
  4. package/dist/botium-es.js +118 -15
  5. package/dist/botium-es.js.map +1 -1
  6. package/package.json +2 -1
  7. package/src/BotDriver.js +2 -2
  8. package/src/Capabilities.js +6 -0
  9. package/src/containers/BaseContainer.js +7 -4
  10. package/src/containers/plugins/SimpleRestContainer.js +49 -0
  11. package/src/scripting/Convo.js +21 -0
  12. package/src/scripting/ScriptingProvider.js +19 -2
  13. package/src/scripting/logichook/LogicHookConsts.js +5 -1
  14. package/src/scripting/logichook/asserter/ButtonsAsserter.js +21 -8
  15. package/src/scripting/logichook/logichooks/ClearQueueLogicHook.js +0 -1
  16. package/src/scripting/logichook/logichooks/ConditionalBusinessHoursLogicHook.js +56 -0
  17. package/src/scripting/logichook/logichooks/ConditionalCapabilityValueBasedLogicHook.js +37 -0
  18. package/src/scripting/logichook/logichooks/ConditionalJsonPathBasedLogicHook.js +31 -0
  19. package/src/scripting/logichook/logichooks/ConditionalTimeBasedLogicHook.js +46 -0
  20. package/test/connectors/logicHook.js +0 -1
  21. package/test/connectors/simplerest.spec.js +79 -4
  22. package/test/scripting/asserters/buttonsAsserter.spec.js +84 -50
  23. package/test/scripting/logichooks/CustomConditionalLogicHook.js +21 -0
  24. package/test/scripting/logichooks/conditionalStepBusinessHoursLogicHook.spec.js +130 -0
  25. package/test/scripting/logichooks/conditionalStepCapabilityValueBasedLogicHook.spec.js +35 -0
  26. package/test/scripting/logichooks/conditionalStepJsonPathBasedLogicHook.spec.js +35 -0
  27. package/test/scripting/logichooks/conditionalStepTimeBasedLogicHook.spec.js +91 -0
  28. package/test/scripting/logichooks/convos/conditional_steps.convo.txt +12 -0
  29. package/test/scripting/logichooks/convos/conditional_steps_business_hours.convo.txt +16 -0
  30. package/test/scripting/logichooks/convos/conditional_steps_cap_value_based.convo.txt +12 -0
  31. package/test/scripting/logichooks/convos/conditional_steps_followed_by_bot_msg.convo.txt +15 -0
  32. package/test/scripting/logichooks/convos/conditional_steps_followed_by_me.convo.txt +18 -0
  33. package/test/scripting/logichooks/convos/conditional_steps_json_path_based.convo.txt.convo.txt +12 -0
  34. package/test/scripting/logichooks/convos/conditional_steps_multiple_condition_groups.convo.txt +20 -0
  35. package/test/scripting/logichooks/convos/conditional_steps_multiple_condition_groups_no_assertion.convo.txt +20 -0
  36. package/test/scripting/logichooks/convos/conditional_steps_time_based.convo.txt +12 -0
  37. package/test/scripting/logichooks/customConditionalStepLogicHook.spec.js +105 -0
  38. package/test/scripting/scriptingProvider.spec.js +1 -1
@@ -12,28 +12,36 @@ describe('scripting.asserters.buttonsAsserter', function () {
12
12
  })
13
13
 
14
14
  it('should succeed on existing button', async function () {
15
+ const payload = {
16
+ value: 'test'
17
+ }
15
18
  await this.buttonsAsserter.assertConvoStep({
16
19
  convoStep: { stepTag: 'test' },
17
- args: ['test'],
20
+ args: ['test', JSON.stringify(payload)],
18
21
  botMsg: {
19
22
  buttons: [
20
23
  {
21
- text: 'test'
24
+ text: 'test',
25
+ payload
22
26
  }
23
27
  ]
24
28
  }
25
29
  })
26
30
  })
27
31
  it('should succeed on existing card button', async function () {
32
+ const payload = {
33
+ value: 'test'
34
+ }
28
35
  await this.buttonsAsserter.assertConvoStep({
29
36
  convoStep: { stepTag: 'test' },
30
- args: ['test'],
37
+ args: ['test', JSON.stringify(payload)],
31
38
  botMsg: {
32
39
  cards: [
33
40
  {
34
41
  buttons: [
35
42
  {
36
- text: 'test'
43
+ text: 'test',
44
+ payload
37
45
  }
38
46
  ]
39
47
  }
@@ -42,42 +50,28 @@ describe('scripting.asserters.buttonsAsserter', function () {
42
50
  })
43
51
  })
44
52
  it('should succeed on existing card buttons', async function () {
53
+ const payload = {
54
+ value: 'test'
55
+ }
56
+ const payloadCard = {
57
+ value: 'card'
58
+ }
45
59
  await this.buttonsAsserter.assertConvoStep({
46
60
  convoStep: { stepTag: 'test' },
47
- args: ['test', 'test1'],
48
- botMsg: {
49
- buttons: [
50
- {
51
- text: 'test'
52
- }
53
- ],
54
- cards: [
55
- {
56
- buttons: [
57
- {
58
- text: 'test1'
59
- }
60
- ]
61
- }
62
- ]
63
- }
64
- })
65
- })
66
- it('should succeed on existing card buttons 2', async function () {
67
- await this.buttonsAsserter.assertConvoStep({
68
- convoStep: { stepTag: 'test' },
69
- args: ['test', 'test1'],
61
+ args: ['test', 'test1', JSON.stringify(payload), JSON.stringify(payloadCard)],
70
62
  botMsg: {
71
63
  buttons: [
72
64
  {
73
- text: 'test'
65
+ text: 'test',
66
+ payload
74
67
  }
75
68
  ],
76
69
  cards: [
77
70
  {
78
71
  buttons: [
79
72
  {
80
- text: 'test1'
73
+ text: 'test1',
74
+ payload: payloadCard
81
75
  }
82
76
  ]
83
77
  }
@@ -86,29 +80,36 @@ describe('scripting.asserters.buttonsAsserter', function () {
86
80
  })
87
81
  })
88
82
  it('should succeed on not existing button', async function () {
83
+ const notPayload = {
84
+ value: 'test1'
85
+ }
89
86
  await this.buttonsAsserter.assertNotConvoStep({
90
87
  convoStep: { stepTag: 'test' },
91
- args: ['test1'],
88
+ args: ['test1', JSON.stringify(notPayload)],
92
89
  botMsg: {
93
90
  buttons: [
94
91
  {
95
- text: 'test'
92
+ text: 'test',
93
+ payload: {
94
+ value: 'test'
95
+ }
96
96
  }
97
97
  ]
98
98
  }
99
99
  })
100
100
  })
101
101
  it('should fail on unexpected button', async function () {
102
+ const buttons = [
103
+ {
104
+ text: 'test'
105
+ }
106
+ ]
102
107
  try {
103
108
  await this.buttonsAsserter.assertNotConvoStep({
104
109
  convoStep: { stepTag: 'test' },
105
110
  args: ['test', 'test1'],
106
111
  botMsg: {
107
- buttons: [
108
- {
109
- text: 'test'
110
- }
111
- ]
112
+ buttons
112
113
  }
113
114
  })
114
115
  assert.fail('should have failed')
@@ -119,10 +120,40 @@ describe('scripting.asserters.buttonsAsserter', function () {
119
120
  assert.isArray(err.context.cause.expected)
120
121
  assert.isTrue(err.context.cause.not)
121
122
  assert.deepEqual(err.context.cause.expected, ['test', 'test1'])
122
- assert.deepEqual(err.context.cause.actual, ['test'])
123
+ assert.deepEqual(err.context.cause.actual, JSON.stringify(buttons, null, 2))
123
124
  assert.deepEqual(err.context.cause.diff, ['test'])
124
125
  }
125
126
  })
127
+ it('should fail on unexpected button payload', async function () {
128
+ const payload = {
129
+ value: 'test'
130
+ }
131
+ const buttons = [
132
+ {
133
+ text: 'test',
134
+ payload
135
+ }
136
+ ]
137
+ try {
138
+ await this.buttonsAsserter.assertNotConvoStep({
139
+ convoStep: { stepTag: 'test' },
140
+ args: [JSON.stringify(payload)],
141
+ botMsg: {
142
+ buttons
143
+ }
144
+ })
145
+ assert.fail('should have failed')
146
+ } catch (err) {
147
+ assert.isTrue(err.message.indexOf(`Not expected button(s) with text "${JSON.stringify(payload)}"`) > 0)
148
+ assert.isNotNull(err.context)
149
+ assert.isNotNull(err.context.cause)
150
+ assert.isArray(err.context.cause.expected)
151
+ assert.isTrue(err.context.cause.not)
152
+ assert.deepEqual(err.context.cause.expected, [JSON.stringify(payload)])
153
+ assert.deepEqual(err.context.cause.actual, JSON.stringify(buttons, null, 2))
154
+ assert.deepEqual(err.context.cause.diff, [JSON.stringify(payload)])
155
+ }
156
+ })
126
157
  it('should succeed on existing button if has no arg', async function () {
127
158
  await this.buttonsAsserter.assertConvoStep({
128
159
  convoStep: { stepTag: 'test' },
@@ -147,23 +178,24 @@ describe('scripting.asserters.buttonsAsserter', function () {
147
178
  assert.isArray(err.context.cause.expected)
148
179
  assert.isNotTrue(err.context.cause.not)
149
180
  assert.deepEqual(err.context.cause.expected, [])
150
- assert.deepEqual(err.context.cause.actual, [])
181
+ assert.deepEqual(err.context.cause.actual, '[]')
151
182
  }
152
183
  })
153
184
  it('should succeed on not existing button if has no arg and negated', async function () {
154
185
  await this.buttonsAsserter.assertNotConvoStep({ convoStep: { stepTag: 'test' } })
155
186
  })
156
187
  it('should fail on button if has no arg and negated', async function () {
188
+ const buttons = [
189
+ {
190
+ text: 'test'
191
+ }
192
+ ]
157
193
  try {
158
194
  await this.buttonsAsserter.assertNotConvoStep({
159
195
  convoStep: { stepTag: 'test' },
160
196
  args: [],
161
197
  botMsg: {
162
- buttons: [
163
- {
164
- text: 'test'
165
- }
166
- ]
198
+ buttons
167
199
  }
168
200
  })
169
201
  assert.fail('should have failed')
@@ -174,7 +206,7 @@ describe('scripting.asserters.buttonsAsserter', function () {
174
206
  assert.isArray(err.context.cause.expected)
175
207
  assert.isTrue(err.context.cause.not)
176
208
  assert.deepEqual(err.context.cause.expected, [])
177
- assert.deepEqual(err.context.cause.actual, ['test'])
209
+ assert.deepEqual(err.context.cause.actual, JSON.stringify(buttons, null, 2))
178
210
  }
179
211
  })
180
212
  })
@@ -302,16 +334,17 @@ describe('scripting.asserters.buttonsAsserter', function () {
302
334
  })
303
335
 
304
336
  it('should fail with normalized text', async function () {
337
+ const buttons = [
338
+ {
339
+ text: '<html><h1>test html header</h1><p>test html text</p>'
340
+ }
341
+ ]
305
342
  try {
306
343
  await this.cardsAsserter.assertConvoStep({
307
344
  convoStep: { stepTag: 'test' },
308
345
  args: ['Test Html header1 test html text'],
309
346
  botMsg: {
310
- buttons: [
311
- {
312
- text: '<html><h1>test html header</h1><p>test html text</p>'
313
- }
314
- ]
347
+ buttons
315
348
  }
316
349
  })
317
350
  assert.fail('should have failed')
@@ -321,7 +354,8 @@ describe('scripting.asserters.buttonsAsserter', function () {
321
354
  assert.isNotNull(err.context.cause)
322
355
  assert.isArray(err.context.cause.expected)
323
356
  assert.deepEqual(err.context.cause.expected, ['Test Html header1 test html text'])
324
- assert.deepEqual(err.context.cause.actual, ['test html header test html text'])
357
+ buttons[0].text = 'test html header test html text'
358
+ assert.deepEqual(err.context.cause.actual, JSON.stringify(buttons, null, 2))
325
359
  assert.deepEqual(err.context.cause.diff, ['Test Html header1 test html text'])
326
360
  }
327
361
  })
@@ -0,0 +1,21 @@
1
+ module.exports = class ConditionalLogicHook {
2
+ constructor (context, caps, globalArgs) {
3
+ this.context = context
4
+ this.caps = caps
5
+ this.globalArgs = globalArgs
6
+ }
7
+
8
+ onBotPrepare ({ convo, convoStep, args }) {
9
+ const conditionGroupId = args[1]
10
+ let params
11
+ try {
12
+ params = JSON.parse(args[0])
13
+ } catch (e) {
14
+ throw new Error(`ConditionalCapabilityValueLogicHook: No parsable JSON object found in params: ${e}`)
15
+ }
16
+ convoStep.conditional = {
17
+ conditionGroupId
18
+ }
19
+ convoStep.conditional.skip = params.skip
20
+ }
21
+ }
@@ -0,0 +1,130 @@
1
+ const path = require('path')
2
+ const moment = require('moment/moment')
3
+ const assert = require('chai').assert
4
+ const BotDriver = require('../../../index').BotDriver
5
+ const Capabilities = require('../../../index').Capabilities
6
+ const ConditionalBusinessHoursLogicHook = require('../../../src/scripting/logichook/logichooks/ConditionalBusinessHoursLogicHook')
7
+
8
+ const echoConnector = ({ queueBotSays }) => {
9
+ return {
10
+ UserSays (msg) {
11
+ const now = moment()
12
+ const start = moment('8:00', [moment.ISO_8601, 'HH:mm'])
13
+ const end = moment('16:30', [moment.ISO_8601, 'HH:mm'])
14
+ if (start.isSameOrAfter(end)) {
15
+ if (now.isSameOrAfter(start)) {
16
+ end.add(1, 'days')
17
+ } else {
18
+ start.add(-1, 'days')
19
+ }
20
+ }
21
+ const businessHoursText = ['Saturday', 'Sunday'].includes(now.format('dddd'))
22
+ ? 'it\'s non-business hours'
23
+ : now.isBetween(start, end, 'minutes', '[]')
24
+ ? 'it\'s business hours'
25
+ : 'it\'s non-business hours'
26
+ const botMsg = { sender: 'bot', sourceData: msg.sourceData, messageText: `Hello, ${businessHoursText}` }
27
+ queueBotSays(botMsg)
28
+ }
29
+ }
30
+ }
31
+
32
+ describe('convo with business hours conditional logichook', function () {
33
+ beforeEach(async function () {
34
+ const myCaps = {
35
+ [Capabilities.PROJECTNAME]: 'scripting.logichooks',
36
+ [Capabilities.CONTAINERMODE]: echoConnector,
37
+ [Capabilities.SCRIPTING_ENABLE_MEMORY]: true
38
+ }
39
+ const driver = new BotDriver(myCaps)
40
+ this.compiler = driver.BuildCompiler()
41
+ this.container = await driver.Build()
42
+ })
43
+
44
+ afterEach(async function () {
45
+ this.container && await this.container.Clean()
46
+ })
47
+
48
+ it('should success', async function () {
49
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'conditional_steps_business_hours.convo.txt')
50
+ await this.compiler.convos[0].Run(this.container)
51
+ })
52
+
53
+ it('is between Monday-Friday 8:00-16:00', async function () {
54
+ const clh = new ConditionalBusinessHoursLogicHook()
55
+ const params = {
56
+ days: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
57
+ start: '8:00',
58
+ end: '16:00'
59
+ }
60
+ // Monday 10:00
61
+ params.now = moment('2023-08-21T10:00:00')
62
+ assert.isTrue(clh._isBetween(params))
63
+ // Monday 08:00
64
+ params.now = moment('2023-08-21T08:00:00')
65
+ assert.isTrue(clh._isBetween(params))
66
+ // Monday 16:00
67
+ params.now = moment('2023-08-21T16:00:00')
68
+ assert.isTrue(clh._isBetween(params))
69
+ // Monday 16:01
70
+ params.now = moment('2023-08-21T16:01:00')
71
+ assert.isFalse(clh._isBetween(params))
72
+ // Sunday 10:00
73
+ params.now = moment('2023-08-20T10:00:00')
74
+ assert.isFalse(clh._isBetween(params))
75
+ // Friday 16:01
76
+ params.now = moment('2023-08-25T16:01:00')
77
+ assert.isFalse(clh._isBetween(params))
78
+ })
79
+
80
+ it('is between Monday-Friday 16:01-7:59', async function () {
81
+ const clh = new ConditionalBusinessHoursLogicHook()
82
+ const params = {
83
+ days: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
84
+ start: '16:01',
85
+ end: '7:59'
86
+ }
87
+
88
+ // Monday 17:00
89
+ params.now = moment('2023-08-21T17:00:00')
90
+ assert.isTrue(clh._isBetween(params))
91
+ // Monday 05:00
92
+ params.now = moment('2023-08-21T05:00:00')
93
+ assert.isTrue(clh._isBetween(params))
94
+ // Monday 16:01
95
+ params.now = moment('2023-08-21T16:01:00')
96
+ assert.isTrue(clh._isBetween(params))
97
+ // Monday 07:59
98
+ params.now = moment('2023-08-21T07:59:00')
99
+ assert.isTrue(clh._isBetween(params))
100
+ // Friday 23:00
101
+ params.now = moment('2023-08-25T23:00:00')
102
+ assert.isTrue(clh._isBetween(params))
103
+ // Monday 16:00
104
+ params.now = moment('2023-08-21T16:00:00')
105
+ assert.isFalse(clh._isBetween(params))
106
+ // Sunday 23:00
107
+ params.now = moment('2023-08-20T23:00:00')
108
+ assert.isFalse(clh._isBetween(params))
109
+ })
110
+
111
+ it('is on Saturday or Sunday', async function () {
112
+ const clh = new ConditionalBusinessHoursLogicHook()
113
+ const params = {
114
+ days: ['Saturday', 'Sunday']
115
+ }
116
+
117
+ // Sunday 17:00
118
+ params.now = moment('2023-08-20T17:00:00')
119
+ assert.isTrue(clh._isBetween(params))
120
+ // Saturday 05:00
121
+ params.now = moment('2023-08-19T05:00:00')
122
+ assert.isTrue(clh._isBetween(params))
123
+ // Monday 16:01
124
+ params.now = moment('2023-08-21T16:01:00')
125
+ assert.isFalse(clh._isBetween(params))
126
+ // Friday 23:00
127
+ params.now = moment('2023-08-25T23:00:00')
128
+ assert.isFalse(clh._isBetween(params))
129
+ })
130
+ })
@@ -0,0 +1,35 @@
1
+ const path = require('path')
2
+ const BotDriver = require('../../../index').BotDriver
3
+ const Capabilities = require('../../../index').Capabilities
4
+
5
+ const echoConnector = ({ queueBotSays }) => {
6
+ return {
7
+ UserSays (msg) {
8
+ const botMsg = { sender: 'bot', sourceData: msg.sourceData, messageText: msg.messageText }
9
+ queueBotSays(botMsg)
10
+ }
11
+ }
12
+ }
13
+
14
+ describe('convo with capablility value based conditional logichook', function () {
15
+ beforeEach(async function () {
16
+ const myCaps = {
17
+ [Capabilities.PROJECTNAME]: 'scripting.logichooks',
18
+ [Capabilities.CONTAINERMODE]: echoConnector,
19
+ [Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
20
+ SIMPLE_TEXT: 'echo1'
21
+ }
22
+ const driver = new BotDriver(myCaps)
23
+ this.compiler = driver.BuildCompiler()
24
+ this.container = await driver.Build()
25
+ })
26
+
27
+ afterEach(async function () {
28
+ this.container && await this.container.Clean()
29
+ })
30
+
31
+ it('should success', async function () {
32
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'conditional_steps_cap_value_based.convo.txt')
33
+ await this.compiler.convos[0].Run(this.container)
34
+ })
35
+ })
@@ -0,0 +1,35 @@
1
+ const path = require('path')
2
+ const BotDriver = require('../../../index').BotDriver
3
+ const Capabilities = require('../../../index').Capabilities
4
+
5
+ const echoConnector = ({ queueBotSays }) => {
6
+ return {
7
+ UserSays (msg) {
8
+ const botMsg = { sender: 'bot', sourceData: msg.sourceData, messageText: msg.messageText }
9
+ queueBotSays(botMsg)
10
+ }
11
+ }
12
+ }
13
+
14
+ describe('convo with capablility value based conditional logichook', function () {
15
+ beforeEach(async function () {
16
+ const myCaps = {
17
+ [Capabilities.PROJECTNAME]: 'scripting.logichooks',
18
+ [Capabilities.CONTAINERMODE]: echoConnector,
19
+ [Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
20
+ SIMPLE_TEXT: 'echo1'
21
+ }
22
+ const driver = new BotDriver(myCaps)
23
+ this.compiler = driver.BuildCompiler()
24
+ this.container = await driver.Build()
25
+ })
26
+
27
+ afterEach(async function () {
28
+ this.container && await this.container.Clean()
29
+ })
30
+
31
+ it('should success', async function () {
32
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'conditional_steps_json_path_based.convo.txt.convo.txt')
33
+ await this.compiler.convos[0].Run(this.container)
34
+ })
35
+ })
@@ -0,0 +1,91 @@
1
+ const path = require('path')
2
+ const moment = require('moment/moment')
3
+ const assert = require('chai').assert
4
+ const BotDriver = require('../../../index').BotDriver
5
+ const Capabilities = require('../../../index').Capabilities
6
+ const ConditionalTimeBasedLogicHook = require('../../../src/scripting/logichook/logichooks/ConditionalTimeBasedLogicHook')
7
+
8
+ const echoConnector = ({ queueBotSays }) => {
9
+ return {
10
+ UserSays (msg) {
11
+ const now = moment()
12
+ const start = moment('8:00', [moment.ISO_8601, 'HH:mm'])
13
+ const end = moment('16:30', [moment.ISO_8601, 'HH:mm'])
14
+ if (start.isSameOrAfter(end)) {
15
+ if (now.isSameOrAfter(start)) {
16
+ end.add(1, 'days')
17
+ } else {
18
+ start.add(-1, 'days')
19
+ }
20
+ }
21
+ const businessHoursText = now.isBetween(start, end, 'minutes', '[]') ? 'we are open' : 'we are closed'
22
+ const botMsg = { sender: 'bot', sourceData: msg.sourceData, messageText: `Hello, ${businessHoursText}` }
23
+ queueBotSays(botMsg)
24
+ }
25
+ }
26
+ }
27
+
28
+ describe('convo with time based conditional logichook', function () {
29
+ beforeEach(async function () {
30
+ const myCaps = {
31
+ [Capabilities.PROJECTNAME]: 'scripting.logichooks',
32
+ [Capabilities.CONTAINERMODE]: echoConnector,
33
+ [Capabilities.SCRIPTING_ENABLE_MEMORY]: true
34
+ }
35
+ const driver = new BotDriver(myCaps)
36
+ this.compiler = driver.BuildCompiler()
37
+ this.container = await driver.Build()
38
+ })
39
+
40
+ afterEach(async function () {
41
+ this.container && await this.container.Clean()
42
+ })
43
+
44
+ it('should success', async function () {
45
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'conditional_steps_time_based.convo.txt')
46
+ await this.compiler.convos[0].Run(this.container)
47
+ })
48
+
49
+ it('is between 8:00-16:00', async function () {
50
+ const clh = new ConditionalTimeBasedLogicHook()
51
+ const params = {
52
+ start: '8:00',
53
+ end: '16:00'
54
+ }
55
+ // Monday 10:00
56
+ params.now = moment('2023-08-21T10:00:00')
57
+ assert.isTrue(clh._isBetween(params))
58
+ // Monday 08:00
59
+ params.now = moment('2023-08-21T08:00:00')
60
+ assert.isTrue(clh._isBetween(params))
61
+ // Monday 16:00
62
+ params.now = moment('2023-08-21T16:00:00')
63
+ assert.isTrue(clh._isBetween(params))
64
+ // Monday 16:01
65
+ params.now = moment('2023-08-21T16:01:00')
66
+ assert.isFalse(clh._isBetween(params))
67
+ })
68
+
69
+ it('is between 16:01-7:59', async function () {
70
+ const clh = new ConditionalTimeBasedLogicHook()
71
+ const params = {
72
+ start: '16:01',
73
+ end: '7:59'
74
+ }
75
+ // Monday 17:00
76
+ params.now = moment('2023-08-21T17:00:00')
77
+ assert.isTrue(clh._isBetween(params))
78
+ // Monday 05:00
79
+ params.now = moment('2023-08-21T05:00:00')
80
+ assert.isTrue(clh._isBetween(params))
81
+ // Monday 16:01
82
+ params.now = moment('2023-08-21T16:01:00')
83
+ assert.isTrue(clh._isBetween(params))
84
+ // Monday 07:59
85
+ params.now = moment('2023-08-21T07:59:00')
86
+ assert.isTrue(clh._isBetween(params))
87
+ // Monday 16:00
88
+ params.now = moment('2023-08-21T16:00:00')
89
+ assert.isFalse(clh._isBetween(params))
90
+ })
91
+ })
@@ -0,0 +1,12 @@
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
@@ -0,0 +1,16 @@
1
+ conditional_steps_time_based
2
+
3
+ #me
4
+ hello
5
+
6
+ #bot
7
+ hello, it's business hours
8
+ CONDITIONAL_STEP_BUSINESS_HOURS { "days": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"], "start":"8:00", "end": "16:30" }
9
+
10
+ #bot
11
+ hello, it's non-business hours
12
+ CONDITIONAL_STEP_BUSINESS_HOURS { "days": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"], "start":"16:31", "end": "7:59" }
13
+
14
+ #bot
15
+ hello, it's non-business hours
16
+ CONDITIONAL_STEP_BUSINESS_HOURS { "days": ["Saturday", "Sunday"] }
@@ -0,0 +1,12 @@
1
+ conditional_steps_time_based
2
+
3
+ #me
4
+ hello
5
+
6
+ #bot
7
+ hello
8
+ CONDITIONAL_STEP_CAPABILITY_VALUE_BASED { "capabilityName":"SIMPLE_TEXT", "value": "echo1" }
9
+
10
+ #bot
11
+ fail
12
+ CONDITIONAL_STEP_CAPABILITY_VALUE_BASED { "capabilityName":"SIMPLE_TEXT", "value": "echo2" }
@@ -0,0 +1,15 @@
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 Duplicate
@@ -0,0 +1,18 @@
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
+ #me
15
+ hello
16
+
17
+ #bot
18
+ hello
@@ -0,0 +1,12 @@
1
+ conditional_steps_time_based
2
+
3
+ #me
4
+ hello
5
+
6
+ #bot
7
+ hello
8
+ CONDITIONAL_STEP_JSON_PATH_BASED { "jsonPath":"$.messageText", "value": "hello" }
9
+
10
+ #bot
11
+ fail
12
+ CONDITIONAL_STEP_JSON_PATH_BASED { "jsonPath":"$.messageText", "value": "fail" }
@@ -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 Duplicate
16
+ CONDITIONAL_STEP_LOGIC_HOOK { "skip":false }|G2
17
+
18
+ #bot
19
+ hello should not assert
20
+ CONDITIONAL_STEP_LOGIC_HOOK { "skip":true }|G2