Skip to content

Commit

Permalink
Add support for single manual steps to Upgrade Assistant. (elastic#11…
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcenizal authored and sabarasaba committed Oct 26, 2021
1 parent e6ac0a3 commit 86991fe
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -24,6 +25,7 @@ const kibanaDeprecations: DomainDeprecationDetails[] = [
},
{
correctiveActions: {
// Has multiple manual steps.
manualSteps: ['Step 1', 'Step 2', 'Step 3'],
},
domainId: 'test_domain_2',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,26 @@ export const DeprecationDetailsFlyout = ({
<h3>{i18nTexts.manualFixTitle}</h3>
</EuiTitle>

<EuiSpacer />
<EuiSpacer size="s" />

<EuiText>
<ol data-test-subj="manualStepsList">
{correctiveActions.manualSteps.map((step, stepIndex) => (
<li key={`step-${stepIndex}`} className="upgResolveStep eui-textBreakWord">
{step}
</li>
))}
</ol>
{correctiveActions.manualSteps.length === 1 ? (
<p data-test-subj="manualStep" className="eui-textBreakWord">
{correctiveActions.manualSteps[0]}
</p>
) : (
<ol data-test-subj="manualStepsList">
{correctiveActions.manualSteps.map((step, stepIndex) => (
<li
data-test-subj="manualStepsListItem"
key={`step-${stepIndex}`}
className="upgResolveStep eui-textBreakWord"
>
{step}
</li>
))}
</ol>
)}
</EuiText>
</div>
)}
Expand Down

0 comments on commit 86991fe

Please sign in to comment.