Browse Source

started work towards automatic regression testing

gemini
Alexander Wunschik 7 years ago
parent
commit
f437c3b654
15 changed files with 677 additions and 65 deletions
  1. +20
    -0
      .gemini.js
  2. BIN
      gemini/reports/images/yandex-icons/plain/PhantomJS~current.png
  3. BIN
      gemini/reports/images/yandex-icons/plain/PhantomJS~ref.png
  4. BIN
      gemini/reports/images/yandex-search/plain/PhantomJS~ref.png
  5. BIN
      gemini/reports/images/yandex-search/with text/PhantomJS~ref.png
  6. +221
    -0
      gemini/reports/index.html
  7. +286
    -0
      gemini/reports/report.css
  8. +2
    -0
      gemini/reports/report.min.js
  9. BIN
      gemini/screens/yandex-icons/plain/PhantomJS.png
  10. BIN
      gemini/screens/yandex-search/plain/PhantomJS.png
  11. BIN
      gemini/screens/yandex-search/with text/PhantomJS.png
  12. +131
    -64
      gulpfile.js
  13. +4
    -1
      package.json
  14. +8
    -0
      test/gemini/demo1.js
  15. +5
    -0
      test/gemini/demo2.js

+ 20
- 0
.gemini.js View File

@ -0,0 +1,20 @@
module.exports = {
rootUrl: "http://yandex.com",
browsers: {
PhantomJS: {
desiredCapabilities: {
browserName: "phantomjs"
}
}
},
system: {
plugins: {
'html-reporter': {
enabled: true,
path: 'gemini/reports'
}
}
}
};

BIN
gemini/reports/images/yandex-icons/plain/PhantomJS~current.png View File

Before After
Width: 1366  |  Height: 768  |  Size: 19 KiB

BIN
gemini/reports/images/yandex-icons/plain/PhantomJS~ref.png View File

Before After
Width: 760  |  Height: 82  |  Size: 11 KiB

BIN
gemini/reports/images/yandex-search/plain/PhantomJS~ref.png View File

Before After
Width: 900  |  Height: 106  |  Size: 5.8 KiB

BIN
gemini/reports/images/yandex-search/with text/PhantomJS~ref.png View File

Before After
Width: 900  |  Height: 106  |  Size: 7.3 KiB

+ 221
- 0
gemini/reports/index.html View File

@ -0,0 +1,221 @@
<!DOCTYPE html>
<html>
<head>
<title>Gemini report</title>
<link rel="stylesheet" type="text/css" href="report.css">
</head>
<body class="report">
<dl class="summary">
<dt class="summary__key">Total Tests</dt><dd class="summary__value">3</dd>
<dt class="summary__key">Passed</dt><dd class="summary__value">2</dd>
<dt class="summary__key summary__key_has-fails">Failed</dt><dd class="summary__value">1</dd>
<dt class="summary__key">Skipped</dt><dd class="summary__value">0</dd>
<dt class="summary__key">Retries</dt><dd class="summary__value">0</dd>
</dl>
<button id="expandAll" class="button">Expand all</button>
<button id="collapseAll" class="button">Collapse all</button>
<button id="expandErrors" class="button">Expand errors</button>
<button id="showSkipped" class="button">Show skipped</button>
<button id="showRetries" class="button">Expand retries</button>
<button id="showOnlyDiff" class="button">Show only diff</button>
<input id="viewHostInput" class="text-input" size="40" placeholder="change original host for view in browser"/>
<div id="skippedList" class="skipped__list collapsed">
There are no skipped tests
</div>
<div class="section section_status_success ">
<div class="section__title">
yandex-search
<button
class="button section__icon section__icon_copy-to-clipboard"
title="copy to clipboard"
data-clipboard-text="yandex-search">
</button>
</div>
<div class="section__body section__body_guided">
<div class="section section_status_success ">
<div class="section__title">
plain
<button
class="button section__icon section__icon_copy-to-clipboard"
title="copy to clipboard"
data-clipboard-text="yandex-search,plain">
</button>
</div>
<div class="section__body section__body_guided">
<div class="section section_collapsed section_status_success ">
<div class="section__title">
PhantomJS
<a
class="button section__icon section__icon_view-local"
data-suite-view-link="http://yandex.com/" href="http://yandex.com/"
title="view in browser"
target="_blank">
</a>
</div>
<div class="section__body">
<div class="image-box ">
<div class="cswitcher">
<button data-id="1" class="state-button cswitcher__item cswitcher_color_1 cswitcher__item_selected">&nbsp;</button>
<button data-id="2" class="state-button cswitcher__item cswitcher_color_2">&nbsp;</button>
<button data-id="3" class="state-button cswitcher__item cswitcher_color_3">&nbsp;</button>
</div>
<div class="tab">
<div class="tab__item tab__item_active" data-position="0">
<div class="meta-info meta-info_collapsed">
<div class="meta-info__switcher">Meta-info</div>
<div class="meta-info__content">
<pre>{
&quot;url&quot;: &quot;/&quot;,
&quot;file&quot;: &quot;test/gemini/demo1.js&quot;,
&quot;sessionId&quot;: &quot;20cafe60-5a4f-11e7-8dde-e99d1aa2245a&quot;
}</pre>
</div>
</div>
<div class="image-box__image">
<img data-src="images/yandex-search/plain/PhantomJS~ref.png">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="section section_status_success ">
<div class="section__title">
with text
<button
class="button section__icon section__icon_copy-to-clipboard"
title="copy to clipboard"
data-clipboard-text="yandex-search,with text">
</button>
</div>
<div class="section__body section__body_guided">
<div class="section section_collapsed section_status_success ">
<div class="section__title">
PhantomJS
<a
class="button section__icon section__icon_view-local"
data-suite-view-link="http://yandex.com/" href="http://yandex.com/"
title="view in browser"
target="_blank">
</a>
</div>
<div class="section__body">
<div class="image-box ">
<div class="cswitcher">
<button data-id="1" class="state-button cswitcher__item cswitcher_color_1 cswitcher__item_selected">&nbsp;</button>
<button data-id="2" class="state-button cswitcher__item cswitcher_color_2">&nbsp;</button>
<button data-id="3" class="state-button cswitcher__item cswitcher_color_3">&nbsp;</button>
</div>
<div class="tab">
<div class="tab__item tab__item_active" data-position="0">
<div class="meta-info meta-info_collapsed">
<div class="meta-info__switcher">Meta-info</div>
<div class="meta-info__content">
<pre>{
&quot;url&quot;: &quot;/&quot;,
&quot;file&quot;: &quot;test/gemini/demo1.js&quot;,
&quot;sessionId&quot;: &quot;20cafe60-5a4f-11e7-8dde-e99d1aa2245a&quot;
}</pre>
</div>
</div>
<div class="image-box__image">
<img data-src="images/yandex-search/with%20text/PhantomJS~ref.png">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="section section_status_fail ">
<div class="section__title">
yandex-icons
<button
class="button section__icon section__icon_copy-to-clipboard"
title="copy to clipboard"
data-clipboard-text="yandex-icons">
</button>
</div>
<div class="section__body section__body_guided">
<div class="section section_status_fail ">
<div class="section__title">
plain
<button
class="button section__icon section__icon_copy-to-clipboard"
title="copy to clipboard"
data-clipboard-text="yandex-icons,plain">
</button>
</div>
<div class="section__body section__body_guided">
<div class="section section_collapsed section_status_fail ">
<div class="section__title">
PhantomJS
<a
class="button section__icon section__icon_view-local"
data-suite-view-link="http://yandex.com/foo" href="http://yandex.com/foo"
title="view in browser"
target="_blank">
</a>
</div>
<div class="section__body">
<div class="image-box image-box_error">
<div class="cswitcher">
<button data-id="1" class="state-button cswitcher__item cswitcher_color_1 cswitcher__item_selected">&nbsp;</button>
<button data-id="2" class="state-button cswitcher__item cswitcher_color_2">&nbsp;</button>
<button data-id="3" class="state-button cswitcher__item cswitcher_color_3">&nbsp;</button>
</div>
<div class="tab">
<div class="tab__item tab__item_active" data-position="0">
<div class="meta-info meta-info_collapsed">
<div class="meta-info__switcher">Meta-info</div>
<div class="meta-info__content">
<pre>{
&quot;url&quot;: &quot;/foo&quot;,
&quot;file&quot;: &quot;test/gemini/demo2.js&quot;,
&quot;sessionId&quot;: &quot;20cafe60-5a4f-11e7-8dde-e99d1aa2245a&quot;
}</pre>
</div>
</div>
<div class="image-box__image">
<pre class="reason">Error
at /home/delphin/workspaces/workspace_vis/vis/node_modules/gemini/lib/browser/client-bridge.js:42:39
at tryCatcher (/home/delphin/workspaces/workspace_vis/vis/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/delphin/workspaces/workspace_vis/vis/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/home/delphin/workspaces/workspace_vis/vis/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/home/delphin/workspaces/workspace_vis/vis/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/home/delphin/workspaces/workspace_vis/vis/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/home/delphin/workspaces/workspace_vis/vis/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/home/delphin/workspaces/workspace_vis/vis/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/home/delphin/workspaces/workspace_vis/vis/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:651:20)
at tryOnImmediate (timers.js:624:5)
at processImmediate [as _immediateCallback] (timers.js:596:5)</pre>
<img data-src="images/yandex-icons/plain/PhantomJS~current.png">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="report.min.js"></script>
</body>
</html>

+ 286
- 0
gemini/reports/report.css View File

@ -0,0 +1,286 @@
.report {
font: 14px Helvetica Neue, Arial, sans-serif;
}
.summary__key {
font-weight: bold;
display: inline;
}
.summary__key::after {
content: ':';
}
.summary__key_has-fails {
color: #c00;
}
.summary__value {
margin-left: 5px;
margin-right: 20px;
display: inline;
}
.button {
background: #fff;
border: 1px solid #ccc;
border-radius: 2px;
outline: 0;
}
.button:hover {
border-color: #555;
}
.button.pressed,
.button:active {
background: #eee;
}
.button_checked {
background: #ffeba0;
border-color: #cebe7d;
}
.image-box {
padding: 5px;
border: 1px solid #ccc;
background: #c9c9c9;
}
.image-box__exp-with-act {
display: inline-block;
}
.report_show-only-diff .image-box__exp-with-act {
display: none;
}
.image-box__image {
padding: 0 5px;
display: inline-block;
vertical-align: top;
}
.section__title {
font-weight: bold;
cursor: pointer;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
.section__title_skipped {
color: #ccc;
cursor: default;
-moz-user-select: text;
-webkit-user-select: text;
-ms-user-select: text;
user-select: text;
}
.section__title:before, .meta-info__switcher:before {
display: inline-block;
margin-right: 2px;
vertical-align: middle;
content: '\25bc';
color: black;
}
.section_status_success > .section__title {
color: #038035;
}
.section_status_fail > .section__title {
color: #c00;
}
.section_status_skip > .section__title,
.section_status_skip > .section__title:hover {
color: #ccc;
cursor: default;
}
.section_status_skip > .section__title::before {
content: none;
}
.section__title:hover {
color: #2d3e50;
}
.section__body {
padding-left: 15px;
}
.section__body_guided {
border-left: 1px dotted #ccc;
}
.section_collapsed .section__body {
display: none;
}
.section__icon {
display: inline-block;
width: 19px;
height: 19px;
vertical-align: top;
padding: 0 3px;
border: none;
opacity: 0.5;
cursor: pointer;
}
.section__icon:hover {
opacity: 1;
}
.section__icon:before {
display: block;
width: 100%;
height: 100%;
content: '';
background-repeat: no-repeat;
background-size: 100%;
background-position: center;
}
.section__icon_view-local:before {
background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3ZnIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgLTAuNzA5IC0zMi4wODEgMTQxLjczMiAxNDEuNzMyIiBoZWlnaHQ9IjE0MS43MzJweCIgaWQ9IkxpdmVsbG9fMSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSItMC43MDkgLTMyLjA4MSAxNDEuNzMyIDE0MS43MzIiIHdpZHRoPSIxNDEuNzMycHgiIHhtbDpzcGFjZT0icHJlc2VydmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxnIGlkPSJMaXZlbGxvXzgwIj48cGF0aCBkPSJNODkuNjY4LDM4Ljc4NmMwLTEwLjc3My04LjczMS0xOS41MTItMTkuNTEtMTkuNTEyUzUwLjY0NiwyOC4wMSw1MC42NDYsMzguNzg2YzAsMTAuNzc0LDguNzMyLDE5LjUxMSwxOS41MTIsMTkuNTExICAgQzgwLjkzNCw1OC4yOTcsODkuNjY4LDQ5LjU2MSw4OS42NjgsMzguNzg2IE0xMjguMzUyLDM4LjcyN2MtMTMuMzE1LDE3LjU5OS0zNC40MjYsMjguOTcyLTU4LjE5MywyOC45NzIgICBjLTIzLjc3LDAtNDQuODc5LTExLjM3My01OC4xOTQtMjguOTcyQzI1LjI3OSwyMS4xMjksNDYuMzg5LDkuNzU2LDcwLjE1OCw5Ljc1NkM5My45MjcsOS43NTYsMTE1LjAzNiwyMS4xMjksMTI4LjM1MiwzOC43MjcgICAgTTE0MC4zMTQsMzguNzZDMTI1LjY2NiwxNS40NzgsOTkuNzI1LDAsNzAuMTU4LDBTMTQuNjQ4LDE1LjQ3OCwwLDM4Ljc2YzE0LjY0OCwyMy4zMTIsNDAuNTkxLDM4LjgxLDcwLjE1OCwzOC44MSAgIFMxMjUuNjY2LDYyLjA3MiwxNDAuMzE0LDM4Ljc2Ii8+PC9nPjxnIGlkPSJMaXZlbGxvXzFfMV8iLz48L3N2Zz4=);
}
.section__icon_copy-to-clipboard:before {
background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3ZnIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDUxMiA1MTIiIGhlaWdodD0iNTEycHgiIGlkPSJMYXllcl8xIiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCA1MTIgNTEyIiB3aWR0aD0iNTEycHgiIHhtbDpzcGFjZT0icHJlc2VydmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxwYXRoIGQ9Ik00NjguNDkzLDEwMS42MzdMMzcxLjk1NSw1LjA5OEgxNTkuNTd2NzcuMjMxSDQzLjcyNHY0MjQuNzY5aDMwOC45MjN2LTc3LjIzMWgxMTUuODQ2VjEwMS42Mzd6ICAgTTM3MS45NTUsMzIuNDAxbDY5LjIzNiw2OS4yMzVoLTY5LjIzNlYzMi40MDF6IE02My4wMzEsNDg3Ljc5VjEwMS42MzdoMTczLjc2OXY5Ni41MzhoOTYuNTM4VjQ4Ny43OUg2My4wMzF6IE0yNTYuMTA4LDEwOS42MzIgIGw2OS4yMzYsNjkuMjM1aC02OS4yMzZWMTA5LjYzMnogTTM1Mi42NDcsNDEwLjU2VjE3OC44NjdsLTk2LjUzOC05Ni41MzhoLTc3LjIzMVYyNC40MDZoMTczLjc2OXY5Ni41MzhoOTYuNTM4VjQxMC41NkgzNTIuNjQ3eiIgZmlsbD0iIzM3NDA0RCIvPjwvc3ZnPg==);
}
.section_collapsed .section__title:before,
.meta-info_collapsed .meta-info__switcher:before {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
transform: rotate(-90deg);
}
.reason {
background: #f6f5f3;
border: 1px solid #ccc;
padding: 5px;
font: 12px Consolas, Monaco, monospace;
}
.state-button {
position: relative;
height: 22px;
display: inline-block;
box-shadow: 0 0 1px #000;
border: 1px solid #fff;
outline: none;
background: #fff;
cursor: pointer;
}
.cswitcher__item, .tab-switcher__button {
width: 22px;
}
.cswitcher__item_selected.cswitcher__item::before {
content: '';
position: absolute;
top: 0;
left: 0;
background: rgba(4, 4, 4, 0.3) no-repeat 3px 2px url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 97.619 97.618" fill="#eee" fill-opacity="0.8"><path d="m96.94 17.358l-12.971-11.399c-.398-.352-.927-.531-1.449-.494-.529.035-1.023.278-1.373.677l-47.05 53.55-16.728-22.14c-.319-.422-.794-.701-1.319-.773-.524-.078-1.059.064-1.481.385l-13.778 10.408c-.881.666-1.056 1.92-.39 2.801l30.974 40.996c.362.479.922.771 1.522.793.024 0 .049 0 .073 0 .574 0 1.122-.246 1.503-.68l62.64-71.3c.73-.829.649-2.094-.181-2.822"/></svg>');
height: 20px;
width: 20px;
}
.cswitcher_color_1 {
background: #c9c9c9;
}
.cswitcher_color_2 {
background: #d5ff09;
}
.cswitcher_color_3 {
background-image: url('data:image/svg+xml;utf8,<svg width="20" height="20" viewBox="0 0 70 70" xmlns="http://www.w3.org/2000/svg"><path fill="#cecece" d="m0 0h35c0 11.67 0 23.33 0 35-11.67 0-23.33 0-35 0v-35"/><g fill="#fff"><path d="m35 0h35v35c-11.67 0-23.33 0-35 0 0-11.67 0-23.33 0-35"/><path d="m0 35c11.67 0 23.33 0 35 0 0 11.67 0 23.33 0 35h-35v-35"/></g><path fill="#cecece" d="m35 35c11.67 0 23.33 0 35 0v35h-35c0-11.67 0-23.33 0-35"/></svg>');
}
.collapsed {
display: none;
}
.skipped__list {
margin: 10px 0;
font-weight: bold;
color: #ccc;
}
a:link,
a:visited {
text-decoration: none;
}
a:hover,
a:active {
text-decoration: underline;
}
.tab__item {
display: none;
}
.tab__item_active {
display: block;
}
.tab-switcher, .cswitcher {
display: inline-block;
vertical-align: top;
padding: 5px;
}
.cswitcher:before {
content: 'Background:';
padding-right: 4px;
}
.tab-switcher:before {
content: 'Attempts:';
padding-right: 4px;
}
.tab-switcher__button_active {
background: #ffeba0;
}
.meta-info {
margin: 5px;
}
.meta-info__switcher {
display: inline-block;
cursor: pointer;
}
.meta-info__content {
margin: 5px 0;
background: #f6f5f3;
padding: 5px;
}
.meta-info_collapsed .meta-info__content {
display: none;
}
.text-input {
outline: 0;
line-height: 14px;
padding: 2px 5px;
border: 1px solid #ccc;
border-radius: 2px;
}

+ 2
- 0
gemini/reports/report.min.js
File diff suppressed because it is too large
View File


BIN
gemini/screens/yandex-icons/plain/PhantomJS.png View File

Before After
Width: 760  |  Height: 82  |  Size: 11 KiB

BIN
gemini/screens/yandex-search/plain/PhantomJS.png View File

Before After
Width: 900  |  Height: 106  |  Size: 5.8 KiB

BIN
gemini/screens/yandex-search/with text/PhantomJS.png View File

Before After
Width: 900  |  Height: 106  |  Size: 7.3 KiB

+ 131
- 64
gulpfile.js View File

@ -1,6 +1,7 @@
var fs = require('fs');
var async = require('async');
var gulp = require('gulp');
var opn = require('opn');
var gutil = require('gulp-util');
var concat = require('gulp-concat');
var cleanCSS = require('gulp-clean-css');
@ -9,24 +10,34 @@ var webpack = require('webpack');
var uglify = require('uglify-js');
var rimraf = require('rimraf');
var argv = require('yargs').argv;
var ENTRY = './index.js';
var HEADER = './lib/header.js';
var DIST = './dist';
var VIS_JS = 'vis.js';
var VIS_MAP = 'vis.map';
var VIS_MIN_JS = 'vis.min.js';
var VIS_CSS = 'vis.css';
var VIS_MIN_CSS = 'vis.min.css';
var INDIVIDUAL_JS_BUNDLES = [
{entry: './index-timeline-graph2d.js', filename: 'vis-timeline-graph2d.min.js'},
{entry: './index-network.js', filename: 'vis-network.min.js'},
{entry: './index-graph3d.js', filename: 'vis-graph3d.min.js'}
];
var INDIVIDUAL_CSS_BUNDLES = [
{entry: ['./lib/shared/**/*.css', './lib/timeline/**/*.css'], filename: 'vis-timeline-graph2d.min.css'},
{entry: ['./lib/shared/**/*.css', './lib/network/**/*.css'], filename: 'vis-network.min.css'}
];
var exec = require('child_process').exec;
var spawn = require('child_process').spawn;
var ENTRY = './index.js';
var HEADER = './lib/header.js';
var DIST = './dist';
var VIS_JS = 'vis.js';
var VIS_MAP = 'vis.map';
var VIS_MIN_JS = 'vis.min.js';
var VIS_CSS = 'vis.css';
var VIS_MIN_CSS = 'vis.min.css';
var INDIVIDUAL_JS_BUNDLES = [{
entry: './index-timeline-graph2d.js',
filename: 'vis-timeline-graph2d.min.js'
}, {
entry: './index-network.js',
filename: 'vis-network.min.js'
}, {
entry: './index-graph3d.js',
filename: 'vis-graph3d.min.js'
}];
var INDIVIDUAL_CSS_BUNDLES = [{
entry: ['./lib/shared/**/*.css', './lib/timeline/**/*.css'],
filename: 'vis-timeline-graph2d.min.css'
}, {
entry: ['./lib/shared/**/*.css', './lib/network/**/*.css'],
filename: 'vis-network.min.css'
}];
// generate banner with today's date and correct version
function createBanner() {
@ -34,8 +45,8 @@ function createBanner() {
var version = require('./package.json').version;
return String(fs.readFileSync(HEADER))
.replace('@@date', today)
.replace('@@version', version);
.replace('@@date', today)
.replace('@@version', version);
}
var bannerPlugin = new webpack.BannerPlugin(createBanner(), {
@ -44,17 +55,15 @@ var bannerPlugin = new webpack.BannerPlugin(createBanner(), {
});
var webpackModule = {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
cacheDirectory: true, // use cache to improve speed
babelrc: true // use the .baberc file
}
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
cacheDirectory: true, // use cache to improve speed
babelrc: true // use the .baberc file
}
],
}],
// exclude requires of moment.js language files
wrappedContextRegExp: /$^/
@ -70,7 +79,7 @@ var webpackConfig = {
sourcePrefix: ' '
},
module: webpackModule,
plugins: [ bannerPlugin ],
plugins: [bannerPlugin],
cache: true,
// generate details sourcempas of webpack modules
@ -90,14 +99,14 @@ var uglifyConfig = {
// create a single instance of the compiler to allow caching
var compiler = webpack(webpackConfig);
function handleCompilerCallback (err, stats) {
function handleCompilerCallback(err, stats) {
if (err) {
gutil.log(err.toString());
}
if (stats && stats.compilation && stats.compilation.errors) {
// output soft errors
stats.compilation.errors.forEach(function (err) {
stats.compilation.errors.forEach(function(err) {
gutil.log(err.toString());
});
@ -107,27 +116,83 @@ function handleCompilerCallback (err, stats) {
}
}
var phantomjsPort = 4444;
gulp.task('gemini-tests', function(cb) {
var phantomjsProcess = spawn('phantomjs', ['--webdriver=' + phantomjsPort]);
var completed = false;
var hasError = false;
phantomjsProcess.stdout.on('data', function(data) {
if (data.toString().indexOf('running on port') >= 0) {
gutil.log("Started phantomjs webdriver");
var geminiProcess = spawn('gemini', ['test', 'test/gemini']);
geminiProcess.stdout.on('data', function(data) {
var msg = data.toString().replace(/\n$/g, '');
if (msg.startsWith('✓')) {
gutil.log(gutil.colors.green(msg));
} else if (msg.startsWith('✘')) {
hasError = true;
gutil.log(gutil.colors.red(msg));
} else {
gutil.log(msg);
}
});
geminiProcess.stderr.on('data', function(data) {
if (!(data.toString().indexOf('DeprecationWarning:') >= 0)) {
hasError = true;
gutil.log(gutil.colors.red(data.toString().replace(/\n$/g,
'')));
}
});
geminiProcess.on('close', function(code) {
completed = true;
phantomjsProcess.kill();
});
}
});
phantomjsProcess.stderr.on('data', function(data) {
gutil.log(gutil.colors.red(data));
});
phantomjsProcess.on('close', function(code) {
if (code && !completed) {
return cb(new Error('✘ phantomjs failed with code: ' + code +
'\n' +
'Check that port ' + phantomjsPort +
' is free and that there are no other ' +
'instances of phantomjs running. (`killall phantomjs`)'));
}
gutil.log("Stoped phantomjs webdriver");
if (hasError) {
opn('./gemini/reports/index.html');
}
cb();
});
});
// clean the dist/img directory
gulp.task('clean', function (cb) {
gulp.task('clean', function(cb) {
rimraf(DIST + '/img', cb);
});
gulp.task('bundle-js', function (cb) {
gulp.task('bundle-js', function(cb) {
// update the banner contents (has a date in it which should stay up to date)
bannerPlugin.banner = createBanner();
compiler.run(function (err, stats) {
compiler.run(function(err, stats) {
handleCompilerCallback(err, stats);
cb();
});
});
// create individual bundles for timeline+graph2d, network, graph3d
gulp.task('bundle-js-individual', function (cb) {
gulp.task('bundle-js-individual', function(cb) {
// update the banner contents (has a date in it which should stay up to date)
bannerPlugin.banner = createBanner();
async.each(INDIVIDUAL_JS_BUNDLES, function (item, callback) {
async.each(INDIVIDUAL_JS_BUNDLES, function(item, callback) {
var webpackTimelineConfig = {
entry: item.entry,
output: {
@ -138,12 +203,12 @@ gulp.task('bundle-js-individual', function (cb) {
sourcePrefix: ' '
},
module: webpackModule,
plugins: [ bannerPlugin, new webpack.optimize.UglifyJsPlugin() ],
plugins: [bannerPlugin, new webpack.optimize.UglifyJsPlugin()],
cache: true
};
var compiler = webpack(webpackTimelineConfig);
compiler.run(function (err, stats) {
compiler.run(function(err, stats) {
handleCompilerCallback(err, stats);
callback();
});
@ -152,48 +217,51 @@ gulp.task('bundle-js-individual', function (cb) {
});
// bundle and minify css
gulp.task('bundle-css', function () {
gulp.task('bundle-css', function() {
return gulp.src('./lib/**/*.css')
.pipe(concat(VIS_CSS))
.pipe(gulp.dest(DIST))
// TODO: nicer to put minifying css in a separate task?
.pipe(cleanCSS())
.pipe(rename(VIS_MIN_CSS))
.pipe(gulp.dest(DIST));
.pipe(concat(VIS_CSS))
.pipe(gulp.dest(DIST))
// TODO: nicer to put minifying css in a separate task?
.pipe(cleanCSS())
.pipe(rename(VIS_MIN_CSS))
.pipe(gulp.dest(DIST));
});
// bundle and minify individual css
gulp.task('bundle-css-individual', function (cb) {
async.each(INDIVIDUAL_CSS_BUNDLES, function (item, callback) {
gulp.task('bundle-css-individual', function(cb) {
async.each(INDIVIDUAL_CSS_BUNDLES, function(item, callback) {
return gulp.src(item.entry)
.pipe(concat(item.filename))
.pipe(cleanCSS())
.pipe(rename(item.filename))
.pipe(gulp.dest(DIST))
.on('end', callback);
.pipe(concat(item.filename))
.pipe(cleanCSS())
.pipe(rename(item.filename))
.pipe(gulp.dest(DIST))
.on('end', callback);
}, cb);
});
gulp.task('copy', ['clean'], function () {
var network = gulp.src('./lib/network/img/**/*')
.pipe(gulp.dest(DIST + '/img/network'));
gulp.task('copy', ['clean'], function() {
var network = gulp.src('./lib/network/img/**/*')
.pipe(gulp.dest(DIST + '/img/network'));
return network;
return network;
});
gulp.task('minify', ['bundle-js'], function (cb) {
gulp.task('minify', ['bundle-js'], function(cb) {
var result = uglify.minify([DIST + '/' + VIS_JS], uglifyConfig);
// note: we add a newline '\n' to the end of the minified file to prevent
// any issues when concatenating the file downstream (the file ends
// with a comment).
fs.writeFileSync(DIST + '/' + VIS_MIN_JS, result.code + '\n');
fs.writeFileSync(DIST + '/' + VIS_MAP, result.map.replace(/"\.\/dist\//g, '"'));
fs.writeFileSync(DIST + '/' + VIS_MAP, result.map.replace(/"\.\/dist\//g,
'"'));
cb();
});
gulp.task('bundle', ['bundle-js', 'bundle-js-individual', 'bundle-css', 'bundle-css-individual', 'copy']);
gulp.task('bundle', ['bundle-js', 'bundle-js-individual', 'bundle-css',
'bundle-css-individual', 'copy'
]);
// read command line arguments --bundle and --minify
var bundle = 'bundle' in argv;
@ -204,14 +272,13 @@ if (bundle || minify) {
watchTasks = [];
if (bundle) watchTasks.push('bundle');
if (minify) watchTasks.push('minify');
}
else {
} else {
// by default, do both bundling and minifying
watchTasks = ['bundle', 'minify'];
}
// The watch task (to automatically rebuild when the source code changes)
gulp.task('watch', watchTasks, function () {
gulp.task('watch', watchTasks, function() {
gulp.watch(['index.js', 'lib/**/*'], watchTasks);
});

+ 4
- 1
package.json View File

@ -24,6 +24,7 @@
"main": "./dist/vis.js",
"scripts": {
"test": "mocha --compilers js:babel-core/register",
"gemini": "gulp gemini-tests",
"build": "gulp",
"lint": "eslint lib",
"watch": "gulp watch",
@ -41,15 +42,16 @@
"babel-core": "^6.6.5",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.2.4",
"babel-polyfill": "^6.22.0",
"babel-plugin-transform-es3-member-expression-literals": "^6.22.0",
"babel-plugin-transform-es3-property-literals": "^6.8.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-polyfill": "^6.22.0",
"babel-preset-es2015": "^6.6.0",
"babel-runtime": "^6.22.0",
"babelify": "^7.3.0",
"clean-css": "^4.0.2",
"eslint": "^3.15.0",
"gemini": "^5.0.0-alpha.3",
"gulp": "^3.9.1",
"gulp-clean-css": "^2.3.2",
"gulp-concat": "^2.6.1",
@ -59,6 +61,7 @@
"jsdom-global": "^2.1.1",
"mocha": "^3.2.0",
"mocha-jsdom": "^1.1.0",
"opn": "^5.1.0",
"rimraf": "^2.5.4",
"uglify-js": "^2.7.5",
"uuid": "^3.0.1",

+ 8
- 0
test/gemini/demo1.js View File

@ -0,0 +1,8 @@
gemini.suite('yandex-search', function(suite) {
suite.setUrl('/')
.setCaptureElements('.main-table')
.capture('plain')
.capture('with text', function(actions, find) {
actions.sendKeys(find('.input__control'), 'hello gemini');
});
});

+ 5
- 0
test/gemini/demo2.js View File

@ -0,0 +1,5 @@
gemini.suite('yandex-icons', function(suite) {
suite.setUrl('/foo')
.setCaptureElements('.tabs')
.capture('plain');
});

Loading…
Cancel
Save