mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-12 23:54:27 +02:00
no more casper etc
This commit is contained in:
parent
7199cce804
commit
6d59d90848
17 changed files with 0 additions and 752 deletions
|
@ -199,10 +199,6 @@ module.exports = function(grunt) {
|
||||||
shell: {
|
shell: {
|
||||||
gitAdd: {
|
gitAdd: {
|
||||||
command: 'git add build/'
|
command: 'git add build/'
|
||||||
},
|
|
||||||
casperTest: {
|
|
||||||
command: 'echo "Running $(ls -1 ./src/__tests__/casperjs/*_test.js | wc -l) tests" && ' +
|
|
||||||
'ls -1 ./src/__tests__/casperjs/*_test.js | while IFS= read -r line; do casperjs test $line; done'
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
jasmine_node: {
|
jasmine_node: {
|
||||||
|
@ -215,7 +211,6 @@ module.exports = function(grunt) {
|
||||||
options: {
|
options: {
|
||||||
transform: [require('grunt-react').browserify],
|
transform: [require('grunt-react').browserify],
|
||||||
ignore: [
|
ignore: [
|
||||||
'src/__tests__/casperjs/*.js',
|
|
||||||
'src/js/__tests__/create.js',
|
'src/js/__tests__/create.js',
|
||||||
'src/js/__tests__/*.js',
|
'src/js/__tests__/*.js',
|
||||||
'src/js/native_react_views/*.js',
|
'src/js/native_react_views/*.js',
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
"browserify": "~3.14.1",
|
"browserify": "~3.14.1",
|
||||||
"grunt": "~0.4.2",
|
"grunt": "~0.4.2",
|
||||||
"grunt-browserify": "~1.3.0",
|
"grunt-browserify": "~1.3.0",
|
||||||
"grunt-casperjs": "^2.1.0",
|
|
||||||
"grunt-cli": "~0.1.11",
|
"grunt-cli": "~0.1.11",
|
||||||
"grunt-contrib-clean": "~0.5.0",
|
"grunt-contrib-clean": "~0.5.0",
|
||||||
"grunt-contrib-jshint": "~0.7.2",
|
"grunt-contrib-jshint": "~0.7.2",
|
||||||
|
@ -20,7 +19,6 @@
|
||||||
"grunt-hash": "~0.5.0",
|
"grunt-hash": "~0.5.0",
|
||||||
"grunt-jasmine-node": "~0.1.0",
|
"grunt-jasmine-node": "~0.1.0",
|
||||||
"grunt-jsxhint": "^0.5.0",
|
"grunt-jsxhint": "^0.5.0",
|
||||||
"grunt-lib-phantomjs": "~0.4.0",
|
|
||||||
"grunt-react": "^0.12.1",
|
"grunt-react": "^0.12.1",
|
||||||
"grunt-shell-spawn": "~0.3.0",
|
"grunt-shell-spawn": "~0.3.0",
|
||||||
"jasmine-node": "~1.12.0",
|
"jasmine-node": "~1.12.0",
|
||||||
|
|
|
@ -1,228 +0,0 @@
|
||||||
|
|
||||||
var screenshotCounter = 0;
|
|
||||||
var screenshotRoot = './src/__tests__/casperjs/screenshots/entirePage';
|
|
||||||
|
|
||||||
var CasperUtils = {
|
|
||||||
|
|
||||||
start: function(casper, url, callback) {
|
|
||||||
// Setup some sanity error handling
|
|
||||||
casper.on('page.error', function(msg, trace) {
|
|
||||||
casper.echo('Error: ' + msg, 'ERROR');
|
|
||||||
casper.echo('Stack: ' + JSON.stringify(trace));
|
|
||||||
});
|
|
||||||
casper.on('remote.error', function(msg) {
|
|
||||||
casper.echo('Console Warn: ' + msg, 'ERROR');
|
|
||||||
});
|
|
||||||
|
|
||||||
casper.options.logLevel ="debug";
|
|
||||||
casper.start(url, callback);
|
|
||||||
return casper;
|
|
||||||
},
|
|
||||||
|
|
||||||
getRoot: function() {
|
|
||||||
// Unfortunately this is hardcoded for now :*( cant get the path
|
|
||||||
// variable synchronously when running this test, and CasperJS does
|
|
||||||
// not like being started asynchronously.
|
|
||||||
return '/Users/pcottle/Dropbox (Personal)/wip/learnGitBranching/';
|
|
||||||
},
|
|
||||||
|
|
||||||
getUrl: function () {
|
|
||||||
return 'file://localhost/' + this.getRoot() + 'index.html?NODEMO';
|
|
||||||
},
|
|
||||||
|
|
||||||
getUrlWithQueryParams: function(params) {
|
|
||||||
var paramsString = '';
|
|
||||||
Object.keys(params).forEach(function(key) {
|
|
||||||
paramsString = paramsString + '&' + key + '=' + params[key];
|
|
||||||
});
|
|
||||||
return this.getUrl() + paramsString;
|
|
||||||
},
|
|
||||||
|
|
||||||
getUrlForCommands: function(commands) {
|
|
||||||
return this.getUrl() + '&command=' + commands.join(';');
|
|
||||||
},
|
|
||||||
|
|
||||||
testDone: function() {
|
|
||||||
this.test.done();
|
|
||||||
},
|
|
||||||
|
|
||||||
enterCommand: function(command) {
|
|
||||||
return function then() {
|
|
||||||
this.sendKeys('#commandTextField', command, { keepFocus: true });
|
|
||||||
this.page.sendEvent('keypress', this.page.event.key.Enter);
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
multiAssert: function() {
|
|
||||||
// Copy the args into a variable we can reference inside
|
|
||||||
// our closure.
|
|
||||||
var asserts = [];
|
|
||||||
for (var i = 0; i < arguments.length; i++) {
|
|
||||||
asserts.push(arguments[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return function then() {
|
|
||||||
for (var i = 0; i < asserts.length; i++) {
|
|
||||||
var assert = asserts[i];
|
|
||||||
assert.bind(this)();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
asserts: {
|
|
||||||
|
|
||||||
visibleIDs: function(visibleIDs) {
|
|
||||||
return function then() {
|
|
||||||
visibleIDs.forEach(function(id) {
|
|
||||||
this.test.assertVisible('#' + id);
|
|
||||||
}.bind(this));
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
visibleSelectors: function(selectors) {
|
|
||||||
return function then() {
|
|
||||||
selectors.forEach(function(selector) {
|
|
||||||
this.test.assertVisible(selector);
|
|
||||||
}.bind(this));
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
visibleSelector: function(selector) {
|
|
||||||
return function then() {
|
|
||||||
this.test.assertVisible(selector);
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
selectorMatchesRegex: function(selector, regex) {
|
|
||||||
return function then() {
|
|
||||||
this.test.assertEvalEquals(function(selector, regex) {
|
|
||||||
return !!document.querySelector(selector).innerText
|
|
||||||
.match(regex);
|
|
||||||
},
|
|
||||||
true,
|
|
||||||
'Checking that selector "' + selector + '" matches regex "' +
|
|
||||||
regex + '".',
|
|
||||||
{selector: selector, regex: regex}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
selectorContainsText: function(selector, text) {
|
|
||||||
return function then() {
|
|
||||||
this.test.assertEvalEquals(function(selector) {
|
|
||||||
if (!document.querySelector(selector)) {
|
|
||||||
return 'Query selector ' + selector + ' did not match!!';
|
|
||||||
}
|
|
||||||
return document.querySelector(selector).innerText
|
|
||||||
.replace(/^\s+/g, '').replace(/\s+$/g, '');
|
|
||||||
},
|
|
||||||
text,
|
|
||||||
'Checking that selector "' + selector + '" contains "' +
|
|
||||||
text + '".',
|
|
||||||
{selector: selector}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
intlKeyReturns: function(key, text) {
|
|
||||||
return function then() {
|
|
||||||
this.test.assertEvalEquals(function(key) {
|
|
||||||
return intl.str(key);
|
|
||||||
},
|
|
||||||
text,
|
|
||||||
'Checking that intl key "' + key + '" contains "' +
|
|
||||||
text + '".',
|
|
||||||
{key: key}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
existingIDs: function(existingIDs) {
|
|
||||||
return function then() {
|
|
||||||
existingIDs.forEach(function(id) {
|
|
||||||
this.test.assertExists('#' + id);
|
|
||||||
}.bind(this));
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
existingSelectors: function(existingSelectors) {
|
|
||||||
return function then() {
|
|
||||||
existingSelectors.forEach(function(selector) {
|
|
||||||
this.test.assertExists(selector);
|
|
||||||
}.bind(this));
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
screenshot: {
|
|
||||||
entirePage: function () {
|
|
||||||
screenshotCounter++;
|
|
||||||
|
|
||||||
casper.capture(screenshotRoot + screenshotCounter + '.png', {
|
|
||||||
top: 0,
|
|
||||||
left: 0,
|
|
||||||
// These seem to be the hardcoded viewport dimensions
|
|
||||||
height: 600,
|
|
||||||
width: 1000
|
|
||||||
});
|
|
||||||
casper.echo('<<< Took screenshot ' + screenshotCounter + ' >>>', 'COMMENT');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
waits: {
|
|
||||||
jsMount: function() {
|
|
||||||
return this.evaluate(function() {
|
|
||||||
var hasHelper = document.querySelectorAll('div.BaseHelperBar').length > 0;
|
|
||||||
if (hasHelper) {
|
|
||||||
__utils__.echo('<<< JS mounted >>>');
|
|
||||||
}
|
|
||||||
return hasHelper;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
allCommandsFinished: function() {
|
|
||||||
return this.evaluate(function() {
|
|
||||||
return document.querySelectorAll('p.commandLine').length ===
|
|
||||||
document.querySelectorAll('p.finished').length;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
selectorVisible: function(selector) {
|
|
||||||
return function waitFor() {
|
|
||||||
return this.evaluate(function() {
|
|
||||||
return document.querySelectorAll(selector).length > 0;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
idsVisible: function(ids) {
|
|
||||||
return function waitFor() {
|
|
||||||
return this.evaluate(function() {
|
|
||||||
var allVisible = true;
|
|
||||||
for (var i = 0; i < ids.length; i++) {
|
|
||||||
allVisible = allVisible && __utils__.visible('#' + ids[i]);
|
|
||||||
}
|
|
||||||
return allVisible;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
idVisible: function(id) {
|
|
||||||
return function waitFor() {
|
|
||||||
return this.evaluate(function() {
|
|
||||||
return __utils__.visible(id);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
commandVisible: function() {
|
|
||||||
return this.evaluate(function() {
|
|
||||||
return document.querySelectorAll('p.commandLine').length > 0;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.CasperUtils = CasperUtils;
|
|
|
@ -1,25 +0,0 @@
|
||||||
var CasperUtils = require('./casperUtils').CasperUtils;
|
|
||||||
|
|
||||||
CasperUtils.start(casper,
|
|
||||||
CasperUtils.getUrl(),
|
|
||||||
function() {
|
|
||||||
this.test.assertTitle('Learn Git Branching');
|
|
||||||
|
|
||||||
casper.waitFor(CasperUtils.waits.jsMount)
|
|
||||||
.wait(300)
|
|
||||||
.then(CasperUtils.enterCommand('git commit'))
|
|
||||||
.wait(800)
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.then(function() {
|
|
||||||
this.page.sendEvent('keypress', this.page.event.key.Up);
|
|
||||||
})
|
|
||||||
.wait(700)
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
// Our command got remembered
|
|
||||||
.then(CasperUtils.asserts.selectorMatchesRegex(
|
|
||||||
'#commandLineBar p.command',
|
|
||||||
// some weird whitespace conversion of non-breaking space
|
|
||||||
/git\scommit/g
|
|
||||||
))
|
|
||||||
.then(CasperUtils.testDone);
|
|
||||||
}).run();
|
|
|
@ -1,32 +0,0 @@
|
||||||
var CasperUtils = require('./casperUtils').CasperUtils;
|
|
||||||
|
|
||||||
CasperUtils.start(casper,
|
|
||||||
CasperUtils.getUrl(),
|
|
||||||
function() {
|
|
||||||
this.test.assertTitle('Learn Git Branching');
|
|
||||||
|
|
||||||
casper.waitFor(CasperUtils.waits.jsMount)
|
|
||||||
.wait(300)
|
|
||||||
.then(CasperUtils.enterCommand('level intro1'))
|
|
||||||
.wait(1500)
|
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
|
||||||
'div.modalView div h2',
|
|
||||||
'Git Commits'
|
|
||||||
))
|
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
|
||||||
'div.modalView.inFront div.inside p',
|
|
||||||
"A commit in a git repository records a snapshot of all the files in your directory. It's like a giant copy and paste, but even better!"
|
|
||||||
))
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.then(function() {
|
|
||||||
this.page.sendEvent('keypress', this.page.event.key.Escape);
|
|
||||||
})
|
|
||||||
.wait(700)
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
|
||||||
'div.levelNameWrapper',
|
|
||||||
"Level Introduction to Git Commits"
|
|
||||||
))
|
|
||||||
.then(CasperUtils.testDone);
|
|
||||||
|
|
||||||
}).run();
|
|
|
@ -1,34 +0,0 @@
|
||||||
var CasperUtils = require('./casperUtils').CasperUtils;
|
|
||||||
|
|
||||||
CasperUtils.start(
|
|
||||||
casper,
|
|
||||||
CasperUtils.getUrlForCommands([
|
|
||||||
'asd'
|
|
||||||
]),
|
|
||||||
function() {
|
|
||||||
this.test.assertTitle('Learn Git Branching');
|
|
||||||
|
|
||||||
casper.waitFor(CasperUtils.waits.jsMount)
|
|
||||||
.wait(200)
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
|
||||||
'#command_0 div.commandLineResult p',
|
|
||||||
'The command "asd" isn\'t supported, sorry!'
|
|
||||||
))
|
|
||||||
.then(CasperUtils.enterCommand('git commit'))
|
|
||||||
.wait(100)
|
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
|
||||||
'#command_1 p.commandLine span:nth-child(2)',
|
|
||||||
'git commit'
|
|
||||||
))
|
|
||||||
.wait(700)
|
|
||||||
.then(CasperUtils.enterCommand('git checkout C1'))
|
|
||||||
.then(CasperUtils.enterCommand('git commit'))
|
|
||||||
.wait(2000)
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
|
||||||
'#commandDisplay div.commandLineWarnings p span',
|
|
||||||
"Warning!! Detached HEAD state"
|
|
||||||
))
|
|
||||||
.then(CasperUtils.testDone);
|
|
||||||
}).run();
|
|
|
@ -1,37 +0,0 @@
|
||||||
var CasperUtils = require('./casperUtils').CasperUtils;
|
|
||||||
|
|
||||||
CasperUtils.start(casper,
|
|
||||||
CasperUtils.getUrl(),
|
|
||||||
function() {
|
|
||||||
|
|
||||||
casper.waitFor(CasperUtils.waits.jsMount)
|
|
||||||
.then(CasperUtils.asserts.visibleSelectors([
|
|
||||||
'a.intl',
|
|
||||||
'a.commands',
|
|
||||||
'a.fb',
|
|
||||||
'div.helperBar'
|
|
||||||
]))
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.then(function() {
|
|
||||||
this.mouse.click('a.intl');
|
|
||||||
})
|
|
||||||
.wait(500)
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.then(CasperUtils.asserts.visibleSelectors([
|
|
||||||
'a.english',
|
|
||||||
'a.korean',
|
|
||||||
'a.japanese',
|
|
||||||
'a.simpchinese'
|
|
||||||
]))
|
|
||||||
.then(function() {
|
|
||||||
this.mouse.click('a.japanese');
|
|
||||||
})
|
|
||||||
.wait(500)
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
|
||||||
'span[data-intl="learn-git-branching"]',
|
|
||||||
"日本語版リポジトリ"
|
|
||||||
))
|
|
||||||
.then(CasperUtils.testDone);
|
|
||||||
}).run();
|
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
var CasperUtils = require('./casperUtils').CasperUtils;
|
|
||||||
|
|
||||||
CasperUtils.start(casper,
|
|
||||||
CasperUtils.getUrl(),
|
|
||||||
function() {
|
|
||||||
this.test.assertTitle('Learn Git Branching');
|
|
||||||
|
|
||||||
casper.waitFor(CasperUtils.waits.jsMount)
|
|
||||||
.wait(300)
|
|
||||||
.then(CasperUtils.enterCommand('levels'))
|
|
||||||
.wait(800)
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
|
||||||
'div.modalView.inFront div.toolbar',
|
|
||||||
'Select a level'
|
|
||||||
))
|
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
|
||||||
'div.modalView.inFront div.displayName h3',
|
|
||||||
'Introduction Sequence'
|
|
||||||
))
|
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
|
||||||
'div.modalView.inFront div.seriesView p',
|
|
||||||
"A nicely paced introduction to the majority of git commands"
|
|
||||||
))
|
|
||||||
.then(function() {
|
|
||||||
this.page.sendEvent('keypress', this.page.event.key.Right);
|
|
||||||
})
|
|
||||||
.wait(700)
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
// Now we have selected the first level
|
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
|
||||||
'div.modalView.inFront div.seriesView p',
|
|
||||||
"Introduction to Git Commits"
|
|
||||||
))
|
|
||||||
.then(function() {
|
|
||||||
this.page.sendEvent('keypress', this.page.event.key.Enter);
|
|
||||||
})
|
|
||||||
.wait(700)
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
|
||||||
'div.levelNameWrapper',
|
|
||||||
"Level Introduction to Git Commits"
|
|
||||||
))
|
|
||||||
.then(CasperUtils.testDone);
|
|
||||||
|
|
||||||
}).run();
|
|
|
@ -1,62 +0,0 @@
|
||||||
var CasperUtils = require('./casperUtils').CasperUtils;
|
|
||||||
|
|
||||||
CasperUtils.start(casper,
|
|
||||||
CasperUtils.getUrl(),
|
|
||||||
function() {
|
|
||||||
this.test.assertTitle('Learn Git Branching');
|
|
||||||
|
|
||||||
casper.waitFor(CasperUtils.waits.jsMount)
|
|
||||||
.wait(300)
|
|
||||||
.then(CasperUtils.enterCommand('levels'))
|
|
||||||
.wait(800)
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
|
||||||
'div.modalView.inFront div.toolbar',
|
|
||||||
'Select a level'
|
|
||||||
))
|
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
|
||||||
'div.modalView.inFront div.displayName h3',
|
|
||||||
'Introduction Sequence'
|
|
||||||
))
|
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
|
||||||
'div.modalView.inFront div.seriesView p',
|
|
||||||
"A nicely paced introduction to the majority of git commands"
|
|
||||||
))
|
|
||||||
// Hit right 5 times
|
|
||||||
.then(function() {
|
|
||||||
this.page.sendEvent('keypress', this.page.event.key.Right);
|
|
||||||
})
|
|
||||||
.then(function() {
|
|
||||||
this.page.sendEvent('keypress', this.page.event.key.Right);
|
|
||||||
})
|
|
||||||
.then(function() {
|
|
||||||
this.page.sendEvent('keypress', this.page.event.key.Right);
|
|
||||||
})
|
|
||||||
.then(function() {
|
|
||||||
this.page.sendEvent('keypress', this.page.event.key.Right);
|
|
||||||
})
|
|
||||||
.then(function() {
|
|
||||||
this.page.sendEvent('keypress', this.page.event.key.Right);
|
|
||||||
})
|
|
||||||
.wait(300)
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
|
||||||
'div.modalView.inFront div.displayName h3',
|
|
||||||
"Push & Pull -- Git Remotes!"
|
|
||||||
))
|
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
|
||||||
'div.modalView.inFront div.seriesView p',
|
|
||||||
"Clone Intro"
|
|
||||||
))
|
|
||||||
.then(function() {
|
|
||||||
this.page.sendEvent('keypress', this.page.event.key.Enter);
|
|
||||||
})
|
|
||||||
.wait(700)
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
|
||||||
'div.levelNameWrapper',
|
|
||||||
"Level Clone Intro"
|
|
||||||
))
|
|
||||||
.then(CasperUtils.testDone);
|
|
||||||
|
|
||||||
}).run();
|
|
|
@ -1,55 +0,0 @@
|
||||||
var CasperUtils = require('./casperUtils').CasperUtils;
|
|
||||||
|
|
||||||
var levels = require('../../levels');
|
|
||||||
|
|
||||||
var numLevelSequences = Object.keys(levels.levelSequences).length;
|
|
||||||
|
|
||||||
var getLevelIconIDs = function(levelID) {
|
|
||||||
var level = levels.levelSequences[levelID];
|
|
||||||
var numLevels = Object.keys(level).length;
|
|
||||||
|
|
||||||
// We index at 1 for the level icons
|
|
||||||
var result = [];
|
|
||||||
for (var i = 1; i <= numLevels; i++) {
|
|
||||||
result.push('levelIcon-' + levelID + i);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var flattenArray = function(a, b) { return a.concat(b);};
|
|
||||||
|
|
||||||
var levelIconIDsForPages = function(start, end) {
|
|
||||||
return Object.keys(levels.levelSequences).slice(start, end)
|
|
||||||
.map(getLevelIconIDs)
|
|
||||||
.reduce(flattenArray);
|
|
||||||
};
|
|
||||||
|
|
||||||
CasperUtils.start(casper,
|
|
||||||
CasperUtils.getUrlForCommands([
|
|
||||||
'levels',
|
|
||||||
]),
|
|
||||||
function() {
|
|
||||||
|
|
||||||
casper.waitFor(CasperUtils.waits.jsMount)
|
|
||||||
.waitFor(CasperUtils.waits.commandVisible)
|
|
||||||
.wait(1000)
|
|
||||||
.then(
|
|
||||||
CasperUtils.multiAssert(
|
|
||||||
CasperUtils.asserts.visibleSelectors([
|
|
||||||
'div.levelDropdownView'
|
|
||||||
]),
|
|
||||||
CasperUtils.asserts.visibleIDs(
|
|
||||||
levelIconIDsForPages(0, 5)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.then(function() {
|
|
||||||
this.mouse.click('div[data-id="remote"]');
|
|
||||||
})
|
|
||||||
.wait(1000)
|
|
||||||
.then(CasperUtils.asserts.visibleIDs(
|
|
||||||
levelIconIDsForPages(5, numLevelSequences)
|
|
||||||
))
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.then(CasperUtils.testDone);
|
|
||||||
}).run();
|
|
|
@ -1,34 +0,0 @@
|
||||||
var CasperUtils = require('./casperUtils').CasperUtils;
|
|
||||||
|
|
||||||
CasperUtils.start(casper,
|
|
||||||
CasperUtils.getUrlForCommands([
|
|
||||||
'level intro1 --noIntroDialog --noStartCommand',
|
|
||||||
]),
|
|
||||||
function() {
|
|
||||||
casper.waitFor(CasperUtils.waits.jsMount)
|
|
||||||
.waitFor(CasperUtils.waits.allCommandsFinished)
|
|
||||||
.then(CasperUtils.asserts.visibleSelectors([
|
|
||||||
'p.commandLine.finished',
|
|
||||||
'div.levelNameWrapper'
|
|
||||||
]))
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.then(function() {
|
|
||||||
this.mouse.click('#show-objective');
|
|
||||||
})
|
|
||||||
.wait(1000)
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.then(CasperUtils.asserts.visibleSelectors([
|
|
||||||
'div.inside',
|
|
||||||
'div.modalTerminal'
|
|
||||||
]))
|
|
||||||
.then(function() {
|
|
||||||
this.test.assertEvalEquals(function() {
|
|
||||||
return document.querySelector('div.inside > div > p').innerText;
|
|
||||||
},
|
|
||||||
"Go ahead and try it out on your own! After this " +
|
|
||||||
"window closes, make two commits to complete the level"
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.then(CasperUtils.testDone);
|
|
||||||
}).run();
|
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
var CasperUtils = require('./casperUtils').CasperUtils;
|
|
||||||
|
|
||||||
CasperUtils.start(casper,
|
|
||||||
CasperUtils.getUrlForCommands([
|
|
||||||
'level intro1 --noIntroDialog --noStartCommand',
|
|
||||||
]),
|
|
||||||
function() {
|
|
||||||
casper.waitFor(CasperUtils.waits.jsMount)
|
|
||||||
.waitFor(CasperUtils.waits.allCommandsFinished)
|
|
||||||
.then(CasperUtils.asserts.visibleSelectors([
|
|
||||||
'p.commandLine.finished',
|
|
||||||
'div.levelNameWrapper'
|
|
||||||
]))
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.then(function() {
|
|
||||||
this.mouse.click('#show-goal');
|
|
||||||
})
|
|
||||||
.wait(1000)
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.then(CasperUtils.asserts.visibleSelector('p.helperText'))
|
|
||||||
.then(function() {
|
|
||||||
var text = this.evaluate(function() {
|
|
||||||
return document.querySelector('p.helperText').innerText;
|
|
||||||
});
|
|
||||||
this.test.assertEquals(
|
|
||||||
text,
|
|
||||||
'You can hide this window with "hide goal"'
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.then(CasperUtils.testDone);
|
|
||||||
}).run();
|
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
var CasperUtils = require('./casperUtils').CasperUtils;
|
|
||||||
|
|
||||||
CasperUtils.start(casper,
|
|
||||||
CasperUtils.getUrlForCommands([
|
|
||||||
'level intro1 --noIntroDialog --noStartCommand',
|
|
||||||
'show goal',
|
|
||||||
'git commit',
|
|
||||||
'git commit'
|
|
||||||
]),
|
|
||||||
function() {
|
|
||||||
this.test.assertTitle('Learn Git Branching');
|
|
||||||
casper.waitFor(CasperUtils.waits.jsMount)
|
|
||||||
.wait(2000)
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.waitFor(CasperUtils.waits.allCommandsFinished)
|
|
||||||
// Have to wait for balls to stop bouncing
|
|
||||||
.wait(5000)
|
|
||||||
.wait(5000)
|
|
||||||
.wait(5000)
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
|
||||||
'div.modalView div.inside h2',
|
|
||||||
"Great Job!!"
|
|
||||||
))
|
|
||||||
.then(CasperUtils.testDone);
|
|
||||||
|
|
||||||
}).run();
|
|
|
@ -1,19 +0,0 @@
|
||||||
var CasperUtils = require('./casperUtils').CasperUtils;
|
|
||||||
|
|
||||||
CasperUtils.start(casper,
|
|
||||||
CasperUtils.getUrlForCommands([
|
|
||||||
'locale fr_FR',
|
|
||||||
]),
|
|
||||||
function() {
|
|
||||||
this.test.assertTitle('Learn Git Branching');
|
|
||||||
|
|
||||||
casper.waitFor(CasperUtils.waits.jsMount)
|
|
||||||
.waitFor(CasperUtils.waits.allCommandsFinished)
|
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
|
||||||
'span[data-intl="learn-git-branching"]',
|
|
||||||
"APPRENEZ GIT BRANCHING"
|
|
||||||
))
|
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
|
||||||
.then(CasperUtils.testDone);
|
|
||||||
|
|
||||||
}).run();
|
|
|
@ -1,60 +0,0 @@
|
||||||
var CasperUtils = require('./casperUtils').CasperUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO(pcottle) -- find a way to get this from
|
|
||||||
* LocaleStore but not have the import error
|
|
||||||
*/
|
|
||||||
var langLocaleMap = {
|
|
||||||
en: 'en_US',
|
|
||||||
zh: 'zh_CN',
|
|
||||||
ja: 'ja',
|
|
||||||
ko: 'ko',
|
|
||||||
es: 'es_AR',
|
|
||||||
fr: 'fr_FR',
|
|
||||||
de: 'de_DE',
|
|
||||||
pt: 'pt_BR'
|
|
||||||
};
|
|
||||||
|
|
||||||
var headerLocaleMap = {
|
|
||||||
'zh-CN': 'zh_CN',
|
|
||||||
'zh-TW': 'zh_TW',
|
|
||||||
'pt-BR': 'pt_BR'
|
|
||||||
};
|
|
||||||
|
|
||||||
CasperUtils.start(casper,
|
|
||||||
CasperUtils.getUrl(),
|
|
||||||
function() {
|
|
||||||
this.test.assertTitle('Learn Git Branching');
|
|
||||||
|
|
||||||
casper.waitFor(CasperUtils.waits.jsMount)
|
|
||||||
.then(function() {
|
|
||||||
Object.keys(langLocaleMap).forEach(function(lang) {
|
|
||||||
var locale = langLocaleMap[lang];
|
|
||||||
this.test.assertEvalEquals(function(lang) {
|
|
||||||
window.LocaleActions.changeLocaleFromHeader(lang);
|
|
||||||
return window.LocaleStore.getLocale();
|
|
||||||
},
|
|
||||||
locale,
|
|
||||||
'Testing changing store locale from ' + lang +
|
|
||||||
' to ' + locale,
|
|
||||||
{lang: lang}
|
|
||||||
);
|
|
||||||
}.bind(this));
|
|
||||||
})
|
|
||||||
.then(function() {
|
|
||||||
Object.keys(headerLocaleMap).forEach(function(header) {
|
|
||||||
var locale = headerLocaleMap[header];
|
|
||||||
this.test.assertEvalEquals(function(header) {
|
|
||||||
window.LocaleActions.changeLocaleFromHeader(header);
|
|
||||||
return window.LocaleStore.getLocale();
|
|
||||||
},
|
|
||||||
locale,
|
|
||||||
'Testing changing store locale from ' + header +
|
|
||||||
' to ' + locale,
|
|
||||||
{header: header}
|
|
||||||
);
|
|
||||||
}.bind(this));
|
|
||||||
})
|
|
||||||
.then(CasperUtils.testDone);
|
|
||||||
|
|
||||||
}).run();
|
|
|
@ -1,20 +0,0 @@
|
||||||
var CasperUtils = require('./casperUtils').CasperUtils;
|
|
||||||
|
|
||||||
CasperUtils.start(casper,
|
|
||||||
CasperUtils.getUrlWithQueryParams({
|
|
||||||
locale: 'fr_FR',
|
|
||||||
}),
|
|
||||||
function() {
|
|
||||||
this.test.assertTitle('Learn Git Branching');
|
|
||||||
casper.waitFor(CasperUtils.waits.jsMount)
|
|
||||||
.then(CasperUtils.asserts.intlKeyReturns(
|
|
||||||
'learn-git-branching',
|
|
||||||
"Apprenez Git Branching"
|
|
||||||
))
|
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
|
||||||
'span[data-intl="learn-git-branching"]',
|
|
||||||
"APPRENEZ GIT BRANCHING"
|
|
||||||
))
|
|
||||||
.then(CasperUtils.testDone);
|
|
||||||
|
|
||||||
}).run();
|
|
|
@ -1,34 +0,0 @@
|
||||||
var CasperUtils = require('./casperUtils').CasperUtils;
|
|
||||||
|
|
||||||
CasperUtils.start(casper,
|
|
||||||
CasperUtils.getUrlForCommands([
|
|
||||||
'git commit',
|
|
||||||
]),
|
|
||||||
function() {
|
|
||||||
this.test.assertTitle('Learn Git Branching');
|
|
||||||
|
|
||||||
casper.waitFor(CasperUtils.waits.jsMount)
|
|
||||||
|
|
||||||
.then(CasperUtils.multiAssert(
|
|
||||||
CasperUtils.asserts.visibleIDs([
|
|
||||||
'commandLineHistory',
|
|
||||||
'terminal',
|
|
||||||
'interfaceWrapper',
|
|
||||||
'mainVisSpace',
|
|
||||||
'commandLineBar'
|
|
||||||
]),
|
|
||||||
CasperUtils.asserts.visibleSelectors([
|
|
||||||
'div.visBackgroundColor',
|
|
||||||
'p.commandLine'
|
|
||||||
])
|
|
||||||
))
|
|
||||||
|
|
||||||
.waitFor(CasperUtils.waits.allCommandsFinished)
|
|
||||||
|
|
||||||
.then(
|
|
||||||
CasperUtils.asserts.visibleSelectors(['p.finished'])
|
|
||||||
)
|
|
||||||
|
|
||||||
.then(CasperUtils.testDone);
|
|
||||||
|
|
||||||
}).run();
|
|
Loading…
Add table
Add a link
Reference in a new issue