2022-10-23 05:55:03 +03:00
|
|
|
import axios from 'axios'
|
2022-02-03 16:44:49 +03:00
|
|
|
|
2022-11-13 19:49:24 +03:00
|
|
|
import server from '@/core/http-server/http-server'
|
2022-02-03 16:44:49 +03:00
|
|
|
|
|
|
|
const urlPrefix = `${process.env.LEON_HOST}:${process.env.LEON_PORT}/api`
|
|
|
|
const queryUrl = `${urlPrefix}/query`
|
2022-09-03 14:12:41 +03:00
|
|
|
const actionSkillUrl = `${urlPrefix}/p/leon/randomnumber/run`
|
2022-02-03 16:44:49 +03:00
|
|
|
|
|
|
|
/**
|
2022-02-10 16:47:43 +03:00
|
|
|
* Test the query endpoint over HTTP
|
2022-08-20 17:47:06 +03:00
|
|
|
* and a simple skill action over HTTP
|
2022-02-03 16:44:49 +03:00
|
|
|
*/
|
|
|
|
|
2022-09-03 14:12:41 +03:00
|
|
|
;(async () => {
|
2022-02-03 16:44:49 +03:00
|
|
|
await server.init()
|
|
|
|
})()
|
|
|
|
|
|
|
|
describe('Over HTTP', () => {
|
|
|
|
test(`Request query endpoint POST ${queryUrl}`, async () => {
|
2022-10-23 05:55:03 +03:00
|
|
|
const { data } = await axios.post(
|
|
|
|
queryUrl,
|
|
|
|
{
|
|
|
|
utterance: 'Hello'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
headers: {
|
|
|
|
'X-API-Key': process.env.LEON_HTTP_API_KEY
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(data).toHaveProperty('success', true)
|
2022-02-03 16:44:49 +03:00
|
|
|
})
|
|
|
|
|
2022-08-20 17:47:06 +03:00
|
|
|
test(`Request an action skill: GET ${actionSkillUrl}`, async () => {
|
2022-10-23 05:55:03 +03:00
|
|
|
const { data } = await axios.get(actionSkillUrl, {
|
|
|
|
headers: {
|
|
|
|
'X-API-Key': process.env.LEON_HTTP_API_KEY
|
|
|
|
}
|
|
|
|
})
|
2022-02-03 16:44:49 +03:00
|
|
|
|
2022-10-23 05:55:03 +03:00
|
|
|
expect(data).toHaveProperty('success', true)
|
2022-02-03 16:44:49 +03:00
|
|
|
})
|
|
|
|
})
|