Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
Merge pull request #828 from mturley/vm-power-warning-tests
Browse files Browse the repository at this point in the history
Add tests for OSP VM power warnings in the Plan wizard

(cherry picked from commit 1a1889b)

https://bugzilla.redhat.com/show_bug.cgi?id=1657285
  • Loading branch information
michaelkro authored and simaishi committed Dec 11, 2018
1 parent 082b195 commit 0da8173
Show file tree
Hide file tree
Showing 5 changed files with 196 additions and 1 deletion.
@@ -0,0 +1,35 @@
import React from 'react';
import { shallow } from 'enzyme';
import PlanWizardResultsStep from '../PlanWizardResultsStep';

describe('Plan wizard results step', () => {
const getBaseProps = () => ({
postPlansUrl: '/api/foo',
editPlansUrl: '/api/bar',
postMigrationPlansAction: jest.fn(),
editMigrationPlansAction: jest.fn(),
plansBody: { mock: 'data' },
planSchedule: 'migration_plan_later',
isPostingPlans: false,
isRejectedPostingPlans: false,
errorPostingPlans: null,
isPuttingPlans: false,
isRejectedPuttingPlans: false,
errorPuttingPlans: null,
migrationPlansResult: { mock: 'data' },
migrationRequestsResult: { mock: 'data' },
hidePlanWizardAction: jest.fn(),
editingPlan: null,
targetProvider: 'openstack'
});

it('renders with a warning if migrating an OSP plan later', () => {
const component = shallow(<PlanWizardResultsStep {...getBaseProps()} />);
expect(component).toMatchSnapshot();
});

it('renders with no warning if migrating an OSP plan immediately', () => {
const component = shallow(<PlanWizardResultsStep {...getBaseProps()} planSchedule="migration_plan_now" />);
expect(component).toMatchSnapshot();
});
});
@@ -0,0 +1,64 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Plan wizard results step renders with a warning if migrating an OSP plan later 1`] = `
<div
className="wizard-pf-complete blank-slate-pf"
>
<div
className="plan-wizard-results-step-icon"
>
<span
className="pficon pficon-ok"
/>
</div>
<h3
className="blank-slate-pf-main-action"
id="migration-plan-results-message"
>
Migration Plan: '%s' has been saved
</h3>
<p
className="blank-slate-pf-secondary-action"
>
Select Migrate on the Migration Plans page to begin migration
</p>
<div
className="plan-wizard-vm-power-warning"
>
<Icon
name="warning-triangle-o"
type="pf"
/>
<p>
VMs must be powered on in order to migrate.
<br />
Ensure that all VMs in the Migration Plan are powered on before starting migration.
</p>
</div>
</div>
`;

exports[`Plan wizard results step renders with no warning if migrating an OSP plan immediately 1`] = `
<div
className="wizard-pf-complete blank-slate-pf"
>
<div
className="plan-wizard-results-step-icon"
>
<span
className="fa fa-clock-o"
/>
</div>
<h3
className="blank-slate-pf-main-action"
id="migration-plan-results-message"
>
Migration Plan: '%s' is in progress
</h3>
<p
className="blank-slate-pf-secondary-action"
>
This may take a long time. Progress of the plan will be shown in the Migration area
</p>
</div>
`;
Expand Up @@ -4,7 +4,7 @@ import { Field, reduxForm } from 'redux-form';
import { Form, Icon } from 'patternfly-react';
import { FormField } from '../../../../../common/forms/FormField';

const PlanWizardScheduleStep = ({ targetProvider, migration_plan_choice_radio }) => (
export const PlanWizardScheduleStep = ({ targetProvider, migration_plan_choice_radio }) => (
<Form className="form-horizontal">
<Field
name="migration_plan_choice_radio"
Expand Down
@@ -0,0 +1,19 @@
import React from 'react';
import { shallow } from 'enzyme';
import { PlanWizardScheduleStep } from '../PlanWizardScheduleStep';

describe('Plan wizard schedule step', () => {
it('renders with a warning if migrating an OSP plan immediately', () => {
const component = shallow(
<PlanWizardScheduleStep targetProvider="openstack" migration_plan_choice_radio="migration_plan_now" />
);
expect(component).toMatchSnapshot();
});

it('renders with no warning if migrating an OSP plan later', () => {
const component = shallow(
<PlanWizardScheduleStep targetProvider="openstack" migration_plan_choice_radio="migration_plan_later" />
);
expect(component).toMatchSnapshot();
});
});
@@ -0,0 +1,77 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Plan wizard schedule step renders with a warning if migrating an OSP plan immediately 1`] = `
<Form
bsClass="form"
className="form-horizontal"
componentClass="form"
horizontal={false}
inline={false}
>
<Field
component={[Function]}
help={
<div
className="plan-wizard-vm-power-warning"
>
<Icon
name="warning-triangle-o"
type="pf"
/>
<p>
VMs must be powered on in order to migrate.
<br />
Ensure that all VMs in the Migration Plan are powered on before selecting Create.
</p>
</div>
}
label="Run migration plan"
labelWidth="3"
name="migration_plan_choice_radio"
options={
Array [
Object {
"id": "migration_plan_later",
"name": "Save migration plan to run later",
},
Object {
"id": "migration_plan_now",
"name": "Start migration immediately",
},
]
}
type="radio"
/>
</Form>
`;

exports[`Plan wizard schedule step renders with no warning if migrating an OSP plan later 1`] = `
<Form
bsClass="form"
className="form-horizontal"
componentClass="form"
horizontal={false}
inline={false}
>
<Field
component={[Function]}
help={null}
label="Run migration plan"
labelWidth="3"
name="migration_plan_choice_radio"
options={
Array [
Object {
"id": "migration_plan_later",
"name": "Save migration plan to run later",
},
Object {
"id": "migration_plan_now",
"name": "Start migration immediately",
},
]
}
type="radio"
/>
</Form>
`;

0 comments on commit 0da8173

Please sign in to comment.