Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Add event and event-track tests #930

Benjamin King2dc44ac43eb8
diff --git a/e2e/custom-assertions/elementCountEquals.js b/e2e/custom-assertions/elementCountEquals.js
new file mode 100644
index 000000000..31b77108b
--- /dev/null
+++ b/e2e/custom-assertions/elementCountEquals.js
@@ -0,0 +1,26 @@
+// A custom Nightwatch assertion.
+// the name of the method is the filename.
+// can be used in tests like this:
+//
+// browser.assert.elementCountGreater(selector, count)
+//
+// for how to write custom assertions see
+// http://nightwatchjs.org/guide#writing-custom-assertions
+exports.assertion = function (selector, count) {
+ this.message = 'Testing if element <' + selector + '> has count: ' + count;
+ this.expected = count;
+ this.pass = function (val) {
+ return val === this.expected;
+ };
+ this.value = function (res) {
+ return res.value;
+ };
+ this.command = function (cb) {
+ var self = this;
+ return this.api.execute(function (selector) {
+ return document.querySelectorAll(selector).length;
+ }, [selector], function (res) {
+ cb.call(self, res);
+ });
+ };
+};
diff --git a/e2e/features/events/events-test.js b/e2e/features/events/events-test.js
new file mode 100644
index 000000000..2e25cd074
--- /dev/null
+++ b/e2e/features/events/events-test.js
@@ -0,0 +1,90 @@
+const reuseables = require('../../reuseables/skip-tour.js');
+const localQuerystrings = require('./querystrings.js');
+const TIME_LIMIT = 10000;
+/**
+ * Selectors
+ */
+const listOfEvents = '#wv-events ul.map-item-list';
+const eventIcons = '.marker .event-icon';
+const firstEvent = '#wv-events ul.map-item-list .item:first-child h4';
+const selectedFirstEvent = '#wv-events ul.map-item-list .item-selected:first-child h4';
+const selectedMarker = '.marker-selected';
+const firstExternalEventLink = '#wv-events ul.map-item-list .item:first-child .natural-event-link:first-child';
+const trackMarker = '.track-marker';
+
+module.exports = {
+ before: function (client) {
+ reuseables.loadAndSkipTour(client, TIME_LIMIT);
+ },
+ 'Use Mock to make sure appropriate number of event markers are appended to map': function(client) {
+ client.url(client.globals.url + localQuerystrings.mockEvents)
+ client.waitForElementVisible(listOfEvents, TIME_LIMIT, function() {
+ client.assert.elementCountEquals(eventIcons, 6);
+ });
+ },
+ 'Use Mock Ensure number of event track points is correct and event markers and tabs are not visible when layer tab is clicked': function(client) {
+ const globalSelectors = client.globals.selectors;
+ client.url(client.globals.url + localQuerystrings.mockEvents);
+ client.waitForElementVisible(listOfEvents, TIME_LIMIT, function() {
+ client.click(firstEvent);
+ client.waitForElementVisible(trackMarker, TIME_LIMIT, function() {
+ client.assert.elementCountEquals(trackMarker, 5);
+ client.click(globalSelectors.dataTab)
+ .pause(2000);
+ client.expect.element(trackMarker).to.not.be.present;
+ client.expect.element(eventIcons).to.not.be.present;
+ client.click(globalSelectors.eventsTab)
+ .pause(2000);
+ client.expect.element(trackMarker).to.be.present;
+ client.expect.element(eventIcons).to.be.present;
+ });
+ });
+ },
+ 'Click Events tab and select an Event from the List': function(client) {
+ const globalSelectors = client.globals.selectors;
+ reuseables.loadAndSkipTour(client, TIME_LIMIT);
+ client.waitForElementVisible(globalSelectors.eventsTab, TIME_LIMIT, function() {
+ client.click(globalSelectors.eventsTab);
+ client.waitForElementVisible(listOfEvents, TIME_LIMIT, function() {
+ client.click(firstEvent)
+ .pause(3000);
+ client.expect.element(selectedMarker).to.be.visible;
+ client.expect.element(selectedFirstEvent).to.be.visible;
+ // test url is updated
+ client
+ .assert.urlParameterEquals('l', true)
+ .assert.urlParameterEquals('t', true)
+ .assert.urlParameterEquals('z', true)
+ .assert.urlParameterEquals('v', true)
+ .assert.urlParameterEquals('e', true);
+ client.assert.containsText(globalSelectors.notifyMessage, 'Events may not be visible at all times');
+ client.click(globalSelectors.notifyMessage)
+ .pause(2000);
+ client.assert.containsText('.wv-data-unavailable-header', 'Why can’t I see an event?');
+ client
+ .click(globalSelectors.notificationDismissButton)
+ .pause(2000);
+ client.expect.element(globalSelectors.notificationDismissButton).to.not.be.visible;
+ client.assert.elementCountGreater(globalSelectors.overlayLayerItems, 4); // At least 4 overlay layers present
+ client.click(selectedFirstEvent)
+ .pause(500);
+ client.expect.element(selectedFirstEvent).to.not.be.present;
+ client.click(firstEvent)
+ .pause(500);
+ client.windowHandles(function (tabs) {
+ client.assert.equal(tabs.value.length, 1);
+ });
+ client.click(firstExternalEventLink)
+ .pause(2000)
+
+ client.windowHandles(function (tabs) {
+ client.assert.equal(tabs.value.length, 2);
+ });
+ });
+ });
+ },
+ after: function(client) {
+ client.end();
+ }
+};
+
diff --git a/e2e/features/events/events.feature b/e2e/features/events/events.feature
deleted file mode 100644
index 17b854e71..000000000
--- a/e2e/features/events/events.feature
+++ /dev/null
@@ -1,50 +0,0 @@
-Feature: Natural Events
- Users should be able to find imagery related to recent natural events via a list and markers on the map
-
-Scenario: Selecting Events Tab
- Users should be able to see all available natural events
-
- Given Worldview is in "initial" state
- And I click "Skip Tour"
- And I click the "events" tab
- Then I see the "list of events" within 3 seconds
- And the page has at least 50 "map markers"
-
-Scenario: Selecting an Event from the List
- Selecting and deselecting events should change the state of the app to display the state related to the event
-
- Given Worldview is in "initial" state
- And I click "Skip Tour"
- And I click the "events" tab
- Then I see the "list of events" within 3 seconds
- When I click the "first event"
- Then I see the "selected marker"
- And I see the "selected first event"
- And the url has these values:
- | l | true |
- | t | true |
- | z | true |
- | v | true |
- | e | true |
- And I see "Events may not be visible at all times" within 4 seconds
- When I click "Events may not be visible at all times"
- Then I see "Why can’t I see an event?"
- When I click the "modal close button"
- And I wait 2 seconds
- Then I don't see "Why can’t I see an event?"
- When I click the "notification dismiss button"
- And I wait 2 seconds
- Then I don't see "Events may not be visible at all times"
- And the page has at least 4 "overlay layer items"
- Then there are 1 tabs open
- When I click the "first external event link"
- Then there are 2 tabs open
- When I close tab number 2
- Then there are 1 tabs open
- When I click the "selected first event"
- Then the page doesn't have the "selected first event"
-
-Scenario: Permalink with events tab
- Given Worldview is in "events tab active" state
- Then I see the "list of events" within 3 seconds
- And the page has at least 50 "map markers"
diff --git a/e2e/features/events/querystrings.js b/e2e/features/events/querystrings.js
new file mode 100644
index 000000000..eef334504
--- /dev/null
+++ b/e2e/features/events/querystrings.js
@@ -0,0 +1,4 @@
+module.exports = {
+ eventsTabActive: '?e=true',
+ mockEvents: '?p=geographic&l=VIIRS_SNPP_CorrectedReflectance_TrueColor(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor,Reference_Labels(hidden),Reference_Features(hidden),Coastlines&t=2018-05-02-T00%3A00%3A00Z&z=3&v=-409.00147812273656,-205.62883007565202,270.5880270080828,219.11461063111003&e=true&mockEvents=20170530'
+}