2017-04-19 17:14:02 -04:00
|
|
|
/*
|
|
|
|
* Checks that the links in the footer on the homepage have the right URLs to redirect to
|
|
|
|
*
|
|
|
|
* Test cases: https://github.com/LLK/scratch-www/wiki/Most-Important-Workflows
|
|
|
|
*/
|
|
|
|
|
2018-01-30 10:33:15 -05:00
|
|
|
const tap = require('tap');
|
2017-04-19 17:14:02 -04:00
|
|
|
|
2017-10-23 20:15:37 -04:00
|
|
|
const {
|
2017-10-24 11:38:07 -04:00
|
|
|
driver,
|
|
|
|
webdriver
|
2017-10-23 20:15:37 -04:00
|
|
|
} = require('../../helpers/selenium-helpers.js');
|
2017-04-19 17:14:02 -04:00
|
|
|
|
2017-10-24 11:38:07 -04:00
|
|
|
// Selenium's promise driver will be deprecated, so we should not rely on it
|
2018-01-30 10:33:15 -05:00
|
|
|
webdriver.SELENIUM_PROMISE_MANAGER = 0;
|
2017-10-24 11:38:07 -04:00
|
|
|
|
2018-01-30 10:33:15 -05:00
|
|
|
const rootUrl = process.env.ROOT_URL || 'https://scratch.ly';
|
2017-04-19 17:14:02 -04:00
|
|
|
|
2018-01-30 10:33:15 -05:00
|
|
|
// timeout for each test; timeout for suite set at command line level
|
|
|
|
const options = {timeout: 30000};
|
2017-04-19 17:14:02 -04:00
|
|
|
|
2018-01-30 10:33:15 -05:00
|
|
|
// number of tests in the plan
|
2017-07-19 12:58:14 -04:00
|
|
|
tap.plan(25);
|
2017-04-19 17:14:02 -04:00
|
|
|
|
|
|
|
tap.tearDown(function () {
|
2018-01-30 10:33:15 -05:00
|
|
|
// quit the instance of the browser
|
2017-04-19 17:14:02 -04:00
|
|
|
driver.quit();
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.beforeEach(function () {
|
2018-01-30 10:33:15 -05:00
|
|
|
// load the page with the driver
|
2017-04-19 17:14:02 -04:00
|
|
|
return driver.get(rootUrl);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Function clicks the link and returns the url of the resulting page
|
2017-10-23 20:15:37 -04:00
|
|
|
|
2018-01-30 10:33:15 -05:00
|
|
|
const clickFooterLinks = function (linkText) {
|
2017-10-24 11:38:07 -04:00
|
|
|
return driver.wait(webdriver.until.elementLocated(webdriver.By.id('footer')))
|
2018-01-30 10:33:15 -05:00
|
|
|
.then(function (element) {
|
|
|
|
return element.findElement(webdriver.By.linkText(linkText));
|
|
|
|
})
|
|
|
|
.then(function (element) {
|
|
|
|
return element.click();
|
|
|
|
})
|
|
|
|
.then(function () {
|
|
|
|
return driver.getCurrentUrl();
|
|
|
|
});
|
|
|
|
};
|
2017-04-19 17:14:02 -04:00
|
|
|
|
|
|
|
// ==== ABOUT SCRATCH column ====
|
|
|
|
|
|
|
|
// ABOUT SCRATCH
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickAboutScratchLink', options, t => {
|
|
|
|
const linkText = 'About Scratch';
|
|
|
|
const expectedHref = '/about';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
|
|
|
// the href should be at the end of the URL
|
2017-04-19 17:14:02 -04:00
|
|
|
t.equal(url.substr(-expectedHref.length), expectedHref);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// FOR PARENTS
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickForParentsLink', options, t => {
|
|
|
|
const linkText = 'For Parents';
|
|
|
|
const expectedHref = '/parents/';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-04-19 17:14:02 -04:00
|
|
|
t.equal(url.substr(-expectedHref.length), expectedHref);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// FOR EDUCATORS
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickForEducatorsLink', options, t => {
|
|
|
|
const linkText = 'For Educators';
|
|
|
|
const expectedHref = '/educators';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-04-19 17:14:02 -04:00
|
|
|
t.equal(url.substr(-expectedHref.length), expectedHref);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// FOR DEVELOPERS
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickForDevelopersScratchLink', options, t => {
|
|
|
|
const linkText = 'For Developers';
|
|
|
|
const expectedHref = '/developers';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-04-19 17:14:02 -04:00
|
|
|
t.equal(url.substr(-expectedHref.length), expectedHref);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// CREDITS
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickCreditsLink', options, t => {
|
|
|
|
const linkText = 'Credits';
|
|
|
|
const expectedHref = '/info/credits';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-04-19 17:14:02 -04:00
|
|
|
t.equal(url.substr(-expectedHref.length), expectedHref);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// JOBS
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickJobsLink', options, t => {
|
|
|
|
const linkText = 'Jobs';
|
|
|
|
const expectedHref = '/jobs';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-04-19 17:14:02 -04:00
|
|
|
t.equal(url.substr(-expectedHref.length), expectedHref);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// PRESS
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickPressLink', options, t => {
|
|
|
|
const linkText = 'Press';
|
|
|
|
const expectedUrl = 'https://wiki.scratch.mit.edu/wiki/Scratch_Press';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-07-19 12:58:14 -04:00
|
|
|
t.equal(url, expectedUrl);
|
2017-04-19 17:14:02 -04:00
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// ==== COMMUNITY column ====
|
|
|
|
|
|
|
|
// COMMUNITY GUIDELINES
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickCommunityGuidelinesLink', options, t => {
|
|
|
|
const linkText = 'Community Guidelines';
|
|
|
|
const expectedHref = '/community_guidelines';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-04-19 17:14:02 -04:00
|
|
|
t.equal(url.substr(-expectedHref.length), expectedHref);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// DISCUSSION FORUMS
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickDiscussionForumsLink', options, t => {
|
|
|
|
const linkText = 'Discussion Forums';
|
|
|
|
const expectedHref = '/discuss/';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-04-19 17:14:02 -04:00
|
|
|
t.equal(url.substr(-expectedHref.length), expectedHref);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// SCRATCH WIKI
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickScratchWikiLink', options, t => {
|
|
|
|
const linkText = 'Scratch Wiki';
|
|
|
|
const expectedUrl = 'https://wiki.scratch.mit.edu/wiki/Scratch_Wiki_Home';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-07-19 12:58:14 -04:00
|
|
|
t.equal(url, expectedUrl);
|
2017-04-19 17:14:02 -04:00
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// STATISTICS
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickStatisticsLink', options, t => {
|
|
|
|
const linkText = 'Statistics';
|
|
|
|
const expectedHref = '/statistics/';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-04-19 17:14:02 -04:00
|
|
|
t.equal(url.substr(-expectedHref.length), expectedHref);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// ==== SUPPORT column ====
|
|
|
|
|
2017-07-19 12:58:14 -04:00
|
|
|
// TIPS PAGE
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickTipsPageLink', options, t => {
|
|
|
|
const linkText = 'Tips';
|
|
|
|
const expectedHref = '/tips';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-04-19 17:14:02 -04:00
|
|
|
t.equal(url.substr(-expectedHref.length), expectedHref);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// FAQ
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickFAQLink', options, t => {
|
|
|
|
const linkText = 'FAQ';
|
|
|
|
const expectedHref = '/info/faq';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-04-19 17:14:02 -04:00
|
|
|
t.equal(url.substr(-expectedHref.length), expectedHref);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// OFFLINE EDITOR
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickOfflineEditorLink', options, t => {
|
|
|
|
const linkText = 'Offline Editor';
|
|
|
|
const expectedHref = '/download';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-04-19 17:14:02 -04:00
|
|
|
t.equal(url.substr(-expectedHref.length), expectedHref);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// CONTACT US
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickContactUsLink', options, t => {
|
|
|
|
const linkText = 'Contact Us';
|
|
|
|
const expectedHref = '/contact-us/';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-04-19 17:14:02 -04:00
|
|
|
t.equal(url.substr(-expectedHref.length), expectedHref);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-07-19 12:58:14 -04:00
|
|
|
// SCRATCH STORE
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickScratchStoreLink', options, t => {
|
|
|
|
const linkText = 'Scratch Store';
|
|
|
|
const expectedUrl = 'https://scratch-foundation.myshopify.com/';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-07-19 12:58:14 -04:00
|
|
|
t.equal(url, expectedUrl);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-04-19 17:14:02 -04:00
|
|
|
// DONATE
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickDonateLink', options, t => {
|
|
|
|
const linkText = 'Donate';
|
|
|
|
const expectedUrl = 'https://secure.donationpay.org/scratchfoundation/';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-07-19 12:58:14 -04:00
|
|
|
t.equal(url, expectedUrl);
|
2017-04-19 17:14:02 -04:00
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// ==== LEGAL column ====
|
|
|
|
|
|
|
|
// TERMS OF USE
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickTermsOfUseLink', options, t => {
|
|
|
|
const linkText = 'Terms of Use';
|
|
|
|
const expectedHref = '/terms_of_use';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-04-19 17:14:02 -04:00
|
|
|
t.equal(url.substr(-expectedHref.length), expectedHref);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// PRIVACY POLICY
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickPrivacyPolicyLink', options, t => {
|
|
|
|
const linkText = 'Privacy Policy';
|
|
|
|
const expectedHref = '/privacy_policy';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-04-19 17:14:02 -04:00
|
|
|
t.equal(url.substr(-expectedHref.length), expectedHref);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// DMCA
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickDMCALink', options, t => {
|
|
|
|
const linkText = 'DMCA';
|
|
|
|
const expectedHref = '/DMCA';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-04-19 17:14:02 -04:00
|
|
|
t.equal(url.substr(-expectedHref.length), expectedHref);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// ==== SCRATCH FAMILY column ====
|
|
|
|
|
|
|
|
// SCRATCH ED (SCRATCHED)
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickScratchEdLink', options, t => {
|
|
|
|
const linkText = 'ScratchEd';
|
|
|
|
const expectedUrl = 'http://scratched.gse.harvard.edu/';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-07-19 12:58:14 -04:00
|
|
|
t.equal(url, expectedUrl);
|
2017-04-19 17:14:02 -04:00
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// SCRATCH JR (SCRATCHJR)
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickScratchJrLink', options, t => {
|
|
|
|
const linkText = 'ScratchJr';
|
|
|
|
const expectedUrl = 'http://www.scratchjr.org/';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-07-19 12:58:14 -04:00
|
|
|
t.equal(url, expectedUrl);
|
2017-04-19 17:14:02 -04:00
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// SCRATCH DAY
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickScratchDayLink', options, t => {
|
|
|
|
const linkText = 'Scratch Day';
|
|
|
|
const expectedUrl = 'https://day.scratch.mit.edu/';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-07-19 12:58:14 -04:00
|
|
|
t.equal(url, expectedUrl);
|
2017-04-19 17:14:02 -04:00
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// SCRATCH CONFERENCE
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickScratchConferenceLink', options, t => {
|
|
|
|
const linkText = 'Scratch Conference';
|
|
|
|
const expectedHref = '/conference';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-04-19 17:14:02 -04:00
|
|
|
t.equal(url.substr(-expectedHref.length), expectedHref);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// SCRATCH FOUNDATION
|
2018-01-30 10:33:15 -05:00
|
|
|
tap.test('clickScratchFoundationLink', options, t => {
|
|
|
|
const linkText = 'Scratch Foundation';
|
|
|
|
const expectedUrl = 'https://www.scratchfoundation.org/';
|
|
|
|
clickFooterLinks(linkText).then(url => {
|
2017-07-19 12:58:14 -04:00
|
|
|
t.equal(url, expectedUrl);
|
2017-04-19 17:14:02 -04:00
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|