scratch-www/test/integration/smoke-testing/test_footer_links.js

310 lines
8.3 KiB
JavaScript
Raw Normal View History

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