From 3b06dfccdbd7f6a5afee7af9265464a0f9a074f4 Mon Sep 17 00:00:00 2001 From: jrmartin Date: Mon, 12 Apr 2021 17:50:34 -0700 Subject: [PATCH 01/24] #1106 Test circuit browser --- .../interface/VFBCircuitBrowser/Controls.js | 24 +++-- .../jest/vfb/review/circuit-browser-tests.js | 93 ++++++++++++++++++- tests/jest/vfb/utils.js | 16 ++++ 3 files changed, 120 insertions(+), 13 deletions(-) diff --git a/components/interface/VFBCircuitBrowser/Controls.js b/components/interface/VFBCircuitBrowser/Controls.js index 7e2d6391d..5acd836fe 100644 --- a/components/interface/VFBCircuitBrowser/Controls.js +++ b/components/interface/VFBCircuitBrowser/Controls.js @@ -171,11 +171,10 @@ class Controls extends Component { // remove neuron textfield let neurons = this.state.neuronFields; neurons.splice(id,1); - - this.props.vfbCircuitBrowser(UPDATE_CIRCUIT_QUERY, neurons); + this?.props?.circuitQuerySelected?.splice(id, 1); // Update state with one fewer neuron textfield - this.setState( { neuronFields : neurons } ); + this.setState( { neuronFields : neurons } ); } /** @@ -272,7 +271,9 @@ class Controls extends Component { resultSelectedChanged (event, value) { // Copy neurons and add selection to correct array index let neurons = this.state.neuronFields; - neurons[this.setInputValue] = { id : this.state.filteredResults?.[value].short_form, label : value }; + let shortForm = this.state.filteredResults?.[value].short_form; + let index = neurons.findIndex((neuron) => neuron.id === shortForm); + index > -1 ? neurons[index] = { id : shortForm, label : value } : null // Keep track of query selected, and send an event to redux store that circuit has been updated this.circuitQuerySelected = neurons; @@ -355,7 +356,7 @@ class Controls extends Component { { this.props.resultsAvailable() - ?