Merge pull request #920 from jwzimmer/issue/gh-590-initial-automated-test

Fix GH-590: initial automated test
This commit is contained in:
jwzimmer 2016-09-21 14:13:03 -04:00 committed by GitHub
commit 5245e93176
2 changed files with 34 additions and 0 deletions

View file

@ -82,6 +82,7 @@
"sass-lint": "1.5.1",
"sass-loader": "2.0.1",
"scratchr2_translations": "git://github.com/LLK/scratchr2_translations.git#master",
"selenium-webdriver": "2.44.0",
"slick-carousel": "1.5.8",
"source-map-support": "0.3.2",
"style-loader": "0.12.3",

View file

@ -0,0 +1,33 @@
/*
* Checks that the links in the navbar on the homepage have the right URLs to redirect to
*
* Test cases: https://github.com/LLK/scratch-www/wiki/Most-Important-Workflows#Create_should_take_you_to_the_editor
*/
var tap=require('tap');
var seleniumWebdriver = require('selenium-webdriver');
//chrome driver
var driver = new seleniumWebdriver.Builder().withCapabilities(seleniumWebdriver.Capabilities.chrome()).build();
//open scratch.ly in a new instance of the browser
driver.get('https://scratch.ly');
//find the create link within the navbar
//the create link depends on whether the user is signed in or not (tips window opens)
tap.test('checkCreateLinkWhenSignedOut', function (t) {
var xPathLink = '//li[contains(@class, "link") and contains(@class, "create")]/a';
var createLinkSignedOut = driver.findElement(seleniumWebdriver.By.xpath(xPathLink));
createLinkSignedOut.getAttribute('href').then( function (url) {
//expected value of the href
var expectedHref = '/projects/editor/?tip_bar=home';
//the create href should match `/projects/editor/?tip_bar=home`
//the create href should be at the end of the URL
t.equal(url.substr(-expectedHref.length), expectedHref);
t.end();
});
});
// close the instance of the browser
driver.quit();