mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-30 10:58:23 -05:00
Merge pull request #4479 from BryceLTaylor/move-footer-tests-to-jest
Move footer integration tests to jest
This commit is contained in:
commit
9f6faee25b
2 changed files with 157 additions and 242 deletions
|
@ -1,242 +0,0 @@
|
||||||
/*
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
const SeleniumHelper = require('../selenium-helpers.js');
|
|
||||||
const helper = new SeleniumHelper();
|
|
||||||
|
|
||||||
const tap = require('tap');
|
|
||||||
|
|
||||||
const webdriver = require('selenium-webdriver');
|
|
||||||
const driver = helper.buildDriver('www-smoke test_footer_links');
|
|
||||||
|
|
||||||
const rootUrl = process.env.ROOT_URL || 'https://scratch.ly';
|
|
||||||
|
|
||||||
// timeout for each test; timeout for suite set at command line level
|
|
||||||
const options = {timeout: 30000};
|
|
||||||
|
|
||||||
tap.tearDown(function () {
|
|
||||||
// quit the instance of the browser
|
|
||||||
driver.quit();
|
|
||||||
});
|
|
||||||
|
|
||||||
tap.beforeEach(function () {
|
|
||||||
// load the page with the driver
|
|
||||||
return driver.get(rootUrl);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Function clicks the link and returns the url of the resulting page
|
|
||||||
|
|
||||||
const clickFooterLinks = function (linkText) {
|
|
||||||
return driver.wait(webdriver.until.elementLocated(webdriver.By.id('footer')))
|
|
||||||
.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
|
|
||||||
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
|
|
||||||
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
|
|
||||||
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
|
|
||||||
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
|
|
||||||
tap.test('clickCreditsLink', options, t => {
|
|
||||||
const linkText = 'Credits';
|
|
||||||
const expectedHref = '/credits';
|
|
||||||
clickFooterLinks(linkText).then(url => {
|
|
||||||
t.equal(url.substr(-expectedHref.length), expectedHref);
|
|
||||||
t.end();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// JOBS
|
|
||||||
tap.test('clickJobsLink', options, t => {
|
|
||||||
const linkText = 'Jobs';
|
|
||||||
const expectedUrl = 'https://www.scratchfoundation.org/opportunities/';
|
|
||||||
clickFooterLinks(linkText).then(url => {
|
|
||||||
t.equal(url, expectedUrl);
|
|
||||||
t.end();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// PRESS
|
|
||||||
tap.test('clickPressLink', options, t => {
|
|
||||||
const linkText = 'Press';
|
|
||||||
const expectedUrl = 'https://www.scratchfoundation.org/media-kit/';
|
|
||||||
clickFooterLinks(linkText).then(url => {
|
|
||||||
t.equal(url, expectedUrl);
|
|
||||||
t.end();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// ==== COMMUNITY column ====
|
|
||||||
|
|
||||||
// COMMUNITY GUIDELINES
|
|
||||||
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
|
|
||||||
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();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// STATISTICS
|
|
||||||
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 ====
|
|
||||||
|
|
||||||
// IDEAS PAGE
|
|
||||||
tap.test('clickIdeasPageLink', options, t => {
|
|
||||||
const linkText = 'Ideas';
|
|
||||||
const expectedHref = '/ideas';
|
|
||||||
clickFooterLinks(linkText).then(url => {
|
|
||||||
t.equal(url.substr(-expectedHref.length), expectedHref);
|
|
||||||
t.end();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// FAQ
|
|
||||||
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
|
|
||||||
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
|
|
||||||
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();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// ==== LEGAL column ====
|
|
||||||
|
|
||||||
// TERMS OF USE
|
|
||||||
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
|
|
||||||
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
|
|
||||||
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 CONFERENCE
|
|
||||||
tap.test('clickScratchConferenceLink', options, t => {
|
|
||||||
const linkText = 'Scratch Conference';
|
|
||||||
const expectedHref = '/conference/20';
|
|
||||||
clickFooterLinks(linkText).then(url => {
|
|
||||||
t.match(url.substr(-(expectedHref.length + 2)), expectedHref);
|
|
||||||
t.end();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
// The following links in are skipped because they are not on scratch.mit.edu
|
|
||||||
|
|
||||||
// SCRATCH STORE
|
|
||||||
// DONATE
|
|
||||||
// SCRATCH WIKI
|
|
||||||
// SCRATCH ED (SCRATCHED)
|
|
||||||
// SCRATCH JR (SCRATCHJR)
|
|
||||||
// SCRATCH DAY
|
|
||||||
// SCRATCH FOUNDATION
|
|
157
test/integration/footer-links.test.js
Normal file
157
test/integration/footer-links.test.js
Normal file
|
@ -0,0 +1,157 @@
|
||||||
|
const SeleniumHelper = require('./selenium-helpers.js');
|
||||||
|
|
||||||
|
const {
|
||||||
|
clickText,
|
||||||
|
buildDriver
|
||||||
|
} = new SeleniumHelper();
|
||||||
|
|
||||||
|
let remote = process.env.SMOKE_REMOTE || false;
|
||||||
|
let rootUrl = process.env.ROOT_URL || 'https://scratch.ly';
|
||||||
|
|
||||||
|
if (remote) {
|
||||||
|
jest.setTimeout(60000);
|
||||||
|
} else {
|
||||||
|
jest.setTimeout(10000);
|
||||||
|
}
|
||||||
|
|
||||||
|
let driver;
|
||||||
|
|
||||||
|
describe('www-integration footer links', () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
driver = await buildDriver('www-integration footer links');
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await driver.get(rootUrl);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => await driver.quit());
|
||||||
|
|
||||||
|
// ==== About Scratch column ====
|
||||||
|
|
||||||
|
test('click About Scratch link', async () => {
|
||||||
|
await clickText('About Scratch');
|
||||||
|
let url = await driver.getCurrentUrl();
|
||||||
|
let pathname = (new URL(url)).pathname;
|
||||||
|
expect(pathname).toMatch(/^\/about\/?$/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('click For Parents link', async () => {
|
||||||
|
await clickText('For Parents');
|
||||||
|
let url = await driver.getCurrentUrl();
|
||||||
|
let pathname = (new URL(url)).pathname;
|
||||||
|
expect(pathname).toMatch(/^\/parents\/?$/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('click For Educators link', async () => {
|
||||||
|
await clickText('For Educators');
|
||||||
|
let url = await driver.getCurrentUrl();
|
||||||
|
let pathname = (new URL(url)).pathname;
|
||||||
|
expect(pathname).toMatch(/^\/educators\/?$/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('click For Developers link', async () => {
|
||||||
|
await clickText('For Developers');
|
||||||
|
let url = await driver.getCurrentUrl();
|
||||||
|
let pathname = (new URL(url)).pathname;
|
||||||
|
expect(pathname).toMatch(/^\/developers\/?$/);
|
||||||
|
});
|
||||||
|
|
||||||
|
// ==== COMMUNITY column ====
|
||||||
|
|
||||||
|
test('click Community Guidelines link', async () => {
|
||||||
|
await clickText('Community Guidelines');
|
||||||
|
let url = await driver.getCurrentUrl();
|
||||||
|
let pathname = (new URL(url)).pathname;
|
||||||
|
expect(pathname).toMatch(/^\/community_guidelines\/?$/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('click Discussion Forums link', async () => {
|
||||||
|
await clickText('Discussion Forums');
|
||||||
|
let url = await driver.getCurrentUrl();
|
||||||
|
let pathname = (new URL(url)).pathname;
|
||||||
|
expect(pathname).toMatch(/^\/discuss\/?$/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('click Statistics link', async () => {
|
||||||
|
await clickText('Statistics');
|
||||||
|
let url = await driver.getCurrentUrl();
|
||||||
|
let pathname = (new URL(url)).pathname;
|
||||||
|
expect(pathname).toMatch(/^\/statistics\/?$/);
|
||||||
|
});
|
||||||
|
|
||||||
|
// ==== SUPPORT column ====
|
||||||
|
|
||||||
|
test('click Ideas link', async () => {
|
||||||
|
await clickText('Ideas');
|
||||||
|
let url = await driver.getCurrentUrl();
|
||||||
|
let pathname = (new URL(url)).pathname;
|
||||||
|
expect(pathname).toMatch(/^\/ideas\/?$/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('click FAQ link', async () => {
|
||||||
|
await clickText('FAQ');
|
||||||
|
let url = await driver.getCurrentUrl();
|
||||||
|
let pathname = (new URL(url)).pathname;
|
||||||
|
expect(pathname).toMatch(/^\/info\/faq\/?$/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('click Download link', async () => {
|
||||||
|
await clickText('Download');
|
||||||
|
let url = await driver.getCurrentUrl();
|
||||||
|
let pathname = (new URL(url)).pathname;
|
||||||
|
expect(pathname).toMatch(/^\/download\/?$/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('click Contact Us link', async () => {
|
||||||
|
await clickText('Contact Us');
|
||||||
|
let url = await driver.getCurrentUrl();
|
||||||
|
let pathname = (new URL(url)).pathname;
|
||||||
|
expect(pathname).toMatch(/^\/contact-us\/?$/);
|
||||||
|
});
|
||||||
|
|
||||||
|
// ==== LEGAL column ====
|
||||||
|
|
||||||
|
test('click Terms of Use link', async () => {
|
||||||
|
await clickText('Terms of Use');
|
||||||
|
let url = await driver.getCurrentUrl();
|
||||||
|
let pathname = (new URL(url)).pathname;
|
||||||
|
expect(pathname).toMatch(/^\/terms_of_use\/?$/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('click Privacy Policy link', async () => {
|
||||||
|
await clickText('Privacy Policy');
|
||||||
|
let url = await driver.getCurrentUrl();
|
||||||
|
let pathname = (new URL(url)).pathname;
|
||||||
|
expect(pathname).toMatch(/^\/privacy_policy\/?$/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('click DMCA link', async () => {
|
||||||
|
await clickText('DMCA');
|
||||||
|
let url = await driver.getCurrentUrl();
|
||||||
|
let pathname = (new URL(url)).pathname;
|
||||||
|
expect(pathname).toMatch(/^\/DMCA\/?$/);
|
||||||
|
});
|
||||||
|
|
||||||
|
// ==== SCRATCH FAMILY column ====
|
||||||
|
|
||||||
|
test('click Scratch Conference link', async () => {
|
||||||
|
await clickText('Scratch Conference');
|
||||||
|
let url = await driver.getCurrentUrl();
|
||||||
|
let pathname = (new URL(url)).pathname;
|
||||||
|
expect(pathname).toMatch(/^\/conference\/2020\/?$/);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// The following links in are skipped because they are not on scratch.mit.edu
|
||||||
|
|
||||||
|
// Jobs
|
||||||
|
// Press
|
||||||
|
// SCRATCH STORE
|
||||||
|
// DONATE
|
||||||
|
// SCRATCH WIKI
|
||||||
|
// SCRATCH ED (SCRATCHED)
|
||||||
|
// SCRATCH JR (SCRATCHJR)
|
||||||
|
// SCRATCH DAY
|
||||||
|
// SCRATCH FOUNDATION
|
Loading…
Reference in a new issue