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) * concatenate data source name with index pattern name Signed-off-by: Lu Yu <nluyu@amazon.com> * add changelog Signed-off-by: Lu Yu <nluyu@amazon.com> * add tests Signed-off-by: Lu Yu <nluyu@amazon.com> --------- Signed-off-by: Lu Yu <nluyu@amazon.com>
- Loading branch information
Showing
6 changed files
with
162 additions
and
14 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
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