mirror of
https://github.com/ansible/awx.git
synced 2026-02-19 04:00:06 -03:30
add tests for preview step extra vars
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
|
|
||||||
export default function mergeExtraVars(extraVars, survey = {}) {
|
export default function mergeExtraVars(extraVars = '', survey = {}) {
|
||||||
const vars = yaml.safeLoad(extraVars) || {};
|
const vars = yaml.safeLoad(extraVars) || {};
|
||||||
return {
|
return {
|
||||||
...vars,
|
...vars,
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ describe('mergeExtraVars', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should handle undefined', () => {
|
||||||
|
expect(mergeExtraVars(undefined, undefined)).toEqual({});
|
||||||
|
});
|
||||||
|
|
||||||
describe('maskPasswords', () => {
|
describe('maskPasswords', () => {
|
||||||
test('should mask password fields', () => {
|
test('should mask password fields', () => {
|
||||||
const vars = {
|
const vars = {
|
||||||
|
|||||||
@@ -71,8 +71,30 @@ describe('PreviewStep', () => {
|
|||||||
expect(detail).toHaveLength(1);
|
expect(detail).toHaveLength(1);
|
||||||
expect(detail.prop('resource')).toEqual(resource);
|
expect(detail.prop('resource')).toEqual(resource);
|
||||||
expect(detail.prop('overrides')).toEqual({
|
expect(detail.prop('overrides')).toEqual({
|
||||||
extra_vars: '---',
|
|
||||||
limit: '4',
|
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',
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user