From 86991fe180f23993e0d7dd745cfeadb988ee43ee Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Wed, 29 Sep 2021 07:01:28 -0700 Subject: [PATCH] Add support for single manual steps to Upgrade Assistant. (#113344) --- .../kibana_deprecations_service.mock.ts | 4 ++- .../deprecation_details_flyout.test.ts | 25 +++++++++--------- .../deprecation_details_flyout.tsx | 26 +++++++++++++------ 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/helpers/kibana_deprecations_service.mock.ts b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/helpers/kibana_deprecations_service.mock.ts index fb3c48785c5f03..c51e415d7e916d 100644 --- a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/helpers/kibana_deprecations_service.mock.ts +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/helpers/kibana_deprecations_service.mock.ts @@ -10,7 +10,8 @@ import type { DeprecationsServiceStart, DomainDeprecationDetails } from 'kibana/ const kibanaDeprecations: DomainDeprecationDetails[] = [ { correctiveActions: { - manualSteps: ['Step 1', 'Step 2', 'Step 3'], + // Only has one manual step. + manualSteps: ['Step 1'], api: { method: 'POST', path: '/test', @@ -24,6 +25,7 @@ const kibanaDeprecations: DomainDeprecationDetails[] = [ }, { correctiveActions: { + // Has multiple manual steps. manualSteps: ['Step 1', 'Step 2', 'Step 3'], }, domainId: 'test_domain_2', diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/kibana_deprecations/deprecation_details_flyout.test.ts b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/kibana_deprecations/deprecation_details_flyout.test.ts index 11b7dc72ea5d21..1b782ae36181c0 100644 --- a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/kibana_deprecations/deprecation_details_flyout.test.ts +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/kibana_deprecations/deprecation_details_flyout.test.ts @@ -40,22 +40,26 @@ describe('Kibana deprecation details flyout', () => { }); describe('Deprecation with manual steps', () => { - test('renders flyout with manual steps only', async () => { + test('renders flyout with single manual step as a standalone paragraph', async () => { const { find, exists, actions } = testBed; const manualDeprecation = mockedKibanaDeprecations[1]; - await actions.table.clickDeprecationAt(1); + await actions.table.clickDeprecationAt(0); expect(exists('kibanaDeprecationDetails')).toBe(true); - expect(exists('kibanaDeprecationDetails.warningDeprecationBadge')).toBe(true); expect(find('kibanaDeprecationDetails.flyoutTitle').text()).toBe(manualDeprecation.title); - expect(find('manualStepsList').find('li').length).toEqual( - manualDeprecation.correctiveActions.manualSteps.length - ); + expect(find('manualStep').length).toBe(1); + }); - // Quick resolve callout and button should not display - expect(exists('quickResolveCallout')).toBe(false); - expect(exists('resolveButton')).toBe(false); + test('renders flyout with multiple manual steps as a list', async () => { + const { find, exists, actions } = testBed; + const manualDeprecation = mockedKibanaDeprecations[1]; + + await actions.table.clickDeprecationAt(1); + + expect(exists('kibanaDeprecationDetails')).toBe(true); + expect(find('kibanaDeprecationDetails.flyoutTitle').text()).toBe(manualDeprecation.title); + expect(find('manualStepsListItem').length).toBe(3); }); }); @@ -71,9 +75,6 @@ describe('Kibana deprecation details flyout', () => { expect(find('kibanaDeprecationDetails.flyoutTitle').text()).toBe( quickResolveDeprecation.title ); - expect(find('manualStepsList').find('li').length).toEqual( - quickResolveDeprecation.correctiveActions.manualSteps.length - ); // Quick resolve callout and button should display expect(exists('quickResolveCallout')).toBe(true); diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/deprecation_details_flyout.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/deprecation_details_flyout.tsx index 6ec9ad175e112b..37b07bc1595775 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/deprecation_details_flyout.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/deprecation_details_flyout.tsx @@ -203,16 +203,26 @@ export const DeprecationDetailsFlyout = ({

{i18nTexts.manualFixTitle}

- + -
    - {correctiveActions.manualSteps.map((step, stepIndex) => ( -
  1. - {step} -
  2. - ))} -
+ {correctiveActions.manualSteps.length === 1 ? ( +

+ {correctiveActions.manualSteps[0]} +

+ ) : ( +
    + {correctiveActions.manualSteps.map((step, stepIndex) => ( +
  1. + {step} +
  2. + ))} +
+ )}
)}