Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Add some events tests

Josiah Spragueb22864104748
diff --git a/e2e/browserstack.conf.js b/e2e/browserstack.conf.js
index 3d85621dd..43957f4e5 100644
--- a/e2e/browserstack.conf.js
+++ b/e2e/browserstack.conf.js
@@ -16,6 +16,7 @@ require('nightwatch-cucumber')({
var nightwatch_config = {
output_folder: 'e2e/reports',
globals_path: 'e2e/globals.js',
+ custom_assertions_path: ['e2e/custom-assertions'],
selenium: {
start_process: false,
host: 'hub-cloud.browserstack.com',
diff --git a/e2e/custom-assertions/elementCountGreater.js b/e2e/custom-assertions/elementCountGreater.js
new file mode 100644
index 000000000..925569d4a
--- /dev/null
+++ b/e2e/custom-assertions/elementCountGreater.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.feature b/e2e/features/events/events.feature
index a106a034d..d6586d8c7 100644
--- a/e2e/features/events/events.feature
+++ b/e2e/features/events/events.feature
@@ -1,17 +1,23 @@
Feature: Natural Events
- As a user of Worldview
- I want to browse natural events
- So that I can see imagery related to events
+ Users should be able to find imagery related to recent natural events via a list and markers on the map
Background:
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
Scenario: Selecting Events Tab
+ Users should be able to see all available natural events
- When I click the "events" tab
- Then I should see the "list of events" within 3 seconds
- And I should see "Fire"
- And I should see "Iceberg"
- And I should see "Hurricane"
- And I should see "Volcano"
+ Given I see "Fire"
+ And I see "Iceberg"
+ And I see "Hurricane"
+ And I see "Volcano"
+ And I see 50+ markers on the map
+
+Scenario: Selecting an Event from the List
+
+ When I click the "first event"
+ Then I see the "selected marker"
+ And I see the "selected first event"
diff --git a/e2e/globals.js b/e2e/globals.js
index b5d150045..0a8321870 100644
--- a/e2e/globals.js
+++ b/e2e/globals.js
@@ -24,7 +24,11 @@ module.exports = {
'GIF download icon': '.jcrop-holder .fa-download',
'GIF results': '.gif-results-dialog-case img',
'GIF results close button': '.wv-gif-results button.ui-dialog-titlebar-close',
- 'list of events': '#wv-events ul.map-item-list'
+ 'list of events': '#wv-events ul.map-item-list',
+ 'first event': '#wv-events ul.map-item-list .item:first-child',
+ 'selected first event': '#wv-events ul.map-item-list .item-selected:first-child',
+ 'selected marker': '.marker-selected',
+ 'map marker': '.ol-viewport .marker'
},
delay: 3000 // Acceptable delay in ms between performing actions and seeing results
};
diff --git a/e2e/step_definitions/events.js b/e2e/step_definitions/events.js
new file mode 100644
index 000000000..7f75bad4d
--- /dev/null
+++ b/e2e/step_definitions/events.js
@@ -0,0 +1,11 @@
+const {client} = require('nightwatch-cucumber');
+const {defineSupportCode} = require('cucumber');
+const delay = client.globals.delay;
+
+defineSupportCode(({Given, Then, When}) => {
+
+ Then('I see {int}+ markers on the map', (count) => {
+ return client.assert.elementCountGreater(client.globals.selectors['map marker'], count);
+ });
+
+});
diff --git a/nightwatch.conf.js b/nightwatch.conf.js
index 3e309457b..f51c86d5d 100644
--- a/nightwatch.conf.js
+++ b/nightwatch.conf.js
@@ -16,6 +16,7 @@ require('nightwatch-cucumber')({
module.exports = {
output_folder: 'e2e/reports',
globals_path: 'e2e/globals.js',
+ custom_assertions_path: ['e2e/custom-assertions'],
selenium: {
start_process: true,
server_path: seleniumServer.path,