Merge pull request #5705 from AlexSCorey/5599-VariableDetailsAbsent

Ensures Variables Details renders even when no value.

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot] 2020-01-20 18:40:04 +00:00 committed by GitHub
commit 99ce277b06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -14,10 +14,6 @@ function VariablesDetail({ value, label, rows }) {
const [currentValue, setCurrentValue] = useState(value);
const [error, setError] = useState(null);
if (!value) {
return null;
}
return (
<>
<DetailName
@ -62,7 +58,7 @@ function VariablesDetail({ value, label, rows }) {
>
<CodeMirrorInput
mode={mode}
value={currentValue}
value={currentValue || '---'} // When github issue https://github.com/ansible/awx/issues/5502 gets resolved this line of code should be revisited and refactored if possible.
readOnly
rows={rows}
css="margin-top: 10px"

View File

@ -40,4 +40,9 @@ describe('<VariablesDetail>', () => {
expect(input2.prop('mode')).toEqual('yaml');
expect(input2.prop('value')).toEqual('foo: bar\n');
});
test('should render label and value= --- when there are no values', () => {
const wrapper = shallow(<VariablesDetail value="" label="Variables" />);
expect(wrapper.find('Styled(CodeMirrorInput)').length).toBe(1);
expect(wrapper.find('div.pf-c-form__label').text()).toBe('Variables');
});
});