diff --git a/superset-frontend/src/components/Tags/utils.test.tsx b/superset-frontend/src/components/Tags/utils.test.tsx new file mode 100644 index 000000000000..72a1df8220af --- /dev/null +++ b/superset-frontend/src/components/Tags/utils.test.tsx @@ -0,0 +1,19 @@ +import { tagToSelectOption } from 'src/components/Tags/utils'; + +describe('tagToSelectOption', () => { + test('converts a Tag object with table_name to a SelectTagsValue', () => { + const tag = { + id: '1', + name: 'TagName', + table_name: 'Table1', + }; + + const expectedSelectTagsValue = { + value: 'TagName', + label: 'TagName', + key: '1', + }; + + expect(tagToSelectOption(tag)).toEqual(expectedSelectTagsValue); + }); +}); diff --git a/superset-frontend/src/components/Tags/utils.tsx b/superset-frontend/src/components/Tags/utils.tsx index 48bd979046d5..2dd38e623691 100644 --- a/superset-frontend/src/components/Tags/utils.tsx +++ b/superset-frontend/src/components/Tags/utils.tsx @@ -46,7 +46,7 @@ export const tagToSelectOption = ( ): SelectTagsValue => ({ value: item.name, label: item.name, - key: item.name, + key: item.id, }); export const loadTags = async (