diff --git a/.gitignore b/.gitignore index 0b4d85c7..e497465f 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ build/* gemini-coverage/* gemini-report/* +test/gemini/screenshots/* node_modules/* diff --git a/js/components/ascribe_accordion_list/accordion_list_item_thumbnail_placeholder.js b/js/components/ascribe_accordion_list/accordion_list_item_thumbnail_placeholder.js index 37c98371..8000affd 100644 --- a/js/components/ascribe_accordion_list/accordion_list_item_thumbnail_placeholder.js +++ b/js/components/ascribe_accordion_list/accordion_list_item_thumbnail_placeholder.js @@ -1,4 +1,4 @@ -'use strict' +'use strict'; import React from 'react'; diff --git a/js/components/ascribe_forms/form.js b/js/components/ascribe_forms/form.js index dc870d5a..fcc2f799 100644 --- a/js/components/ascribe_forms/form.js +++ b/js/components/ascribe_forms/form.js @@ -156,7 +156,7 @@ let Form = React.createClass({ for(let ref in this.refs) { if(this.refs[ref] && typeof this.refs[ref].handleSuccess === 'function'){ - this.refs[ref].handleSuccess(); + this.refs[ref].handleSuccess(response); } } this.setState({ diff --git a/js/components/ascribe_forms/form_loan.js b/js/components/ascribe_forms/form_loan.js index 861806ae..e04eb209 100644 --- a/js/components/ascribe_forms/form_loan.js +++ b/js/components/ascribe_forms/form_loan.js @@ -171,7 +171,7 @@ let LoanForm = React.createClass({ editable={!gallery} overrideForm={!!gallery}> diff --git a/js/components/ascribe_forms/input_date.js b/js/components/ascribe_forms/input_date.js index 3e2892c0..d7e36b0d 100644 --- a/js/components/ascribe_forms/input_date.js +++ b/js/components/ascribe_forms/input_date.js @@ -17,10 +17,7 @@ let InputDate = React.createClass({ }, getInitialState() { - return { - value: null, - value_moment: null - }; + return this.getStateFromMoment(this.props.defaultValue); }, // InputDate needs to support setting a defaultValue from outside. @@ -28,20 +25,30 @@ let InputDate = React.createClass({ // to the outer Property componentWillReceiveProps(nextProps) { if(!this.state.value && !this.state.value_moment && nextProps.defaultValue) { - this.handleChange(this.props.defaultValue); + this.handleChange(nextProps.defaultValue); } }, - handleChange(date) { - let formattedDate = date.format('YYYY-MM-DD'); - this.setState({ - value: formattedDate, - value_moment: date - }); + getStateFromMoment(date) { + const state = {}; + if (date) { + state.value = date.format('YYYY-MM-DD'); + state.value_moment = date; + } + + return state; + }, + + handleChange(date) { + const newState = this.getStateFromMoment(date); + + this.setState(newState); + + // Propagate change up by faking event this.props.onChange({ target: { - value: formattedDate + value: newState.value } }); }, diff --git a/js/components/piece_list.js b/js/components/piece_list.js index 567a53e9..caf48aae 100644 --- a/js/components/piece_list.js +++ b/js/components/piece_list.js @@ -36,7 +36,10 @@ let PieceList = React.createClass({ accordionListItemType: React.PropTypes.func, bulkModalButtonListType: React.PropTypes.func, canLoadPieceList: React.PropTypes.bool, - redirectTo: React.PropTypes.string, + redirectTo: React.PropTypes.shape({ + pathname: React.PropTypes.string, + query: React.PropTypes.object + }), shouldRedirect: React.PropTypes.func, customSubmitButton: React.PropTypes.element, customThumbnailPlaceholder: React.PropTypes.func, @@ -62,8 +65,11 @@ let PieceList = React.createClass({ ] }], orderParams: ['artist_name', 'title'], - redirectTo: '/register_piece', - shouldRedirect: () => true + redirectTo: { + pathname: '/register_piece', + query: null + }, + shouldRedirect: (pieceCount) => !pieceCount }; }, @@ -120,10 +126,16 @@ let PieceList = React.createClass({ const { location: { query }, redirectTo, shouldRedirect } = this.props; const { unfilteredPieceListCount } = this.state; - if (redirectTo && unfilteredPieceListCount === 0 && + if (redirectTo && redirectTo.pathname && (typeof shouldRedirect === 'function' && shouldRedirect(unfilteredPieceListCount))) { // FIXME: hack to redirect out of the dispatch cycle - window.setTimeout(() => this.history.push({ query, pathname: redirectTo }), 0); + window.setTimeout(() => this.history.push({ + // Occasionally, the back end also sets query parameters for Onion. + // We need to consider this by merging all passed query parameters, as we'll + // otherwise end up in a 404 screen + query: Object.assign({}, query, redirectTo.query), + pathname: redirectTo.pathname + }), 0); } }, diff --git a/js/components/whitelabel/prize/prize_routes.js b/js/components/whitelabel/prize/prize_routes.js index 73608ae2..86cf3a9b 100644 --- a/js/components/whitelabel/prize/prize_routes.js +++ b/js/components/whitelabel/prize/prize_routes.js @@ -73,7 +73,7 @@ const ROUTES = { component={EditionContainer} hideFooter /> + location={this.props.location} + shouldRedirect={() => !(isJury || isJudge || isAdmin)} /> ); } diff --git a/js/components/whitelabel/prize/sluice/components/sluice_buttons/sluice_selected_prize_action_button.js b/js/components/whitelabel/prize/sluice/components/sluice_buttons/sluice_selected_prize_action_button.js index 7778a8de..7d013d5d 100644 --- a/js/components/whitelabel/prize/sluice/components/sluice_buttons/sluice_selected_prize_action_button.js +++ b/js/components/whitelabel/prize/sluice/components/sluice_buttons/sluice_selected_prize_action_button.js @@ -1,4 +1,4 @@ -'use strict' +'use strict'; import React from 'react'; import Moment from 'moment'; diff --git a/js/components/whitelabel/wallet/components/23vivi/23vivi_accordion_list/23vivi_accordion_list_item_thumbnail_placeholder.js b/js/components/whitelabel/wallet/components/23vivi/23vivi_accordion_list/23vivi_accordion_list_item_thumbnail_placeholder.js index f360c932..3a9b3943 100644 --- a/js/components/whitelabel/wallet/components/23vivi/23vivi_accordion_list/23vivi_accordion_list_item_thumbnail_placeholder.js +++ b/js/components/whitelabel/wallet/components/23vivi/23vivi_accordion_list/23vivi_accordion_list_item_thumbnail_placeholder.js @@ -1,4 +1,4 @@ -'use strict' +'use strict'; import React from 'react'; diff --git a/js/components/whitelabel/wallet/components/23vivi/23vivi_piece_list.js b/js/components/whitelabel/wallet/components/23vivi/23vivi_piece_list.js index 0bfb8aa0..fa2bf5f0 100644 --- a/js/components/whitelabel/wallet/components/23vivi/23vivi_piece_list.js +++ b/js/components/whitelabel/wallet/components/23vivi/23vivi_piece_list.js @@ -1,4 +1,4 @@ -'use strict' +'use strict'; import React from 'react'; diff --git a/js/components/whitelabel/wallet/components/cyland/cyland_piece_list.js b/js/components/whitelabel/wallet/components/cyland/cyland_piece_list.js index c40b455a..29c7d46f 100644 --- a/js/components/whitelabel/wallet/components/cyland/cyland_piece_list.js +++ b/js/components/whitelabel/wallet/components/cyland/cyland_piece_list.js @@ -6,11 +6,14 @@ import PieceList from '../../../../piece_list'; import UserActions from '../../../../../actions/user_actions'; import UserStore from '../../../../../stores/user_store'; +import WhitelabelActions from '../../../../../actions/whitelabel_actions'; +import WhitelabelStore from '../../../../../stores/whitelabel_store'; + import CylandAccordionListItem from './cyland_accordion_list/cyland_accordion_list_item'; import { getLangText } from '../../../../../utils/lang_utils'; import { setDocumentTitle } from '../../../../../utils/dom_utils'; - +import { mergeOptions } from '../../../../../utils/general_utils'; let CylandPieceList = React.createClass({ propTypes: { @@ -18,15 +21,22 @@ let CylandPieceList = React.createClass({ }, getInitialState() { - return UserStore.getState(); + return mergeOptions( + UserStore.getState(), + WhitelabelStore.getState() + ); }, componentDidMount() { UserStore.listen(this.onChange); + WhitelabelStore.listen(this.onChange); + + WhitelabelActions.fetchWhitelabel(); UserActions.fetchCurrentUser(); }, componentWillUnmount() { + WhitelabelStore.unlisten(this.onChange); UserStore.unlisten(this.onChange); }, @@ -34,13 +44,28 @@ let CylandPieceList = React.createClass({ this.setState(state); }, + shouldRedirect(pieceCount) { + const { currentUser: { email: userEmail }, + whitelabel: { + user: whitelabelAdminEmail + } } = this.state; + + return userEmail !== whitelabelAdminEmail && !pieceCount; + }, + render() { setDocumentTitle(getLangText('Collection')); return (
!isUserAdmin && !pieceCount} bulkModalButtonListType={MarketAclButtonList} customThumbnailPlaceholder={customThumbnailPlaceholder} filterParams={filterParams} diff --git a/js/components/whitelabel/wallet/components/market/market_register_piece.js b/js/components/whitelabel/wallet/components/market/market_register_piece.js index 53c1a59d..aa71c207 100644 --- a/js/components/whitelabel/wallet/components/market/market_register_piece.js +++ b/js/components/whitelabel/wallet/components/market/market_register_piece.js @@ -112,12 +112,11 @@ let MarketRegisterPiece = React.createClass({ render() { const { location } = this.props; - const { - piece, - step, - whitelabel: { - name: whitelabelName = 'Market' - } } = this.state; + const { piece, + step, + whitelabel: { + name: whitelabelName = 'Market' + } } = this.state; setDocumentTitle(getLangText('Register a new piece')); diff --git a/js/components/whitelabel/wallet/wallet_routes.js b/js/components/whitelabel/wallet/wallet_routes.js index bf2008c3..134290f7 100644 --- a/js/components/whitelabel/wallet/wallet_routes.js +++ b/js/components/whitelabel/wallet/wallet_routes.js @@ -218,7 +218,7 @@ let ROUTES = { + hideFooter /> { // also defines a `.before()` // FIXME: use a more generic class for this, like just '.app', // when we can use this file with the whitelabels - actions.waitForElementToShow('.ascribe-default-app', 5000); + actions.waitForElementToShow('.ascribe-default-app', TIMEOUTS.NORMAL); }); // Suite just to log us in before any other suites run @@ -23,13 +26,13 @@ gemini.suite('Authenticated', (suite) => { .setUrl('/login') .ignoreElements('.ascribe-body') .capture('logged in', (actions, find) => { - actions.waitForElementToShow('.ascribe-form', 5000); + actions.waitForElementToShow('.ascribe-form', TIMEOUTS.NORMAL); - actions.sendKeys(find('.ascribe-login-wrapper input[name=email]'), 'dimi@mailinator.com'); - actions.sendKeys(find('.ascribe-login-wrapper input[name=password]'), '0000000000'); + actions.sendKeys(find('.ascribe-login-wrapper input[name=email]'), MAIN_USER.email); + actions.sendKeys(find('.ascribe-login-wrapper input[name=password]'), MAIN_USER.password); actions.click(find('.ascribe-login-wrapper button[type=submit]')); - actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', 5000); + actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', TIMEOUTS.NORMAL); }); }); @@ -40,7 +43,7 @@ gemini.suite('Authenticated', (suite) => { .ignoreElements('.client--cyland img.img-brand') .skip(/Mobile/) .before((actions, find) => { - actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', 5000); + actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', TIMEOUTS.NORMAL); }) .capture('desktop header'); @@ -69,7 +72,7 @@ gemini.suite('Authenticated', (suite) => { .ignoreElements('.client--cyland img.img-brand') .skip(/Desktop/) .before((actions, find) => { - actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', 5000); + actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', TIMEOUTS.NORMAL); }) .capture('mobile header') .capture('expanded mobile header', (actions, find) => { @@ -89,18 +92,18 @@ gemini.suite('Authenticated', (suite) => { collectionSuite .setCaptureElements('.ascribe-accordion-list') .before((actions, find) => { - actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', 5000); + 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 // so we're forced to wait and hope that the images will all finish loading after 5s. // We could also change the thumbnails with JS, but setting up a test user is probably easier. - actions.wait(5000); + actions.wait(TIMEOUTS.NORMAL); }) .capture('collection') .capture('expanded edition in collection', (actions, find) => { 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', 5000); + actions.waitForElementToShow('.ascribe-accordion-list-item-table', TIMEOUTS.LONG); }) gemini.suite('Collection placeholder', (collectionPlaceholderSuite) => { @@ -108,7 +111,7 @@ gemini.suite('Authenticated', (suite) => { .setCaptureElements('.ascribe-accordion-list-placeholder') .capture('collection empty search', (actions, find) => { actions.sendKeys(find('.ascribe-piece-list-toolbar .search-bar input[type="text"]'), 'no search result'); - actions.waitForElementToShow('.ascribe-accordion-list-placeholder', 5000); + actions.waitForElementToShow('.ascribe-accordion-list-placeholder', TIMEOUTS.NORMAL); }); }); @@ -118,7 +121,7 @@ gemini.suite('Authenticated', (suite) => { .capture('items selected', (actions, find) => { 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', 5000); + actions.waitForElementToShow('.ascribe-accordion-list-item-table', TIMEOUTS.NORMAL); actions.click('.ascribe-table thead tr input[type="checkbox"]'); actions.waitForElementToShow('.piece-list-bulk-modal'); @@ -132,6 +135,7 @@ 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); }) gemini.suite('Order widget dropdown', (pieceListToolbarOrderWidgetSuite) => { @@ -142,7 +146,7 @@ gemini.suite('Authenticated', (suite) => { actions.click(find('#ascribe-piece-list-toolbar-order-widget-dropdown')); // Wait as the dropdown screenshot still includes the collection in the background - actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', 5000); + actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', TIMEOUTS.NORMAL); }); }); @@ -154,7 +158,7 @@ gemini.suite('Authenticated', (suite) => { actions.click(find('#ascribe-piece-list-toolbar-filter-widget-dropdown')); // Wait as the dropdown screenshot still includes the collection in the background - actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', 5000); + actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', TIMEOUTS.NORMAL); }); }); }); @@ -165,7 +169,7 @@ gemini.suite('Authenticated', (suite) => { .capture('register work', (actions, find) => { // The uploader options are only rendered after the user is fetched, so // we have to wait for it here - actions.waitForElementToShow('.file-drag-and-drop-dialog .present-options', 5000); + actions.waitForElementToShow('.file-drag-and-drop-dialog .present-options', TIMEOUTS.NORMAL); }) .capture('register work filled', (actions, find) => { actions.sendKeys(find('.ascribe-form input[name="artist_name"]'), 'artist name'); @@ -197,7 +201,7 @@ gemini.suite('Authenticated', (suite) => { .before((actions, find) => { // This will be called before every nested suite begins unless that suite // also defines a `.before()` - actions.waitForElementToShow('.settings-container', 5000); + actions.waitForElementToShow('.settings-container', TIMEOUTS.NORMAL); }) .capture('user settings'); }); @@ -208,7 +212,7 @@ gemini.suite('Authenticated', (suite) => { .setUrl('/logout') .ignoreElements('.ascribe-body') .capture('logout', (actions, find) => { - actions.waitForElementToShow('.ascribe-login-wrapper', 10000); + actions.waitForElementToShow('.ascribe-login-wrapper', TIMEOUTS.LONG); }); }); }); diff --git a/test/gemini/tests/main/basic.js b/test/gemini/tests/main/basic.js index 317c5d84..5657f77f 100644 --- a/test/gemini/tests/main/basic.js +++ b/test/gemini/tests/main/basic.js @@ -1,6 +1,9 @@ 'use strict'; const gemini = require('gemini'); +const environment = require('../environment'); +const MAIN_USER = environment.MAIN_USER; +const TIMEOUTS = environment.TIMEOUTS; /** * Basic suite of tests against routes that do not require the user to be authenticated. @@ -13,7 +16,7 @@ gemini.suite('Basic', (suite) => { // 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' - actions.waitForElementToShow('.ascribe-default-app', 5000); + actions.waitForElementToShow('.ascribe-default-app', TIMEOUTS.NORMAL); }); gemini.suite('Header-desktop', (headerSuite) => { @@ -21,7 +24,7 @@ gemini.suite('Basic', (suite) => { .setCaptureElements('nav.navbar .container') .skip(/Mobile/) .capture('desktop header', (actions, find) => { - actions.waitForElementToShow('nav.navbar .container', 5000); + actions.waitForElementToShow('nav.navbar .container', TIMEOUTS.NORMAL); }) .capture('hover on active item', (actions, find) => { const activeItem = find('nav.navbar li.active'); @@ -39,7 +42,7 @@ gemini.suite('Basic', (suite) => { .setCaptureElements('nav.navbar .container') .skip(/Desktop/) .capture('mobile header', (actions, find) => { - actions.waitForElementToShow('nav.navbar .container', 5000); + actions.waitForElementToShow('nav.navbar .container', TIMEOUTS.NORMAL); }) .capture('expanded mobile header', (actions, find) => { actions.click(find('nav.navbar .navbar-toggle')); @@ -55,7 +58,7 @@ gemini.suite('Basic', (suite) => { footerSuite .setCaptureElements('.ascribe-footer') .capture('footer', (actions, find) => { - actions.waitForElementToShow('.ascribe-footer', 5000); + actions.waitForElementToShow('.ascribe-footer', TIMEOUTS.NORMAL); }) .capture('hover on footer item', (actions, find) => { const footerItem = find('.ascribe-footer a:not(.social)'); @@ -70,7 +73,7 @@ gemini.suite('Basic', (suite) => { gemini.suite('Login', (loginSuite) => { loginSuite .capture('login', (actions, find) => { - actions.waitForElementToShow('.ascribe-form', 5000); + actions.waitForElementToShow('.ascribe-form', TIMEOUTS.NORMAL); }) .capture('hover on login submit', (actions, find) => { actions.mouseMove(find('.ascribe-form button[type=submit]')); @@ -84,8 +87,8 @@ gemini.suite('Basic', (suite) => { // Remove hover from sign up link actions.click(emailInput); - actions.sendKeys(emailInput, 'dimi@mailinator.com'); - actions.sendKeys(find('.ascribe-form input[name=password]'), '0000000000'); + actions.sendKeys(emailInput, MAIN_USER.email); + actions.sendKeys(find('.ascribe-form input[name=password]'), MAIN_USER.password); }) .capture('login form filled', (actions, find) => { actions.click(find('.ascribe-form-header')); @@ -96,12 +99,12 @@ gemini.suite('Basic', (suite) => { signUpSuite .setUrl('/signup') .capture('sign up', (actions, find) => { - actions.waitForElementToShow('.ascribe-form', 5000); + actions.waitForElementToShow('.ascribe-form', TIMEOUTS.NORMAL); }) .capture('sign up form filled with focus', (actions, find) => { - actions.sendKeys(find('.ascribe-form input[name=email]'), 'dimi@mailinator.com'); - actions.sendKeys(find('.ascribe-form input[name=password]'), '0000000000'); - actions.sendKeys(find('.ascribe-form input[name=password_confirm]'), '0000000000'); + actions.sendKeys(find('.ascribe-form input[name=email]'), MAIN_USER.email); + actions.sendKeys(find('.ascribe-form input[name=password]'), MAIN_USER.password); + actions.sendKeys(find('.ascribe-form input[name=password_confirm]'), MAIN_USER.password); }) .capture('sign up form filled with check', (actions, find) => { actions.click(find('.ascribe-form input[type="checkbox"] ~ .checkbox')); @@ -112,10 +115,10 @@ gemini.suite('Basic', (suite) => { passwordResetSuite .setUrl('/password_reset') .capture('password reset', (actions, find) => { - actions.waitForElementToShow('.ascribe-form', 5000); + actions.waitForElementToShow('.ascribe-form', TIMEOUTS.NORMAL); }) .capture('password reset form filled with focus', (actions, find) => { - actions.sendKeys(find('.ascribe-form input[name="email"]'), 'dimi@mailinator.com'); + actions.sendKeys(find('.ascribe-form input[name="email"]'), MAIN_USER.email); }) .capture('password reset form filled', (actions, find) => { actions.click(find('.ascribe-form-header')); @@ -126,7 +129,7 @@ gemini.suite('Basic', (suite) => { coaVerifySuite .setUrl('/coa_verify') .capture('coa verify', (actions, find) => { - actions.waitForElementToShow('.ascribe-form', 5000); + 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'); diff --git a/test/gemini/tests/main/detail.js b/test/gemini/tests/main/detail.js index 7adad5d4..39e83d70 100644 --- a/test/gemini/tests/main/detail.js +++ b/test/gemini/tests/main/detail.js @@ -1,8 +1,12 @@ 'use strict'; const gemini = require('gemini'); -const pieceUrl = '/pieces/12374'; -const editionUrl = '/editions/14gw9x3VA9oJaxp4cHaAuK2bvJzvEj4Xvc'; +const environment = require('../environment'); +const MAIN_USER = environment.MAIN_USER; +const TIMEOUTS = environment.TIMEOUTS; + +const pieceUrl = `/pieces/${environment.MAIN_PIECE_ID}`; +const editionUrl = `/editions/${environment.MAIN_EDITION_ID}`; /** * Suite of tests against the piece and edition routes. @@ -17,12 +21,12 @@ gemini.suite('Work detail', (suite) => { // also defines a `.before()` // FIXME: use a more generic class for this, like just '.app', // when we can use this file with the whitelabels - actions.waitForElementToShow('.ascribe-default-app', 5000); + actions.waitForElementToShow('.ascribe-default-app', TIMEOUTS.NORMAL); // Wait for the social media buttons to appear - actions.waitForElementToShow('.ascribe-social-button-list .fb-share-button iframe', 20000); - actions.waitForElementToShow('.ascribe-social-button-list .twitter-share-button', 20000); - actions.waitForElementToShow('.ascribe-media-player', 10000); + 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) => { @@ -35,7 +39,7 @@ gemini.suite('Work detail', (suite) => { setCaptureElements('.shmui-wrap') .capture('shmui', (actions, find) => { actions.click(find('.ascribe-media-player')); - actions.waitForElementToShow('.shmui-wrap:not(.loading)', 30000); + actions.waitForElementToShow('.shmui-wrap:not(.loading)', TIMEOUTS.SUPER_DUPER_EXTRA_LONG); // Wait for the transition to end actions.wait(1000); }); @@ -54,14 +58,14 @@ gemini.suite('Work detail', (suite) => { .setUrl('/login') .ignoreElements('.ascribe-body') .before((actions, find) => { - actions.waitForElementToShow('.ascribe-default-app', 5000); + actions.waitForElementToShow('.ascribe-default-app', TIMEOUTS.NORMAL); }) .capture('logged in', (actions, find) => { - actions.sendKeys(find('.ascribe-login-wrapper input[name=email]'), 'dimi@mailinator.com'); - actions.sendKeys(find('.ascribe-login-wrapper input[name=password]'), '0000000000'); + actions.sendKeys(find('.ascribe-login-wrapper input[name=email]'), MAIN_USER.email); + actions.sendKeys(find('.ascribe-login-wrapper input[name=password]'), MAIN_USER.password); actions.click(find('.ascribe-login-wrapper button[type=submit]')); - actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', 5000); + actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', TIMEOUTS.NORMAL); }); }); @@ -121,10 +125,10 @@ gemini.suite('Work detail', (suite) => { .setUrl('/logout') .ignoreElements('.ascribe-body') .before((actions, find) => { - actions.waitForElementToShow('.ascribe-default-app', 5000); + actions.waitForElementToShow('.ascribe-default-app', TIMEOUTS.NORMAL); }) .capture('logout', (actions, find) => { - actions.waitForElementToShow('.ascribe-login-wrapper', 10000); + actions.waitForElementToShow('.ascribe-login-wrapper', TIMEOUTS.LONG); }); }); }); diff --git a/test/gemini/tests/whitelabel/23vivi/23vivi.js b/test/gemini/tests/whitelabel/23vivi/23vivi.js index cafdfc6d..99efb310 100644 --- a/test/gemini/tests/whitelabel/23vivi/23vivi.js +++ b/test/gemini/tests/whitelabel/23vivi/23vivi.js @@ -1,6 +1,8 @@ 'use strict'; const gemini = require('gemini'); +const environment = require('../../environment'); +const TIMEOUTS = environment.TIMEOUTS; /** * Suite of tests against 23vivi specific routes @@ -11,7 +13,7 @@ gemini.suite('23vivi', (suite) => { .setCaptureElements('.ascribe-wallet-app') .before((actions, find) => { // This will be called before every nested suite begins - actions.waitForElementToShow('.ascribe-wallet-app', 5000); + actions.waitForElementToShow('.ascribe-wallet-app', TIMEOUTS.NORMAL); }); gemini.suite('Landing', (landingSuite) => { @@ -19,7 +21,7 @@ gemini.suite('23vivi', (suite) => { .setUrl('/') .capture('landing', (actions, find) => { // Wait for the logo to appear - actions.waitForElementToShow('.vivi23-landing--header-logo', 10000); + actions.waitForElementToShow('.vivi23-landing--header-logo', TIMEOUTS.LONG); }); }); diff --git a/test/gemini/tests/whitelabel/cyland/cyland.js b/test/gemini/tests/whitelabel/cyland/cyland.js index 06709f39..8159f53e 100644 --- a/test/gemini/tests/whitelabel/cyland/cyland.js +++ b/test/gemini/tests/whitelabel/cyland/cyland.js @@ -1,6 +1,8 @@ 'use strict'; const gemini = require('gemini'); +const environment = require('../../environment'); +const TIMEOUTS = environment.TIMEOUTS; /** * Suite of tests against Cyland specific routes @@ -11,7 +13,7 @@ gemini.suite('Cyland', (suite) => { .setCaptureElements('.ascribe-wallet-app') .before((actions, find) => { // This will be called before every nested suite begins - actions.waitForElementToShow('.ascribe-wallet-app', 5000); + actions.waitForElementToShow('.ascribe-wallet-app', TIMEOUTS.NORMAL); }); gemini.suite('Landing', (landingSuite) => { @@ -20,7 +22,7 @@ gemini.suite('Cyland', (suite) => { // Ignore Cyland's logo as it's a gif .ignoreElements('.cyland-landing img') .capture('landing', (actions, find) => { - actions.waitForElementToShow('.cyland-landing img', 10000); + actions.waitForElementToShow('.cyland-landing img', TIMEOUTS.LONG); }); }); diff --git a/test/gemini/tests/whitelabel/ikonotv/ikonotv.js b/test/gemini/tests/whitelabel/ikonotv/ikonotv.js index 1741aaa0..84d743c0 100644 --- a/test/gemini/tests/whitelabel/ikonotv/ikonotv.js +++ b/test/gemini/tests/whitelabel/ikonotv/ikonotv.js @@ -1,6 +1,9 @@ 'use strict'; const gemini = require('gemini'); +const environment = require('../../environment'); +const MAIN_USER = environment.MAIN_USER; +const TIMEOUTS = environment.TIMEOUTS; /** * Suite of tests against Cyland specific routes @@ -11,7 +14,7 @@ gemini.suite('Ikonotv', (suite) => { .setCaptureElements('.ascribe-wallet-app') .before((actions, find) => { // This will be called before every nested suite begins - actions.waitForElementToShow('.ascribe-wallet-app', 5000); + actions.waitForElementToShow('.ascribe-wallet-app', TIMEOUTS.NORMAL); }); gemini.suite('Landing', (landingSuite) => { @@ -29,7 +32,7 @@ gemini.suite('Ikonotv', (suite) => { }); // Wait for logo to appear - actions.waitForElementToShow('.ikonotv-landing header img', 10000); + actions.waitForElementToShow('.ikonotv-landing header img', TIMEOUTS.LONG); }); }); @@ -43,13 +46,13 @@ gemini.suite('Ikonotv', (suite) => { // also defines a `.before()` // FIXME: use a more generic class for this, like just '.app', // when we can use this file with the whitelabels - actions.waitForElementToShow('.ascribe-wallet-app', 5000); + actions.waitForElementToShow('.ascribe-wallet-app', TIMEOUTS.NORMAL); // Wait for the forms to appear - actions.waitForElementToShow('.ascribe-form', 5000); + actions.waitForElementToShow('.ascribe-form', TIMEOUTS.NORMAL); // Just use a dumb wait because the logo is set as a background image - actions.wait(3000); + actions.wait(TIMEOUTS.SHORT); }); gemini.suite('Login', (loginSuite) => { @@ -68,8 +71,8 @@ gemini.suite('Ikonotv', (suite) => { // Remove hover from sign up link actions.click(emailInput); - actions.sendKeys(emailInput, 'dimi@mailinator.com'); - actions.sendKeys(find('.ascribe-form input[name=password]'), '0000000000'); + actions.sendKeys(emailInput, MAIN_USER.email); + actions.sendKeys(find('.ascribe-form input[name=password]'), MAIN_USER.password); }) .capture('login form filled', (actions, find) => { actions.click(find('.ascribe-form-header')); @@ -81,9 +84,9 @@ gemini.suite('Ikonotv', (suite) => { .setUrl('/signup') .capture('sign up') .capture('sign up form filled with focus', (actions, find) => { - actions.sendKeys(find('.ascribe-form input[name=email]'), 'dimi@mailinator.com'); - actions.sendKeys(find('.ascribe-form input[name=password]'), '0000000000'); - actions.sendKeys(find('.ascribe-form input[name=password_confirm]'), '0000000000'); + actions.sendKeys(find('.ascribe-form input[name=email]'), MAIN_USER.email); + actions.sendKeys(find('.ascribe-form input[name=password]'), MAIN_USER.password); + actions.sendKeys(find('.ascribe-form input[name=password_confirm]'), MAIN_USER.password); }) .capture('sign up form filled with check', (actions, find) => { actions.click(find('.ascribe-form input[type="checkbox"] ~ .checkbox')); diff --git a/test/gemini/tests/whitelabel/lumenus/lumenus.js b/test/gemini/tests/whitelabel/lumenus/lumenus.js index a9ff53cd..8e8f568d 100644 --- a/test/gemini/tests/whitelabel/lumenus/lumenus.js +++ b/test/gemini/tests/whitelabel/lumenus/lumenus.js @@ -1,6 +1,8 @@ 'use strict'; const gemini = require('gemini'); +const environment = require('../../environment'); +const TIMEOUTS = environment.TIMEOUTS; /** * Suite of tests against lumenus specific routes @@ -11,7 +13,7 @@ gemini.suite('Lumenus', (suite) => { .setCaptureElements('.ascribe-wallet-app') .before((actions, find) => { // This will be called before every nested suite begins - actions.waitForElementToShow('.ascribe-wallet-app', 5000); + actions.waitForElementToShow('.ascribe-wallet-app', TIMEOUTS.NORMAL); }); gemini.suite('Landing', (landingSuite) => { @@ -19,7 +21,7 @@ gemini.suite('Lumenus', (suite) => { .setUrl('/') .capture('landing', (actions, find) => { // Wait for the logo to appear - actions.waitForElementToShow('.wp-landing-wrapper img', 10000); + actions.waitForElementToShow('.wp-landing-wrapper img', TIMEOUTS.LONG); }); }); diff --git a/test/gemini/tests/whitelabel/shared/whitelabel_basic.js b/test/gemini/tests/whitelabel/shared/whitelabel_basic.js index 7fe5c256..0d5ac26b 100644 --- a/test/gemini/tests/whitelabel/shared/whitelabel_basic.js +++ b/test/gemini/tests/whitelabel/shared/whitelabel_basic.js @@ -1,6 +1,9 @@ 'use strict'; const gemini = require('gemini'); +const environment = require('../../environment'); +const MAIN_USER = environment.MAIN_USER; +const TIMEOUTS = environment.TIMEOUTS; /** * Basic suite of tests against whitelabel routes that do not require authentication. @@ -12,7 +15,7 @@ gemini.suite('Whitelabel basic', (suite) => { // 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' - actions.waitForElementToShow('.ascribe-wallet-app', 5000); + actions.waitForElementToShow('.ascribe-wallet-app', TIMEOUTS.NORMAL); // Use a dumb wait in case we're still waiting for other assets, like fonts, to load actions.wait(1000); @@ -24,12 +27,12 @@ gemini.suite('Whitelabel basic', (suite) => { // See Ikono .skip(/Ikono/) .capture('login', (actions, find) => { - actions.waitForElementToShow('.ascribe-form', 5000); + 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 // and the cache isn't hot yet?). // Let's wait a bit and hope they load. - actions.wait(3000); + actions.wait(TIMEOUTS.SHORT); }) .capture('hover on login submit', (actions, find) => { actions.mouseMove(find('.ascribe-form button[type=submit]')); @@ -43,8 +46,8 @@ gemini.suite('Whitelabel basic', (suite) => { // Remove hover from sign up link actions.click(emailInput); - actions.sendKeys(emailInput, 'dimi@mailinator.com'); - actions.sendKeys(find('.ascribe-form input[name=password]'), '0000000000'); + actions.sendKeys(emailInput, MAIN_USER.email); + actions.sendKeys(find('.ascribe-form input[name=password]'), MAIN_USER.password); }) .capture('login form filled', (actions, find) => { actions.click(find('.ascribe-form-header')); @@ -57,14 +60,14 @@ gemini.suite('Whitelabel basic', (suite) => { // See Ikono .skip(/Ikono/) .capture('sign up', (actions, find) => { - actions.waitForElementToShow('.ascribe-form', 5000); + actions.waitForElementToShow('.ascribe-form', TIMEOUTS.NORMAL); // Wait in case the form reloads due to other assets loading actions.wait(500); }) .capture('sign up form filled with focus', (actions, find) => { - actions.sendKeys(find('.ascribe-form input[name=email]'), 'dimi@mailinator.com'); - actions.sendKeys(find('.ascribe-form input[name=password]'), '0000000000'); - actions.sendKeys(find('.ascribe-form input[name=password_confirm]'), '0000000000'); + actions.sendKeys(find('.ascribe-form input[name=email]'), MAIN_USER.email); + actions.sendKeys(find('.ascribe-form input[name=password]'), MAIN_USER.password); + actions.sendKeys(find('.ascribe-form input[name=password_confirm]'), MAIN_USER.password); }) .capture('sign up form filled with check', (actions, find) => { actions.click(find('.ascribe-form input[type="checkbox"] ~ .checkbox')); @@ -75,12 +78,12 @@ gemini.suite('Whitelabel basic', (suite) => { passwordResetSuite .setUrl('/password_reset') .capture('password reset', (actions, find) => { - actions.waitForElementToShow('.ascribe-form', 5000); + actions.waitForElementToShow('.ascribe-form', TIMEOUTS.NORMAL); // Wait in case the form reloads due to other assets loading actions.wait(500); }) .capture('password reset form filled with focus', (actions, find) => { - actions.sendKeys(find('.ascribe-form input[name="email"]'), 'dimi@mailinator.com'); + actions.sendKeys(find('.ascribe-form input[name="email"]'), MAIN_USER.email); }) .capture('password reset form filled', (actions, find) => { actions.click(find('.ascribe-form-header')); @@ -91,7 +94,7 @@ gemini.suite('Whitelabel basic', (suite) => { coaVerifySuite .setUrl('/coa_verify') .capture('coa verify', (actions, find) => { - actions.waitForElementToShow('.ascribe-form', 5000); + actions.waitForElementToShow('.ascribe-form', TIMEOUTS.NORMAL); // Wait in case the form reloads due to other assets loading actions.wait(500); })