Skip to content

Commit

Permalink
[Obs AI Assistant] Unskip user instructions test (elastic#205656) (el…
Browse files Browse the repository at this point in the history
…astic#205897)

Closes elastic#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)
  • Loading branch information
viduni94 authored and Zacqary committed Jan 9, 2025
1 parent bd08528 commit d54b7e4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
{
Expand Down Expand Up @@ -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;
Expand All @@ -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 });
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
const svlCommonApi = getService('svlCommonApi');
const retry = getService('retry');

// Failing: See https://github.com/elastic/kibana/issues/205656
describe.skip('Knowledge base user instructions', function () {
describe('Knowledge base user instructions', function () {
// TODO: https://github.com/elastic/kibana/issues/192751
this.tags(['skipMKI']);
let editorRoleAuthc: RoleCredentials;
Expand Down Expand Up @@ -248,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[] = [
{
Expand Down Expand Up @@ -298,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;
Expand All @@ -318,6 +313,8 @@ export default function ApiTest({ getService }: FtrProviderContext) {

after(async () => {
proxy.close();
await clearKnowledgeBase(es);
await clearConversations(es);
await deleteActionConnector({
supertest: supertestWithoutAuth,
connectorId,
Expand Down

0 comments on commit d54b7e4

Please sign in to comment.