mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Siem Migrations - Fix rules upload API Error Test. (#212290)
## Summary This PR fixes a incorrect UI test : - Rules Upload File component should only display API Error in case it occurs, while previously the tests was check if the button is disabled or not. Disability of button is irrelevant. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
This commit is contained in:
parent
ca6cc7520b
commit
681cef4590
1 changed files with 2 additions and 28 deletions
|
@ -132,42 +132,16 @@ describe('RulesFileUpload', () => {
|
|||
},
|
||||
];
|
||||
|
||||
it('should not be able to upload on API Error', async () => {
|
||||
it('should display API Error', async () => {
|
||||
renderTestComponent({
|
||||
apiError: mockApiError,
|
||||
});
|
||||
|
||||
const fileName = 'splunk_rules.test.data.json';
|
||||
const ndJSONString = splunkTestRules.map((obj) => JSON.stringify(obj)).join('\n');
|
||||
const testFile = createRulesFileFromRulesData(ndJSONString, getTestDir(), fileName);
|
||||
|
||||
const filePicker = screen.getByTestId('rulesFilePicker');
|
||||
|
||||
act(() => {
|
||||
fireEvent.change(filePicker, {
|
||||
target: {
|
||||
files: [testFile],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(filePicker).toHaveAttribute('data-loading', 'true');
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(filePicker).toHaveAttribute('data-loading', 'false');
|
||||
});
|
||||
|
||||
await act(async () => {
|
||||
fireEvent.click(screen.getByTestId('uploadFileButton'));
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(mockApiError)).toBeVisible();
|
||||
expect(screen.getByTestId('uploadFileButton')).toBeDisabled();
|
||||
});
|
||||
});
|
||||
|
||||
scenarios.forEach((scenario, _idx) => {
|
||||
it(`should not be able to upload when file has - ${scenario.subject}`, async () => {
|
||||
const fileName = 'invalid_rule_file.json';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue