Commit b4b9c12c authored by Flavio TARSETTI's avatar Flavio TARSETTI

Merge branch 'new-alg-with-io-145' into 'master'

New algorithms are created with an input & output

Closes #145

See merge request !46
parents fbe7bd60 1b0beb77
Pipeline #27541 passed with stages
in 19 minutes and 20 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 = {
......
......@@ -122,21 +122,16 @@ describe('<AlgorithmEditor />', () => {
expect(wrapper.props().data.contents.groups[0]).to.have.property('name', 'group');
wrapper.find('button#newInputBtn').simulate('click');
expect(updateFunc.callCount).to.equal(2);
wrapper.find('button#newOutputBtn').simulate('click');
expect(updateFunc.callCount).to.equal(3);
wrapper.find('.algInput').find('CacheInput').prop('onChange')( { target: { value: 'in_data' }});
expect(updateFunc.callCount).to.equal(4);
expect(updateFunc.callCount).to.equal(2);
wrapper.find('.algOutput').find('CacheInput').prop('onChange')( { target: { value: 'out_data' }});
expect(updateFunc.callCount).to.equal(5);
expect(updateFunc.callCount).to.equal(3);
const ioType = 'system/integer/1';
wrapper.find('.algInput select').prop('onChange')( { target: { value: ioType }});
expect(updateFunc.callCount).to.equal(6);
expect(updateFunc.callCount).to.equal(4);
wrapper.find('.algOutput select').prop('onChange')( { target: { value: ioType }});
expect(updateFunc.callCount).to.equal(7);
expect(updateFunc.callCount).to.equal(5);
expect(wrapper.props().data.contents.groups[0].inputs).to.have.deep.property('in_data', { type: ioType });
expect(wrapper.props().data.contents.groups[0].outputs).to.have.deep.property('out_data', { type: ioType });
......@@ -198,9 +193,6 @@ describe('<AlgorithmEditor />', () => {
expect(wrapper.props().data.contents.groups[0]).to.have.property('name', 'group');
wrapper.find('button#newInputBtn').simulate('click');
wrapper.find('button#newOutputBtn').simulate('click');
wrapper.find('.algInput').find('CacheInput').prop('onChange')( { target: { value: 'in_data' }});
wrapper.find('.algOutput').find('CacheInput').prop('onChange')( { target: { value: 'out_data' }});
......@@ -311,8 +303,6 @@ describe('<AlgorithmEditor />', () => {
expect(wrapper.props().data.contents.groups[0]).to.have.property('name', 'group');
wrapper.find('button#newInputBtn').simulate('click');
wrapper.find('.algInput').find('CacheInput').prop('onChange')( { target: { value: 'in_data' }});
const ioType = 'system/integer/1';
......@@ -438,9 +428,6 @@ describe('<AlgorithmEditor />', () => {
// Group 1
expect(wrapper.props().data.contents.groups[0]).to.have.property('name', 'group');
wrapper.find('#endpoint0 button#newInputBtn').simulate('click');
wrapper.find('#endpoint0 button#newOutputBtn').simulate('click');
wrapper.find('#endpoint0 .algInput').find('CacheInput').prop('onChange')( { target: { value: 'in_data' }});
wrapper.find('#endpoint0 .algOutput').find('CacheInput').prop('onChange')( { target: { value: 'out_data' }});
......@@ -525,9 +512,6 @@ describe('<AlgorithmEditor />', () => {
expect(wrapper.props().data.contents.groups[0]).to.have.property('name', 'group');
wrapper.find('button#newInputBtn').simulate('click');
wrapper.find('button#newOutputBtn').simulate('click');
wrapper.find('.algInput').find('CacheInput').prop('onChange')( { target: { value: 'in_data' }});
wrapper.find('.algOutput').find('CacheInput').prop('onChange')( { target: { value: 'out_data' }});
......@@ -622,8 +606,6 @@ describe('<AlgorithmEditor />', () => {
expect(wrapper.props().data.contents.groups[0]).to.have.property('name', 'group');
wrapper.find('button#newInputBtn').simulate('click');
wrapper.find('.algInput').find('CacheInput').prop('onChange')( { target: { value: 'in_data' }});
const ioType = 'system/integer/1';
......@@ -688,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: ''
});
});
});
});
......@@ -272,8 +272,8 @@ export const getValidAlgorithmObj = (data: BeatObject = {name: '', contents: {}}
groups: [
{
name: 'group',
inputs: {},
outputs: {},
inputs: {'input': { type: '' }},
outputs: {'output': { type: '' }},
}
],
description: '',
......
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