From 5522caffbbb601680520df36b630b051bf393467 Mon Sep 17 00:00:00 2001 From: Viduni Wickramarachchi Date: Thu, 9 Jan 2025 10:01:15 -0500 Subject: [PATCH] [Obs AI Assistant] Unskip user instructions test (#205656) (#205897) Closes https://github.com/elastic/kibana/issues/205656 ## Summary ### Problem There seems to be a race condition and state contamination between tests in the KB user instructions tests. ### Solution - Clear knowledge base and conversations after tests - Remove title interceptor --> we don't need title interception for these tests ### Checklist - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) (cherry picked from commit 37d7a5efb760dc271a4fb26f1eeba0d66e037b07) --- .../knowledge_base_user_instructions.spec.ts | 14 ++++++-------- .../knowledge_base_user_instructions.spec.ts | 14 ++++++-------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/x-pack/test/observability_ai_assistant_api_integration/tests/knowledge_base/knowledge_base_user_instructions.spec.ts b/x-pack/test/observability_ai_assistant_api_integration/tests/knowledge_base/knowledge_base_user_instructions.spec.ts index d5022a052d781..e6f7d728c6e0b 100644 --- a/x-pack/test/observability_ai_assistant_api_integration/tests/knowledge_base/knowledge_base_user_instructions.spec.ts +++ b/x-pack/test/observability_ai_assistant_api_integration/tests/knowledge_base/knowledge_base_user_instructions.spec.ts @@ -233,12 +233,9 @@ export default function ApiTest({ getService }: FtrProviderContext) { }) .expect(200); - const interceptPromises = [ - proxy.interceptConversationTitle('LLM-generated title').completeAfterIntercept(), - proxy - .interceptConversation({ name: 'conversation', response: 'I, the LLM, hear you!' }) - .completeAfterIntercept(), - ]; + const interceptPromise = proxy + .interceptConversation({ name: 'conversation', response: 'I, the LLM, hear you!' }) + .completeAfterIntercept(); const messages: Message[] = [ { @@ -283,8 +280,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { }, }); - // wait for all interceptors to be settled - await Promise.all(interceptPromises); + await interceptPromise; const conversation = res.body; return conversation; @@ -297,6 +293,8 @@ export default function ApiTest({ getService }: FtrProviderContext) { after(async () => { proxy.close(); + await clearKnowledgeBase(es); + await clearConversations(es); await deleteActionConnector({ supertest, connectorId, log }); }); diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/tests/knowledge_base/knowledge_base_user_instructions.spec.ts b/x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/tests/knowledge_base/knowledge_base_user_instructions.spec.ts index d2b8f96060527..ddd5c6957c4e2 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/tests/knowledge_base/knowledge_base_user_instructions.spec.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/tests/knowledge_base/knowledge_base_user_instructions.spec.ts @@ -247,12 +247,9 @@ export default function ApiTest({ getService }: FtrProviderContext) { }) .expect(200); - const interceptPromises = [ - proxy.interceptConversationTitle('LLM-generated title').completeAfterIntercept(), - proxy - .interceptConversation({ name: 'conversation', response: 'I, the LLM, hear you!' }) - .completeAfterIntercept(), - ]; + const interceptPromise = proxy + .interceptConversation({ name: 'conversation', response: 'I, the LLM, hear you!' }) + .completeAfterIntercept(); const messages: Message[] = [ { @@ -297,8 +294,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { }, }); - // wait for all interceptors to be settled - await Promise.all(interceptPromises); + await interceptPromise; const conversation = res.body; return conversation; @@ -317,6 +313,8 @@ export default function ApiTest({ getService }: FtrProviderContext) { after(async () => { proxy.close(); + await clearKnowledgeBase(es); + await clearConversations(es); await deleteActionConnector({ supertest: supertestWithoutAuth, connectorId,