Skip to content

Commit

Permalink
Fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv committed Mar 3, 2025
1 parent 9f7df32 commit c2aadc3
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon
},
},
});
await proxy.waitForAllInterceptorsSettled();
await proxy.waitForAllInterceptorsToHaveBeenCalled();
expect(status).to.be(200);
});

Expand All @@ -104,7 +104,7 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon
},
},
});
await proxy.waitForAllInterceptorsSettled();
await proxy.waitForAllInterceptorsToHaveBeenCalled();
const simulator = await simulatorPromise;
const requestData = simulator.requestBody; // This is the request sent to the LLM
expect(requestData.messages[0].content).to.eql(SYSTEM_MESSAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon
scopes: ['all'],
});

await proxy.waitForAllInterceptorsSettled();
await proxy.waitForAllInterceptorsToHaveBeenCalled();

return String(response.body)
.split('\n')
Expand Down Expand Up @@ -133,7 +133,7 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon

await new Promise<void>((resolve) => passThrough.on('end', () => resolve()));

await proxy.waitForAllInterceptorsSettled();
await proxy.waitForAllInterceptorsToHaveBeenCalled();

parsedEvents = decodeEvents(receivedChunks.join(''));
});
Expand Down Expand Up @@ -243,7 +243,7 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon
},
},
});
await proxy.waitForAllInterceptorsSettled();
await proxy.waitForAllInterceptorsToHaveBeenCalled();
const simulator = await simulatorPromise;
const requestData = simulator.requestBody;
expect(requestData.messages[0].role).to.eql('system');
Expand Down Expand Up @@ -420,7 +420,7 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon

expect(createResponse.status).to.be(200);

await proxy.waitForAllInterceptorsSettled();
await proxy.waitForAllInterceptorsToHaveBeenCalled();

conversationCreatedEvent = getConversationCreatedEvent(createResponse.body);

Expand Down Expand Up @@ -463,7 +463,7 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon

expect(updatedResponse.status).to.be(200);

await proxy.waitForAllInterceptorsSettled();
await proxy.waitForAllInterceptorsToHaveBeenCalled();
});

after(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon
},
});

await proxy.waitForAllInterceptorsSettled();
await proxy.waitForAllInterceptorsToHaveBeenCalled();

alertsEvents = getMessageAddedEvents(alertsResponseBody);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon
},
});

await proxy.waitForAllInterceptorsSettled();
await proxy.waitForAllInterceptorsToHaveBeenCalled();

events = getMessageAddedEvents(responseBody);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon
port: llmProxy.getPort(),
});

llmProxy.interceptWithFunctionRequest({
void llmProxy.interceptWithFunctionRequest({
name: 'get_alerts_dataset_info',
arguments: () => JSON.stringify({ start: 'now-10d', end: 'now' }),
when: () => true,
});

llmProxy.interceptWithFunctionRequest({
void llmProxy.interceptWithFunctionRequest({
name: 'select_relevant_fields',
// @ts-expect-error
when: (requestBody) => requestBody.tool_choice?.function?.name === 'select_relevant_fields',
Expand All @@ -80,13 +80,15 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon
},
});

llmProxy.interceptWithFunctionRequest({
void llmProxy.interceptWithFunctionRequest({
name: 'alerts',
arguments: () => JSON.stringify({ start: 'now-10d', end: 'now' }),
when: () => true,
});

llmProxy.interceptConversation(`You have active alerts for the past 10 days. Back to work!`);
void llmProxy.interceptConversation(
`You have active alerts for the past 10 days. Back to work!`
);

const { status, body } = await observabilityAIAssistantAPIClient.editor({
endpoint: 'POST /internal/observability_ai_assistant/chat/complete',
Expand All @@ -111,7 +113,7 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon

expect(status).to.be(200);

await llmProxy.waitForAllInterceptorsSettled();
await llmProxy.waitForAllInterceptorsToHaveBeenCalled();
messageAddedEvents = getMessageAddedEvents(body);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon
},
});

await proxy.waitForAllInterceptorsSettled();
await proxy.waitForAllInterceptorsToHaveBeenCalled();
});

after(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon
});
expect(createResponse.status).to.be(200);

await proxy.waitForAllInterceptorsSettled();
await proxy.waitForAllInterceptorsToHaveBeenCalled();
const conversationCreatedEvent = getConversationCreatedEvent(createResponse.body);
const conversationId = conversationCreatedEvent.conversation.id;

Expand All @@ -321,7 +321,7 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon
},
});

await proxy.waitForAllInterceptorsSettled();
await proxy.waitForAllInterceptorsToHaveBeenCalled();

const conversation = res.body;
return conversation;
Expand Down Expand Up @@ -470,7 +470,7 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon
},
},
});
await proxy.waitForAllInterceptorsSettled();
await proxy.waitForAllInterceptorsToHaveBeenCalled();
const simulator = await simulatorPromise;
const requestData = simulator.requestBody;
expect(requestData.messages[0].content).to.contain(userInstructionText);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon
},
});

await proxy.waitForAllInterceptorsSettled();
await proxy.waitForAllInterceptorsToHaveBeenCalled();

const titleSimulator = await titleSimulatorPromise;
const conversationSimulator = await conversationSimulatorPromise;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface ToolMessage {
}
export interface LlmResponseSimulator {
requestBody: ChatCompletionStreamParams;
status: (code: number) => Promise<void>;
status: (code: number) => void;
next: (msg: string | ToolMessage) => Promise<void>;
error: (error: any) => Promise<void>;
complete: () => Promise<void>;
Expand Down Expand Up @@ -113,7 +113,7 @@ export class LlmProxy {
this.server.close();
}

waitForAllInterceptorsSettled() {
waitForAllInterceptorsToHaveBeenCalled() {
return pRetry(
async () => {
if (this.interceptors.length === 0) {
Expand Down Expand Up @@ -212,7 +212,7 @@ export class LlmProxy {

const simulator: LlmResponseSimulator = {
requestBody,
status: once(async (status: number) => {
status: once((status: number) => {
response.writeHead(status, {
'Elastic-Interceptor': name,
'Content-Type': 'text/event-stream',
Expand All @@ -221,12 +221,12 @@ export class LlmProxy {
});
}),
next: (msg) => {
simulator.status(200);
void simulator.status(200);
const chunk = createOpenAiChunk(msg);
return write(sseEvent(chunk));
},
rawWrite: (chunk: string) => {
simulator.status(200);
void simulator.status(200);
return write(chunk);
},
rawEnd: async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default function ApiTest({ getService, getPageObjects }: FtrProviderConte

await openContextualInsights();

await proxy.waitForAllInterceptorsSettled();
await proxy.waitForAllInterceptorsToHaveBeenCalled();

await retry.tryForTime(5 * 1000, async () => {
const llmResponse = await testSubjects.getVisibleText(ui.pages.contextualInsights.text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export default function ApiTest({ getService, getPageObjects }: FtrProviderConte
await testSubjects.setValue(ui.pages.conversations.chatInput, 'hello');
await testSubjects.pressEnter(ui.pages.conversations.chatInput);

await proxy.waitForAllInterceptorsSettled();
await proxy.waitForAllInterceptorsToHaveBeenCalled();
await header.waitUntilLoadingHasFinished();
});

Expand Down Expand Up @@ -305,7 +305,7 @@ export default function ApiTest({ getService, getPageObjects }: FtrProviderConte
await testSubjects.setValue(ui.pages.conversations.chatInput, 'hello');
await testSubjects.pressEnter(ui.pages.conversations.chatInput);

await proxy.waitForAllInterceptorsSettled();
await proxy.waitForAllInterceptorsToHaveBeenCalled();
await header.waitUntilLoadingHasFinished();
});

Expand Down Expand Up @@ -396,7 +396,7 @@ export default function ApiTest({ getService, getPageObjects }: FtrProviderConte
await testSubjects.pressEnter(ui.pages.conversations.chatInput);
log.info('SQREN: Waiting for the message to be displayed');

await proxy.waitForAllInterceptorsSettled();
await proxy.waitForAllInterceptorsToHaveBeenCalled();
await header.waitUntilLoadingHasFinished();
});

Expand Down

0 comments on commit c2aadc3

Please sign in to comment.