2022-02-03 16:44:49 +03:00
|
|
|
import superagent from 'superagent'
|
|
|
|
|
|
|
|
import server from '@/core/http-server/server'
|
|
|
|
|
|
|
|
const urlPrefix = `${process.env.LEON_HOST}:${process.env.LEON_PORT}/api`
|
|
|
|
const queryUrl = `${urlPrefix}/query`
|
|
|
|
const actionModuleUrl = `${urlPrefix}/p/leon/randomnumber/run`;
|
|
|
|
|
|
|
|
/**
|
2022-02-10 16:47:43 +03:00
|
|
|
* Test the query endpoint over HTTP
|
2022-02-03 16:46:13 +03:00
|
|
|
* and a simple module action over HTTP
|
2022-02-03 16:44:49 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
(async () => {
|
|
|
|
await server.init()
|
|
|
|
})()
|
|
|
|
|
|
|
|
describe('Over HTTP', () => {
|
|
|
|
test(`Request query endpoint POST ${queryUrl}`, async () => {
|
|
|
|
const { body } = await superagent.post(queryUrl)
|
2022-02-10 16:47:43 +03:00
|
|
|
.send({ utterance: 'Hello' })
|
2022-02-03 16:44:49 +03:00
|
|
|
.set('X-API-Key', process.env.LEON_HTTP_API_KEY)
|
|
|
|
|
|
|
|
expect(body).toHaveProperty('success', true)
|
|
|
|
})
|
|
|
|
|
|
|
|
test(`Request an action module: GET ${actionModuleUrl}`, async () => {
|
|
|
|
const { body } = await superagent.get(actionModuleUrl)
|
|
|
|
.set('X-API-Key', process.env.LEON_HTTP_API_KEY)
|
|
|
|
|
|
|
|
expect(body).toHaveProperty('success', true)
|
|
|
|
})
|
|
|
|
})
|