Skip to content

Commit 8ebcd64

Browse files
anuj-kumaryclaude
andcommitted
Add unit tests for #32658 single-select TreeSelect value normalization and tree injection
Tests cover: scalar value passthrough in single-select mode, array value preserved in multi-select mode, initial option injection into treeData when the term's glossary hasn't been lazy-loaded, and edge cases (missing parent, single-segment FQN, empty options). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2ffad0c commit 8ebcd64

2 files changed

Lines changed: 404 additions & 21 deletions

File tree

openmetadata-ui/src/main/resources/ui/src/components/Tag/TagsSelectForm/TagsSelectForm.component.test.tsx

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,71 @@ describe('TagSelectForm', () => {
132132
{}
133133
);
134134
});
135+
136+
it('should pass scalar value to TreeAsyncSelectList in single-select mode', () => {
137+
(TreeAsyncSelectList as unknown as jest.Mock).mockClear();
138+
139+
render(
140+
<TagSelectForm
141+
defaultValue={['Glossary.term1']}
142+
multiSelect={false}
143+
placeholder={placeholder}
144+
tagType={TagSource.Glossary}
145+
onCancel={onCancel}
146+
onSubmit={onSubmit}
147+
/>
148+
);
149+
150+
expect(TreeAsyncSelectList).toHaveBeenCalledWith(
151+
expect.objectContaining({
152+
isMultiSelect: false,
153+
value: 'Glossary.term1',
154+
}),
155+
{}
156+
);
157+
});
158+
159+
it('should pass array value to TreeAsyncSelectList in multi-select mode', () => {
160+
(TreeAsyncSelectList as unknown as jest.Mock).mockClear();
161+
162+
render(
163+
<TagSelectForm
164+
defaultValue={['Glossary.term1', 'Glossary.term2']}
165+
placeholder={placeholder}
166+
tagType={TagSource.Glossary}
167+
onCancel={onCancel}
168+
onSubmit={onSubmit}
169+
/>
170+
);
171+
172+
expect(TreeAsyncSelectList).toHaveBeenCalledWith(
173+
expect.objectContaining({
174+
value: ['Glossary.term1', 'Glossary.term2'],
175+
}),
176+
{}
177+
);
178+
});
179+
180+
it('should pass undefined value when single-select with empty defaultValue', () => {
181+
(TreeAsyncSelectList as unknown as jest.Mock).mockClear();
182+
183+
render(
184+
<TagSelectForm
185+
defaultValue={[]}
186+
multiSelect={false}
187+
placeholder={placeholder}
188+
tagType={TagSource.Glossary}
189+
onCancel={onCancel}
190+
onSubmit={onSubmit}
191+
/>
192+
);
193+
194+
expect(TreeAsyncSelectList).toHaveBeenCalledWith(
195+
expect.objectContaining({
196+
isMultiSelect: false,
197+
value: undefined,
198+
}),
199+
{}
200+
);
201+
});
135202
});

0 commit comments

Comments
 (0)