1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00

Fix ESLint errors on visual and integration test code

This commit is contained in:
Brett Sun 2016-06-02 16:42:20 +02:00
parent 42d35e7807
commit 92978269cc
17 changed files with 111 additions and 102 deletions

View File

@ -43,6 +43,7 @@
"babel-jest": "^5.2.0",
"chai": "^3.4.1",
"chai-as-promised": "^5.1.0",
"colors": "^1.1.2",
"dotenv": "^1.2.0",
"gemini": "^2.1.0",
"jest-cli": "^0.4.0",

View File

@ -1,36 +0,0 @@
{
"parser": "babel-eslint",
"env": {
"mocha": true,
"node": true
},
"rules": {
"new-cap": [2, {newIsCap: true, capIsNew: false}],
"quotes": [2, "single"],
"eol-last": [0],
"no-mixed-requires": [0],
"no-underscore-dangle": [0],
"global-strict": [2, "always"],
"no-trailing-spaces": [2, { skipBlankLines: true }],
"no-console": 0,
"camelcase": [2, {"properties": "never"}],
},
"globals": {},
"plugins": [],
"ecmaFeatures": {
"modules": 1,
"arrowFunctions",
"classes": 1,
"blockBindings": 1,
"defaultParams": 1,
"destructuring": 1,
"objectLiteralComputedProperties": 1,
"objectLiteralDuplicateProperties": 0,
"objectLiteralShorthandMethods": 1,
"objectLiteralShorthandProperties": 1,
"restParams": 1,
"spread": 1,
"superInFunctions": 1,
"templateStrings": 1
}
}

13
test/.eslintrc.json Normal file
View File

@ -0,0 +1,13 @@
{
"env": {
"node": true
},
"rules": {
"func-names": [0],
"no-console": [0],
"no-process-exit": [0],
"strict": [0],
"import/newline-after-import": [0],
"import/no-extraneous-dependencies": [2, { "devDependencies": true, "optionalDependencies": false }]
}
}

View File

@ -0,0 +1,5 @@
{
"rules": {
"max-len": [2, { "code": 125 }]
}
}

View File

@ -1,3 +1,4 @@
/* eslint-disable strict, no-console */
'use strict';
const MAIN_USER = {

View File

@ -12,7 +12,7 @@ gemini.suite('Authenticated', (suite) => {
suite
.setUrl('/collection')
.setCaptureElements('.ascribe-body')
.before((actions, find) => {
.before((actions) => {
// This will be called before every nested suite begins unless that suite
// also defines a `.before()`
actions.waitForElementToShow('.ascribe-app', TIMEOUTS.NORMAL);
@ -40,7 +40,7 @@ gemini.suite('Authenticated', (suite) => {
// Ignore Cyland's logo as it's a gif
.ignoreElements('.client--cyland img.img-brand')
.skip(/Mobile/)
.before((actions, find) => {
.before((actions) => {
actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', TIMEOUTS.NORMAL);
})
.capture('desktop header');
@ -69,7 +69,7 @@ gemini.suite('Authenticated', (suite) => {
// Ignore Cyland's logo as it's a gif
.ignoreElements('.client--cyland img.img-brand')
.skip(/Desktop/)
.before((actions, find) => {
.before((actions) => {
actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', TIMEOUTS.NORMAL);
})
.capture('mobile header')
@ -89,7 +89,7 @@ gemini.suite('Authenticated', (suite) => {
gemini.suite('Collection', (collectionSuite) => {
collectionSuite
.setCaptureElements('.ascribe-accordion-list')
.before((actions, find) => {
.before((actions) => {
actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', TIMEOUTS.NORMAL);
// Wait for the images to load
// FIXME: unfortuntately gemini doesn't support ignoring multiple elements from a single selector
@ -102,7 +102,7 @@ gemini.suite('Authenticated', (suite) => {
actions.click(find('.ascribe-accordion-list-item .ascribe-accordion-list-item-edition-widget'));
// Wait for editions to load
actions.waitForElementToShow('.ascribe-accordion-list-item-table', TIMEOUTS.LONG);
})
});
gemini.suite('Collection placeholder', (collectionPlaceholderSuite) => {
collectionPlaceholderSuite
@ -133,8 +133,9 @@ gemini.suite('Authenticated', (suite) => {
.capture('piece list toolbar')
.capture('piece list toolbar search filled', (actions, find) => {
actions.sendKeys(find('.ascribe-piece-list-toolbar .search-bar input[type="text"]'), 'search text');
actions.waitForElementToShow('.ascribe-piece-list-toolbar .search-bar .icon-ascribe-search', TIMEOUTS.NORMAL);
})
actions.waitForElementToShow('.ascribe-piece-list-toolbar .search-bar .icon-ascribe-search',
TIMEOUTS.NORMAL);
});
gemini.suite('Order widget dropdown', (pieceListToolbarOrderWidgetSuite) => {
pieceListToolbarOrderWidgetSuite
@ -164,13 +165,14 @@ gemini.suite('Authenticated', (suite) => {
gemini.suite('Register work', (registerSuite) => {
registerSuite
.setUrl('/register_piece')
.before((actions, find) => {
.before((actions) => {
// The editions options are only rendered after the whitelabel is fetched, so
// we have to wait for it here
// We have to check for the sibling checkbox class as the input itself is hidden
actions.waitForElementToShow('.ascribe-form input[name="num_editions-checkbox"] ~ .checkbox', TIMEOUTS.NORMAL);
actions.waitForElementToShow('.ascribe-form input[name="num_editions-checkbox"] ~ .checkbox',
TIMEOUTS.NORMAL);
})
.capture('register work', (actions, find) => {
.capture('register work', (actions) => {
// The uploader options are only rendered after the user is fetched, so
// we also have to wait for it here
actions.waitForElementToShow('.file-drag-and-drop-dialog .present-options', TIMEOUTS.NORMAL);
@ -203,7 +205,7 @@ gemini.suite('Authenticated', (suite) => {
gemini.suite('User settings', (userSettingsSuite) => {
userSettingsSuite
.setUrl('/settings')
.before((actions, find) => {
.before((actions) => {
// This will be called before every nested suite begins unless that suite
// also defines a `.before()`
actions.waitForElementToShow('.settings-container', TIMEOUTS.NORMAL);
@ -216,7 +218,7 @@ gemini.suite('Authenticated', (suite) => {
logoutSuite
.setUrl('/logout')
.ignoreElements('.ascribe-body')
.capture('logout', (actions, find) => {
.capture('logout', (actions) => {
actions.waitForElementToShow('.ascribe-login-wrapper', TIMEOUTS.LONG);
});
});

View File

@ -12,7 +12,7 @@ gemini.suite('Basic', (suite) => {
suite
.setUrl('/login')
.setCaptureElements('.ascribe-body')
.before((actions, find) => {
.before((actions) => {
// This will be called before every nested suite begins unless that suite
// also defines a `.before()`
actions.waitForElementToShow('.ascribe-app', TIMEOUTS.NORMAL);
@ -22,7 +22,7 @@ gemini.suite('Basic', (suite) => {
headerSuite
.setCaptureElements('nav.navbar .container')
.skip(/Mobile/)
.capture('desktop header', (actions, find) => {
.capture('desktop header', (actions) => {
actions.waitForElementToShow('nav.navbar .container', TIMEOUTS.NORMAL);
})
.capture('hover on active item', (actions, find) => {
@ -40,7 +40,7 @@ gemini.suite('Basic', (suite) => {
headerMobileSuite
.setCaptureElements('nav.navbar .container')
.skip(/Desktop/)
.capture('mobile header', (actions, find) => {
.capture('mobile header', (actions) => {
actions.waitForElementToShow('nav.navbar .container', TIMEOUTS.NORMAL);
})
.capture('expanded mobile header', (actions, find) => {
@ -56,7 +56,7 @@ gemini.suite('Basic', (suite) => {
gemini.suite('Footer', (footerSuite) => {
footerSuite
.setCaptureElements('.ascribe-footer')
.capture('footer', (actions, find) => {
.capture('footer', (actions) => {
actions.waitForElementToShow('.ascribe-footer', TIMEOUTS.NORMAL);
})
.capture('hover on footer item', (actions, find) => {
@ -64,14 +64,14 @@ gemini.suite('Basic', (suite) => {
actions.mouseMove(footerItem);
})
.capture('hover on footer social item', (actions, find) => {
const footerSocialItem = find('.ascribe-footer a.social')
const footerSocialItem = find('.ascribe-footer a.social');
actions.mouseMove(footerSocialItem);
});
});
gemini.suite('Login', (loginSuite) => {
loginSuite
.capture('login', (actions, find) => {
.capture('login', (actions) => {
actions.waitForElementToShow('.ascribe-form', TIMEOUTS.NORMAL);
})
.capture('hover on login submit', (actions, find) => {
@ -97,7 +97,7 @@ gemini.suite('Basic', (suite) => {
gemini.suite('Sign up', (signUpSuite) => {
signUpSuite
.setUrl('/signup')
.capture('sign up', (actions, find) => {
.capture('sign up', (actions) => {
actions.waitForElementToShow('.ascribe-form', TIMEOUTS.NORMAL);
})
.capture('sign up form filled with focus', (actions, find) => {
@ -113,7 +113,7 @@ gemini.suite('Basic', (suite) => {
gemini.suite('Password reset', (passwordResetSuite) => {
passwordResetSuite
.setUrl('/password_reset')
.capture('password reset', (actions, find) => {
.capture('password reset', (actions) => {
actions.waitForElementToShow('.ascribe-form', TIMEOUTS.NORMAL);
})
.capture('password reset form filled with focus', (actions, find) => {
@ -127,12 +127,13 @@ gemini.suite('Basic', (suite) => {
gemini.suite('Coa verify', (coaVerifySuite) => {
coaVerifySuite
.setUrl('/coa_verify')
.capture('coa verify', (actions, find) => {
.capture('coa verify', (actions) => {
actions.waitForElementToShow('.ascribe-form', TIMEOUTS.NORMAL);
})
.capture('coa verify form filled with focus', (actions, find) => {
actions.sendKeys(find('.ascribe-form input[name="message"]'), 'sample text');
actions.sendKeys(find('.ascribe-form .ascribe-property-wrapper:nth-of-type(2) textarea'), 'sample signature');
actions.sendKeys(find('.ascribe-form .ascribe-property-wrapper:nth-of-type(2) textarea'),
'sample signature');
})
.capture('coa verify form filled', (actions, find) => {
actions.click(find('.ascribe-login-header'));

View File

@ -16,21 +16,23 @@ const editionUrl = `/editions/${environment.MAIN_EDITION_ID}`;
gemini.suite('Work detail', (suite) => {
suite
.setCaptureElements('.ascribe-body')
.before((actions, find) => {
.before((actions) => {
// This will be called before every nested suite begins unless that suite
// also defines a `.before()`
actions.waitForElementToShow('.ascribe-app', TIMEOUTS.NORMAL);
// Wait for the social media buttons to appear
actions.waitForElementToShow('.ascribe-social-button-list .fb-share-button iframe', TIMEOUTS.SUPER_DUPER_EXTRA_LONG);
actions.waitForElementToShow('.ascribe-social-button-list .twitter-share-button', TIMEOUTS.SUPER_DUPER_EXTRA_LONG);
actions.waitForElementToShow('.ascribe-social-button-list .fb-share-button iframe',
TIMEOUTS.SUPER_DUPER_EXTRA_LONG);
actions.waitForElementToShow('.ascribe-social-button-list .twitter-share-button',
TIMEOUTS.SUPER_DUPER_EXTRA_LONG);
actions.waitForElementToShow('.ascribe-media-player', TIMEOUTS.LONG);
});
gemini.suite('Basic piece', (basicPieceSuite) => {
basicPieceSuite
.setUrl(pieceUrl)
.capture('basic piece')
.capture('basic piece');
gemini.suite('Shmui', (shmuiSuite) => {
shmuiSuite.
@ -55,7 +57,7 @@ gemini.suite('Work detail', (suite) => {
loginSuite
.setUrl('/login')
.ignoreElements('.ascribe-body')
.before((actions, find) => {
.before((actions) => {
actions.waitForElementToShow('.ascribe-app', TIMEOUTS.NORMAL);
})
.capture('logged in', (actions, find) => {
@ -76,7 +78,7 @@ gemini.suite('Work detail', (suite) => {
gemini.suite('Authorized edition', (authorizedEditionSuite) => {
authorizedEditionSuite
.setUrl(editionUrl)
.capture('authorized edition')
.capture('authorized edition');
});
gemini.suite('Detail action buttons', (detailActionButtonSuite) => {
@ -102,13 +104,19 @@ gemini.suite('Work detail', (suite) => {
.setCaptureElements('.modal-dialog')
.capture('open email form', (actions, find) => {
// Add class names to make the action buttons easier to select
actions.executeJS(function (window) {
var actionButtons = window.document.querySelectorAll('.ascribe-detail-property .ascribe-button-list button.btn-default');
for (var ii = 0; ii < actionButtons.length; ++ii) {
// eslint-disable-next-line prefer-arrow-callback
actions.executeJS(function addButtonTypeAsClass(window) {
/* eslint-disable no-var, prefer-template */
var actionButtonsSelector = '.ascribe-detail-property .ascribe-button-list button.btn-default';
var actionButtons = window.document.querySelectorAll(actionButtonsSelector);
var ii = 0;
for (; ii < actionButtons.length; ++ii) {
if (actionButtons[ii].textContent) {
actionButtons[ii].className += ' ascribe-action-button-' + actionButtons[ii].textContent.toLowerCase();
actionButtons[ii].className += ' ascribe-action-button-' +
actionButtons[ii].textContent.toLowerCase();
}
}
/* eslint-enable no-var */
});
actions.click(find('.ascribe-detail-property .ascribe-button-list button.ascribe-action-button-email'));
@ -122,10 +130,10 @@ gemini.suite('Work detail', (suite) => {
logoutSuite
.setUrl('/logout')
.ignoreElements('.ascribe-body')
.before((actions, find) => {
.before((actions) => {
actions.waitForElementToShow('.ascribe-app', TIMEOUTS.NORMAL);
})
.capture('logout', (actions, find) => {
.capture('logout', (actions) => {
actions.waitForElementToShow('.ascribe-login-wrapper', TIMEOUTS.LONG);
});
});

View File

@ -10,7 +10,7 @@ const TIMEOUTS = environment.TIMEOUTS;
gemini.suite('23vivi', (suite) => {
suite
.setCaptureElements('.ascribe-body')
.before((actions, find) => {
.before((actions) => {
// This will be called before every nested suite begins
actions.waitForElementToShow('.ascribe-app', TIMEOUTS.NORMAL);
});
@ -18,7 +18,7 @@ gemini.suite('23vivi', (suite) => {
gemini.suite('Landing', (landingSuite) => {
landingSuite
.setUrl('/')
.capture('landing', (actions, find) => {
.capture('landing', (actions) => {
// Wait for the logo to appear
actions.waitForElementToShow('.vivi23-landing--header-logo', TIMEOUTS.LONG);
});

View File

@ -10,7 +10,7 @@ const TIMEOUTS = environment.TIMEOUTS;
gemini.suite('Cyland', (suite) => {
suite
.setCaptureElements('.ascribe-body')
.before((actions, find) => {
.before((actions) => {
// This will be called before every nested suite begins
actions.waitForElementToShow('.ascribe-app', TIMEOUTS.NORMAL);
});
@ -20,7 +20,7 @@ gemini.suite('Cyland', (suite) => {
.setUrl('/')
// Ignore Cyland's logo as it's a gif
.ignoreElements('.cyland-landing img')
.capture('landing', (actions, find) => {
.capture('landing', (actions) => {
actions.waitForElementToShow('.cyland-landing img', TIMEOUTS.LONG);
});
});

View File

@ -11,7 +11,7 @@ const TIMEOUTS = environment.TIMEOUTS;
gemini.suite('Ikonotv', (suite) => {
suite
.setCaptureElements('.ascribe-body')
.before((actions, find) => {
.before((actions) => {
// This will be called before every nested suite begins
actions.waitForElementToShow('.ascribe-app', TIMEOUTS.NORMAL);
});
@ -22,9 +22,11 @@ gemini.suite('Ikonotv', (suite) => {
// Gemini complains if we try to capture the entire app for Ikonotv's landing page for some reason
.setCaptureElements('.ikonotv-landing')
.setTolerance(5)
.capture('landing', (actions, find) => {
.capture('landing', (actions) => {
// Stop background animation
actions.executeJS(function (window) {
// eslint-disable-next-line prefer-arrow-callback
actions.executeJS(function removeBackgroundAnimation(window) {
/* eslint-disable no-var */
var landingBackground = window.document.querySelector('.client--ikonotv .route--landing');
landingBackground.style.animation = 'none';
landingBackground.style.webkitAnimation = 'none';
@ -37,10 +39,10 @@ gemini.suite('Ikonotv', (suite) => {
// Ikono needs its own set of tests for some pre-authorization pages to wait for
// its logo to appear
gemini.suite('Ikonotv basic', (suite) => {
suite
gemini.suite('Ikonotv basic', (basicSuite) => {
basicSuite
.setCaptureElements('.ascribe-app')
.before((actions, find) => {
.before((actions) => {
// This will be called before every nested suite begins unless that suite
// also defines a `.before()`
actions.waitForElementToShow('.ascribe-app', TIMEOUTS.NORMAL);

View File

@ -10,7 +10,7 @@ const TIMEOUTS = environment.TIMEOUTS;
gemini.suite('Lumenus', (suite) => {
suite
.setCaptureElements('.ascribe-body')
.before((actions, find) => {
.before((actions) => {
// This will be called before every nested suite begins
actions.waitForElementToShow('.ascribe-app', TIMEOUTS.NORMAL);
});
@ -18,7 +18,7 @@ gemini.suite('Lumenus', (suite) => {
gemini.suite('Landing', (landingSuite) => {
landingSuite
.setUrl('/')
.capture('landing', (actions, find) => {
.capture('landing', (actions) => {
// Wait for the logo to appear
actions.waitForElementToShow('.wp-landing-wrapper img', TIMEOUTS.LONG);
});

View File

@ -11,7 +11,7 @@ const TIMEOUTS = environment.TIMEOUTS;
gemini.suite('Whitelabel basic', (suite) => {
suite
.setCaptureElements('.ascribe-wallet-app > .container')
.before((actions, find) => {
.before((actions) => {
// This will be called before every nested suite begins unless that suite
// also defines a `.before()`
// FIXME: use a more generic class for this, like just '.ascribe-app'
@ -26,7 +26,7 @@ gemini.suite('Whitelabel basic', (suite) => {
.setUrl('/login')
// See Ikono
.skip(/Ikono/)
.capture('login', (actions, find) => {
.capture('login', (actions) => {
actions.waitForElementToShow('.ascribe-form', TIMEOUTS.NORMAL);
// For some reason, the screenshots seem to keep catching the whitelabel login form
// on a refresh and without fonts loaded (maybe because they're the first tests run
@ -59,7 +59,7 @@ gemini.suite('Whitelabel basic', (suite) => {
.setUrl('/signup')
// See Ikono
.skip(/Ikono/)
.capture('sign up', (actions, find) => {
.capture('sign up', (actions) => {
actions.waitForElementToShow('.ascribe-form', TIMEOUTS.NORMAL);
// Wait in case the form reloads due to other assets loading
actions.wait(500);
@ -77,7 +77,7 @@ gemini.suite('Whitelabel basic', (suite) => {
gemini.suite('Password reset', (passwordResetSuite) => {
passwordResetSuite
.setUrl('/password_reset')
.capture('password reset', (actions, find) => {
.capture('password reset', (actions) => {
actions.waitForElementToShow('.ascribe-form', TIMEOUTS.NORMAL);
// Wait in case the form reloads due to other assets loading
actions.wait(500);
@ -93,14 +93,15 @@ gemini.suite('Whitelabel basic', (suite) => {
gemini.suite('Coa verify', (coaVerifySuite) => {
coaVerifySuite
.setUrl('/coa_verify')
.capture('coa verify', (actions, find) => {
.capture('coa verify', (actions) => {
actions.waitForElementToShow('.ascribe-form', TIMEOUTS.NORMAL);
// Wait in case the form reloads due to other assets loading
actions.wait(500);
})
.capture('coa verify form filled with focus', (actions, find) => {
actions.sendKeys(find('.ascribe-form input[name="message"]'), 'sample text');
actions.sendKeys(find('.ascribe-form .ascribe-property-wrapper:nth-of-type(2) textarea'), 'sample signature');
actions.sendKeys(find('.ascribe-form .ascribe-property-wrapper:nth-of-type(2) textarea'),
'sample signature');
})
.capture('coa verify form filled', (actions, find) => {
actions.click(find('.ascribe-login-header'));

View File

@ -0,0 +1,9 @@
{
"env": {
"mocha": true
},
"rules": {
"max-len": [2, { "code": 125 }],
"prefer-arrow-callback": [0]
}
}

View File

@ -1,20 +1,20 @@
'use strict';
const config = require('./config');
const colors = require('colors');
const sauceConnectLauncher = require('sauce-connect-launcher');
const config = require('./config');
let globalSauceProcess;
if (!process.env.SAUCE_USERNAME) {
console.log(colors.red('SAUCE_USERNAME is missing. Please check the README.md file.'));
process.exit(1); //eslint-disable-line no-process-exit
process.exit(1);
}
if (!process.env.SAUCE_ACCESS_KEY) {
console.log(colors.red('SAUCE_ACCESS_KEY is missing. Please check the README.md file.'));
process.exit(1); //eslint-disable-line no-process-exit
process.exit(1);
}

View File

@ -40,9 +40,9 @@ function testSuite(browserName, version, platform) {
});
it('should contain "Log in" in the title', function () {
return browser.
waitForElementByCss('.ascribe-login-wrapper', asserters.isDisplayed, 2000)
title().should.become('Log in');
return browser
.waitForElementByCss('.ascribe-login-wrapper', asserters.isDisplayed, 2000)
.title().should.become('Log in');
});
});
}

View File

@ -1,15 +1,17 @@
'use strict';
const config = require('./config'); //eslint-disable-line no-unused-vars
const colors = require('colors');
const sauceConnectLauncher = require('sauce-connect-launcher');
const config = require('./config'); // eslint-disable-line no-unused-vars
function connect() {
console.log(colors.yellow('Setting up tunnel from Saucelabs to your lovely computer, will take a while.'));
console.log(
colors.yellow('Setting up tunnel from Saucelabs to your lovely computer, will take a while.')
);
// Creating the tunnel takes a bit of time. For this case we can safely disable Mocha timeouts.
sauceConnectLauncher(function (err) {
sauceConnectLauncher((err) => {
if (err) {
console.error(err.message);
return;