From 1f5adbee7f0329e68420714ac8d83c5ab5e6eedb Mon Sep 17 00:00:00 2001 From: Kristina Durivage Date: Wed, 20 Dec 2023 13:37:40 -0600 Subject: [PATCH] Fix changes to correlations --- .../correlations/CorrelationsPage.test.tsx | 21 ++++++++------- .../Forms/ConfigureCorrelationSourceForm.tsx | 2 +- .../Forms/TransformationEditorRow.tsx | 3 +-- public/app/features/correlations/types.ts | 4 +-- .../app/features/correlations/utils.test.ts | 12 ++++----- .../features/explore/CorrelationHelper.tsx | 6 ++--- .../CorrelationTransformationAddModal.tsx | 27 ++++++++++--------- .../features/explore/state/correlations.ts | 1 - public/app/features/explore/utils/links.ts | 4 +-- 9 files changed, 41 insertions(+), 39 deletions(-) diff --git a/public/app/features/correlations/CorrelationsPage.test.tsx b/public/app/features/correlations/CorrelationsPage.test.tsx index 0c72265d451a..108d6502849b 100644 --- a/public/app/features/correlations/CorrelationsPage.test.tsx +++ b/public/app/features/correlations/CorrelationsPage.test.tsx @@ -287,7 +287,7 @@ describe('CorrelationsPage', () => { await userEvent.click(screen.getByRole('button', { name: /add transformation/i })); const typeFilterSelect = screen.getAllByLabelText('Type'); openMenu(typeFilterSelect[0]); - await userEvent.click(screen.getAllByText('Regular expression')[0]); + await userEvent.click(screen.getByText('Regular expression')); await userEvent.type(screen.getByLabelText(/expression/i), 'test expression'); await userEvent.click(await screen.findByRole('button', { name: /add$/i })); @@ -363,7 +363,7 @@ describe('CorrelationsPage', () => { provisioned: false, config: { field: 'line', - target: { title: '', url: '' }, + target: {}, type: 'query', transformations: [ { type: SupportedTransformationType.Regex, expression: 'url=http[s]?://(S*)', mapValue: 'path' }, @@ -375,7 +375,7 @@ describe('CorrelationsPage', () => { targetUID: 'loki', uid: '2', label: 'Prometheus to Loki', - config: { field: 'label', target: { title: '', url: '' }, type: 'query' }, + config: { field: 'label', target: {}, type: 'query' }, provisioned: false, }, ] @@ -538,7 +538,7 @@ describe('CorrelationsPage', () => { // select Regex, be sure expression field is not disabled and contains the former expression openMenu(typeFilterSelect[0]); - await userEvent.click(screen.getByText('Regular expression', { selector: 'span' })); + await userEvent.click(screen.getByText('Regular expression')); expressionInput = screen.queryByLabelText(/expression/i); expect(expressionInput).toBeInTheDocument(); expect(expressionInput).toBeEnabled(); @@ -554,7 +554,8 @@ describe('CorrelationsPage', () => { await userEvent.click(screen.getByRole('button', { name: /add transformation/i })); typeFilterSelect = screen.getAllByLabelText('Type'); openMenu(typeFilterSelect[0]); - await userEvent.click(screen.getAllByText('Regular expression')[1]); + const menu = await screen.findByLabelText('Select options menu'); + await userEvent.click(within(menu).getByText('Regular expression')); expressionInput = screen.queryByLabelText(/expression/i); expect(expressionInput).toBeInTheDocument(); expect(expressionInput).toBeEnabled(); @@ -597,7 +598,7 @@ describe('CorrelationsPage', () => { provisioned: false, config: { field: 'line', - target: { title: '', url: '' }, + target: {}, type: 'query', transformations: [ { type: SupportedTransformationType.Regex, expression: 'url=http[s]?://(S*)', mapValue: 'path' }, @@ -612,7 +613,7 @@ describe('CorrelationsPage', () => { provisioned: false, config: { field: 'line', - target: { title: '', url: '' }, + target: {}, type: 'query', transformations: [ { type: SupportedTransformationType.Regex, expression: 'url=http[s]?://(S*)', mapValue: 'path' }, @@ -624,7 +625,7 @@ describe('CorrelationsPage', () => { targetUID: 'loki', uid: '3', label: 'Prometheus to Loki', - config: { field: 'label', target: { title: '', url: '' }, type: 'query' }, + config: { field: 'label', target: {}, type: 'query' }, provisioned: false, }, { @@ -632,7 +633,7 @@ describe('CorrelationsPage', () => { targetUID: 'prometheus', uid: '4', label: 'Prometheus to Prometheus', - config: { field: 'label', target: { title: '', url: '' }, type: 'query' }, + config: { field: 'label', target: {}, type: 'query' }, provisioned: false, }, ] @@ -659,7 +660,7 @@ describe('CorrelationsPage', () => { provisioned: true, config: { field: 'line', - target: { title: '', url: '' }, + target: {}, type: 'query', transformations: [{ type: SupportedTransformationType.Regex, expression: '(?:msg)=' }], }, diff --git a/public/app/features/correlations/Forms/ConfigureCorrelationSourceForm.tsx b/public/app/features/correlations/Forms/ConfigureCorrelationSourceForm.tsx index ebadc6d38fd3..f62050a18743 100644 --- a/public/app/features/correlations/Forms/ConfigureCorrelationSourceForm.tsx +++ b/public/app/features/correlations/Forms/ConfigureCorrelationSourceForm.tsx @@ -84,7 +84,7 @@ export const ConfigureCorrelationSourceForm = () => { )} htmlFor="source" invalid={!!formState.errors.sourceUID} - error={String(formState.errors.sourceUID?.message || '')} + error={formState.errors.sourceUID?.message} > { } invalid={!!formState.errors?.config?.transformations?.[index]?.type} - // @ts-expect-error TODO Figure out how to get proper types here - error={formState.errors?.config?.transformations?.[index]?.type?.message} + error={formState.errors?.config?.transformations?.[index]?.message} validationMessageHorizontalOverflow={true} >