Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Update react version to 16.9.x #1030

Merged
merged 5 commits into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

exports[`Mapping Wizard integration test should mount the MappingWizardClusterStep with mapStateToProps reduced 1`] = `
Object {
"destroyOnUnmount": false,
"enableReinitialize": true,
"fetchSourceClustersAction": [Function],
"fetchSourceClustersUrl": "/api/dummyProviders",
"fetchTargetClustersAction": [Function],
"forceUnregisterOnUnmount": false,
"form": "mappingWizardClustersStep",
"getFormState": [Function],
"hideAlertAction": [Function],
"initialValues": Object {
"clusterMappings": Array [],
Expand All @@ -16,10 +20,20 @@ Object {
"isRejectedTargetClusters": false,
"keepDirtyOnReinitialize": true,
"ospConversionHosts": Array [],
"persistentSubmitErrors": false,
"pure": true,
"rhvConversionHosts": Array [],
"shouldAsyncValidate": [Function],
"shouldError": [Function],
"shouldValidate": [Function],
"shouldWarn": [Function],
"showAlertAction": [Function],
"sourceClusters": Array [],
"submitAsSideEffect": false,
"targetClusters": Array [],
"targetProvider": "rhevm",
"touchOnBlur": true,
"touchOnChange": false,
"updateUnregisteredFields": false,
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { getConversionHostSshKeyInfoMessage } from '../../../../../helpers';

const requiredWithMessage = required({ msg: __('This field is required') });

const ConversionHostWizardAuthenticationStep = ({
export const ConversionHostWizardAuthenticationStep = ({
selectedProviderType,
selectedTransformationMethod,
verifyOpenstackCerts
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import React from 'react';
import { shallow, mount } from 'enzyme';
import { Provider } from 'react-redux';
import { reducer as formReducer } from 'redux-form';

import { generateStore } from '../../../../../../../common/testReduxHelpers';
import ConversionHostWizardAuthenticationStep from '../ConversionHostWizardAuthenticationStep';
import ConversionHostWizardAuthenticationStepConnected, {
ConversionHostWizardAuthenticationStep
} from '../ConversionHostWizardAuthenticationStep';
import { RHV, OPENSTACK } from '../../../../../../../../../../common/constants';
import { SSH, VDDK } from '../../ConversionHostWizardConstants';

Expand All @@ -17,20 +20,15 @@ describe('conversion host wizard authentication step', () => {
store
};

const shallowDive = jsx => {
const connectWrapper = shallow(jsx); // <Connect(Form(ConversionHostWizardAuthenticationStep))>
const formWrapper = connectWrapper.dive(); // <Form(ConversionHostWizardAuthenticationStep)>
const componentWrapper = formWrapper.dive(); // <ConversionHostWizardAuthenticationStep>
return componentWrapper.dive(); // shallow-rendered ConversionHostWizardAuthenticationStep
};
const ProviderWrapper = ({ children }) => <Provider store={store}>{children}</Provider>; // eslint-disable-line react/prop-types

it('renders the redux-form wrapper correctly', () => {
const component = shallow(<ConversionHostWizardAuthenticationStep {...baseProps} />);
expect(component).toMatchSnapshot();
});

it('renders correctly in the initial state for RHV', () => {
const component = shallowDive(<ConversionHostWizardAuthenticationStep {...baseProps} />);
const component = shallow(<ConversionHostWizardAuthenticationStep {...baseProps} />);
expect(component.find('Field[controlId="openstack-user-input"]')).toHaveLength(0);
expect(component.find('TextFileField[controlId="vmware-ssh-key-input"]')).toHaveLength(0);
expect(component.find('Field[controlId="vddk-library-path"]')).toHaveLength(0);
Expand All @@ -40,7 +38,7 @@ describe('conversion host wizard authentication step', () => {
});

it('renders correctly in the initial state for OSP', () => {
const component = shallowDive(
const component = shallow(
<ConversionHostWizardAuthenticationStep {...baseProps} selectedProviderType={OPENSTACK} />
);
expect(component.find('Field[controlId="openstack-user-input"]')).toHaveLength(1);
Expand All @@ -52,29 +50,33 @@ describe('conversion host wizard authentication step', () => {
});

it('renders the verify TLS certs switch correctly', () => {
const component = shallowDive(
<ConversionHostWizardAuthenticationStep {...baseProps} selectedProviderType={OPENSTACK} />
const component = mount(
<ProviderWrapper>
<ConversionHostWizardAuthenticationStepConnected {...baseProps} selectedProviderType={OPENSTACK} />
</ProviderWrapper>
);
const onSwitchChange = jest.fn();
const switchRenderProp = component.find('Field[controlId="verify-openstack-certs"]').props().children;
const switchRenderProp = component
.find('Field[controlId="verify-openstack-certs"]')
.first()
.props().children;
const renderedSwitch = switchRenderProp({ input: { value: false, onChange: onSwitchChange } });
expect(renderedSwitch).toMatchSnapshot();
mount(renderedSwitch)
.props()
.onChange(null, true);
expect(onSwitchChange).toHaveBeenCalledWith(true);
});

it('renders correctly with verify OSP TLS certs turned on', () => {
const component = shallowDive(
const component = shallow(
<ConversionHostWizardAuthenticationStep {...baseProps} selectedProviderType={OPENSTACK} verifyOpenstackCerts />
);
expect(component.find('TextFileField[controlId="openstack-ca-certs-input"]')).toHaveLength(1);
expect(component).toMatchSnapshot();
});

it('renders correctly with SSH transformation method selected', () => {
const component = shallowDive(
const component = shallow(
<ConversionHostWizardAuthenticationStep {...baseProps} selectedTransformationMethod={SSH} />
);
expect(component.find('TextFileField[controlId="vmware-ssh-key-input"]')).toHaveLength(1);
Expand All @@ -83,7 +85,7 @@ describe('conversion host wizard authentication step', () => {
});

it('renders correctly with VDDK transformation method selected', () => {
const component = shallowDive(
const component = shallow(
<ConversionHostWizardAuthenticationStep {...baseProps} selectedTransformationMethod={VDDK} />
);
expect(component.find('TextFileField[controlId="vmware-ssh-key-input"]')).toHaveLength(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,76 +367,55 @@ exports[`conversion host wizard authentication step renders correctly with verif
`;

exports[`conversion host wizard authentication step renders the redux-form wrapper correctly 1`] = `
<Connect(Form(ConversionHostWizardAuthenticationStep))
destroyOnUnmount={false}
enableReinitialize={false}
forceUnregisterOnUnmount={true}
form="conversionHostWizardAuthenticationStep"
getFormState={[Function]}
initialValues={
Object {
"conversionHostSshKey": Object {
"body": "",
"filename": "",
},
"openstackCaCerts": Object {
"body": "",
"filename": "",
},
"openstackUser": "cloud-user",
"transformationMethod": "VDDK",
"verifyOpenstackCerts": false,
"vmwareSshKey": Object {
"body": "",
"filename": "",
},
<Form
bsClass="form"
className="form-horizontal"
componentClass="form"
horizontal={false}
inline={false}
>
<TextFileField
controlId="host-ssh-key-input"
controlWidth={7}
help="Upload your SSH key file or paste its contents below."
hideBody={false}
info="RHV-M deploys a common SSH public key on all hosts when configuring them. This allows commands and playbooks to be run from RHV-M. The associated private key is in the file /etc/pki/ovirt-engine/keys/engine_id_rsa on RHV-M."
label="Conversion Host SSH private key"
labelWidth={4}
name="conversionHostSshKey"
/>
<Field
component={[Function]}
controlWidth={7}
inline_label={true}
label="Transformation method"
labelWidth={4}
name="transformationMethod"
option_key="id"
option_value="name"
options={
Array [
Object {
"id": "VDDK",
"name": "VDDK",
},
Object {
"id": "SSH",
"name": "SSH",
},
]
}
}
keepDirtyOnReinitialize={false}
persistentSubmitErrors={false}
pure={true}
selectedProviderType="rhevm"
selectedTransformationMethod={null}
shouldAsyncValidate={[Function]}
shouldError={[Function]}
shouldValidate={[Function]}
shouldWarn={[Function]}
store={
Object {
"dispatch": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
Symbol(observable): [Function],
required={true}
style={
Object {
"marginTop": 25,
}
}
}
touchOnBlur={true}
touchOnChange={false}
updateUnregisteredFields={false}
verifyOpenstackCerts={null}
/>
`;

exports[`conversion host wizard authentication step renders the verify TLS certs switch correctly 1`] = `
<Switch
animate={true}
baseClass="bootstrap-switch"
bsSize="normal"
defaultValue={false}
disabled={false}
handleWidth="auto"
id="verify-openstack-certs-switch"
inverse={false}
labelText=" "
labelWidth="auto"
offColor="default"
offText="No"
onChange={[Function]}
onColor="primary"
onText="Yes"
readonly={false}
tristate={false}
value={false}
wrapperClass="wrapper"
/>
validate={
Array [
[Function],
]
}
/>
</Form>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,41 @@

exports[`ConversionHostWizardAuthenticationStep integration test should mount ConversionHostWizardAuthenticationStep with mapStateToProps reduced 1`] = `
Object {
"destroyOnUnmount": false,
"enableReinitialize": false,
"forceUnregisterOnUnmount": true,
"form": "conversionHostWizardAuthenticationStep",
"getFormState": [Function],
"initialValues": Object {
"conversionHostSshKey": Object {
"body": "",
"filename": "",
},
"openstackCaCerts": Object {
"body": "",
"filename": "",
},
"openstackUser": "cloud-user",
"transformationMethod": "VDDK",
"verifyOpenstackCerts": false,
"vmwareSshKey": Object {
"body": "",
"filename": "",
},
},
"keepDirtyOnReinitialize": false,
"persistentSubmitErrors": false,
"pure": true,
"selectedProviderType": "openstack",
"selectedTransformationMethod": "VDDK",
"shouldAsyncValidate": [Function],
"shouldError": [Function],
"shouldValidate": [Function],
"shouldWarn": [Function],
"submitAsSideEffect": false,
"touchOnBlur": true,
"touchOnChange": false,
"updateUnregisteredFields": false,
"verifyOpenstackCerts": false,
}
`;
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow, mount } from 'enzyme';
import { Provider } from 'react-redux';
import { reducer as formReducer } from 'redux-form';

import { generateStore } from '../../../../../../../common/testReduxHelpers';
Expand Down Expand Up @@ -58,6 +59,8 @@ const mockTasksByResource = {
describe('conversion host wizard hosts step', () => {
const store = generateStore({ form: formReducer }, {});

const ProviderWraper = ({ children }) => <Provider store={store}>{children}</Provider>; // eslint-disable-line react/prop-types

const baseProps = {
selectedProviderType: RHV,
selectedCluster: mockRhvCluster,
Expand All @@ -84,8 +87,15 @@ describe('conversion host wizard hosts step', () => {
});

it('filters out options for RHV hosts that are configured or being configured', () => {
const component = shallowDive(<ConversionHostWizardHostsStep {...baseProps} />);
const filteredHostOptions = component.find('Field[controlId="host-selection"]').props().options;
const component = mount(
<ProviderWraper>
<ConversionHostWizardHostsStep {...baseProps} />
</ProviderWraper>
);
const filteredHostOptions = component
.find('Field[controlId="host-selection"]')
.first()
.props().options;
expect(filteredHostOptions.find(option => option === mockConfiguredRhvHost)).toBeFalsy();
expect(filteredHostOptions.find(option => option === mockInProgressRhvHost)).toBeFalsy();
});
Expand All @@ -98,10 +108,19 @@ describe('conversion host wizard hosts step', () => {
});

it('filters out options for OSP hosts that are configured or being configured', () => {
const component = shallowDive(
<ConversionHostWizardHostsStep {...baseProps} selectedProviderType={OPENSTACK} selectedCluster={mockOspTenant} />
const component = mount(
<ProviderWraper>
<ConversionHostWizardHostsStep
{...baseProps}
selectedProviderType={OPENSTACK}
selectedCluster={mockOspTenant}
/>
</ProviderWraper>
);
const filteredHostOptions = component.find('Field[controlId="host-selection"]').props().options;
const filteredHostOptions = component
.find('Field[controlId="host-selection"]')
.first()
.props().options;
expect(filteredHostOptions.find(option => option === mockConfiguredOspVm)).toBeFalsy();
expect(filteredHostOptions.find(option => option === mockInProgressOspVm)).toBeFalsy();
});
Expand Down
Loading