From 4dcb6757e172ba8253dc9a155e79c9488f095cf1 Mon Sep 17 00:00:00 2001 From: Dario Gieselaar Date: Sat, 8 Jun 2024 14:54:50 +0200 Subject: [PATCH] Fix failing tests --- .../server/service/client/index.test.ts | 2 -- .../tests/complete/complete.spec.ts | 1 - .../tests/public_complete/public_complete.spec.ts | 14 +++++++++++--- .../tests/conversations/index.spec.ts | 4 +--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/client/index.test.ts b/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/client/index.test.ts index 5d43fdad58eb3..0349d597b7ba0 100644 --- a/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/client/index.test.ts +++ b/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/client/index.test.ts @@ -1232,7 +1232,6 @@ describe('Observability AI Assistant client', () => { role: MessageRole.Assistant, function_call: { name: CONTEXT_FUNCTION_NAME, - arguments: JSON.stringify({}), trigger: MessageRole.Assistant, }, }, @@ -1456,7 +1455,6 @@ describe('Observability AI Assistant client', () => { role: MessageRole.Assistant, function_call: { name: CONTEXT_FUNCTION_NAME, - arguments: JSON.stringify({}), trigger: MessageRole.Assistant, }, }, diff --git a/x-pack/test/observability_ai_assistant_api_integration/tests/complete/complete.spec.ts b/x-pack/test/observability_ai_assistant_api_integration/tests/complete/complete.spec.ts index 01f6e8cdd7bce..eb5ed07d3ea08 100644 --- a/x-pack/test/observability_ai_assistant_api_integration/tests/complete/complete.spec.ts +++ b/x-pack/test/observability_ai_assistant_api_integration/tests/complete/complete.spec.ts @@ -193,7 +193,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { role: MessageRole.Assistant, function_call: { name: 'context', - arguments: JSON.stringify({ queries: [], categories: [] }), trigger: MessageRole.Assistant, }, }, diff --git a/x-pack/test/observability_ai_assistant_api_integration/tests/public_complete/public_complete.spec.ts b/x-pack/test/observability_ai_assistant_api_integration/tests/public_complete/public_complete.spec.ts index ac2fa36f6b0fd..f496e42868ac8 100644 --- a/x-pack/test/observability_ai_assistant_api_integration/tests/public_complete/public_complete.spec.ts +++ b/x-pack/test/observability_ai_assistant_api_integration/tests/public_complete/public_complete.spec.ts @@ -72,6 +72,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { format, }) .set('kbn-xsrf', 'foo') + .set('elastic-api-version', '2023-10-31') .send({ messages, connectorId, @@ -83,13 +84,20 @@ export default function ApiTest({ getService }: FtrProviderContext) { if (err) { return reject(err); } + if (response.status !== 200) { + return reject(new Error(`${response.status}: ${JSON.stringify(response.body)}`)); + } return resolve(response); }); }); - const [conversationSimulator, titleSimulator] = await Promise.all([ - conversationInterceptor.waitForIntercept(), - titleInterceptor.waitForIntercept(), + const [conversationSimulator, titleSimulator] = await Promise.race([ + Promise.all([ + conversationInterceptor.waitForIntercept(), + titleInterceptor.waitForIntercept(), + ]), + // make sure any request failures (like 400s) are properly propagated + responsePromise.then(() => []), ]); await titleSimulator.status(200); diff --git a/x-pack/test/observability_ai_assistant_functional/tests/conversations/index.spec.ts b/x-pack/test/observability_ai_assistant_functional/tests/conversations/index.spec.ts index b7c33db0a4122..3e766877c5bca 100644 --- a/x-pack/test/observability_ai_assistant_functional/tests/conversations/index.spec.ts +++ b/x-pack/test/observability_ai_assistant_functional/tests/conversations/index.spec.ts @@ -94,7 +94,7 @@ export default function ApiTest({ getService, getPageObjects }: FtrProviderConte content: '', function_call: { name: 'context', - arguments: '{"queries":[],"categories":[]}', + arguments: '{}', trigger: MessageRole.Assistant, }, }, @@ -290,7 +290,6 @@ export default function ApiTest({ getService, getPageObjects }: FtrProviderConte expect(pick(contextRequest.function_call, 'name', 'arguments')).to.eql({ name: 'context', - arguments: JSON.stringify({ queries: [], categories: [] }), }); expect(contextResponse.name).to.eql('context'); @@ -354,7 +353,6 @@ export default function ApiTest({ getService, getPageObjects }: FtrProviderConte expect(pick(contextRequest.function_call, 'name', 'arguments')).to.eql({ name: 'context', - arguments: JSON.stringify({ queries: [], categories: [] }), }); expect(contextResponse.name).to.eql('context');