Commit 6c4ee404 authored by Jaden DIEFENBAUGH's avatar Jaden DIEFENBAUGH Committed by Flavio TARSETTI
Browse files

[js][exp] keep type inference on after choosing data/alg, closes #127

parent cc0f5743
......@@ -141,14 +141,15 @@ const isValidEntity = (
possibleObj: {inputs: any, outputs: any} = {inputs:{},outputs:{}},
inferredTypes = {}
): boolean => {
if(!blockTcEntity.hasOwnProperty('inputs') && Object.keys(possibleObj.inputs).length > 0)
const hasInputs = Array.isArray(blockTcEntity.inputs);
const hasOutputs = Array.isArray(blockTcEntity.outputs);
if(!hasInputs && Object.keys(possibleObj.inputs).length > 0)
return false;
if(!blockTcEntity.hasOwnProperty('outputs') && Object.keys(possibleObj.outputs).length > 0)
if(!hasOutputs && Object.keys(possibleObj.outputs).length > 0)
return false;
if(blockTcEntity.hasOwnProperty('inputs') && blockTcEntity.inputs.length !== Object.keys(possibleObj.inputs).length)
if(hasInputs && blockTcEntity.inputs.length !== Object.keys(possibleObj.inputs).length)
return false;
if(blockTcEntity.hasOwnProperty('inputs') &&
blockTcEntity.hasOwnProperty('outputs') &&
if(hasInputs && hasOutputs &&
blockTcEntity.outputs.length !== Object.keys(possibleObj.outputs).length
)
return false;
......@@ -590,9 +591,11 @@ export class ExperimentEditor extends React.Component<Props, State> {
const newDs = JSON.parse(str);
//console.log(newDs);
this.setContents({...this.props.data.contents, datasets: newDs});
/*
for(const dataset in this.props.data.contents.datasets){
this.setLockMap(dataset, true);
}
*/
}}
>
<option value=''>Protocol...</option>
......@@ -692,7 +695,7 @@ export class ExperimentEditor extends React.Component<Props, State> {
const newDs = {...this.props.data.contents.datasets, [name]: ds};
this.setContents({...this.props.data.contents, datasets: newDs});
this.setLockMap(name, true);
//this.setLockMap(name, true);
}}
>
<option value=''>Dataset...</option>
......@@ -897,7 +900,7 @@ export class ExperimentEditor extends React.Component<Props, State> {
};
updateBlock(thisBlock, globals);
this.setLockMap(blockName, true);
//this.setLockMap(blockName, true);
}}
>
<option value=''>Algorithm...</option>
......
......@@ -611,5 +611,84 @@ describe('<ExperimentEditor />', () => {
}
});
});
it(`doesnt change the lockMap after an algorithm or dataset is assigned`, () => {
const expName = 'user/user/single/1/single_add';
const saveFunc = sinon.spy();
const _updateFunc = (obj) => {
wrapper.setProps && wrapper.setProps({ data: obj });
};
const updateFunc = sinon.spy(_updateFunc);
const tc = testTcs.find(tc => expName.includes(tc.name));
wrapper = mount(
<C
data={getValidObj({name: expName, contents: {}}, tc, [...normalBlocks, ...analyzerBlocks])}
experiments={[]}
normalBlocks={normalBlocks}
analyzerBlocks={analyzerBlocks}
datasets={datasets}
toolchain={tc}
saveFunc={saveFunc}
environments={envs}
updateFunc={updateFunc}
/>
);
expect(wrapper.props().data).to.have.property('name', expName);
//console.log('finished name change, doing dataset');
wrapper.find('svg #block_set').simulate('click');
wrapper.find('div.dataset0 select').simulate('change', { target: { value: 'protocol/set (simple/1)'}});
expect(updateFunc.callCount).to.equal(1);
expect(wrapper.props().data.contents).to.have.deep.property('datasets', {
'set': {
'set': 'set',
'protocol': 'protocol',
'database': 'simple/1'
}
});
//console.log('finished dataset, doing block');
wrapper.find('svg #block_echo').simulate('click');
expect(wrapper.find({ name: 'echo', set: 'blocks'}).find('.tcBlockBackground').prop('className')).to.include('highlighted');
wrapper.find('div.block0 div.algorithm select').at(0).simulate('change', { target: { value: 'user/integers_add/1'}});
expect(updateFunc.callCount).to.equal(2);
expect(wrapper.props().data.contents).to.have.deep.property('blocks', {
'echo': {
'inputs': {
'in_data': 'in'
},
'algorithm': 'user/integers_add/1',
'outputs': {
'out_data': 'out'
},
parameters: {}
}
});
//console.log('finished block, doing analyzer');
wrapper.find('svg #block_analysis').simulate('click');
expect(wrapper.find({ name: 'analysis', set: 'analyzers'}).find('.tcBlockBackground').prop('className')).to.include('highlighted');
wrapper.find('div.block0 div.algorithm select').at(0).simulate('change', { target: { value: 'user/integers_echo_analyzer/1'}});
expect(updateFunc.callCount).to.equal(3);
expect(wrapper.props().data.contents).to.have.deep.property('analyzers', {
'analysis': {
'inputs': {
'in_data': 'in'
},
'algorithm': 'user/integers_echo_analyzer/1',
parameters: {},
}
});
expect(wrapper.state().lockMap).to.deep.equal({
set: false,
echo: false,
analysis: false,
});
});
});
});
Supports Markdown
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