Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

e2e tests with localStorage disabled

Jason Kent08d4f7e9d89d
diff --git a/.travis.yml b/.travis.yml
index f10bda7ed..57110674a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -34,6 +34,7 @@ matrix:
script:
- npm run build:ci
- npm run start &
+ - npm run e2e:headless:chrome:localStorageDisabled
- npm run e2e:headless:chrome
- os: osx
@@ -62,6 +63,7 @@ matrix:
script:
- npm run build:ci
- npm run start &
+ - npm run e2e:headless:firefox:localStorageDisabled
- npm run e2e:headless:firefox
- os: linux
diff --git a/e2e/.eslintrc b/e2e/.eslintrc
index 3173459e0..f69d3d85f 100644
--- a/e2e/.eslintrc
+++ b/e2e/.eslintrc
@@ -47,6 +47,7 @@
"max-len": "off",
"func-names": "off",
"no-shadow": "off",
- "no-plusplus": "off"
+ "no-plusplus": "off",
+ "prefer-arrow-callback": "off"
}
}
\ No newline at end of file
diff --git a/e2e/features/local-storage/disabled-local-storage-test.js b/e2e/features/local-storage/disabled-local-storage-test.js
new file mode 100644
index 000000000..a3df8c558
--- /dev/null
+++ b/e2e/features/local-storage/disabled-local-storage-test.js
@@ -0,0 +1,37 @@
+const { normalizeViewport } = require('../../reuseables/normalize-viewport.js');
+
+module.exports = {
+ '@tags': ['localStorageDisabled'],
+ before(client) {
+ normalizeViewport(client, 1000, 850);
+ client.url(client.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);
+ }
+ } 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');
+ });
+ },
+ after(client) {
+ client.end();
+ },
+};
diff --git a/e2e/features/tour/tour-test.js b/e2e/features/tour/tour-test.js
index 8126cdd12..7b708f944 100644
--- a/e2e/features/tour/tour-test.js
+++ b/e2e/features/tour/tour-test.js
@@ -5,21 +5,25 @@ const TIME_LIMIT = 10000;
module.exports = {
before(client) {
normalizeViewport(client, 1000, 850);
- client.url(client.globals.url)
- .execute(() => !window.localStorage.getItem('hideTour'));
+ client.url(client.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); })
+ 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, () => {
+ })
+ .waitForElementVisible('.tour-complete button.close', 2000, () => {
client.click('.tour-complete button.close');
});
});
diff --git a/nightwatch.conf.js b/nightwatch.conf.js
index 8ec290f4a..5a6899ae7 100644
--- a/nightwatch.conf.js
+++ b/nightwatch.conf.js
@@ -46,6 +46,16 @@ module.exports = {
},
},
},
+ chromeLocalStorageDisabled: {
+ desiredCapabilities: {
+ browserName: 'chrome',
+ 'goog:chromeOptions': {
+ w3c: false,
+ prefs: { 'profile.managed_default_content_settings.notifications': 1 },
+ args: ['headless', 'no-sandbox', 'disable-gpu', 'disable-local-storage'],
+ },
+ },
+ },
firefox: {
desiredCapabilities: {
browserName: 'firefox',
@@ -61,5 +71,17 @@ module.exports = {
},
},
},
+ firefoxLocalStorageDisabled: {
+ desiredCapabilities: {
+ browserName: 'firefox',
+ javascriptEnabled: true,
+ 'moz:firefoxOptions': {
+ args: ['--headless'],
+ prefs: {
+ 'dom.storage.enabled': false,
+ },
+ },
+ },
+ },
},
};
diff --git a/package.json b/package.json
index d17017776..9f8196adf 100644
--- a/package.json
+++ b/package.json
@@ -54,8 +54,10 @@
"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",
- "e2e:headless:firefox": "npx nightwatch -e firefoxHeadless",
+ "e2e:headless:chrome": "npx nightwatch -e chromeHeadless --skipTags localStorageDisabled --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:localStorageDisabled": "npx nightwatch -e firefoxLocalStorageDisabled --tag localStorageDisabled",
"getcapabilities": "bash -c 'FETCH_GC=1 tasks/buildOptions.sh'",
"generatePreviews": "python3 tasks/python3/fetchPreviewSnapshots.py",
"linkcheck": "node ./tasks/linkcheck",