Commit 1b0a4516 authored by Jaden DIEFENBAUGH's avatar Jaden DIEFENBAUGH
Browse files

[js][tc] blocks are created w empty channel but w 1 i/o, first conn sets channel, closes #120

parent 460b8ddb
Pipeline #23689 failed with stages
in 56 minutes and 25 seconds
......@@ -259,7 +259,7 @@ export class ToolchainEditor extends React.PureComponent<Props, State> {
const toBlockNamesAndChannels = connectionData.map(c => [c.to.split('.')[0], c.channel]);
const assignBlockChannels = (blocks: BlockType[]) => {
return blocks.map(b => {
if(b.synchronized_channel !== '')
if(this.props.data.contents.connections.find(c => c.to.startsWith(`${ b.name }.`)) && b.synchronized_channel !== '')
return b;
const tbnc = toBlockNamesAndChannels.find(([n, c]) => n === b.name);
if(!tbnc)
......@@ -465,11 +465,15 @@ export class ToolchainEditor extends React.PureComponent<Props, State> {
if(newBlock === undefined){
newBlock = {};
if(set === 'blocks' || set === 'analyzers'){
newBlock.inputs = [];
newBlock.synchronized_channel = Object.keys(this.props.data.contents.representation.channel_colors)[0];
newBlock.inputs = [
'input',
];
newBlock.synchronized_channel = '';
}
if(set === 'blocks' || set === 'datasets'){
newBlock.outputs = [];
newBlock.outputs = [
'output',
];
}
}
newBlock.name = blockName;
......
......@@ -302,11 +302,13 @@ describe('<ToolchainEditor />', function() {
wrapper.find('rect#block_dataset').simulate('click');
wrapper.update();
expect(wrapper.find('ToolchainModal').props().active).to.equal(true);
expect(wrapper.find('.modal').find('CacheInput').props().value).to.equal('dataset');
wrapper.find('.modal').find('CacheInput').prop('onChange')( { target: { value: 'training_data' }});
expect(wrapper.find('.modal').find('CacheInput#tcModalInitFocus').props().value).to.equal('dataset');
wrapper.find('.modal').find('CacheInput#tcModalInitFocus').prop('onChange')( { target: { value: 'training_data' }});
wrapper.update();
/*
wrapper.find('.modal button.btn-secondary').simulate('click');
wrapper.update();
*/
wrapper.find('.modal button.btn-secondary').simulate('click');
wrapper.update();
wrapper.find('.modal CacheInput[value="output"]').prop('onChange')( { target: { value: 'measurements' }});
......@@ -329,11 +331,13 @@ describe('<ToolchainEditor />', function() {
wrapper.find('rect#block_dataset0').simulate('click');
wrapper.update();
expect(wrapper.find('ToolchainModal').props().active).to.equal(true);
expect(wrapper.find('.modal').find('CacheInput').props().value).to.equal('dataset0');
wrapper.find('.modal').find('CacheInput').prop('onChange')( { target: { value: 'testing_data' }});
expect(wrapper.find('.modal').find('CacheInput#tcModalInitFocus').props().value).to.equal('dataset0');
wrapper.find('.modal').find('CacheInput#tcModalInitFocus').prop('onChange')( { target: { value: 'testing_data' }});
wrapper.update();
/*
wrapper.find('.modal button.btn-secondary').simulate('click');
wrapper.update();
*/
wrapper.find('.modal button.btn-secondary').simulate('click');
wrapper.update();
wrapper.find('.modal CacheInput[value="output"]').prop('onChange')( { target: { value: 'measurements' }});
......@@ -355,15 +359,17 @@ describe('<ToolchainEditor />', function() {
wrapper.find('rect#block_block').simulate('click');
wrapper.update();
expect(wrapper.find('ToolchainModal').props().active).to.equal(true);
expect(wrapper.find('.modal').find('CacheInput').props().value).to.equal('block');
wrapper.find('.modal').find('CacheInput').prop('onChange')( { target: { value: 'training_alg' }});
expect(wrapper.find('.modal').find('CacheInput#tcModalInitFocus').props().value).to.equal('block');
wrapper.find('.modal').find('CacheInput#tcModalInitFocus').prop('onChange')( { target: { value: 'training_alg' }});
wrapper.update();
wrapper.find('.modal button.btn-secondary').at(0).simulate('click');
wrapper.update();
/*
wrapper.find('.modal button.btn-secondary').at(0).simulate('click');
wrapper.update();
wrapper.find('.modal button.btn-secondary').at(1).simulate('click');
wrapper.update();
*/
wrapper.find('.modal CacheInput[value="input"]').prop('onChange')( { target: { value: 'measurements' }});
wrapper.update();
wrapper.find('.modal CacheInput[value="input0"]').prop('onChange')( { target: { value: 'species' }});
......@@ -382,22 +388,24 @@ describe('<ToolchainEditor />', function() {
'outputs': [
'lda_machine'
],
'synchronized_channel': 'training_data',
'synchronized_channel': '',
});
// testing_alg
wrapper.find('rect#block_block0').simulate('click');
wrapper.update();
expect(wrapper.find('ToolchainModal').props().active).to.equal(true);
expect(wrapper.find('.modal').find('CacheInput').props().value).to.equal('block0');
wrapper.find('.modal').find('CacheInput').prop('onChange')( { target: { value: 'testing_alg' }});
expect(wrapper.find('.modal').find('CacheInput#tcModalInitFocus').props().value).to.equal('block0');
wrapper.find('.modal').find('CacheInput#tcModalInitFocus').prop('onChange')( { target: { value: 'testing_alg' }});
wrapper.update();
wrapper.find('.modal button.btn-secondary').at(0).simulate('click');
wrapper.update();
/*
wrapper.find('.modal button.btn-secondary').at(0).simulate('click');
wrapper.update();
wrapper.find('.modal button.btn-secondary').at(1).simulate('click');
wrapper.update();
*/
wrapper.find('.modal CacheInput[value="input"]').prop('onChange')( { target: { value: 'measurements' }});
wrapper.update();
wrapper.find('.modal CacheInput[value="input0"]').prop('onChange')( { target: { value: 'lda_machine' }});
......@@ -416,16 +424,18 @@ describe('<ToolchainEditor />', function() {
'outputs': [
'scores'
],
'synchronized_channel': 'training_data',
'synchronized_channel': '',
});
// analyzer
wrapper.find('rect#block_analyzer').simulate('click');
wrapper.update();
expect(wrapper.find('ToolchainModal').props().active).to.equal(true);
expect(wrapper.find('.modal').find('CacheInput').props().value).to.equal('analyzer');
expect(wrapper.find('.modal').find('CacheInput#tcModalInitFocus').props().value).to.equal('analyzer');
/*
wrapper.find('.modal button.btn-secondary').simulate('click');
wrapper.update();
*/
wrapper.find('.modal button.btn-secondary').simulate('click');
wrapper.update();
wrapper.find('.modal CacheInput[value="input"]').prop('onChange')( { target: { value: 'scores' }});
......@@ -441,7 +451,7 @@ describe('<ToolchainEditor />', function() {
'scores',
'species'
],
'synchronized_channel': 'training_data',
'synchronized_channel': '',
});
/* connect stuff via createConnections() */
......@@ -449,16 +459,17 @@ describe('<ToolchainEditor />', function() {
wrapper.instance().createConnections([{ from: 'training_data.measurements', to: 'training_alg.measurements', channel: 'training_data' }]);
// channel: training_data
wrapper.instance().createConnections([{ from: 'training_data.species', to: 'training_alg.species', channel: 'training_data' }]);
// channel: training_data
wrapper.instance().createConnections([{ from: 'training_alg.lda_machine', to: 'testing_alg.lda_machine', channel: 'training_data' }]);
// channel: testing_data
wrapper.instance().createConnections([{ from: 'testing_data.measurements', to: 'testing_alg.measurements', channel: 'testing_data' }]);
// channel: training_data
wrapper.instance().createConnections([{ from: 'testing_alg.scores', to: 'analyzer.scores', channel: 'training_data' }]);
wrapper.instance().createConnections([{ from: 'training_alg.lda_machine', to: 'testing_alg.lda_machine', channel: 'training_data' }]);
// channel: testing_data
wrapper.instance().createConnections([{ from: 'testing_data.species', to: 'analyzer.species', channel: 'testing_data' }]);
// channel: testing_data
wrapper.instance().createConnections([{ from: 'testing_alg.scores', to: 'analyzer.scores', channel: 'testing_data' }]);
/* fix channels */
/*
// testing_alg
wrapper.find('rect#block_testing_alg').simulate('click');
wrapper.update();
......@@ -467,6 +478,7 @@ describe('<ToolchainEditor />', function() {
wrapper.update();
wrapper.find('button.close').simulate('click');
wrapper.update();
*/
expect(wrapper.props().data.contents.blocks[1]).to.deep.equal({
'name': 'testing_alg',
......@@ -481,6 +493,7 @@ describe('<ToolchainEditor />', function() {
});
// analyzer
/*
wrapper.find('rect#block_analyzer').simulate('click');
wrapper.update();
expect(wrapper.find('ToolchainModal').props().active).to.equal(true);
......@@ -488,6 +501,7 @@ describe('<ToolchainEditor />', function() {
wrapper.update();
wrapper.find('button.close').simulate('click');
wrapper.update();
*/
expect(wrapper.props().data.contents.analyzers[0]).to.deep.equal({
'name': 'analyzer',
......
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