forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into xinrui_DataSourceIdRequired_WithNoHostConfig
- Loading branch information
Showing
24 changed files
with
418 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/plugins/data/common/index_patterns/lib/get_title.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { SavedObjectsClientContract } from '../../../../../core/public'; | ||
import { getTitle } from './get_title'; | ||
|
||
describe('test getTitle', () => { | ||
let client: SavedObjectsClientContract; | ||
|
||
it('with dataSourceId match', async () => { | ||
const dataSourceIdToTitle = new Map(); | ||
dataSourceIdToTitle.set('dataSourceId', 'dataSourceTitle'); | ||
client = { | ||
get: jest.fn().mockResolvedValue({ | ||
attributes: { title: 'indexTitle' }, | ||
references: [{ type: 'data-source', id: 'dataSourceId' }], | ||
}), | ||
} as any; | ||
const title = await getTitle(client, 'indexPatternId', dataSourceIdToTitle); | ||
expect(title).toEqual('dataSourceTitle::indexTitle'); | ||
}); | ||
|
||
it('with no dataSourceId match and error to get data source', async () => { | ||
const dataSourceIdToTitle = new Map(); | ||
client = { | ||
get: jest | ||
.fn() | ||
.mockResolvedValueOnce({ | ||
attributes: { title: 'indexTitle' }, | ||
references: [{ type: 'data-source', id: 'dataSourceId' }], | ||
}) | ||
.mockRejectedValue(new Error('error')), | ||
} as any; | ||
const title = await getTitle(client, 'indexPatternId', dataSourceIdToTitle); | ||
expect(title).toEqual('dataSourceId::indexTitle'); | ||
}); | ||
|
||
it('with no dataSourceId match and success to get data source', async () => { | ||
const dataSourceIdToTitle = new Map(); | ||
client = { | ||
get: jest | ||
.fn() | ||
.mockResolvedValueOnce({ | ||
attributes: { title: 'indexTitle' }, | ||
references: [{ type: 'data-source', id: 'dataSourceId' }], | ||
}) | ||
.mockResolvedValue({ attributes: { title: 'acquiredDataSourceTitle' } }), | ||
} as any; | ||
const title = await getTitle(client, 'indexPatternId', dataSourceIdToTitle); | ||
expect(title).toEqual('acquiredDataSourceTitle::indexTitle'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/plugins/data_source/server/auth_registry/authentication_methods_registry.mock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { IAuthenticationMethodRegistery } from './authentication_methods_registry'; | ||
|
||
const create = () => | ||
(({ | ||
getAllAuthenticationMethods: jest.fn(), | ||
getAuthenticationMethod: jest.fn(), | ||
} as unknown) as jest.Mocked<IAuthenticationMethodRegistery>); | ||
|
||
export const authenticationMethodRegisteryMock = { create }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.