Skip to content

Commit

Permalink
[Obs AI Assistant] Remove the retry statements (elastic#192222)
Browse files Browse the repository at this point in the history
  • Loading branch information
viduni94 committed Oct 31, 2024
1 parent 89a864e commit 042b9ea
Showing 1 changed file with 51 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,68 +93,64 @@ export default function ApiTest({ getService }: FtrProviderContext) {
});

it('"editor" can retrieve their own private instructions and the public instruction', async () => {
await retry.try(async () => {
const res = await observabilityAIAssistantAPIClient.editorUser({
endpoint: 'GET /internal/observability_ai_assistant/kb/user_instructions',
});
const res = await observabilityAIAssistantAPIClient.editorUser({
endpoint: 'GET /internal/observability_ai_assistant/kb/user_instructions',
});

const instructions = res.body.userInstructions;
const instructions = res.body.userInstructions;

const sortByDocId = (data: Array<Instruction & { public?: boolean }>) =>
sortBy(data, 'doc_id');
const sortByDocId = (data: Array<Instruction & { public?: boolean }>) =>
sortBy(data, 'doc_id');

expect(sortByDocId(instructions)).to.eql(
sortByDocId([
{
doc_id: 'private-doc-from-editor',
public: false,
text: 'Private user instruction from "editor"',
},
{
doc_id: 'public-doc-from-editor',
public: true,
text: 'Public user instruction from "editor"',
},
{
doc_id: 'public-doc-from-john',
public: true,
text: 'Public user instruction from "john"',
},
])
);
});
expect(sortByDocId(instructions)).to.eql(
sortByDocId([
{
doc_id: 'private-doc-from-editor',
public: false,
text: 'Private user instruction from "editor"',
},
{
doc_id: 'public-doc-from-editor',
public: true,
text: 'Public user instruction from "editor"',
},
{
doc_id: 'public-doc-from-john',
public: true,
text: 'Public user instruction from "john"',
},
])
);
});

it('"john" can retrieve their own private instructions and the public instruction', async () => {
await retry.try(async () => {
const res = await getScopedApiClientForUsername(userJohn)({
endpoint: 'GET /internal/observability_ai_assistant/kb/user_instructions',
});
const instructions = res.body.userInstructions;

const sortByDocId = (data: Array<Instruction & { public?: boolean }>) =>
sortBy(data, 'doc_id');

expect(sortByDocId(instructions)).to.eql(
sortByDocId([
{
doc_id: 'public-doc-from-editor',
public: true,
text: 'Public user instruction from "editor"',
},
{
doc_id: 'public-doc-from-john',
public: true,
text: 'Public user instruction from "john"',
},
{
doc_id: 'private-doc-from-john',
public: false,
text: 'Private user instruction from "john"',
},
])
);
const res = await getScopedApiClientForUsername(userJohn)({
endpoint: 'GET /internal/observability_ai_assistant/kb/user_instructions',
});
const instructions = res.body.userInstructions;

const sortByDocId = (data: Array<Instruction & { public?: boolean }>) =>
sortBy(data, 'doc_id');

expect(sortByDocId(instructions)).to.eql(
sortByDocId([
{
doc_id: 'public-doc-from-editor',
public: true,
text: 'Public user instruction from "editor"',
},
{
doc_id: 'public-doc-from-john',
public: true,
text: 'Public user instruction from "john"',
},
{
doc_id: 'private-doc-from-john',
public: false,
text: 'Private user instruction from "john"',
},
])
);
});
});

Expand Down

0 comments on commit 042b9ea

Please sign in to comment.