From 76b691ce40faaeb1184efdc2c1587b91f47383d6 Mon Sep 17 00:00:00 2001 From: Lily Kuang Date: Mon, 6 Nov 2023 09:44:05 -0800 Subject: [PATCH] fix(tagging): change key from name to id for tagToSelectOption (#25856) --- .../src/components/Tags/utils.test.tsx | 19 +++++++++++++++++++ .../src/components/Tags/utils.tsx | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 superset-frontend/src/components/Tags/utils.test.tsx 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 0000000000000..72a1df8220af4 --- /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 48bd979046d5b..2dd38e6236911 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 (