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