Interactive interface for browsing global, full-resolution satellite imagery
localStorage enabled/disabled tests
Jason Kentb9581e22e7da
diff --git a/e2e/features/animation/animation-test.js b/e2e/features/animation/animation-test.jsindex c791a57f8..dfc78f981 100644--- a/e2e/features/animation/animation-test.js+++ b/e2e/features/animation/animation-test.js@@ -4,6 +4,7 @@ const localQuerystrings = require('../../reuseables/querystrings.js');const TIME_LIMIT = 10000;module.exports = {+ '@tags': ['localStorageDisabled'],beforeEach(client) {reuseables.loadAndSkipTour(client, TIME_LIMIT);},diff --git a/e2e/features/local-storage/disabled-local-storage-test.js b/e2e/features/local-storage/disabled-local-storage-test.jsindex a3df8c558..ecfb9e54a 100644--- a/e2e/features/local-storage/disabled-local-storage-test.js+++ b/e2e/features/local-storage/disabled-local-storage-test.js@@ -1,37 +1,27 @@const { normalizeViewport } = require('../../reuseables/normalize-viewport.js');+const { localStorageEnabled } = require('../../reuseables/local-storage-check.js');module.exports = {- '@tags': ['localStorageDisabled'],- before(client) {- normalizeViewport(client, 1000, 850);- client.url(client.globals.url);+ '@tags': ['localStorageDisabled', 'skipLocalStorageEnabled'],+ before(c) {+ normalizeViewport(c, 1000, 850);+ c.url(c.globals.url);},- 'Verify tour modal does not display when local storage disabled': function(client, done) {- client.execute(function() {- let enabled;- try {- if (window.localStorage) {- const uid = new Date().toString();- window.localStorage.setItem(uid, uid);- enabled = window.localStorage.getItem(uid) === uid;- window.localStorage.removeItem(uid);+ 'Verify tour modal does not display when local storage disabled': function(c) {+ c.execute(+ localStorageEnabled,+ [],+ function(result) {+ if (result.value) {+ throw new Error('Local storage enabled for test that expected disabled.');}- } catch (error) {- enabled = false;- }- return !!enabled;- },- [],- function(result) {- if (result.value) {- throw new Error('Local storage enabled for test that expected disabled.');- }- // eslint-disable-next-line no-console- console.log('Local storage disabled');- client.assert.not.elementPresent('.tour-start');- });+ // eslint-disable-next-line no-console+ console.log('Local storage disabled');+ c.assert.not.elementPresent('.tour-start');+ },+ );},- after(client) {- client.end();+ after(c) {+ c.end();},};diff --git a/e2e/features/tour/tour-test.js b/e2e/features/tour/tour-test.jsindex 7b708f944..c427608a5 100644--- a/e2e/features/tour/tour-test.js+++ b/e2e/features/tour/tour-test.js@@ -1,36 +1,56 @@const { normalizeViewport } = require('../../reuseables/normalize-viewport.js');+const { localStorageEnabled } = require('../../reuseables/local-storage-check.js');const TIME_LIMIT = 10000;+const runTour = function(c) {+ let totalSteps;+ c.waitForElementVisible('.tour-start', TIME_LIMIT, () => {+ c.click('.tour-box:first-child');+ c.waitForElementVisible('.tour-in-progress .step-total', 2000, () => {+ c+ .getText('.tour-in-progress .step-total', (result) => {+ totalSteps = parseInt(result.value, 10);+ })+ .perform(() => {+ for (let i = 0; i < totalSteps; i += 1) {+ c.pause(500);+ c.click('.step-container .step-next');+ }+ })+ .waitForElementVisible('.tour-complete button.close', 2000, () => {+ c.click('.tour-complete button.close');+ });+ });+ });+};module.exports = {- before(client) {- normalizeViewport(client, 1000, 850);- client.url(client.globals.url);+ '@tags': ['localStorageDisabled'],+ before(c) {+ normalizeViewport(c, 1000, 850);+ c.url(c.globals.url);},- 'Verify that all tour modals are present when the page is loaded': function(client) {- let totalSteps;- client.waitForElementVisible('.tour-start', TIME_LIMIT, () => {- client.click('.tour-box:first-child');- client.waitForElementVisible('.tour-in-progress .step-total', 2000, () => {- client- .getText(- '.tour-in-progress .step-total',- (result) => { totalSteps = parseInt(result.value, 10); },- )- .perform(() => {- for (let i = 0; i < totalSteps; i += 1) {- client.pause(500);- client.click('.step-container .step-next');- }- })- .waitForElementVisible('.tour-complete button.close', 2000, () => {- client.click('.tour-complete button.close');+ 'Verify that all tour modals are present when the page is loaded': function(c) {+ c.execute(+ localStorageEnabled,+ [],+ function({ value }) {+ if (!value) {+ c.waitForElementVisible('#wv-info-button', 1000, () => {+ c.click('#wv-info-button');+ c.waitForElementVisible('#start_tour_info_item', 1000, () => {+ c.click('#start_tour_info_item');+ runTour(c);+ });});- });- });+ } else {+ runTour(c);+ }+ },+ );},- after(client) {- client.end();+ after(c) {+ c.end();},};diff --git a/e2e/reuseables/local-storage-check.js b/e2e/reuseables/local-storage-check.jsnew file mode 100644index 000000000..6f0c68a33--- /dev/null+++ b/e2e/reuseables/local-storage-check.js@@ -0,0 +1,17 @@+/* eslint-disable object-shorthand */+module.exports = {+ localStorageEnabled: function() {+ let enabled;+ try {+ if (window.localStorage) {+ const uid = new Date().toString();+ window.localStorage.setItem(uid, uid);+ enabled = window.localStorage.getItem(uid) === uid;+ window.localStorage.removeItem(uid);+ }+ } catch (error) {+ enabled = false;+ }+ return !!enabled;+ },+};diff --git a/e2e/reuseables/skip-tour.js b/e2e/reuseables/skip-tour.jsindex 1f5e11dd3..136fc8243 100644--- a/e2e/reuseables/skip-tour.js+++ b/e2e/reuseables/skip-tour.js@@ -1,20 +1,32 @@const { normalizeViewport } = require('./normalize-viewport.js');module.exports = {- loadAndSkipTour(client, wait) {- normalizeViewport(client, 1024, 768);- client.url(client.globals.url)- .execute(() => !window.localStorage.getItem('hideTour'), // See if there should be a tour- [], (result) => {- const hasTour = result.value;- if (hasTour) {- client.waitForElementVisible('.tour button.close', wait, () => {- client.click('.tour button.close');- client.pause(1000);- });- } else {- client.waitForElementVisible('#wv-logo', wait);+ loadAndSkipTour(c, wait) {+ normalizeViewport(c, 1024, 768);+ c.url(c.globals.url).execute(+ function() {+ let showModal;+ try {+ if (window.localStorage) {+ showModal = !window.localStorage.getItem('hideTour');}- });+ } catch (error) {+ // If localStorage is disabled, tour modal does not show+ showModal = false;+ }+ return showModal;+ },+ [],+ function({ value: showModal }) {+ if (showModal) {+ c.waitForElementVisible('.tour button.close', wait, () => {+ c.click('.tour button.close');+ c.pause(1000);+ });+ } else {+ c.waitForElementVisible('#wv-logo', wait);+ }+ },+ );},};diff --git a/package.json b/package.jsonindex 5cd55cf74..7ebc4a5c8 100644--- a/package.json+++ b/package.json@@ -54,9 +54,9 @@"e2e:headless": "run-s --continue-on-error --silent e2e:headless:*","e2e:gui:chrome": "npx nightwatch -e chrome","e2e:gui:firefox": "npx nightwatch -e firefox",- "e2e:headless:chrome": "npx nightwatch -e chromeHeadless --skiptags localStorageDisabled --suiteRetries 2",+ "e2e:headless:chrome": "npx nightwatch -e chromeHeadless --skiptags skipLocalStorageEnabled --suiteRetries 2","e2e:headless:chrome:localStorageDisabled": "npx nightwatch -e chromeLocalStorageDisabled --tag localStorageDisabled",- "e2e:headless:firefox": "npx nightwatch -e firefoxHeadless --skiptags localStorageDisabled --suiteRetries 2",+ "e2e:headless:firefox": "npx nightwatch -e firefoxHeadless --skiptags skipLocalStorageEnabled --suiteRetries 2","e2e:headless:firefox:localStorageDisabled": "npx nightwatch -e firefoxLocalStorageDisabled --tag localStorageDisabled","getcapabilities": "bash -c 'FETCH_GC=1 tasks/buildOptions.sh'","generatePreviews": "python3 tasks/python3/fetchPreviewSnapshots.py",