-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Component Integration Test for Append Processor (#95001)
* Added first steps for append processor test and added data test subject for append processor input combo box. * Added first steps for append processor test and added data test subject for append processor input combo box. * Fixed assertion for processor. * Merged in newer test functionality and used it in the append processor test. * Fixed asssertion and form to use append box. * Update snapshot. * Fixed assertion for array. * Made changes per notes in PR. * Used common fields var in test. * Fixed merge conflict. * Fixed unused vars and added data test subject to helper file. * Removed this snapshot that was erronously added to PR due to a merge conflict. * Removed old common field var from uri tests. * Fixed nits in PR in all tet files. Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
d5a16f4
commit f058d27
Showing
5 changed files
with
149 additions
and
45 deletions.
There are no files selected for viewing
118 changes: 118 additions & 0 deletions
118
...pelines/public/application/components/pipeline_editor/__jest__/processors/append.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { act } from 'react-dom/test-utils'; | ||
import { setup, SetupResult, getProcessorValue } from './processor.helpers'; | ||
|
||
const APPEND_TYPE = 'append'; | ||
|
||
describe('Processor: Append', () => { | ||
let onUpdate: jest.Mock; | ||
let testBed: SetupResult; | ||
|
||
beforeAll(() => { | ||
jest.useFakeTimers(); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.useRealTimers(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
onUpdate = jest.fn(); | ||
|
||
await act(async () => { | ||
testBed = await setup({ | ||
value: { | ||
processors: [], | ||
}, | ||
onFlyoutOpen: jest.fn(), | ||
onUpdate, | ||
}); | ||
}); | ||
testBed.component.update(); | ||
const { | ||
actions: { addProcessor, addProcessorType }, | ||
} = testBed; | ||
// Open the processor flyout | ||
addProcessor(); | ||
|
||
// Add type (the other fields are not visible until a type is selected) | ||
await addProcessorType(APPEND_TYPE); | ||
}); | ||
|
||
test('prevents form submission if required fields are not provided', async () => { | ||
const { | ||
actions: { saveNewProcessor }, | ||
form, | ||
} = testBed; | ||
|
||
// Click submit button with only the type defined | ||
await saveNewProcessor(); | ||
|
||
// Expect form error as "field" and "value" are required parameters | ||
expect(form.getErrorsMessages()).toEqual([ | ||
'A field value is required.', | ||
'A value is required.', | ||
]); | ||
}); | ||
|
||
test('saves with required parameter values', async () => { | ||
const { | ||
actions: { saveNewProcessor }, | ||
form, | ||
find, | ||
component, | ||
} = testBed; | ||
|
||
// Add "field" value (required) | ||
form.setInputValue('fieldNameField.input', 'field_1'); | ||
|
||
await act(async () => { | ||
find('appendValueField.input').simulate('change', [{ label: 'Some_Value' }]); | ||
}); | ||
component.update(); | ||
|
||
// Save the field | ||
await saveNewProcessor(); | ||
|
||
const processors = getProcessorValue(onUpdate, APPEND_TYPE); | ||
expect(processors[0].append).toEqual({ | ||
field: 'field_1', | ||
value: ['Some_Value'], | ||
}); | ||
}); | ||
|
||
test('allows optional parameters to be set', async () => { | ||
const { | ||
actions: { saveNewProcessor }, | ||
form, | ||
find, | ||
component, | ||
} = testBed; | ||
|
||
// Add "field" value (required) | ||
form.setInputValue('fieldNameField.input', 'field_1'); | ||
|
||
// Set optional parameteres | ||
await act(async () => { | ||
find('appendValueField.input').simulate('change', [{ label: 'Some_Value' }]); | ||
component.update(); | ||
}); | ||
|
||
form.toggleEuiSwitch('ignoreFailureSwitch.input'); | ||
// Save the field with new changes | ||
await saveNewProcessor(); | ||
|
||
const processors = getProcessorValue(onUpdate, APPEND_TYPE); | ||
expect(processors[0].append).toEqual({ | ||
field: 'field_1', | ||
ignore_failure: true, | ||
value: ['Some_Value'], | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters