mirror of
https://github.com/leon-ai/leon.git
synced 2024-12-25 09:44:22 +03:00
test(server): add minimal e2e tests for over HTTP
This commit is contained in:
parent
aa0136baec
commit
58f5f2d21c
@ -22,12 +22,13 @@
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "babel-node scripts/lint.js",
|
||||
"test": "npm run test:json && npm run test:unit && npm run test:e2e",
|
||||
"test": "npm run test:json && npm run test:over-http && npm run test:unit && npm run test:e2e",
|
||||
"test:unit": "npm run train en && cross-env PIPENV_PIPFILE=bridges/python/Pipfile LEON_NODE_ENV=testing jest --forceExit --silent --projects test/unit/unit.jest.json && npm run train",
|
||||
"test:e2e": "npm run test:e2e:nlp-modules && npm run test:e2e:modules",
|
||||
"test:e2e:modules": "babel-node scripts/run-clean-test-dbs.js && npm run train en && cross-env PIPENV_PIPFILE=bridges/python/Pipfile LEON_NODE_ENV=testing jest --forceExit --silent --verbose --projects test/e2e/modules/e2e.modules.jest.json && babel-node scripts/run-clean-test-dbs.js && npm run train",
|
||||
"test:e2e:nlp-modules": "npm run train en && cross-env PIPENV_PIPFILE=bridges/python/Pipfile LEON_NODE_ENV=testing jest --forceExit --silent --verbose --setupTestFrameworkScriptFile=./test/paths.setup.js test/e2e/nlp-modules.spec.js && npm run train",
|
||||
"test:json": "jest --silent --projects test/json/json.jest.json",
|
||||
"test:over-http": "npm run generate:pkgs-endpoints && cross-env PIPENV_PIPFILE=bridges/python/Pipfile LEON_NODE_ENV=testing LEON_HOST=http://localhost LEON_PORT=1338 LEON_HTTP_API_KEY=72aeb5ba324580963114481144385d7179c106fc jest --forceExit --silent --verbose --notify=false --bail --collectCoverage=false test/e2e/over-http.spec.js",
|
||||
"test:module": "babel-node scripts/test-module.js",
|
||||
"setup:offline": "babel-node scripts/setup-offline/setup-offline.js",
|
||||
"setup:offline-stt": "babel-node scripts/setup-offline/run-setup-stt.js",
|
||||
|
32
test/e2e/over-http.spec.js
Normal file
32
test/e2e/over-http.spec.js
Normal file
@ -0,0 +1,32 @@
|
||||
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`;
|
||||
|
||||
/**
|
||||
* Test a simple module action over HTTP
|
||||
*/
|
||||
|
||||
(async () => {
|
||||
await server.init()
|
||||
})()
|
||||
|
||||
describe('Over HTTP', () => {
|
||||
test(`Request query endpoint POST ${queryUrl}`, async () => {
|
||||
const { body } = await superagent.post(queryUrl)
|
||||
.send({ query: 'Hello' })
|
||||
.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)
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user