1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00

Update gemini and docs for visual regression testing

This commit is contained in:
Brett Sun 2016-06-03 11:38:42 +02:00
parent c13a24a107
commit 319261f15e
11 changed files with 256 additions and 229 deletions

View File

@ -45,10 +45,9 @@
"chai-as-promised": "^5.1.0", "chai-as-promised": "^5.1.0",
"colors": "^1.1.2", "colors": "^1.1.2",
"dotenv": "^1.2.0", "dotenv": "^1.2.0",
"gemini": "^2.1.0", "gemini": "^4.3.0",
"jest-cli": "^0.4.0", "jest-cli": "^0.4.0",
"mocha": "^2.3.4", "mocha": "^2.3.4",
"phantomjs2": "^2.0.2",
"rimraf": "^2.5.2", "rimraf": "^2.5.2",
"sauce-connect-launcher": "^0.13.0", "sauce-connect-launcher": "^0.13.0",
"wd": "^0.4.0" "wd": "^0.4.0"

View File

@ -1,4 +1,7 @@
{ {
"globals": {
"gemini": true
},
"rules": { "rules": {
"max-len": [2, { "code": 125 }] "max-len": [2, { "code": 125 }]
} }

View File

@ -23,30 +23,41 @@ Then, install [PhantomJS2](https://www.npmjs.com/package/phantomjs2):
```bash ```bash
# Until phantomjs2 is updated for the new 2.1 version of PhantomJS, use the following (go to https://bitbucket.org/ariya/phantomjs/downloads to find a build for your OS) # Until phantomjs2 is updated for the new 2.1 version of PhantomJS, use the following (go to https://bitbucket.org/ariya/phantomjs/downloads to find a build for your OS)
npm install -g phantomjs2 --phantomjs_downloadurl=https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-macosx.zip npm install phantomjs2 --phantomjs_downloadurl=https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-macosx.zip
npm install --save-dev phantomjs2 --phantomjs_downloadurl=https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-macosx.zip
# If using OSX, you may have to install upx and decompress the binary downloaded by npm manually: # If using OSX, you may have to install upx and decompress the binary downloaded by npm manually:
brew install upx brew install upx
# Navigate to the binary, ie. /Users/Brett/.nvm/versions/node/v5.4.0/lib/node_modules/phantomjs2/lib/phantom/bin/phantomjs # Navigate to the binary, ie. node_modules/phantomjs2/lib/phantom/bin/ (for the local installation)
upx -d phantomjs upx -d phantomjs
# If using Linux or OSX, you may also have to convert the binary using `dos2unix`:
brew install dos2unix
dos2unix phantomjs
``` ```
Finally, [install Gemini globally and locally with npm](https://github.com/gemini-testing/gemini/blob/master/README.md#installation). Finally, [install Gemini locally with npm](https://github.com/gemini-testing/gemini/blob/master/README.md#installation), if it
hasn't already been installed through `package.json`.
Running Tests Running Tests
============= =============
Run Spool and Onion (on localhost.com:3000).
Run PhantomJS: Run PhantomJS:
```bash ```bash
npm run vi-phantom npm run vi-phantom
``` ```
And then run Gemini tests: Gather your initial baseline (on the master branch, for example):
```bash
npm run vi-update
```
And then run Gemini tests (on your current branch with changes, to test for regressions):
```bash ```bash
npm run vi-test npm run vi-test
@ -61,8 +72,8 @@ npm run vi-test:whitelabel
npm run vi-test:cyland npm run vi-test:cyland
``` ```
If you've made changes and want them to be the new baseline (ie. it's a correct change--**make sure** to test there are Later on, if you've made changes and want them to be the new baseline (ie. it's a correct change--**make sure** to test
no regressions first!), use there are no regressions first!), use:
```bash ```bash
npm run vi-update npm run vi-update

View File

@ -1,6 +1,5 @@
'use strict'; 'use strict';
const gemini = require('gemini');
const environment = require('../environment'); const environment = require('../environment');
const MAIN_USER = environment.MAIN_USER; const MAIN_USER = environment.MAIN_USER;
const TIMEOUTS = environment.TIMEOUTS; const TIMEOUTS = environment.TIMEOUTS;
@ -30,10 +29,11 @@ gemini.suite('Authenticated', (suite) => {
actions.sendKeys(find('.ascribe-login-wrapper input[name=password]'), MAIN_USER.password); actions.sendKeys(find('.ascribe-login-wrapper input[name=password]'), MAIN_USER.password);
actions.click(find('.ascribe-login-wrapper button[type=submit]')); actions.click(find('.ascribe-login-wrapper button[type=submit]'));
actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', TIMEOUTS.NORMAL); actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', TIMEOUTS.LONG);
}); });
}); });
gemini.suite('Authenticated', (authenticatedSuite) => {
gemini.suite('Header-desktop', (headerSuite) => { gemini.suite('Header-desktop', (headerSuite) => {
headerSuite headerSuite
.setCaptureElements('nav.navbar .container') .setCaptureElements('nav.navbar .container')
@ -41,7 +41,8 @@ gemini.suite('Authenticated', (suite) => {
.ignoreElements('.client--cyland img.img-brand') .ignoreElements('.client--cyland img.img-brand')
.skip(/Mobile/) .skip(/Mobile/)
.before((actions) => { .before((actions) => {
actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', TIMEOUTS.NORMAL); actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', TIMEOUTS.LONG);
actions.waitForElementToShow('#header-notification-dropdown', TIMEOUTS.SUPER_DUPER_EXTRA_LONG);
}) })
.capture('desktop header'); .capture('desktop header');
@ -70,13 +71,14 @@ gemini.suite('Authenticated', (suite) => {
.ignoreElements('.client--cyland img.img-brand') .ignoreElements('.client--cyland img.img-brand')
.skip(/Desktop/) .skip(/Desktop/)
.before((actions) => { .before((actions) => {
actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', TIMEOUTS.NORMAL); actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', TIMEOUTS.LONG);
}) })
.capture('mobile header') .capture('mobile header')
.capture('expanded mobile header', (actions, find) => { .capture('expanded mobile header', (actions, find) => {
actions.click(find('nav.navbar .navbar-toggle')); actions.click(find('nav.navbar .navbar-toggle'));
// Wait for the header to expand // Wait for the header to expand
actions.wait(500); actions.wait(500);
actions.waitForElementToShow('#header-notification-dropdown', TIMEOUTS.SUPER_DUPER_EXTRA_LONG);
}) })
.capture('expanded user dropdown', (actions, find) => { .capture('expanded user dropdown', (actions, find) => {
actions.click(find('#nav-route-user-dropdown')); actions.click(find('#nav-route-user-dropdown'));
@ -212,6 +214,7 @@ gemini.suite('Authenticated', (suite) => {
}) })
.capture('user settings'); .capture('user settings');
}); });
});
// Suite just to log out after suites have run // Suite just to log out after suites have run
gemini.suite('Log out', (logoutSuite) => { gemini.suite('Log out', (logoutSuite) => {

View File

@ -1,6 +1,5 @@
'use strict'; 'use strict';
const gemini = require('gemini');
const environment = require('../environment'); const environment = require('../environment');
const MAIN_USER = environment.MAIN_USER; const MAIN_USER = environment.MAIN_USER;
const TIMEOUTS = environment.TIMEOUTS; const TIMEOUTS = environment.TIMEOUTS;

View File

@ -1,6 +1,5 @@
'use strict'; 'use strict';
const gemini = require('gemini');
const environment = require('../environment'); const environment = require('../environment');
const MAIN_USER = environment.MAIN_USER; const MAIN_USER = environment.MAIN_USER;
const TIMEOUTS = environment.TIMEOUTS; const TIMEOUTS = environment.TIMEOUTS;
@ -13,12 +12,10 @@ const editionUrl = `/editions/${environment.MAIN_EDITION_ID}`;
* Tests include accessing the piece / edition as the owner or as another user * Tests include accessing the piece / edition as the owner or as another user
* (we can just use an anonymous user in this case). * (we can just use an anonymous user in this case).
*/ */
gemini.suite('Work detail', (suite) => { gemini.suite('Basic work detail', (suite) => {
suite suite
.setCaptureElements('.ascribe-body') .setCaptureElements('.ascribe-body')
.before((actions) => { .before((actions) => {
// This will be called before every nested suite begins unless that suite
// also defines a `.before()`
actions.waitForElementToShow('.ascribe-app', TIMEOUTS.NORMAL); actions.waitForElementToShow('.ascribe-app', TIMEOUTS.NORMAL);
// Wait for the social media buttons to appear // Wait for the social media buttons to appear
@ -51,25 +48,42 @@ gemini.suite('Work detail', (suite) => {
.setUrl(editionUrl) .setUrl(editionUrl)
.capture('basic edition'); .capture('basic edition');
}); });
});
gemini.suite('Authenticated work detail', (suite) => {
suite
.setCaptureElements('.ascribe-body')
.before((actions) => {
actions.waitForElementToShow('.ascribe-app', TIMEOUTS.NORMAL);
});
// Suite just to log us in before any other suites run
gemini.suite('Login', (loginSuite) => { gemini.suite('Login', (loginSuite) => {
loginSuite loginSuite
.setUrl('/login') .setUrl('/login')
.ignoreElements('.ascribe-body') .ignoreElements('.ascribe-body')
.before((actions) => {
actions.waitForElementToShow('.ascribe-app', TIMEOUTS.NORMAL);
})
.capture('logged in', (actions, find) => { .capture('logged in', (actions, find) => {
console.log('logging in');
actions.sendKeys(find('.ascribe-login-wrapper input[name=email]'), MAIN_USER.email); 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.sendKeys(find('.ascribe-login-wrapper input[name=password]'), MAIN_USER.password);
actions.click(find('.ascribe-login-wrapper button[type=submit]')); actions.click(find('.ascribe-login-wrapper button[type=submit]'));
actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', TIMEOUTS.NORMAL); actions.waitForElementToShow('.ascribe-accordion-list:not(.ascribe-loading-position)', TIMEOUTS.LONG);
}); });
}); });
gemini.suite('Authenticated', (authenticatedSuite) => {
authenticatedSuite
.before((actions) => {
// 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-media-player', TIMEOUTS.LONG);
});
gemini.suite('Authorized piece', (authorizedPieceSuite) => { gemini.suite('Authorized piece', (authorizedPieceSuite) => {
console.log('authorized piece');
authorizedPieceSuite authorizedPieceSuite
.setUrl(pieceUrl) .setUrl(pieceUrl)
.capture('authorized piece'); .capture('authorized piece');
@ -85,6 +99,7 @@ gemini.suite('Work detail', (suite) => {
detailActionButtonSuite detailActionButtonSuite
.setUrl(editionUrl) .setUrl(editionUrl)
.capture('hover on action button', (actions, find) => { .capture('hover on action button', (actions, find) => {
console.log('hover on action button');
actions.mouseMove(find('.ascribe-detail-property .ascribe-button-list button.btn-default')); actions.mouseMove(find('.ascribe-detail-property .ascribe-button-list button.btn-default'));
}) })
.capture('hover on delete button', (actions, find) => { .capture('hover on delete button', (actions, find) => {
@ -124,6 +139,7 @@ gemini.suite('Work detail', (suite) => {
actions.wait(1000); actions.wait(1000);
}); });
}); });
});
// Suite just to log out after suites have run // Suite just to log out after suites have run
gemini.suite('Log out', (logoutSuite) => { gemini.suite('Log out', (logoutSuite) => {
@ -131,6 +147,7 @@ gemini.suite('Work detail', (suite) => {
.setUrl('/logout') .setUrl('/logout')
.ignoreElements('.ascribe-body') .ignoreElements('.ascribe-body')
.before((actions) => { .before((actions) => {
console.log('before log out');
actions.waitForElementToShow('.ascribe-app', TIMEOUTS.NORMAL); actions.waitForElementToShow('.ascribe-app', TIMEOUTS.NORMAL);
}) })
.capture('logout', (actions) => { .capture('logout', (actions) => {

View File

@ -1,6 +1,5 @@
'use strict'; 'use strict';
const gemini = require('gemini');
const environment = require('../../environment'); const environment = require('../../environment');
const TIMEOUTS = environment.TIMEOUTS; const TIMEOUTS = environment.TIMEOUTS;

View File

@ -1,6 +1,5 @@
'use strict'; 'use strict';
const gemini = require('gemini');
const environment = require('../../environment'); const environment = require('../../environment');
const TIMEOUTS = environment.TIMEOUTS; const TIMEOUTS = environment.TIMEOUTS;

View File

@ -1,6 +1,5 @@
'use strict'; 'use strict';
const gemini = require('gemini');
const environment = require('../../environment'); const environment = require('../../environment');
const MAIN_USER = environment.MAIN_USER; const MAIN_USER = environment.MAIN_USER;
const TIMEOUTS = environment.TIMEOUTS; const TIMEOUTS = environment.TIMEOUTS;

View File

@ -1,6 +1,5 @@
'use strict'; 'use strict';
const gemini = require('gemini');
const environment = require('../../environment'); const environment = require('../../environment');
const TIMEOUTS = environment.TIMEOUTS; const TIMEOUTS = environment.TIMEOUTS;

View File

@ -1,6 +1,5 @@
'use strict'; 'use strict';
const gemini = require('gemini');
const environment = require('../../environment'); const environment = require('../../environment');
const MAIN_USER = environment.MAIN_USER; const MAIN_USER = environment.MAIN_USER;
const TIMEOUTS = environment.TIMEOUTS; const TIMEOUTS = environment.TIMEOUTS;