mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Make sure to close mock connector server after tests
This commit is contained in:
parent
7f6c24e91f
commit
b90ba848e3
2 changed files with 13 additions and 11 deletions
|
@ -8,7 +8,7 @@
|
|||
import expect from '@kbn/expect';
|
||||
import { MessageRole, type Message } from '@kbn/observability-ai-assistant-plugin/public';
|
||||
import getPort from 'get-port';
|
||||
import http from 'http';
|
||||
import http, { Server } from 'http';
|
||||
import { PassThrough } from 'stream';
|
||||
import { FtrProviderContext } from '../../common/ftr_provider_context';
|
||||
|
||||
|
@ -42,10 +42,12 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
|
||||
let connectorId: string;
|
||||
|
||||
let server: Server;
|
||||
|
||||
before(async () => {
|
||||
const port = await getPort({ port: getPort.makeRange(9000, 9100) });
|
||||
|
||||
http
|
||||
server = http
|
||||
.createServer((request, response) => {
|
||||
requestHandler(request, response);
|
||||
})
|
||||
|
@ -70,6 +72,10 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
connectorId = response.body.id;
|
||||
});
|
||||
|
||||
after(() => {
|
||||
server.close();
|
||||
});
|
||||
|
||||
it("returns a 4xx if the connector doesn't exist", async () => {
|
||||
await supertest
|
||||
.post(CHAT_API_URL)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { EXPECTED_COLOR } from 'jest-matcher-utils';
|
||||
import { FtrProviderContext } from '../../common/ftr_provider_context';
|
||||
|
||||
export default function ApiTest({ getService }: FtrProviderContext) {
|
||||
|
@ -14,16 +15,11 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
|
||||
describe('List connectors', () => {
|
||||
it('Returns a 2xx for enterprise license', async () => {
|
||||
let res: any;
|
||||
try {
|
||||
res = await observabilityAIAssistantAPIClient.readUser({
|
||||
endpoint: 'GET /internal/observability_ai_assistant/connectors',
|
||||
});
|
||||
} catch {
|
||||
//
|
||||
}
|
||||
const res = await observabilityAIAssistantAPIClient.readUser({
|
||||
endpoint: 'GET /internal/observability_ai_assistant/connectors',
|
||||
});
|
||||
|
||||
expect(!!res).to.be(true);
|
||||
expect(res.status).to.be(200);
|
||||
});
|
||||
|
||||
it('returns an empty list of connectors', async () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue