Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

some refinements and e2e tests

Jason Kent04fe3699c748
diff --git a/e2e/features/events/event-filter-test.js b/e2e/features/events/event-filter-test.js
new file mode 100644
index 000000000..d8bb13a47
--- /dev/null
+++ b/e2e/features/events/event-filter-test.js
@@ -0,0 +1,222 @@
+const reuseables = require('../../reuseables/skip-tour.js');
+const { switchProjection } = require('../../reuseables/switch-projection');
+const {
+ fixedAppNow,
+ wildfiresWithDates,
+ backwardsCompatibleEventUrl,
+} = require('../../reuseables/querystrings.js');
+
+const TIME_LIMIT = 10000;
+const layersTab = '#layers-sidebar-tab';
+const eventsTab = '#events-sidebar-tab';
+const filterIcons = '.filter-icons > .event-icon';
+const dustHazeIcon = '.filter-icons > #filter-dust-and-haze';
+const volcanoesIcon = '.filter-icons > #filter-volcanoes';
+const wildfiresIcon = '.filter-icons > #filter-wildfires';
+const filterDates = '.filter-dates';
+const filterButton = '#event-filter-button';
+const filterModal = '.event-filter-modal';
+const filterModalApply = '#filter-apply-btn';
+const filterModalCancel = '#filter-cancel-btn';
+const eventList = '.wv-eventslist';
+const startInput = {
+ year: '#year-event-filter-start',
+ month: '#month-event-filter-start',
+ day: '#day-event-filter-start',
+};
+const endInput = {
+ year: '#year-event-filter-end',
+ month: '#month-event-filter-end',
+ day: '#day-event-filter-end',
+};
+const dustSwitch = '#dustHaze-switch';
+const manmadeSwitch = '#manmade-switch';
+const seaLakeIceSwitch = '#seaLakeIce-switch';
+const severeStormsSwitch = '#severeStorms-switch';
+const snowSwitch = '#snow-switch';
+const volcanoesSwitch = '#volcanoes-switch';
+const watercolorSwitch = '#waterColor-switch';
+const wildfiresSwitch = '#wildfires-switch';
+const mapExtentFilterCheckbox = '#map-extent-filter';
+
+const getSwitchToggle = (inputId) => `${inputId} + .react-switch-label`;
+
+const openFilterModal = (c) => {
+ c.waitForElementVisible(eventList, TIME_LIMIT);
+ c.click(filterButton);
+ c.waitForElementVisible(filterModal, TIME_LIMIT);
+};
+
+const assertDateInputValues = (c, start, end) => {
+ const [startYear, startMonth, startDay] = start.split('-');
+ const [endYear, endMonth, endDay] = end.split('-');
+ c.assert.value(startInput.year, startYear);
+ c.assert.value(startInput.month, startMonth);
+ c.assert.value(startInput.day, startDay);
+ c.assert.value(endInput.year, endYear);
+ c.assert.value(endInput.month, endMonth);
+ c.assert.value(endInput.day, endDay);
+};
+
+module.exports = {
+ before(c) {
+ reuseables.loadAndSkipTour(c, TIME_LIMIT);
+ },
+ 'Default filtering includes last 120 days and all categories': (c) => {
+ c.url(c.globals.url + fixedAppNow);
+ c.waitForElementVisible(layersTab, TIME_LIMIT);
+ c.click(eventsTab);
+ c.expect.elements(filterIcons).count.to.equal(8);
+ c.assert.containsText(filterDates, '2011 SEP 01 - 2011 DEC 31');
+ },
+ 'Filter modal inputs are correct': (c) => {
+ openFilterModal(c);
+ assertDateInputValues(c, '2011-SEP-01', '2011-DEC-31');
+ c.expect.element(dustSwitch).to.be.selected;
+ c.expect.element(manmadeSwitch).to.be.selected;
+ c.expect.element(seaLakeIceSwitch).to.be.selected;
+ c.expect.element(severeStormsSwitch).to.be.selected;
+ c.expect.element(snowSwitch).to.be.selected;
+ c.expect.element(volcanoesSwitch).to.be.selected;
+ c.expect.element(watercolorSwitch).to.be.selected;
+ c.expect.element(wildfiresSwitch).to.be.selected;
+ c.expect.element(mapExtentFilterCheckbox).to.not.be.selected;
+ },
+ 'URL params for categories, dates, and extent filtering are present': (c) => {
+ c.assert.urlParameterEquals('e', 'true');
+ c.assert.urlParameterEquals('efc', 'dustHaze,manmade,seaLakeIce,severeStorms,snow,volcanoes,waterColor,wildfires');
+ c.assert.urlParameterEquals('efd', '2011-09-01,2011-12-31');
+ c.assert.urlParameterEquals('efs', 'true');
+ },
+
+ 'Loading from permalink sets all criteria properly': (c) => {
+ c.url(c.globals.url + wildfiresWithDates);
+ c.assert.urlParameterEquals('e', 'true');
+ c.assert.urlParameterEquals('efc', 'wildfires');
+ c.assert.urlParameterEquals('efd', '2020-01-16,2020-06-16');
+ c.assert.urlParameterEquals('efs', 'false');
+
+ // Check filter criteria summary in sidebar
+ c.expect.elements(filterIcons).count.to.equal(1);
+ c.expect.element(wildfiresIcon).to.be.present;
+ c.assert.containsText(filterDates, '2020 JAN 16 - 2020 JUN 16');
+ c.waitForElementVisible(eventList, TIME_LIMIT);
+
+ // Check filter modal
+ c.click(filterButton);
+ c.waitForElementVisible(filterModal, TIME_LIMIT);
+ assertDateInputValues(c, '2020-JAN-16', '2020-JUN-16');
+ c.expect.element(dustSwitch).to.not.be.selected;
+ c.expect.element(manmadeSwitch).to.not.be.selected;
+ c.expect.element(seaLakeIceSwitch).to.not.be.selected;
+ c.expect.element(severeStormsSwitch).to.not.be.selected;
+ c.expect.element(snowSwitch).to.not.be.selected;
+ c.expect.element(volcanoesSwitch).to.not.be.selected;
+ c.expect.element(watercolorSwitch).to.not.be.selected;
+ c.expect.element(wildfiresSwitch).to.be.selected;
+ c.expect.element(mapExtentFilterCheckbox).to.be.selected;
+ },
+
+ 'Changing criteria in modal DOES NOT update summary of criteria in sidebar on CANCEL': (c) => {
+ c.url(c.globals.url + wildfiresWithDates);
+ openFilterModal(c);
+ c.click(startInput.year).setValue(startInput.year, [2000, c.keys.ENTER]);
+ c.click(startInput.month).setValue(startInput.month, ['APR', c.keys.ENTER]);
+ c.click(startInput.day).setValue(startInput.day, [19, c.keys.ENTER]);
+ c.click(endInput.year).setValue(endInput.year, [2001, c.keys.ENTER]);
+ c.click(endInput.month).setValue(endInput.month, ['NOV', c.keys.ENTER]);
+ c.click(endInput.day).setValue(endInput.day, [11, c.keys.ENTER]);
+ c.click(getSwitchToggle(wildfiresSwitch)); // OFF
+ c.pause(250);
+ c.click(getSwitchToggle(dustSwitch)); // ON
+ c.pause(250);
+ c.click(getSwitchToggle(volcanoesSwitch)); // ON
+ c.pause(250);
+ c.click(mapExtentFilterCheckbox); // OFF
+
+ // Cancel
+ c.click(filterModalCancel);
+
+ // assert sidebar values
+ c.assert.containsText(filterDates, '2020 JAN 16 - 2020 JUN 16');
+ c.expect.elements(filterIcons).count.to.equal(1);
+ c.expect.element(wildfiresIcon).to.be.present; // ON
+ },
+ 'Opening modal after cancelling changed values shows previous unchanged values': (c) => {
+ openFilterModal(c);
+ assertDateInputValues(c, '2020-JAN-16', '2020-JUN-16');
+ c.expect.element(dustSwitch).to.not.be.selected;
+ c.expect.element(manmadeSwitch).to.not.be.selected;
+ c.expect.element(seaLakeIceSwitch).to.not.be.selected;
+ c.expect.element(snowSwitch).to.not.be.selected;
+ c.expect.element(volcanoesSwitch).to.not.be.selected;
+ c.expect.element(watercolorSwitch).to.not.be.selected;
+ c.expect.element(wildfiresSwitch).to.be.selected; // ON
+ c.expect.element(mapExtentFilterCheckbox).to.be.selected;
+ },
+ 'Changing criteria in modal DOES update summary of criteria in sidebar on APPLY': (c) => {
+ c.click(startInput.year).setValue(startInput.year, [2000, c.keys.ENTER]);
+ c.click(startInput.month).setValue(startInput.month, ['APR', c.keys.ENTER]);
+ c.click(startInput.day).setValue(startInput.day, [19, c.keys.ENTER]);
+ c.click(endInput.year).setValue(endInput.year, [2001, c.keys.ENTER]);
+ c.click(endInput.month).setValue(endInput.month, ['NOV', c.keys.ENTER]);
+ c.click(endInput.day).setValue(endInput.day, [11, c.keys.ENTER]);
+ c.click(getSwitchToggle(wildfiresSwitch)); // OFF
+ c.pause(250);
+ c.click(getSwitchToggle(dustSwitch)); // ON
+ c.pause(250);
+ c.click(getSwitchToggle(volcanoesSwitch)); // ON
+ c.pause(250);
+ c.click(mapExtentFilterCheckbox); // OFF
+
+ // APPLY
+ c.click(filterModalApply);
+
+ // assert sidebar values
+ c.assert.containsText(filterDates, '2000 APR 19 - 2001 NOV 11');
+ c.expect.elements(filterIcons).count.to.equal(2);
+ c.expect.element(dustHazeIcon).to.be.present; // ON
+ c.expect.element(volcanoesIcon).to.be.present; // ON
+ c.expect.element(wildfiresIcon).to.not.be.present; // OFF
+ c.expect.element(mapExtentFilterCheckbox).to.not.be.selected;
+ },
+
+ 'Event Selected, No Filter Params: Shows only day of event, all categories, checkbox unchecked': (c) => {
+ // TODO limit category to only the event category?
+ c.url(c.globals.url + backwardsCompatibleEventUrl);
+ c.assert.containsText(filterDates, '2005 DEC 31 - 2005 DEC 31');
+ openFilterModal(c);
+ assertDateInputValues(c, '2005-DEC-31', '2005-DEC-31');
+ c.expect.elements(filterIcons).count.to.equal(8);
+ c.expect.element(mapExtentFilterCheckbox).to.not.be.selected;
+ c.click(filterModalCancel);
+ },
+
+ 'No extent search checkbox in polar projections': (c) => {
+ c.url(`${c.globals.url}?e=true&efs=false`);
+
+ openFilterModal(c);
+ c.expect.element(mapExtentFilterCheckbox).to.be.present;
+ c.expect.element(mapExtentFilterCheckbox).to.be.selected;
+ c.click(filterModalCancel);
+
+ switchProjection(c, 'arctic');
+ openFilterModal(c);
+ c.expect.element(mapExtentFilterCheckbox).to.not.be.present;
+ c.click(filterModalCancel);
+
+ switchProjection(c, 'geographic');
+ openFilterModal(c);
+ c.expect.element(mapExtentFilterCheckbox).to.be.present;
+ c.expect.element(mapExtentFilterCheckbox).to.be.selected;
+ c.click(filterModalCancel);
+
+ switchProjection(c, 'antarctic');
+ openFilterModal(c);
+ c.expect.element(mapExtentFilterCheckbox).to.not.be.present;
+ c.click(filterModalCancel);
+ },
+ after(c) {
+ c.end();
+ },
+};
diff --git a/e2e/features/events/list-all-test.js b/e2e/features/events/list-all-test.js
deleted file mode 100644
index d6f227481..000000000
--- a/e2e/features/events/list-all-test.js
+++ /dev/null
@@ -1,46 +0,0 @@
-const reuseables = require('../../reuseables/skip-tour.js');
-const localQueryStrings = require('../../reuseables/querystrings.js');
-
-const TIME_LIMIT = 10000;
-const layersTab = '#layers-sidebar-tab';
-const eventsTab = '#events-sidebar-tab';
-
-module.exports = {
- before(client) {
- reuseables.loadAndSkipTour(client, TIME_LIMIT);
- client.url(client.globals.url + localQueryStrings.mockEvents);
- },
- 'Seleting a category filters events': function(client) {
- client.click('#event-category-dropdown');
- client.waitForElementVisible('#event-category-menu');
- client.click('#event-category-item-wildfires');
- client.expect.element('#sidebar-event-EONET_3931').to.be.visible;
- client.expect.element('ul#wv-eventscontent > li:nth-child(2)').to.not.be.present;
- },
- 'Seleting all events removes filtering': function(client) {
- client.click('#event-category-dropdown');
- client.waitForElementVisible('#event-category-menu');
- client.click('#event-category-item-all');
- client.expect.element('ul#wv-eventscontent > li:nth-child(9)').to.be.present;
- },
- 'Hide events that are not in view': function(client) {
- client.waitForElementVisible('#sidebar-event-EONET_3931', TIME_LIMIT);
- client.click('#sidebar-event-EONET_3931');
- client.click(layersTab);
- client.waitForElementPresent('#active-VIIRS_SNPP_Thermal_Anomalies_375m_Night', TIME_LIMIT);
- client.click(eventsTab);
- client.expect.element('#sidebar-event-EONET_2703').to.be.visible;
- client.expect.element('ul#wv-eventscontent > li:nth-child(9)').to.be.visible;
- client.click('#events-footer-checkbox').pause(1000);
- client.expect.element('#sidebar-event-EONET_2703').to.not.be.visible;
- client.expect.element('ul#wv-eventscontent > li:nth-child(2)').to.not.be.visible;
- },
- 'Show events that are not in view': function(client) {
- client.click('#events-footer-checkbox').pause(1000);
- client.expect.element('#sidebar-event-EONET_2703').to.be.visible;
- client.expect.element('ul#wv-eventscontent > li:nth-child(9)').to.be.visible;
- },
- after(client) {
- client.end();
- },
-};
diff --git a/e2e/reuseables/querystrings.js b/e2e/reuseables/querystrings.js
index c9162ebd1..94f3147f1 100644
--- a/e2e/reuseables/querystrings.js
+++ b/e2e/reuseables/querystrings.js
@@ -23,10 +23,12 @@ module.exports = {
subdailyLayerIntervalTimescale: '?t=2019-10-04-T09%3A46%3A32Z&z=4&i=4&l=GOES-East_ABI_Band2_Red_Visible_1km,Reference_Labels_15m(hidden),Reference_Features_15m(hidden),Coastlines_15m,VIIRS_SNPP_CorrectedReflectance_TrueColor(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor',
// events
- eventsTabActive: '?e=true',
mockEvents: '?p=geographic&l=VIIRS_SNPP_CorrectedReflectance_TrueColor(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor,Reference_Labels_15m(hidden),Reference_Features_15m(hidden),Coastlines_15m&t=2018-05-02-T00%3A00%3A00Z&z=3&v=-409.00147812273656,-205.62883007565202,270.5880270080828,219.11461063111003&e=true&mockEvents=20170530',
stormEventSelected: '?v=175.65863037109375,10.918751525878907,182.25042724609375,22.643360900878907&e=EONET_2777,2017-05-31&l=IMERG_Precipitation_Rate,VIIRS_SNPP_DayNightBand_ENCC(hidden),VIIRS_SNPP_DayNightBand_At_Sensor_Radiance(hidden),Reference_Labels,Reference_Features,Coastlines(hidden),VIIRS_NOAA20_CorrectedReflectance_TrueColor(hidden),VIIRS_SNPP_CorrectedReflectance_TrueColor,MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor(hidden)&lg=true&t=2017-05-31-T00%3A00%3A00Z&mockEvents=20170530',
- closedEvent: '?e=EONET_5133',
+ fixedAppNow: '?now=2012-01-01T00%3A00%3A00Z',
+ wildfiresWithDates: '?v=-139.02635001706034,25.660099233568406,-85.27770827186355,43.288373996427595&e=true&efs=false&efd=2020-01-16,2020-06-16&efc=wildfires&t=2020-06-16-T18%3A31%3A28Z',
+ backwardsCompatibleEventUrl: '?v=-49.6224609375,13.940234375000001,-26.5775390625,37.459765625&e=EONET_1874,2005-12-31&l=IMERG_Precipitation_Rate,Reference_Labels_15m,Reference_Features_15m,MODIS_Terra_CorrectedReflectance_TrueColor&lg=true&t=2005-12-31-T00%3A00%3A00Z',
+
// layers
multipleDataLayers: '?p=geographic&l=MODIS_Terra_Aerosol,MODIS_Terra_Brightness_Temp_Band31_Day&t=2017-03-22&z=3&v=136.07019188386334,14.722152527011556,155.59817576644127,24.312819167567586',
diff --git a/web/js/components/sidebar/events-filter.js b/web/js/components/sidebar/events-filter.js
index c7f07f7fc..9a1e506b9 100644
--- a/web/js/components/sidebar/events-filter.js
+++ b/web/js/components/sidebar/events-filter.js
@@ -123,7 +123,7 @@ function EventFilterModalBody (props) {
{!isPolarProj && (
<Checkbox
- id="events-footer-checkbox"
+ id="map-extent-filter"
label="Only list events in current map view"
onCheck={() => setListAll(!listAll)}
checked={!listAll}
@@ -141,6 +141,7 @@ function EventFilterModalBody (props) {
Apply
</Button>
<Button
+ id="filter-cancel-btn"
color="secondary"
onClick={closeModal}
>
diff --git a/web/js/location.js b/web/js/location.js
index b01127529..69bfac1a8 100644
--- a/web/js/location.js
+++ b/web/js/location.js
@@ -346,6 +346,7 @@ const getParameters = function(config, parameters) {
options: {
serialize: serializeCategories,
serializeNeedsGlobalState: true,
+ setAsEmptyItem: true,
},
},
l: {
diff --git a/web/js/modules/natural-events/reducers.js b/web/js/modules/natural-events/reducers.js
index 64cde3f43..4fbd3cb15 100644
--- a/web/js/modules/natural-events/reducers.js
+++ b/web/js/modules/natural-events/reducers.js
@@ -15,7 +15,7 @@ import { CHANGE_TAB as CHANGE_SIDEBAR_TAB } from '../sidebar/constants';
import util from '../../util/util';
/**
- * Sort events by date, filter by categories
+ * Sort events by date
*
* @param {*} events
* @param {*} categories
@@ -36,19 +36,7 @@ const sortEvents = function(events) {
});
};
-const endDate = util.toISOStringDate(new Date());
-const startDate = util.toISOStringDate(new Date(new Date().setDate(new Date().getDate() - 120)));
-
-export function getInitialEventsState(config) {
- const { categories } = config.naturalEvents;
- return {
- ...eventsReducerState,
- allCategories: categories,
- selectedCategories: categories,
- };
-}
-
-export const eventsReducerState = {
+const eventsReducerState = {
selected: {
id: '',
date: null,
@@ -61,11 +49,26 @@ export const eventsReducerState = {
allCategories: [],
selectedCategories: [],
selectedDates: {
- start: startDate,
- end: endDate,
+ start: null,
+ end: null,
},
};
+export function getInitialEventsState(config) {
+ const { initialDate, naturalEvents } = config;
+ const { categories } = naturalEvents;
+ const endDate = util.toISOStringDate(new Date(initialDate));
+ return {
+ ...eventsReducerState,
+ allCategories: categories,
+ selectedCategories: categories,
+ selectedDates: {
+ start: util.toISOStringDate(new Date(new Date(initialDate).setDate(new Date(initialDate).getDate() - 120))),
+ end: endDate,
+ },
+ };
+}
+
export function eventsReducer(state = eventsReducerState, action) {
switch (action.type) {
case SELECT_EVENT: {
diff --git a/web/js/modules/natural-events/util.js b/web/js/modules/natural-events/util.js
index cd5b21a51..b48d0b87b 100644
--- a/web/js/modules/natural-events/util.js
+++ b/web/js/modules/natural-events/util.js
@@ -53,7 +53,7 @@ export function serializeEventFilterDates(currentItemState, state) {
export function serializeCategories(categories, state) {
const eventsTabActive = state.events.active;
- return eventsTabActive ? categories.map(({ id }) => id) : undefined;
+ return eventsTabActive ? categories.map(({ id }) => id).join(',') : undefined;
}
export function mapLocationToEventFilterState(parameters, stateFromLocation, state) {