Skip to content

Commit e5b4ad0

Browse files
add test
1 parent 964ea5c commit e5b4ad0

File tree

1 file changed

+27
-0
lines changed
  • x-pack/plugins/index_management/public/application/components/mappings_editor/__jest__/client_integration

1 file changed

+27
-0
lines changed

x-pack/plugins/index_management/public/application/components/mappings_editor/__jest__/client_integration/mappings_editor.test.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,33 @@ describe('Mappings editor: core', () => {
223223
isNumericDetectionVisible = exists('advancedConfiguration.numericDetection');
224224
expect(isNumericDetectionVisible).toBe(false);
225225
});
226+
227+
test('should keep default dynamic templates value when switching tabs', async () => {
228+
await act(async () => {
229+
testBed = setup({
230+
value: { ...defaultMappings, dynamic_templates: [] }, // by default, the UI will provide an empty array for dynamic templates
231+
onChange: onChangeHandler,
232+
});
233+
});
234+
testBed.component.update();
235+
236+
const {
237+
actions: { selectTab, getJsonEditorValue },
238+
} = testBed;
239+
240+
// Navigate to dynamic templates tab and verify empty array
241+
await selectTab('templates');
242+
let templatesValue = getJsonEditorValue('dynamicTemplatesEditor');
243+
expect(templatesValue).toEqual([]);
244+
245+
// Navigate to advanced tab
246+
await selectTab('advanced');
247+
248+
// Navigate back to dynamic templates tab and verify empty array persists
249+
await selectTab('templates');
250+
templatesValue = getJsonEditorValue('dynamicTemplatesEditor');
251+
expect(templatesValue).toEqual([]);
252+
});
226253
});
227254

228255
describe('component props', () => {

0 commit comments

Comments
 (0)