mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 02:50:02 -03:30
add tests for preview step extra vars
This commit is contained in:
parent
5eeb8b0337
commit
fe7df910e2
@ -1,6 +1,6 @@
|
||||
import yaml from 'js-yaml';
|
||||
|
||||
export default function mergeExtraVars(extraVars, survey = {}) {
|
||||
export default function mergeExtraVars(extraVars = '', survey = {}) {
|
||||
const vars = yaml.safeLoad(extraVars) || {};
|
||||
return {
|
||||
...vars,
|
||||
|
||||
@ -32,6 +32,10 @@ describe('mergeExtraVars', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('should handle undefined', () => {
|
||||
expect(mergeExtraVars(undefined, undefined)).toEqual({});
|
||||
});
|
||||
|
||||
describe('maskPasswords', () => {
|
||||
test('should mask password fields', () => {
|
||||
const vars = {
|
||||
|
||||
@ -71,8 +71,30 @@ describe('PreviewStep', () => {
|
||||
expect(detail).toHaveLength(1);
|
||||
expect(detail.prop('resource')).toEqual(resource);
|
||||
expect(detail.prop('overrides')).toEqual({
|
||||
extra_vars: '---',
|
||||
limit: '4',
|
||||
});
|
||||
});
|
||||
|
||||
test('should handle extra vars without survey', async () => {
|
||||
let wrapper;
|
||||
await act(async () => {
|
||||
wrapper = mountWithContexts(
|
||||
<Formik initialValues={{ extra_vars: 'one: 1' }}>
|
||||
<PreviewStep
|
||||
resource={resource}
|
||||
config={{
|
||||
ask_variables_on_launch: true,
|
||||
}}
|
||||
/>
|
||||
</Formik>
|
||||
);
|
||||
});
|
||||
|
||||
const detail = wrapper.find('PromptDetail');
|
||||
expect(detail).toHaveLength(1);
|
||||
expect(detail.prop('resource')).toEqual(resource);
|
||||
expect(detail.prop('overrides')).toEqual({
|
||||
extra_vars: 'one: 1',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user