mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 10:40:07 -04:00
[Index Management] Fix broken jest tests (#173029)
This commit is contained in:
parent
7faa488a13
commit
164427463e
3 changed files with 59 additions and 59 deletions
|
@ -1,3 +1 @@
|
|||
[
|
||||
"x-pack/plugins/index_management/jest.config.js"
|
||||
]
|
||||
[]
|
||||
|
|
|
@ -100,14 +100,10 @@ describe('<TemplateCreate />', () => {
|
|||
|
||||
httpRequestsMockHelpers.setLoadComponentTemplatesResponse(componentTemplates);
|
||||
httpRequestsMockHelpers.setLoadNodesPluginsResponse([]);
|
||||
|
||||
// disable all react-beautiful-dnd development warnings
|
||||
(window as any)['__@hello-pangea/dnd-disable-dev-warnings'] = true;
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
jest.useRealTimers();
|
||||
(window as any)['__@hello-pangea/dnd-disable-dev-warnings'] = false;
|
||||
});
|
||||
|
||||
describe('composable index template', () => {
|
||||
|
@ -533,11 +529,6 @@ describe('<TemplateCreate />', () => {
|
|||
name: TEMPLATE_NAME,
|
||||
indexPatterns: DEFAULT_INDEX_PATTERNS,
|
||||
dataStream: {},
|
||||
lifecycle: {
|
||||
enabled: true,
|
||||
value: 1,
|
||||
unit: 'd',
|
||||
},
|
||||
allowAutoCreate: true,
|
||||
});
|
||||
// Component templates
|
||||
|
@ -551,13 +542,14 @@ describe('<TemplateCreate />', () => {
|
|||
});
|
||||
|
||||
it('should send the correct payload', async () => {
|
||||
const { actions, find } = testBed;
|
||||
const { component, actions, find } = testBed;
|
||||
|
||||
expect(find('stepTitle').text()).toEqual(`Review details for '${TEMPLATE_NAME}'`);
|
||||
|
||||
await act(async () => {
|
||||
actions.clickNextButton();
|
||||
});
|
||||
component.update();
|
||||
|
||||
expect(httpSetup.post).toHaveBeenLastCalledWith(
|
||||
`${API_BASE_PATH}/index_templates`,
|
||||
|
@ -589,10 +581,6 @@ describe('<TemplateCreate />', () => {
|
|||
},
|
||||
},
|
||||
aliases: ALIASES,
|
||||
lifecycle: {
|
||||
enabled: true,
|
||||
data_retention: '1d',
|
||||
},
|
||||
},
|
||||
}),
|
||||
})
|
||||
|
@ -620,44 +608,59 @@ describe('<TemplateCreate />', () => {
|
|||
});
|
||||
});
|
||||
|
||||
test('preview data stream', async () => {
|
||||
await act(async () => {
|
||||
testBed = await setup(httpSetup);
|
||||
});
|
||||
testBed.component.update();
|
||||
describe('DSL', () => {
|
||||
beforeEach(async () => {
|
||||
await act(async () => {
|
||||
testBed = await setup(httpSetup);
|
||||
});
|
||||
testBed.component.update();
|
||||
|
||||
const { actions } = testBed;
|
||||
// Logistics
|
||||
await actions.completeStepOne({
|
||||
name: TEMPLATE_NAME,
|
||||
indexPatterns: DEFAULT_INDEX_PATTERNS,
|
||||
dataStream: {},
|
||||
lifecycle: {
|
||||
enabled: true,
|
||||
value: 1,
|
||||
unit: 'd',
|
||||
},
|
||||
await testBed.actions.completeStepOne({
|
||||
name: TEMPLATE_NAME,
|
||||
indexPatterns: DEFAULT_INDEX_PATTERNS,
|
||||
dataStream: {},
|
||||
lifecycle: {
|
||||
enabled: true,
|
||||
value: 1,
|
||||
unit: 'd',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
await act(async () => {
|
||||
await actions.previewTemplate();
|
||||
test('should include DSL in summary when set in step 1', async () => {
|
||||
const { find, component } = testBed;
|
||||
|
||||
await act(async () => {
|
||||
testBed.find('formWizardStep-5').simulate('click');
|
||||
});
|
||||
component.update();
|
||||
|
||||
expect(find('lifecycleValue').text()).toContain('1 day');
|
||||
});
|
||||
|
||||
expect(httpSetup.post).toHaveBeenLastCalledWith(
|
||||
`${API_BASE_PATH}/index_templates/simulate`,
|
||||
expect.objectContaining({
|
||||
body: JSON.stringify({
|
||||
template: {
|
||||
lifecycle: {
|
||||
enabled: true,
|
||||
data_retention: '1d',
|
||||
test('preview data stream', async () => {
|
||||
const { actions } = testBed;
|
||||
|
||||
await act(async () => {
|
||||
await actions.previewTemplate();
|
||||
});
|
||||
|
||||
expect(httpSetup.post).toHaveBeenLastCalledWith(
|
||||
`${API_BASE_PATH}/index_templates/simulate`,
|
||||
expect.objectContaining({
|
||||
body: JSON.stringify({
|
||||
template: {
|
||||
lifecycle: {
|
||||
enabled: true,
|
||||
data_retention: '1d',
|
||||
},
|
||||
},
|
||||
},
|
||||
index_patterns: DEFAULT_INDEX_PATTERNS,
|
||||
data_stream: {},
|
||||
allow_auto_create: false,
|
||||
}),
|
||||
})
|
||||
);
|
||||
index_patterns: DEFAULT_INDEX_PATTERNS,
|
||||
data_stream: {},
|
||||
allow_auto_create: false,
|
||||
}),
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -185,27 +185,24 @@ export const formSetup = async (initTestBed: SetupFunc<TestSubjects>) => {
|
|||
if (version) {
|
||||
form.setInputValue('versionField.input', JSON.stringify(version));
|
||||
}
|
||||
|
||||
if (allowAutoCreate) {
|
||||
form.toggleEuiSwitch('allowAutoCreateField.input');
|
||||
}
|
||||
});
|
||||
component.update();
|
||||
|
||||
if (lifecycle && lifecycle.enabled) {
|
||||
act(() => {
|
||||
await act(async () => {
|
||||
form.toggleEuiSwitch('dataRetentionToggle.input');
|
||||
});
|
||||
component.update();
|
||||
|
||||
act(() => {
|
||||
form.setInputValue('valueDataRetentionField', String(lifecycle.value));
|
||||
});
|
||||
form.setInputValue('valueDataRetentionField', String(lifecycle.value));
|
||||
}
|
||||
|
||||
await act(async () => {
|
||||
if (allowAutoCreate) {
|
||||
form.toggleEuiSwitch('allowAutoCreateField.input');
|
||||
}
|
||||
|
||||
clickNextButton();
|
||||
jest.advanceTimersByTime(0);
|
||||
});
|
||||
|
||||
component.update();
|
||||
|
@ -378,6 +375,8 @@ export type TestSubjects =
|
|||
| 'settingsEditor'
|
||||
| 'versionField.input'
|
||||
| 'valueDataRetentionField'
|
||||
| 'formWizardStep-5'
|
||||
| 'lifecycleValue'
|
||||
| 'mappingsEditor.formTab'
|
||||
| 'mappingsEditor.advancedConfiguration.sizeEnabledToggle'
|
||||
| 'previewIndexTemplate';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue