Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Obs AI Assistant] Prefer observabilityAIAssistantAPIClient over supertest #205599

Open
sorenlouv opened this issue Jan 6, 2025 · 3 comments
Open
Labels
good first issue low hanging fruit Team:Obs AI Assistant Observability AI Assistant

Comments

@sorenlouv
Copy link
Member

sorenlouv commented Jan 6, 2025

For api and e2e tests we should use observabilityAIAssistantAPIClient when calling any of the Obs AI Assistants endpoints (internal and public). supertest should only be used for calling apis for the platform and other plugins.

observabilityAIAssistantAPIClient is type safety so errors caused by invalid urls/params will be surfaces at compile time. With supertest these errors are not visible before running the test.

Places where supertest is used for calling own endpoints:

await supertest
.post(CHAT_API_URL)
.set('kbn-xsrf', 'foo')
.send({
name: 'my_api_call',
messages,
connectorId: 'does not exist',
functions: [],
scopes: ['all'],
})

supertest
.post(COMPLETE_API_URL)
.set('kbn-xsrf', 'foo')
.send({
messages,
connectorId,
persist: true,
screenContexts: params.screenContexts || [],
scopes: ['all'],
})

await supertestEditorWithCookieCredentials
.post(CHAT_API_URL)
.send({
name: 'my_api_call',
messages,
connectorId: 'does not exist',
functions: [],
scopes: ['all'],
})

supertestEditorWithCookieCredentials
.post(COMPLETE_API_URL)
.send({
messages,
connectorId,
persist: true,
screenContexts: params.screenContexts || [],
scopes: ['all'],
})

@sorenlouv sorenlouv added the Team:Obs AI Assistant Observability AI Assistant label Jan 6, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ai-assistant (Team:Obs AI Assistant)

@sorenlouv sorenlouv changed the title [Obs AI Assistant] [Obs AI Assistant] Prefer observabilityAIAssistantAPIClient over supertest Jan 6, 2025
@sorenlouv sorenlouv added the good first issue low hanging fruit label Jan 6, 2025
@dgieselaar
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue low hanging fruit Team:Obs AI Assistant Observability AI Assistant
Projects
None yet
Development

No branches or pull requests

3 participants