Repository navigation
feat(team): add setting for default and allowed query languages #3282
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
base: main
Are you sure you want to change the base?
Changes from all commits
548a3f4
b17aeb5
cff70b9
75ffe89
e109007
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@hyperdx/app': minor | ||
| '@hyperdx/api': minor | ||
| '@hyperdx/common-utils': minor | ||
| --- | ||
|
|
||
| feat: Add team setting to change default query language and enable/disable query languages |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,11 @@ import _ from 'lodash'; | |
| import { ObjectId } from 'mongodb'; | ||
| import mongoose from 'mongoose'; | ||
|
|
||
| import * as config from '@/config'; | ||
| import { | ||
| LOCAL_APP_TEAM, | ||
| updateTeamQueryLanguageSettings, | ||
| } from '@/controllers/team'; | ||
| import { getLoggedInAgent, getServer } from '@/fixtures'; | ||
| import Alert, { AlertSource, AlertThresholdType } from '@/models/alert'; | ||
| import Team from '@/models/team'; | ||
|
|
@@ -34,12 +39,75 @@ describe('team router', () => { | |
| .toMatchInlineSnapshot(` | ||
| { | ||
| "allowedAuthMethods": [], | ||
| "allowedQueryLanguages": [ | ||
| "lucene", | ||
| "sql", | ||
| ], | ||
| "defaultQueryLanguage": "lucene", | ||
| "isMetricsSeriesTableEnabled": false, | ||
| "name": "fake@deploysentinel.com's Team", | ||
| } | ||
| `); | ||
| }); | ||
|
|
||
| it('PATCH /team/query-language-settings - update query language settings', async () => { | ||
| const { agent } = await getLoggedInAgent(server); | ||
|
|
||
| const patchResp = await agent | ||
| .patch('/team/query-language-settings') | ||
| .send({ | ||
| allowedQueryLanguages: ['sql'], | ||
| defaultQueryLanguage: 'sql', | ||
| }) | ||
| .expect(200); | ||
|
|
||
| expect(patchResp.body).toEqual({ | ||
| allowedQueryLanguages: ['sql'], | ||
| defaultQueryLanguage: 'sql', | ||
| }); | ||
|
|
||
| const getResp = await agent.get('/team').expect(200); | ||
| expect(getResp.body.allowedQueryLanguages).toEqual(['sql']); | ||
| expect(getResp.body.defaultQueryLanguage).toEqual('sql'); | ||
| }); | ||
|
|
||
| it('PATCH /team/query-language-settings - rejects invalid configuration', async () => { | ||
| const { agent } = await getLoggedInAgent(server); | ||
|
|
||
| // Rejects empty allowed languages | ||
| await agent | ||
| .patch('/team/query-language-settings') | ||
| .send({ | ||
| allowedQueryLanguages: [], | ||
| }) | ||
| .expect(400); | ||
|
|
||
| // Rejects default language not in allowed languages | ||
| await agent | ||
| .patch('/team/query-language-settings') | ||
| .send({ | ||
| allowedQueryLanguages: ['sql'], | ||
| defaultQueryLanguage: 'lucene', | ||
| }) | ||
| .expect(400); | ||
| }); | ||
|
|
||
| it('updateTeamQueryLanguageSettings works in local app mode', async () => { | ||
| const origLocalMode = config.IS_LOCAL_APP_MODE; | ||
| try { | ||
| (config as { IS_LOCAL_APP_MODE: boolean }).IS_LOCAL_APP_MODE = true; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Context Used: AGENTS.md (source) Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
| const res = await updateTeamQueryLanguageSettings(LOCAL_APP_TEAM._id, { | ||
| allowedQueryLanguages: ['sql'], | ||
| defaultQueryLanguage: 'sql', | ||
| }); | ||
| expect(res.allowedQueryLanguages).toEqual(['sql']); | ||
| expect(res.defaultQueryLanguage).toEqual('sql'); | ||
| } finally { | ||
| (config as { IS_LOCAL_APP_MODE: boolean }).IS_LOCAL_APP_MODE = | ||
| origLocalMode; | ||
| } | ||
| }); | ||
|
|
||
| it('GET /team reflects isMetricsSeriesTableEnabled when set', async () => { | ||
| const { agent, team } = await getLoggedInAgent(server); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.