Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Resolves extent bug before and after 3:00 UTC. Restored timeline-mobile-test to previous modifications. E2E tests ran.

Stephan Wlodarczyk9a67122e6493
diff --git a/e2e/features/timeline/timeline-mobile-test.js b/e2e/features/timeline/timeline-mobile-test.js
index 443035299..9203ee027 100644
--- a/e2e/features/timeline/timeline-mobile-test.js
+++ b/e2e/features/timeline/timeline-mobile-test.js
@@ -1,54 +1,50 @@
const skipTour = require('../../reuseables/skip-tour.js');
-const moment = require('moment');
+
const mobileDatePickerSelectBtn = '#date-selector-main .mobile-date-picker-select-btn';
const nextDayArrowContainer = '#right-arrow-group';
const datepickerHeader = '.datepicker .datepicker-header';
const TIME_LIMIT = 10000;
-const TODAY = moment(new Date()).format('YYYY-MM-DD');
-const YESTERDAY = moment(new Date()).subtract(1, 'days').format('YYYY-MM-DD');
-const TOMORROW = moment(new Date()).add(1, 'days').format('YYYY-MM-DD');
module.exports = {
- before: c => {
+ before: (c) => {
skipTour.loadAndSkipTour(c, TIME_LIMIT);
- c.url(c.globals.url + '?now=' + TODAY);
+ c.url(`${c.globals.url}?now=2013-03-15T0`);
c.resizeWindow(375, 667); // iPhone 6/7/8 dimensions
},
- 'date.mob.init.2a: Before 3:00 UTC: load yesterdays date': c => {
- c.waitForElementVisible(mobileDatePickerSelectBtn, TIME_LIMIT, e => {
- c.assert.containsText(mobileDatePickerSelectBtn, YESTERDAY);
+ 'date.mob.init.2a: Before 3:00 UTC: load yesterdays date': (c) => {
+ c.waitForElementVisible(mobileDatePickerSelectBtn, TIME_LIMIT, (e) => {
+ c.assert.containsText(mobileDatePickerSelectBtn, '2013-03-14');
});
},
- 'date.mob.init.2b: Before 3:00 UTC: right button is not disabled': c => {
+ 'date.mob.init.2b: Before 3:00 UTC: right button is not disabled': (c) => {
c.expect.element(nextDayArrowContainer).to.be.present;
- c.expect.element(nextDayArrowContainer + '.button-disabled').to.not.be.present;
+ c.expect.element(`${nextDayArrowContainer}.button-disabled`).to.not.be.present;
c.click(nextDayArrowContainer);
- c.waitForElementVisible(nextDayArrowContainer, TIME_LIMIT);
+ c.waitForElementVisible(`${nextDayArrowContainer}.button-disabled`, TIME_LIMIT);
},
- 'date.mob.init.3a: After 3:00 UTC: load todays date': c => {
- c.url(c.globals.url + '?now=' + TODAY + 'T4');
- c.waitForElementVisible(mobileDatePickerSelectBtn, TIME_LIMIT, e => {
- c.assert.containsText(mobileDatePickerSelectBtn, TODAY);
+ 'date.mob.init.3a: After 3:00 UTC: load todays date': (c) => {
+ c.url(`${c.globals.url}?now=2013-03-15T4`);
+ c.waitForElementVisible(mobileDatePickerSelectBtn, TIME_LIMIT, (e) => {
+ c.assert.containsText(mobileDatePickerSelectBtn, '2013-03-15');
});
},
- 'date.mob.init.3b:After 3:00 UTC: right button is disabled': c => {
+ 'date.mob.init.3b:After 3:00 UTC: right button is disabled': (c) => {
c.expect.element(nextDayArrowContainer).to.be.present;
- c.click(nextDayArrowContainer);
- c.expect.element(nextDayArrowContainer + '.button-disabled').to.be.present;
+ c.expect.element(`${nextDayArrowContainer}.button-disabled`).to.be.present;
},
- 'date.mob.range.1: Date label should show 2013-03-15': c => {
- c.url(c.globals.url + '?now=2013-03-15T12');
- c.waitForElementVisible(mobileDatePickerSelectBtn, TIME_LIMIT, e => {
+ 'date.mob.range.1: Date label should show 2013-07-20': (c) => {
+ c.url(`${c.globals.url}?now=2013-03-15T12`);
+ c.waitForElementVisible(mobileDatePickerSelectBtn, TIME_LIMIT, (e) => {
c.assert.containsText(mobileDatePickerSelectBtn, '2013-03-15');
});
},
- 'date.mob.range.2: mobile selector header should show 2013-03-15': c => {
+ 'date.mob.range.2: mobile selector header should show 2013-03-15': (c) => {
c.click(mobileDatePickerSelectBtn);
- c.waitForElementVisible(datepickerHeader, TIME_LIMIT, e => {
+ c.waitForElementVisible(datepickerHeader, TIME_LIMIT, (e) => {
c.assert.containsText(datepickerHeader, '2013-03-15');
});
},
- 'date.mob.range.3: Date label should show 2012-03-15 after year drag': c => {
+ 'date.mob.range.3: Date label should show 2012-03-15 after year drag': (c) => {
c.moveToElement('xpath', "//li[text()='2013']", 15, 15)
.mouseButtonDown(0)
.moveToElement('xpath', "//li[contains(@class, 'disabled') and text()='2014']", 10, 10)
@@ -57,7 +53,7 @@ module.exports = {
c.useCss();
c.assert.containsText(datepickerHeader, '2012-03-15');
},
- 'date.mob.range.4: Date in header should be 2012-01-15 after month drag': c => {
+ 'date.mob.range.4: Date in header should be 2012-01-15 after month drag': (c) => {
c.moveToElement('xpath', "//li[text()='03']", 10, 10)
.mouseButtonDown(0)
.moveToElement('xpath', "//li[text()='04']", 10, 10)
@@ -71,7 +67,7 @@ module.exports = {
c.useCss();
c.assert.containsText(datepickerHeader, '2012-01-15');
},
- 'date.mob.range.5: Date in header should be 2012-01-19 after day drag': c => {
+ 'date.mob.range.5: Date in header should be 2012-01-19 after day drag': (c) => {
c.moveToElement('xpath', "//li[text()='15']", 10, 10)
.mouseButtonDown(0)
.moveToElement('xpath', "//li[text()='14']", 10, 10)
@@ -95,25 +91,25 @@ module.exports = {
c.useCss();
c.assert.containsText(datepickerHeader, '2012-01-19');
},
- 'date.mob.range.6: Click okay button verify date has updated': c => {
+ 'date.mob.range.6: Click okay button verify date has updated': (c) => {
c.useXpath().click("//a[text()='OK']");
c.pause(1000);
c.useCss();
c.assert.containsText(mobileDatePickerSelectBtn, '2012-01-19');
},
- 'date.mob.nav.1: Date label should show 2013-07-20': c => {
- c.url(c.globals.url + '?now=2014-03-15&t=2013-07-20T12');
- c.waitForElementVisible(mobileDatePickerSelectBtn, TIME_LIMIT, e => {
+ 'date.mob.nav.1: Date label should show 2013-07-20': (c) => {
+ c.url(`${c.globals.url}?now=2014-03-15&t=2013-07-20T12`);
+ c.waitForElementVisible(mobileDatePickerSelectBtn, TIME_LIMIT, (e) => {
c.assert.containsText(mobileDatePickerSelectBtn, '2013-07-20');
});
},
- 'date.mob.nav.2a: mobile selector header should show 2013-07-20': c => {
+ 'date.mob.nav.2a: mobile selector header should show 2013-07-20': (c) => {
c.click(mobileDatePickerSelectBtn);
- c.waitForElementVisible(datepickerHeader, TIME_LIMIT, e => {
+ c.waitForElementVisible(datepickerHeader, TIME_LIMIT, (e) => {
c.assert.containsText(datepickerHeader, '2013-07-20');
});
},
- 'date.mob.nav.2b: Year 2014 should be disabled and 2013 is not': c => {
+ 'date.mob.nav.2b: Year 2014 should be disabled and 2013 is not': (c) => {
c.waitForElementVisible(datepickerHeader, TIME_LIMIT, () => {
c.useXpath(); // https://github.com/nightwatchjs/nightwatch/issues/633#issuecomment-222968466
c.expect.element("//li[contains(@class, 'disabled') and text()='2014']").to.be.present;
@@ -121,7 +117,7 @@ module.exports = {
c.expect.element("//li[text()='2013']").to.be.present;
});
},
- 'date.mob.nav.3: Date in header should be 2013-02-20 after year drag': c => {
+ 'date.mob.nav.3: Date in header should be 2013-02-20 after year drag': (c) => {
c.moveToElement('xpath', "//li[text()='07']", 15, 15)
.mouseButtonDown(0)
.moveToElement('xpath', "//li[text()='08']", 10, 10)
@@ -150,7 +146,7 @@ module.exports = {
c.useCss();
c.assert.containsText(datepickerHeader, '2013-02-20');
},
- 'date.mob.nav.4: Date label should show 2014-02-20 after year drag': c => {
+ 'date.mob.nav.4: Date label should show 2014-02-20 after year drag': (c) => {
c.moveToElement('xpath', "//li[text()='2013']", 15, 15)
.mouseButtonDown(0)
.moveToElement('xpath', "//li[text()='2012']", 10, 10)
@@ -159,7 +155,7 @@ module.exports = {
c.useCss();
c.assert.containsText(datepickerHeader, '2014-02-20');
},
- 'date.mob.nav.5: Date in header should be 2013-12-20 after year drag': c => {
+ 'date.mob.nav.5: Date in header should be 2013-12-20 after year drag': (c) => {
c.moveToElement('xpath', "//li[text()='02']", 15, 15)
.mouseButtonDown(0)
.moveToElement('xpath', "//li[text()='03']", 10, 10)
@@ -173,13 +169,13 @@ module.exports = {
c.useCss();
c.assert.containsText(datepickerHeader, '2013-12-20');
},
- 'date.mob.nav.6: Click okay button verify date has updated to 2013-12-20': c => {
+ 'date.mob.nav.6: Click okay button verify date has updated to 2013-12-20': (c) => {
c.useXpath().click("//a[text()='OK']");
c.pause(1000);
c.useCss();
c.assert.containsText(mobileDatePickerSelectBtn, '2013-12-20');
},
- after: c => {
+ after: (c) => {
c.end();
}
};
diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.js
index a20659ef7..50280ba15 100644
--- a/web/js/containers/timeline/timeline.js
+++ b/web/js/containers/timeline/timeline.js
@@ -1273,9 +1273,7 @@ function mapStateToProps(state) {
hasSubdailyLayers = hasSubDaily(layers[compare.activeString]);
endTime = layersLastDateTime(layers[activeString], config);
}
- /** endTime = appNow; This was originally here, wondering why the
- above logic is there when it gets set here **/
- endTime = state.config.todaysDate;
+ endTime = appNow;
const dimensionsAndOffsetValues = getOffsetValues(
screenWidth,
diff --git a/web/js/fixtures.js b/web/js/fixtures.js
index 7cf762d1a..fdb923ade 100644
--- a/web/js/fixtures.js
+++ b/web/js/fixtures.js
@@ -189,6 +189,7 @@ fixtures.getState = function() {
fixtures.config = function() {
return {
pageLoadTime: new Date(),
+ initialDate: new Date(),
now: new Date(),
defaults: {
projection: 'geographic',
diff --git a/web/js/location.js b/web/js/location.js
index aa8c50f19..09cdb1780 100644
--- a/web/js/location.js
+++ b/web/js/location.js
@@ -158,11 +158,9 @@ const getParameters = function(config, parameters) {
const compareIsActive = get(state, 'compare.active');
const isCompareA = get(state, 'compare.isCompareA');
const dateB = get(state, 'date.selectedB');
- const appNow = get(state, 'date.appNow');
- const appNowString = util.toISOStringSeconds(appNow);
const initialDateString = util.toISOStringSeconds(initialDate);
return !compareIsActive && !isCompareA
- ? util.toISOStringSeconds(dateB) === appNowString
+ ? util.toISOStringSeconds(dateB) === initialDateString
? undefined
: serializeDate(dateB)
: util.toISOStringSeconds(currentItemState) === initialDateString
@@ -194,8 +192,8 @@ const getParameters = function(config, parameters) {
setAsEmptyItem: true,
serialize: (currentItemState, state) => {
const isActive = get(state, 'compare.active');
- const appNow = get(state, 'date.appNow');
- const appNowMinusSevenDays = util.dateAdd(appNow, 'day', -7);
+ const initialDateString = util.toISOStringSeconds(initialDate);
+ const appNowMinusSevenDays = util.dateAdd(initialDateString, 'day', -7);
const appNowMinusSevenDaysString = util.toISOStringSeconds(
appNowMinusSevenDays
);
diff --git a/web/js/main.js b/web/js/main.js
index 423f0f20c..44eff066e 100644
--- a/web/js/main.js
+++ b/web/js/main.js
@@ -63,13 +63,11 @@ window.onload = () => {
? util.parseDateUTC(parameters.now) || new Date()
: new Date();
- config.initialDate = config.pageLoadTime.getUTCHours() < 3
- ? new Date((config.pageLoadTime).setUTCDate(config.pageLoadTime.getUTCDate() - 1))
- : config.pageLoadTime;
+ const pageLoadTime = new Date(config.pageLoadTime);
- config.todaysDate = new Date().getUTCHours() < 3
- ? new Date((new Date()).setUTCDate(new Date().getUTCDate() - 1))
- : new Date();
+ config.initialDate = config.pageLoadTime.getUTCHours() < 3
+ ? new Date(pageLoadTime.setUTCDate(pageLoadTime.getUTCDate() - 1))
+ : pageLoadTime;
config.palettes = {
rendered: {},
diff --git a/web/js/modules/animation/reducers.js b/web/js/modules/animation/reducers.js
index f01104ba3..9967b4945 100644
--- a/web/js/modules/animation/reducers.js
+++ b/web/js/modules/animation/reducers.js
@@ -27,8 +27,8 @@ export const defaultState = {
};
export function getInitialState(config) {
return lodashAssign({}, defaultState, {
- startDate: util.dateAdd(config.pageLoadTime, 'day', -7),
- endDate: config.pageLoadTime
+ startDate: util.dateAdd(config.initialDate, 'day', -7),
+ endDate: config.initialDate
});
}
diff --git a/web/js/modules/date/reducers.js b/web/js/modules/date/reducers.js
index 111b04af5..50aeec529 100644
--- a/web/js/modules/date/reducers.js
+++ b/web/js/modules/date/reducers.js
@@ -25,8 +25,8 @@ export const dateReducerState = {
export function getInitialState(config) {
return lodashAssign({}, dateReducerState, {
- selected: config.pageLoadTime,
- selectedB: util.dateAdd(config.pageLoadTime, 'day', -7),
+ selected: config.initialDate,
+ selectedB: util.dateAdd(config.initialDate, 'day', -7),
appNow: config.pageLoadTime
});
}
diff --git a/web/js/modules/date/util.test.js b/web/js/modules/date/util.test.js
index 09bd3778a..ba0937274 100644
--- a/web/js/modules/date/util.test.js
+++ b/web/js/modules/date/util.test.js
@@ -22,7 +22,7 @@ test('parses valid date: 1.2', () => {
const date = tryCatchDate(param.t, state.date.appNow);
expect(date).toEqual(d);
});
-test('If date is invalid, uses pageLoad Time', () => {
+test('If date is invalid, uses initialDate Time', () => {
const param = {
time: 'X'
};
@@ -31,5 +31,5 @@ test('If date is invalid, uses pageLoad Time', () => {
};
stateFromLocation = mapLocationToDateState(param, stateFromLocation, state);
- expect(stateFromLocation.date.selected).toBe(state.date.appNow);
+ expect(stateFromLocation.date.selected).toBe(state.date.initialDate);
});