From 5ab640b9e2a0529aeb6cc917b5ca59625638b5de Mon Sep 17 00:00:00 2001
From: mbucknell <mbucknell@usgs.gov>
Date: Mon, 8 Mar 2021 11:09:02 -0600
Subject: [PATCH] Need to set the selectedIVMethodID regardless of whether
 showOnlyGraph is true or false. This will fix the issue with WDFN-504.

---
 .../components/hydrograph/index.js            |  7 ++++++-
 .../components/hydrograph/index.test.js       | 21 -------------------
 2 files changed, 6 insertions(+), 22 deletions(-)

diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/index.js b/assets/src/scripts/monitoring-location/components/hydrograph/index.js
index b9d68e99e..3957098a2 100644
--- a/assets/src/scripts/monitoring-location/components/hydrograph/index.js
+++ b/assets/src/scripts/monitoring-location/components/hydrograph/index.js
@@ -30,6 +30,9 @@ import {drawSelectionTable} from './parameters';
 import {drawTimeSeriesGraph} from './time-series-graph';
 import {drawTooltipCursorSlider} from './tooltip';
 
+import {getPreferredIVMethodID} from './selectors/time-series-data';
+
+
 
 /*
  * Renders the hydrograph on the node element using the Redux store for state information. The siteno, latitude, and
@@ -93,7 +96,6 @@ export const attachToNode = function(store,
         } else {
             store.dispatch(setSelectedDateRange('P7D'));
         }
-        store.dispatch(setSelectedIVMethodID(timeSeriesId));
     }
 
     // Fetch waterwatch flood levels
@@ -106,6 +108,9 @@ export const attachToNode = function(store,
     }
     Promise.all(fetchDataPromises).then(() => {
         showDataLoadingIndicator(false);
+        // selectedIVMethodID should be set regardless of whether we are showing only the graph but the preferred method ID
+        // can not be determined until the data is fetched so that is done here.
+        store.dispatch(setSelectedIVMethodID(timeSeriesId) || getPreferredIVMethodID(store.getState()));
         let graphContainer = nodeElem.select('.graph-container');
         graphContainer.call(drawTimeSeriesGraph, store, siteno, agencyCode, sitename, showMLName, !showOnlyGraph);
 
diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/index.test.js b/assets/src/scripts/monitoring-location/components/hydrograph/index.test.js
index 5e16f4269..a784d7f34 100644
--- a/assets/src/scripts/monitoring-location/components/hydrograph/index.test.js
+++ b/assets/src/scripts/monitoring-location/components/hydrograph/index.test.js
@@ -199,27 +199,6 @@ describe('monitoring-location/components/hydrograph module', () => {
                     selectedIVMethodID: undefined
                 });
             });
-
-            it('With timeSeriesId set', () => {
-                attachToNode(store, graphNode, {
-                    ...INITIAL_PARAMETERS,
-                    timeSeriesId: '90649'
-                });
-                expect(retrieveHydrographDataSpy).toHaveBeenCalledWith('11112222', {
-                    parameterCode: '72019',
-                    period: 'P7D',
-                    startTime: null,
-                    endTime: null,
-                    loadCompare: undefined,
-                    loadMedian: false
-                });
-                expect(store.getState().hydrographState).toEqual({
-                    selectedParameterCode: '72019',
-                    selectedDateRange: 'P7D',
-                    showCompareIVData: undefined,
-                    selectedIVMethodID: '90649'
-                });
-            });
         });
 
         it('Should fetch the hydrograph parameters', () => {
-- 
GitLab