Commit 1b0beb77 authored by Jaden Diefenbaugh's avatar Jaden Diefenbaugh

Toggling analyzer to normal alg adds an output

When changing an analyzer algorithm to be a normal algorithm,
the editor will automatically add an output to the first
endpoint group in the algorithm, if a group exists.

See #145 and !46
parent f627c099
Pipeline #27509 passed with stages
in 18 minutes and 32 seconds
......@@ -182,7 +182,7 @@ export class AlgorithmEditor extends React.Component<Props, State> {
const contents = copyObj(this.props.data.contents);
delete contents.results;
if(contents.groups.length > 0)
contents.groups[0].outputs = {};
contents.groups[0].outputs = {'output': { type: '' }};
contents.splittable = false;
const newCache = {
......
......@@ -670,4 +670,71 @@ describe('<AlgorithmEditor />', () => {
});
});
describe.only('regression', () => {
it(`adds an output and removes results when toggling from analyzer to normal`, () => {
const contents = {
description: '',
uses: {},
parameters: {},
'language': 'python',
'groups': [
{
name: 'group',
'inputs': {
'in_data': {
'type': 'system/integer/1'
}
}
}
],
'results': {
'out_data': {
'type': 'float32',
'display': false
},
'plot': {
'type': 'plot/scatter/1',
'display': false
}
}
};
const saveFunc = sinon.spy();
const _updateFunc = (obj) => {
wrapper.setProps && wrapper.setProps({ data: obj });
};
const updateFunc = sinon.spy(_updateFunc);
const algName = 'user/integers_mean_analyzer/1';
const obj = {
name: algName,
contents,
};
wrapper = mount(
<C
data={getValidObj(obj)}
algorithms={[]}
dataformats={testDfs}
libraries={testLibs}
saveFunc={saveFunc}
updateFunc={updateFunc}
/>
);
expect(wrapper).to.have.props(
['data', 'algorithms', 'dataformats', 'libraries', 'saveFunc', 'updateFunc']
);
expect(wrapper.props().data).to.have.property('name', algName);
wrapper.find('#algAnalyzer input').prop('onChange')( { target: { checked: false }});
expect(wrapper.props().data.contents).to.not.have.property('results');
expect(wrapper.props().data.contents).to.have.property('groups').with.lengthOf(1);
expect(wrapper.props().data.contents.groups[0]).to.have.property('inputs');
expect(wrapper.props().data.contents.groups[0]).to.have.property('outputs');
expect(wrapper.props().data.contents.groups[0].outputs).to.have.deep.property('output', {
type: ''
});
});
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment