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.
[MD] Concatenate data source name with index pattern name and change …
…delimiter to double colon (opensearch-project#5907) (opensearch-project#5930) * concatenate data source name with index pattern name * add changelog * add tests --------- (cherry picked from commit 4ab0ca8) Signed-off-by: Lu Yu <nluyu@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
7e4b67d
commit 86ad8f2
Showing
5 changed files
with
161 additions
and
14 deletions.
There are no files selected for viewing
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