This repository has been archived by the owner on Jul 21, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for resolving migration plan POST body from redux state
- Loading branch information
Showing
3 changed files
with
200 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
...eact/screens/App/Overview/screens/PlanWizard/__tests__/__snapshots__/helpers.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`createMigrationPlans with a RHV target and playbooks 1`] = ` | ||
Object { | ||
"config_info": Object { | ||
"actions": Array [ | ||
Object { | ||
"osp_flavor_id": undefined, | ||
"osp_security_group_id": undefined, | ||
"post_service": false, | ||
"pre_service": true, | ||
"vm_id": "28", | ||
}, | ||
Object { | ||
"osp_flavor_id": undefined, | ||
"osp_security_group_id": undefined, | ||
"post_service": true, | ||
"pre_service": false, | ||
"vm_id": "36", | ||
}, | ||
], | ||
"post_service_id": "2", | ||
"pre_service_id": "1", | ||
"transformation_mapping_id": "1", | ||
}, | ||
"description": "", | ||
"name": "test RHV w/ playbooks", | ||
"prov_type": "generic_transformation_plan", | ||
} | ||
`; | ||
|
||
exports[`createMigrationPlans with an OSP target 1`] = ` | ||
Object { | ||
"config_info": Object { | ||
"actions": Array [ | ||
Object { | ||
"osp_flavor_id": "42000000000004", | ||
"osp_security_group_id": "42000000000016", | ||
"post_service": false, | ||
"pre_service": false, | ||
"vm_id": "42000000000017", | ||
}, | ||
Object { | ||
"osp_flavor_id": "42000000000002", | ||
"osp_security_group_id": "42000000000022", | ||
"post_service": false, | ||
"pre_service": false, | ||
"vm_id": "42000000000006", | ||
}, | ||
], | ||
"post_service_id": "", | ||
"pre_service_id": "", | ||
"transformation_mapping_id": "42000000000002", | ||
}, | ||
"description": "", | ||
"name": "test OSP plan", | ||
"prov_type": "generic_transformation_plan", | ||
} | ||
`; |
36 changes: 36 additions & 0 deletions
36
app/javascript/react/screens/App/Overview/screens/PlanWizard/__tests__/helpers.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { createMigrationPlans } from '../helpers'; | ||
import { ospPlanReduxFormState, rhvPlanReduxFormState } from '../planWizard.fixtures'; | ||
|
||
describe('createMigrationPlans', () => { | ||
test('with an OSP target', () => { | ||
const { | ||
planWizardGeneralStep, | ||
planWizardVMStep, | ||
planWizardInstancePropertiesStep, | ||
planWizardAdvancedOptionsStep | ||
} = ospPlanReduxFormState; | ||
const plansBody = createMigrationPlans( | ||
planWizardGeneralStep, | ||
planWizardVMStep, | ||
planWizardInstancePropertiesStep, | ||
planWizardAdvancedOptionsStep | ||
); | ||
expect(plansBody).toMatchSnapshot(); | ||
}); | ||
|
||
test('with a RHV target and playbooks', () => { | ||
const { | ||
planWizardGeneralStep, | ||
planWizardVMStep, | ||
planWizardInstancePropertiesStep, | ||
planWizardAdvancedOptionsStep | ||
} = rhvPlanReduxFormState; | ||
const plansBody = createMigrationPlans( | ||
planWizardGeneralStep, | ||
planWizardVMStep, | ||
planWizardInstancePropertiesStep, | ||
planWizardAdvancedOptionsStep | ||
); | ||
expect(plansBody).toMatchSnapshot(); | ||
}); | ||
}); |
105 changes: 105 additions & 0 deletions
105
app/javascript/react/screens/App/Overview/screens/PlanWizard/planWizard.fixtures.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
export const ospPlanReduxFormState = { | ||
planWizardGeneralStep: { | ||
registeredFields: { | ||
infrastructure_mapping: { name: 'infrastructure_mapping', type: 'Field', count: 0 }, | ||
name: { name: 'name', type: 'Field', count: 0 }, | ||
description: { name: 'description', type: 'Field', count: 0 }, | ||
vm_choice_radio: { name: 'vm_choice_radio', type: 'Field', count: 0 } | ||
}, | ||
values: { | ||
infrastructure_mapping: '42000000000002', | ||
vm_choice_radio: 'vms_via_discovery', | ||
name: 'test OSP plan', | ||
description: '' | ||
}, | ||
initial: { infrastructure_mapping: null, vm_choice_radio: 'vms_via_discovery', name: '', description: '' }, | ||
fields: { | ||
infrastructure_mapping: { visited: true }, | ||
name: { visited: true, touched: true }, | ||
description: { visited: true, touched: true } | ||
}, | ||
anyTouched: true | ||
}, | ||
planWizardVMStep: { | ||
registeredFields: { selectedVms: { name: 'selectedVms', type: 'Field', count: 0 } }, | ||
values: { selectedVms: ['42000000000017', '42000000000006'] }, | ||
initial: { selectedVms: [] } | ||
}, | ||
planWizardInstancePropertiesStep: { | ||
values: { | ||
instancePropertiesVms: { | ||
rows: { | ||
'42000000000017': { osp_security_group_id: '42000000000016', osp_flavor_id: '42000000000004' }, | ||
'42000000000006': { osp_security_group_id: '42000000000022', osp_flavor_id: '42000000000002' } | ||
}, | ||
updatedInstancePropertiesRowOnStandby: {} | ||
} | ||
}, | ||
initial: { instancePropertiesVms: { updatedInstancePropertiesRowOnStandby: {} } }, | ||
registeredFields: { instancePropertiesVms: { name: 'instancePropertiesVms', type: 'Field', count: 0 } } | ||
}, | ||
planWizardAdvancedOptionsStep: { | ||
values: { | ||
playbookVms: { preMigration: [], postMigration: [] }, | ||
preMigrationPlaybook: '', | ||
postMigrationPlaybook: '' | ||
}, | ||
initial: { | ||
playbookVms: { preMigration: [], postMigration: [] }, | ||
preMigrationPlaybook: '', | ||
postMigrationPlaybook: '' | ||
}, | ||
registeredFields: { | ||
preMigrationPlaybook: { name: 'preMigrationPlaybook', type: 'Field', count: 0 }, | ||
postMigrationPlaybook: { name: 'postMigrationPlaybook', type: 'Field', count: 0 }, | ||
playbookVms: { name: 'playbookVms', type: 'Field', count: 0 } | ||
} | ||
} | ||
}; | ||
|
||
export const rhvPlanReduxFormState = { | ||
planWizardGeneralStep: { | ||
values: { | ||
infrastructure_mapping: '1', | ||
vm_choice_radio: 'vms_via_discovery', | ||
name: 'test RHV w/ playbooks', | ||
description: '' | ||
}, | ||
initial: { infrastructure_mapping: null, vm_choice_radio: 'vms_via_discovery', name: '', description: '' }, | ||
registeredFields: { | ||
infrastructure_mapping: { name: 'infrastructure_mapping', type: 'Field', count: 0 }, | ||
name: { name: 'name', type: 'Field', count: 0 }, | ||
description: { name: 'description', type: 'Field', count: 0 }, | ||
vm_choice_radio: { name: 'vm_choice_radio', type: 'Field', count: 0 } | ||
}, | ||
fields: { | ||
infrastructure_mapping: { visited: true }, | ||
name: { visited: true, touched: true }, | ||
description: { visited: true, touched: true } | ||
}, | ||
anyTouched: true | ||
}, | ||
planWizardVMStep: { | ||
values: { selectedVms: ['28', '36'] }, | ||
initial: { selectedVms: [] }, | ||
registeredFields: { selectedVms: { name: 'selectedVms', type: 'Field', count: 0 } } | ||
}, | ||
planWizardInstancePropertiesStep: {}, | ||
planWizardAdvancedOptionsStep: { | ||
values: { | ||
playbookVms: { preMigration: ['28'], postMigration: ['36'] }, | ||
preMigrationPlaybook: '1', | ||
postMigrationPlaybook: '2' | ||
}, | ||
initial: { | ||
playbookVms: { preMigration: [], postMigration: [] }, | ||
preMigrationPlaybook: '', | ||
postMigrationPlaybook: '' | ||
}, | ||
registeredFields: { | ||
preMigrationPlaybook: { name: 'preMigrationPlaybook', type: 'Field', count: 0 }, | ||
postMigrationPlaybook: { name: 'postMigrationPlaybook', type: 'Field', count: 0 }, | ||
playbookVms: { name: 'playbookVms', type: 'Field', count: 0 } | ||
} | ||
} | ||
}; |