From dae8695cc4cf0d9d8c60e741330b8b2b8b3c8e77 Mon Sep 17 00:00:00 2001 From: Karl Godard Date: Mon, 15 May 2023 17:19:54 +0000 Subject: [PATCH] more testing --- .../index.test.tsx | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/x-pack/plugins/cloud_defend/public/components/control_general_view_selector/index.test.tsx b/x-pack/plugins/cloud_defend/public/components/control_general_view_selector/index.test.tsx index 824d0d88a120e..5ab2886de9604 100644 --- a/x-pack/plugins/cloud_defend/public/components/control_general_view_selector/index.test.tsx +++ b/x-pack/plugins/cloud_defend/public/components/control_general_view_selector/index.test.tsx @@ -300,25 +300,27 @@ describe('', () => { } updatedSelector = onChange.mock.calls[1][0]; + expect(updatedSelector.hasErrors).toBeFalsy(); rerender(); - expect(findByText(errorStr)).toMatchObject({}); userEvent.type(el, '/*{enter}'); updatedSelector = onChange.mock.calls[2][0]; expect(updatedSelector.hasErrors).toBeFalsy(); - rerender(); - expect(findByText(errorStr)).toMatchObject({}); userEvent.type(el, 'badpath{enter}'); updatedSelector = onChange.mock.calls[3][0]; expect(updatedSelector.hasErrors).toBeTruthy(); - rerender(); - expect(getByText(errorStr)).toBeTruthy(); + + userEvent.type(el, ' {enter}'); + updatedSelector = onChange.mock.calls[4][0]; + expect(updatedSelector.hasErrors).toBeTruthy(); + rerender(); + expect(getByText('"targetFilePath" values cannot be empty')).toBeTruthy(); }); it('validates processExecutable conditions values', async () => { @@ -339,7 +341,7 @@ describe('', () => { 'input' ); - const errorStr = i18n.errorInvalidProcessExecutable; + const regexError = i18n.errorInvalidProcessExecutable; if (el) { userEvent.type(el, '/usr/bin/**{enter}'); @@ -350,31 +352,31 @@ describe('', () => { updatedSelector = onChange.mock.calls[1][0]; expect(updatedSelector.hasErrors).toBeFalsy(); rerender(); - expect(findByText(errorStr)).toMatchObject({}); + expect(findByText(regexError)).toMatchObject({}); userEvent.type(el, '/*{enter}'); updatedSelector = onChange.mock.calls[2][0]; expect(updatedSelector.hasErrors).toBeFalsy(); rerender(); - expect(findByText(errorStr)).toMatchObject({}); + expect(findByText(regexError)).toMatchObject({}); userEvent.type(el, '/usr/bin/ls{enter}'); updatedSelector = onChange.mock.calls[3][0]; expect(updatedSelector.hasErrors).toBeFalsy(); rerender(); - expect(findByText(errorStr)).toMatchObject({}); + expect(findByText(regexError)).toMatchObject({}); userEvent.type(el, 'badpath{enter}'); updatedSelector = onChange.mock.calls[4][0]; expect(updatedSelector.hasErrors).toBeTruthy(); rerender(); - expect(getByText(errorStr)).toBeTruthy(); + expect(getByText(regexError)).toBeTruthy(); userEvent.type(el, ' {enter}'); updatedSelector = onChange.mock.calls[4][0]; expect(updatedSelector.hasErrors).toBeTruthy(); rerender(); - expect(getByText(errorStr)).toBeTruthy(); + expect(getByText('"processExecutable" values cannot be empty')).toBeTruthy(); }); it('validates containerImageFullName conditions values', async () => { @@ -393,7 +395,7 @@ describe('', () => { 'input' ); - const errorStr = i18n.errorInvalidFullContainerImageName; + const regexError = i18n.errorInvalidFullContainerImageName; if (el) { userEvent.type(el, 'docker.io/nginx{enter}'); @@ -404,13 +406,13 @@ describe('', () => { updatedSelector = onChange.mock.calls[1][0]; rerender(); - expect(findByText(errorStr)).toMatchObject({}); + expect(findByText(regexError)).toMatchObject({}); userEvent.type(el, 'nginx{enter}'); updatedSelector = onChange.mock.calls[2][0]; rerender(); - expect(getByText(errorStr)).toBeTruthy(); + expect(getByText(regexError)).toBeTruthy(); }); it('validates kubernetesPodLabel conditions values', async () => {