botium-core 1.12.2 → 1.12.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/LICENSES-3RDPARTY.txt +901 -751
- package/dist/botium-cjs.js +211 -90
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +211 -90
- package/dist/botium-es.js.map +1 -1
- package/package.json +24 -24
- package/src/BotDriver.js +27 -22
- package/src/Capabilities.js +6 -0
- package/src/Defaults.js +1 -1
- package/src/containers/plugins/SimpleRestContainer.js +117 -35
- package/src/containers/plugins/index.js +1 -1
- package/src/helpers/Utils.js +1 -1
- package/src/scripting/CompilerXlsx.js +2 -2
- package/src/scripting/Convo.js +6 -6
- package/src/scripting/ScriptingProvider.js +1 -1
- package/src/scripting/helper.js +1 -1
- package/src/scripting/logichook/asserter/BaseCountAsserter.js +1 -1
- package/test/connectors/simplerest.spec.js +113 -8
- package/test/logichooks/convos/WAITFORBOT_INFINITE.convo.txt +1 -1
- package/test/logichooks/hookfromsrc.spec.js +1 -1
- package/test/scripting/scriptingProvider.spec.js +1 -1
|
@@ -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
|
|
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
|
|
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
|
|
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 () {
|
|
@@ -760,6 +801,70 @@ describe('connectors.simplerest.processBody', function () {
|
|
|
760
801
|
assert.equal(msgs[2].messageText, 'text 3')
|
|
761
802
|
assert.equal(msgs[2].media[0].mediaUri, 'http://botium.at/3.jpg')
|
|
762
803
|
|
|
804
|
+
await container.Clean()
|
|
805
|
+
})
|
|
806
|
+
it('should process card responses', async function () {
|
|
807
|
+
const myCaps = Object.assign({}, myCapsGet, {
|
|
808
|
+
[Capabilities.SIMPLEREST_RESPONSE_JSONPATH]: '$.text',
|
|
809
|
+
[Capabilities.SIMPLEREST_CARDS_JSONPATH]: '$.cards',
|
|
810
|
+
[Capabilities.SIMPLEREST_CARD_TEXT_JSONPATH]: '$.title',
|
|
811
|
+
[Capabilities.SIMPLEREST_CARD_SUBTEXT_JSONPATH]: '$.subTitle',
|
|
812
|
+
[Capabilities.SIMPLEREST_CARD_ATTACHMENTS_JSONPATH]: '$.media',
|
|
813
|
+
[Capabilities.SIMPLEREST_CARD_BUTTONS_JSONPATH]: '$.buttons[*].text'
|
|
814
|
+
})
|
|
815
|
+
const driver = new BotDriver(myCaps)
|
|
816
|
+
const container = await driver.Build()
|
|
817
|
+
assert.equal(container.pluginInstance.constructor.name, 'SimpleRestContainer')
|
|
818
|
+
|
|
819
|
+
await container.Start()
|
|
820
|
+
const msgs = await container.pluginInstance._processBodyAsyncImpl({
|
|
821
|
+
cards: [
|
|
822
|
+
{
|
|
823
|
+
title: 'card1',
|
|
824
|
+
subTitle: 'card1 sub',
|
|
825
|
+
media: 'http://botium.at/1.jpg',
|
|
826
|
+
buttons: [
|
|
827
|
+
{
|
|
828
|
+
text: 'c1b1'
|
|
829
|
+
},
|
|
830
|
+
{
|
|
831
|
+
text: 'c1b2'
|
|
832
|
+
}
|
|
833
|
+
]
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
title: 'card2',
|
|
837
|
+
subTitle: 'card2 sub',
|
|
838
|
+
media: 'http://botium.at/2.jpg',
|
|
839
|
+
buttons: [
|
|
840
|
+
{
|
|
841
|
+
text: 'c2b1'
|
|
842
|
+
}
|
|
843
|
+
]
|
|
844
|
+
}
|
|
845
|
+
]
|
|
846
|
+
}, true)
|
|
847
|
+
|
|
848
|
+
assert.exists(msgs)
|
|
849
|
+
assert.equal(msgs.length, 1)
|
|
850
|
+
assert.equal(msgs[0].cards.length, 2)
|
|
851
|
+
assert.equal(msgs[0].cards[0].text, 'card1')
|
|
852
|
+
assert.equal(msgs[0].cards[0].subtext, 'card1 sub')
|
|
853
|
+
assert.equal(msgs[0].cards[0].media.length, 1)
|
|
854
|
+
assert.equal(msgs[0].cards[0].media[0].mediaUri, 'http://botium.at/1.jpg')
|
|
855
|
+
assert.equal(msgs[0].cards[0].media[0].mimeType, 'image/jpeg')
|
|
856
|
+
assert.equal(msgs[0].cards[0].buttons.length, 2)
|
|
857
|
+
assert.equal(msgs[0].cards[0].buttons[0].text, 'c1b1')
|
|
858
|
+
assert.equal(msgs[0].cards[0].buttons[1].text, 'c1b2')
|
|
859
|
+
|
|
860
|
+
assert.equal(msgs[0].cards[1].text, 'card2')
|
|
861
|
+
assert.equal(msgs[0].cards[1].subtext, 'card2 sub')
|
|
862
|
+
assert.equal(msgs[0].cards[1].media.length, 1)
|
|
863
|
+
assert.equal(msgs[0].cards[1].media[0].mediaUri, 'http://botium.at/2.jpg')
|
|
864
|
+
assert.equal(msgs[0].cards[1].media[0].mimeType, 'image/jpeg')
|
|
865
|
+
assert.equal(msgs[0].cards[1].buttons.length, 1)
|
|
866
|
+
assert.equal(msgs[0].cards[1].buttons[0].text, 'c2b1')
|
|
867
|
+
|
|
763
868
|
await container.Clean()
|
|
764
869
|
})
|
|
765
870
|
})
|
|
@@ -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
|
|
72
|
+
assert.isTrue(err.message.includes('Line 6: assertion error - Unexpected end of input'))
|
|
73
73
|
}
|
|
74
74
|
})
|
|
75
75
|
})
|
|
@@ -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
|
|
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
|
})
|