Skip to content

Commit 55a7a65

Browse files
committed
started moar refactorings of v5 by improving tests a bit
1 parent eb63a30 commit 55a7a65

12 files changed

Lines changed: 231 additions & 34 deletions

File tree

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
all:
2-
casperjs test test-visualize-html.js
3-
casperjs test test-load-from-URL.js
2+
@casperjs test test-visualize-html.js
3+
@casperjs test test-load-from-URL.js
4+
@casperjs test test-embedding-demo.js

‎tests/frontend-regression-tests/phantomcss.js‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ https://github.com/Huddle/PhantomCSS
44
http://tldr.huddle.com/blog/css-testing/
55
*/
66

7+
// modifications by Philip Guo labeled with 'pgbovine'
8+
79
var fs = require( 'fs' );
810

911
var _src = '.' + fs.separator + 'screenshots';
@@ -631,8 +633,10 @@ function initClient() {
631633
}
632634

633635
function _onPass( test ) {
634-
console.log( '\n' );
635-
casper.test.pass( 'No changes found for screenshot ' + test.filename );
636+
// pgbovine - briefer pass msgs
637+
//console.log( '\n' );
638+
//casper.test.pass( 'No changes found for screenshot ' + test.filename );
639+
casper.test.pass('yay');
636640
}
637641

638642
function _onFail( test ) {
@@ -661,8 +665,9 @@ function _onComplete( tests, noOfFails, noOfErrors ) {
661665
} else {
662666

663667
if ( noOfFails === 0 ) {
664-
console.log( "\nPhantomCSS found " + tests.length + " tests, None of them failed. Which is good right?" );
665-
console.log( "\nIf you want to make them fail, change some CSS." );
668+
// pgbovine
669+
//console.log( "\nPhantomCSS found " + tests.length + " tests, None of them failed. Which is good right?" );
670+
//console.log( "\nIf you want to make them fail, change some CSS." );
666671
} else {
667672
console.log( "\nPhantomCSS found " + tests.length + " tests, " + noOfFails + ' of them failed.' );
668673
if ( _failures ) {
233 KB
Loading
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Run a visual regression test on htmlPath, putting outputs in outputDir
2+
var htmlPath = "http://localhost:8003/embedding-demo.html"
3+
var outputDir = "/test-embedding-demo-outputs"
4+
5+
var DELAY_MS = 100;
6+
7+
var fs = require('fs');
8+
var path = fs.absolute(fs.workingDirectory + '/phantomcss.js');
9+
var phantomcss = require(path);
10+
11+
casper.test.begin('Testing ' + htmlPath, function (test) {
12+
// boring setup code taken from PhantomCSS demo
13+
phantomcss.init({
14+
rebase: casper.cli.get( "rebase" ),
15+
// SlimerJS needs explicit knowledge of this Casper, and lots of absolute paths
16+
casper: casper,
17+
libraryRoot: fs.absolute( fs.workingDirectory + '' ),
18+
screenshotRoot: fs.absolute( fs.workingDirectory + outputDir + '/screenshots' ),
19+
failedComparisonsRoot: fs.absolute( fs.workingDirectory + outputDir + '/failures' ),
20+
addLabelToFailedImage: false,
21+
});
22+
23+
casper.on('remote.message', function(msg) {this.echo(msg);});
24+
casper.on('error', function (err) {this.die( "PhantomJS has errored: " + err );});
25+
casper.on('resource.error', function (err) {casper.log( 'Resource load error: ' + err, 'warning' );});
26+
27+
28+
// start with a baseline image
29+
casper.start(htmlPath);
30+
casper.viewport(1440, 900, function () {
31+
casper.waitFor(function check() {
32+
return this.evaluate(function() {
33+
return document.querySelectorAll("#happyDiv #dataViz").length > 0;
34+
});
35+
}, function then() {
36+
this.wait(DELAY_MS, function() {
37+
phantomcss.screenshot('body', 'embedding-demo-page');
38+
});
39+
});
40+
});
41+
42+
43+
// run all tests:
44+
casper.then(function now_check_the_screenshots() {
45+
phantomcss.compareAll(); // compare screenshots
46+
});
47+
48+
casper.run(function() {
49+
//phantomcss.getExitStatus() // pass or fail?
50+
casper.test.done();
51+
});
52+
});

‎v3/embedding-demo.js‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎v5-unity/embedding-demo.html‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
4+
<!--
5+
Python Tutor: https://github.com/pgbovine/OnlinePythonTutor/
6+
Copyright (C) Philip Guo (philip@pgbovine.net)
7+
LICENSE: https://github.com/pgbovine/OnlinePythonTutor/blob/master/LICENSE.txt
8+
-->
9+
10+
<head>
11+
<title>Online Python Tutor embedding demo</title>
12+
13+
<!-- let Webpack take care of everything. Use the [hash] feature to
14+
create unique filenames for releases:
15+
https://webpack.github.io/docs/long-term-caching.html -->
16+
<script type="text/javascript" src="build/embedding-demo.bundle.js" charset="utf-8"></script>
17+
18+
</head>
19+
20+
<body style="background-color: white;">
21+
<!-- This demo shows three visualizations, each embedded within a div ... -->
22+
<p>Recursive list sum (from <a href="http://pythontutor.com">pythontutor.com</a> home page):</p>
23+
<div id="listSumLabel"></div>
24+
<div id="listSumDiv"></div>
25+
26+
<p>Towers of Hanoi:</p>
27+
<div id="hanoiLabel"></div>
28+
<div id="hanoiDiv"></div>
29+
30+
<p>Happy Birthday:</p>
31+
<div id="happyLabel"></div>
32+
<div id="happyDiv"></div>
33+
</body>
34+
</html>

‎v5-unity/js/embedding-demo.ts‎

Lines changed: 105 additions & 0 deletions
Large diffs are not rendered by default.

‎v5-unity/js/iframe-embed.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// Copyright (C) Philip Guo (philip@pgbovine.net)
33
// LICENSE: https://github.com/pgbovine/OnlinePythonTutor/blob/master/LICENSE.txt
44

5-
require('./lib/jquery-3.0.0.min.js');
6-
require('./lib/jquery.ba-bbq.js'); // contains slight pgbovine modifications
7-
85
var optCommon = require('./opt-frontend-common.ts');
96
var pytutor = require('./pytutor.ts');
107
var assert = pytutor.assert;

‎v5-unity/js/opt-frontend-common.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// LICENSE: https://github.com/pgbovine/OnlinePythonTutor/blob/master/LICENSE.txt
44

55
require('./lib/diff_match_patch.js');
6-
require('./lib/jquery-3.0.0.min.js');
7-
require('./lib/jquery.ba-bbq.js'); // contains slight pgbovine modifications
86
require('./lib/jquery.ba-dotimeout.min.js');
97

108
var pytutor = require('./pytutor.ts');

‎v5-unity/js/opt-live.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,6 @@ function optLiveExecuteCode(forceStartingInstr, forceRawInputLst) {
589589
}
590590

591591
var backend_script = optliveLangToBackendScript($('#pythonVersionSelector').val());
592-
console.log('backend_script:', backend_script);
593592

594593
var backendOptionsObj = {cumulative_mode: ($('#cumulativeModeSelector').val() == 'true'),
595594
heap_primitives: ($('#heapPrimitivesSelector').val() == 'true'),

0 commit comments

Comments
 (0)