Skip to content
Snippets Groups Projects
Commit 103dde84 authored by Bucknell, Mary S.'s avatar Bucknell, Mary S.
Browse files

Added code to change the classic page link if no iv time series data has been...

Added code to change the classic page link if no iv time series data has been fetched. Added a few tests for this and the appearance of the info alert that is shown when there is no iv time series data
parent 9b548ada
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ import {select} from 'd3-selection';
import {createStructuredSelector} from 'reselect';
import config from '../../config.js';
import {drawWarningAlert, drawInfoAlert} from '../../d3-rendering/alerts';
import {drawLoadingIndicator} from '../../d3-rendering/loading-indicator';
import {link} from '../../lib/d3-redux';
......@@ -114,6 +115,10 @@ export const attachToNode = function (store,
.call(drawLoadingIndicator, {showLoadingIndicator: false, sizeClass: 'fa-3x'});
if (!hasAnyTimeSeries(store.getState())) {
drawInfoAlert(nodeElem, {body: 'No time series data available for this site'});
if (!showOnlyGraph) {
document.getElementById('classic-page-link')
.setAttribute('href', `${config.NWIS_INVENTORY_ENDPOINT}?site_no=${siteno}`);
}
} else {
//Update time series state
if (parameterCode) {
......
......@@ -166,6 +166,9 @@ describe('Hydrograph charting and Loading indicators and data alerts', () => {
beforeEach(() => {
let body = select('body');
body.append('a')
.attr('id','classic-page-link')
.attr('href', 'https://fakeserver/link');
let component = body.append('div')
.attr('id', 'hydrograph');
component.append('div').attr('class', 'loading-indicator-container');
......@@ -182,6 +185,7 @@ describe('Hydrograph charting and Loading indicators and data alerts', () => {
afterEach(() => {
jasmine.Ajax.uninstall();
select('#hydrograph').remove();
select('#classic-page-link').remove();
});
it('expect alert if no siteno defined', () => {
......@@ -411,6 +415,44 @@ describe('Hydrograph charting and Loading indicators and data alerts', () => {
});
});
describe('graphNode contains the expected elements when no IV time series has been retrieved and showOnlyGraph is false', () => {
let store;
beforeEach((done) => {
spyOn(floodDataActions, 'retrieveWaterwatchData').and.returnValue(function () {
return Promise.resolve({});
});
spyOn(ivTimeSeriesDataActions, 'retrieveIVTimeSeries').and.returnValue(function () {
return Promise.resolve({});
});
store = configureStore({
...TEST_STATE,
ivTimeSeriesData: {},
ivTimeSeriesState: {
...TEST_STATE.ivTimeSeriesState,
currentIVVariableID: '',
currentIVDateRangeKind: ''
},
ui: {
windowWidth: 400,
width: 400
}
});
attachToNode(store, graphNode, {siteno: '12345678'});
window.requestAnimationFrame(() => {
done();
});
});
it('should show info alert', () => {
expect(select('.usa-alert--info').size()).toBe(1);
});
it('should use inventory for classic page link', () => {
expect(select('#classic-page-link').attr('href')).toContain('https://fakenwis.usgs.gov/inventory');
});
});
describe('graphNode contains the expected elements when showOnlyGraph is false', () => {
/* eslint no-use-before-define: 0 */
let store;
......@@ -458,14 +500,7 @@ describe('Hydrograph charting and Loading indicators and data alerts', () => {
ui: {
windowWidth: 400,
width: 400
},
floodState: {
actionStage: 1,
floodStage: 2,
moderateFloodStage: 3,
majorFloodStage: 4
}
}
});
attachToNode(store, graphNode, {siteno: '12345678'});
......@@ -474,6 +509,14 @@ describe('Hydrograph charting and Loading indicators and data alerts', () => {
});
});
it('should not show info alert', () => {
expect(select('.usa-alert--info').size()).toBe(0);
});
it('should not use inventory for classic page link', () => {
expect(select('#classic-page-link').attr('href')).not.toContain('https://fakenwis.usgs.gov/inventory');
});
it('should render the correct number of svg nodes', () => {
// one main hydrograph, brush, slider, legend and two sparklines
expect(selectAll('svg').size()).toBe(6);
......
var CONFIG = {
TIMESERIES_AUDIO_ENABLED: true,
FIM_GIS_ENDPOINT: 'https:/fakelegendservice.com',
NWIS_INVENTORY_ENDPOINT: 'https://fakenwis.usgs.gov/inventory',
NETWORK_ENDPOINT: 'https://fakeogcservice.com/observations/collections',
OBSERVATIONS_ENDPOINT: 'https://fakeogcservice.com/observations/collections/monitoring-locations',
uvPeriodOfRecord: {
......
......@@ -16,6 +16,7 @@
var CONFIG = {
'SERVICE_ROOT': '{{ config.SERVICE_ROOT }}/nwis',
'PAST_SERVICE_ROOT': '{{ config.PAST_SERVICE_ROOT }}/nwis',
'NWIS_INVENTORY_ENDPOINT': '{{ config.NWIS_ENDPOINTS.INVENTORY }}',
'OBSERVATIONS_ENDPOINT': '{{ config.OBSERVATIONS_ENDPOINT }}',
'HYDRO_ENDPOINT': '{{ config.HYDRO_ENDPOINT }}',
'FIM_GIS_ENDPOINT': '{{ config.FIM_GIS_ENDPOINT }}',
......
......@@ -70,7 +70,7 @@
<h1>{{ stations[0].station_nm }}</h1>
<div>
<span class="usa-tag">Important</span>
<a class="usa-link" aria-describedby="{{ 'classic'|tooltip_content_id }}" href="{{ config.NWIS_ENDPOINTS.UV}}?site_no={{stations[0].site_no}}" target="_blank">Classic Page</a>
<a id="classic-page-link" class="usa-link" aria-describedby="{{ 'classic'|tooltip_content_id }}" href="{{ config.NWIS_ENDPOINTS.UV}}?site_no={{stations[0].site_no}}" target="_blank">Classic Page</a>
{{ components.QuestionTooltip('classic', 'View all current conditions values on the classic Water Data for the Nation interface.', True) }}
</div>
<p id="site-description">{{ components.Description(stations[0].site_no, location_with_values, parm_grp_summary) }}</p>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment