From 95da70bc8a055257bc6441e24ab1e781faeaffaa Mon Sep 17 00:00:00 2001 From: David Sanchez Soler Date: Mon, 22 Mar 2021 10:45:59 +0100 Subject: [PATCH] Fixes failing test and added new test case --- .../view/trusted_apps_page.test.tsx | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.test.tsx b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.test.tsx index 69c7616b502c8..d891731f6d768 100644 --- a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.test.tsx @@ -201,7 +201,7 @@ describe('When on the Trusted Apps Page', () => { fireEvent.change( getByTestId('addTrustedAppFlyout-createForm-conditionsBuilder-group1-entry0-value'), - { target: { value: 'SOME$HASH#HERE' } } + { target: { value: '44ed10b389dbcd1cf16cec79d16d7378' } } ); fireEvent.change(getByTestId('addTrustedAppFlyout-createForm-descriptionField'), { @@ -363,6 +363,29 @@ describe('When on the Trusted Apps Page', () => { }); }); }); + + describe('and when the form data is not valid', () => { + it('should not enable the Flyout Add button with an invalid hash', async () => { + const renderResult = await renderAndClickAddButton(); + const { getByTestId } = renderResult; + + reactTestingLibrary.act(() => { + fireEvent.change(getByTestId('addTrustedAppFlyout-createForm-nameTextField'), { + target: { value: 'trusted app A' }, + }); + + fireEvent.change( + getByTestId('addTrustedAppFlyout-createForm-conditionsBuilder-group1-entry0-value'), + { target: { value: 'invalid hash' } } + ); + }); + + const flyoutAddButton = getByTestId( + 'addTrustedAppFlyout-createButton' + ) as HTMLButtonElement; + expect(flyoutAddButton.disabled).toBe(true); + }); + }); }); describe('and there are no trusted apps', () => {