Interactive interface for browsing global, full-resolution satellite imagery
Use Cucumber for Layers Search tests
Josiah Sprague7b3e1f8bf091
diff --git a/e2e/features/layers.feature b/e2e/features/layers.featureindex c41c1a4f7..603637b7e 100644--- a/e2e/features/layers.feature+++ b/e2e/features/layers.feature@@ -5,17 +5,33 @@ Background:Given Worldview is in initial stateAnd I click "Skip Tour"-Scenario: Layer Info Links+Scenario: Getting Layer InfoWhen I click the "info button"- Then I should see the "info dialog" element+ Then I should see the "info dialog"When I click the "info button"- Then I should not see the "info dialog" element+ Then I should not see the "info dialog"When I click the "info button"- Then I should see the "info dialog" element+ Then I should see the "info dialog"- Scenario: Layer Options Links+Scenario: Changing Layer Options- When I click the "options button"- Then I should not see the "info dialog" element- Then I should see the "options dialog" element+ When I click the "options button"+ Then I should not see the "info dialog"+ Then I should see the "options dialog"++Scenario: Adding Layers and Layer Search++ When I click "Add Layers"+ And I input "Corrected Reflectance (True Color)" in the "layers search field"+ Then I should see "Corrected Reflectance (True Color)"+ And I should see "Suomi NPP / VIIRS"+ When I click the "source info icon"+ Then I should see "VIIRS Corrected Reflectance"+ When I click the "source info icon"+ Then I should not see "VIIRS Corrected Reflectance"+ When I click the "source info icon"+ Then I should see "VIIRS Corrected Reflectance"+ When I scroll to the "source metadata close button"+ And I click the "source metadata close button"+ Then I should not see "VIIRS Corrected Reflectance"diff --git a/e2e/globals.js b/e2e/globals.jsindex f927e3373..b7e64c14a 100644--- a/e2e/globals.js+++ b/e2e/globals.js@@ -1,3 +1,13 @@module.exports = {- url: 'http://localhost:3000'+ url: 'http://localhost:3000',+ selectors: {+ 'info button': '.wv-layers-info',+ 'options button': '.wv-layers-options',+ 'info dialog': '[aria-describedby="wv-layers-info-dialog"]',+ 'options dialog': '[aria-describedby="wv-layers-options-dialog"]',+ 'layers search field': '#layers-search-input',+ 'source info icon': '.layers-all-layer .fa-info-circle',+ 'source metadata close button': '.source-metadata .metadata-more'+ },+ delay: 3000 // Acceptable delay in ms between performing actions and seeing results};diff --git a/e2e/step_definitions/app.js b/e2e/step_definitions/app.jsindex c6cfecf4c..0327c9523 100644--- a/e2e/step_definitions/app.js+++ b/e2e/step_definitions/app.js@@ -1,16 +1,16 @@const {client} = require('nightwatch-cucumber');const {defineSupportCode} = require('cucumber');--var labels = {- 'info button': '.wv-layers-info',- 'options button': '.wv-layers-options',- 'info dialog': '[aria-describedby="wv-layers-info-dialog"]',- 'options dialog': '[aria-describedby="wv-layers-options-dialog"]'-}+const delay = client.globals.delay;+const selectors = client.globals.selectors;defineSupportCode(({Given, Then, When}) => {Given('Worldview is in initial state', () => {- return client.url(client.globals.url).waitForElementVisible('body', 1000);+ return client.url(client.globals.url).waitForElementVisible('body', delay);+ });++ // Scroll to an element by predefined selector+ When('I scroll to the {string}', function (label) {+ return client.useCss().moveToElement(selectors[label], 10, 10);});// Click any element that contains the string@@ -23,9 +23,9 @@ defineSupportCode(({Given, Then, When}) => {return client.useXpath().click('//a[text()="'+ text +'"]');});- // Click a button by predefined label+ // Click an element by predefined selectorWhen('I click the {string}', function (label) {- return client.useCss().click(labels[label]);+ return client.useCss().click(selectors[label]);});// Click a Worldview tab@@ -33,6 +33,21 @@ defineSupportCode(({Given, Then, When}) => {return client.useCss().click('[data-tab="' + name + '"]');});+ // Input a value into a labeled element+ When('I input {string} in the {string}', function(value, label) {+ return client.useCss().setValue(selectors[label], value);+ });++ // Wait until an element is visible+ When('I wait to see {string}', function(label) {+ return client.useCss().waitForElementVisible(selectors[label], delay);+ });++ // Pause for n seconds+ When('I wait {int} seconds', function(seconds) {+ return client.pause(seconds*1000);+ });+// Check for a stringThen('I should see {string}', function (text) {return client.useCss().assert.containsText('body', text);@@ -43,14 +58,14 @@ defineSupportCode(({Given, Then, When}) => {return client.useCss().expect.element('body').text.not.contains(text);});- // Click for an element by predefined label- Then('I should see the {string} element', function (label) {- return client.useCss().expect.element(labels[label]).to.be.visible;+ // Check for an element by predefined selector+ Then('I should see the {string}', function (label) {+ return client.useCss().expect.element(selectors[label]).to.be.visible;});- // Click for abscense of an element by predefined label- Then('I should not see the {string} element', function (label) {- return client.useCss().expect.element(labels[label]).to.not.be.present;+ // Check for abscense of an element by predefined selector+ Then('I should not see the {string}', function (label) {+ return client.useCss().expect.element(selectors[label]).to.not.be.present;});});diff --git a/e2e/step_definitions/events.js b/e2e/step_definitions/events.jsindex 767937c67..6d3e43d52 100644--- a/e2e/step_definitions/events.js+++ b/e2e/step_definitions/events.js@@ -1,11 +1,12 @@const {client} = require('nightwatch-cucumber');const {defineSupportCode} = require('cucumber');+const delay = client.globals.delay;defineSupportCode(({Given, Then, When}) => {Then('the tab should have a list of events', function () {return client.useCss()- .waitForElementVisible('#wv-events ul.map-item-list', 3000);+ .waitForElementVisible('#wv-events ul.map-item-list', delay);});});diff --git a/e2e/step_definitions/google.js b/e2e/step_definitions/google.jsdeleted file mode 100644index 2f7c80682..000000000--- a/e2e/step_definitions/google.js+++ /dev/null@@ -1,19 +0,0 @@-const {client} = require('nightwatch-cucumber');-const {defineSupportCode} = require('cucumber');--defineSupportCode(({Given, Then, When}) => {- Given(/^I open Google's search page$/, () => {- return client- .url('http://google.com')- .waitForElementVisible('body', 1000);- });-- Then(/^the title is "([^"]*)"$/, (title) => {- return client.assert.title(title);- });-- Then(/^the Google search form exists$/, () => {- return client.assert.visible('input[name="q"]');- });--});diff --git a/e2e/tests/layer-descriptions/search.js b/e2e/tests/layer-descriptions/search.jsdeleted file mode 100644index 629df8a36..000000000--- a/e2e/tests/layer-descriptions/search.js+++ /dev/null@@ -1,46 +0,0 @@-module.exports = {- 'Layer Descriptions - Layer search ("Add Layers" Search: "Corrected Reflectance (True Color)"': function(browser) {- browser.url(browser.globals.url)- .pause(1000);- browser.waitForElementVisible('#skipTour', 10000, function(el) {- browser.click('#skipTour');-- // Check to see if 'Add Layers' Button is present and click to open it- browser.expect.element('#layers-add').to.be.present;- browser.click('#layers-add')- .pause(500);- browser.waitForElementVisible('#layers-search-input', 5000, function(el) {- // Search for Corrected Reflectance (True Color) as this should have a descrition.- browser.setValue('#layers-search-input', 'Corrected Reflectance (True Color)');- browser.waitForElementVisible('#layer-flat-VIIRS_SNPP_CorrectedReflectance_TrueColor', 5000, function(el) {- browser.expect.element('#layer-flat-VIIRS_SNPP_CorrectedReflectance_TrueColor').to.be.present;-- // Click the info icon and check if css hidden class has been removed (to expose description).- browser.click('#layer-flat-VIIRS_SNPP_CorrectedReflectance_TrueColor .fa-info-circle')- .pause(500);- browser.assert.cssClassNotPresent('#layer-flat-VIIRS_SNPP_CorrectedReflectance_TrueColor .source-metadata', 'hidden');-- // Click the info icon and check if css hidden class has been added (to hide description).- browser.click('#layer-flat-VIIRS_SNPP_CorrectedReflectance_TrueColor .fa-info-circle')- .pause(500);- browser.assert.cssClassPresent('#layer-flat-VIIRS_SNPP_CorrectedReflectance_TrueColor .source-metadata', 'hidden');-- // Click the info icon, check if no hidden class is present and element is visible.- browser.click('#layer-flat-VIIRS_SNPP_CorrectedReflectance_TrueColor .fa-info-circle')- .pause(500);- browser.assert.cssClassNotPresent('#layer-flat-VIIRS_SNPP_CorrectedReflectance_TrueColor .source-metadata', 'hidden');- browser.expect.element('#layer-flat-VIIRS_SNPP_CorrectedReflectance_TrueColor .source-metadata').to.be.visible;-- // Scroll to close arrow at bottom of description, click close arrow, check hidden class, check if element is not visible.- browser.moveToElement('#layer-flat-VIIRS_SNPP_CorrectedReflectance_TrueColor .source-metadata .metadata-more', 10, 10)- .pause(500);- browser.click('#layer-flat-VIIRS_SNPP_CorrectedReflectance_TrueColor .source-metadata .metadata-more')- .pause(500);- browser.assert.cssClassPresent('#layer-flat-VIIRS_SNPP_CorrectedReflectance_TrueColor .source-metadata', 'hidden');- browser.expect.element('#layer-flat-VIIRS_SNPP_CorrectedReflectance_TrueColor .source-metadata').to.not.be.visible;- });- });- });- browser.end();- }-};