mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-03-23 19:30:34 -04:00
Move Project Rows tests from Tap to Jest
This commit is contained in:
parent
19edd363c5
commit
b4dfbc0ecf
2 changed files with 59 additions and 93 deletions
test
|
@ -1,93 +0,0 @@
|
|||
/*
|
||||
* Checks that the some of the homepage rows on the homepage are displayed and
|
||||
* contents 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();
|
||||
|
||||
var tap = require('tap');
|
||||
|
||||
const webdriver = require('selenium-webdriver');
|
||||
const driver = helper.buildDriver('www-smoke test_project_rows');
|
||||
|
||||
var rootUrl = process.env.ROOT_URL || 'https://scratch.ly';
|
||||
|
||||
// number of tests in the plan
|
||||
tap.plan(4);
|
||||
|
||||
tap.tearDown(function () {
|
||||
// quit the instance of the browser
|
||||
driver.quit();
|
||||
});
|
||||
|
||||
tap.beforeEach(function () {
|
||||
// load the page with the driver
|
||||
return driver.get(rootUrl);
|
||||
});
|
||||
|
||||
// checks that the title of the first row is Featured Projects
|
||||
tap.test('checkFeaturedProjectsRowTitleWhenSignedOut', function (t) {
|
||||
var xPathLink = '//div[@class="box"]/div[@class="box-header"]/h4';
|
||||
driver.findElement(webdriver.By.xpath(xPathLink))
|
||||
.then(function (element) {
|
||||
element.getText('h4')
|
||||
.then(function (text) {
|
||||
// expected value of the title text
|
||||
var expectedText = 'Featured Projects';
|
||||
t.equal(text, expectedText);
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// checks that the link for a project makes sense
|
||||
tap.test('checkFeaturedProjectsRowLinkWhenSignedOut', function (t) {
|
||||
var xPathLink = '//div[contains(@class, "thumbnail") ' +
|
||||
'and contains(@class, "project") and contains(@class, "slick-slide") ' +
|
||||
'and contains(@class, "slick-active")]/a[@class="thumbnail-image"]';
|
||||
driver.wait(webdriver.until
|
||||
.elementLocated(webdriver.By.xpath(xPathLink)))
|
||||
.then(function (element) {
|
||||
element.getAttribute('href')
|
||||
.then(function (url) {
|
||||
// expected pattern for the project URL
|
||||
// since I don't know the length of the project ID number
|
||||
var expectedUrlRegExp = new RegExp('/projects/.*[0-9].*/?');
|
||||
t.match(url, expectedUrlRegExp);
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// checks that the title of the 2nd row is Featured Studios
|
||||
tap.test('checkFeaturedStudiosRowWhenSignedOut', function (t) {
|
||||
var xPathLink = '//div[@class="box"][2]/div[@class="box-header"]/h4';
|
||||
driver.findElement(webdriver.By.xpath(xPathLink))
|
||||
.then(function (element) {
|
||||
element.getText('h4')
|
||||
.then(function (text) {
|
||||
var expectedText = 'Featured Studios';
|
||||
t.equal(text, expectedText);
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// checks that the link for a studio makes sense
|
||||
tap.test('checkFeaturedStudiosRowLinkWhenSignedOut', function (t) {
|
||||
var xPathLink = '//div[contains(@class, "thumbnail") and contains(@class, "gallery") ' +
|
||||
'and contains(@class, "slick-slide") ' +
|
||||
'and contains(@class, "slick-active")]/a[@class="thumbnail-image"]';
|
||||
driver.findElement(webdriver.By.xpath(xPathLink))
|
||||
.then(function (element) {
|
||||
element.getAttribute('href')
|
||||
.then(function (url) {
|
||||
var expectedUrlRegExp = new RegExp('/studios/.*[0-9].*/?');
|
||||
t.match(url, expectedUrlRegExp);
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
});
|
59
test/integration/project-rows.test.js
Normal file
59
test/integration/project-rows.test.js
Normal file
|
@ -0,0 +1,59 @@
|
|||
const SeleniumHelper = require('./selenium-helpers.js');
|
||||
|
||||
const {
|
||||
clickXpath,
|
||||
findByXpath,
|
||||
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 project rows', () => {
|
||||
beforeAll(async () => {
|
||||
driver = await buildDriver('www-integration project rows');
|
||||
// driver.get(rootUrl);
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
await driver.get(rootUrl);
|
||||
});
|
||||
|
||||
afterAll(async () => await driver.quit());
|
||||
|
||||
test('Featured Projects row title', async () => {
|
||||
let projects = await findByXpath('//div[@class="box"]/div[@class="box-header"]/h4');
|
||||
let projectsText = await projects.getText();
|
||||
await expect(projectsText).toEqual('Featured Projects');
|
||||
});
|
||||
|
||||
test('Featured Project link', async () => {
|
||||
await clickXpath('//div[@class="box"][descendant::text()="Featured Projects"]' +
|
||||
'//div[contains(@class, "thumbnail")][1]/a[@class="thumbnail-image"]');
|
||||
let gfOverlay = await findByXpath('//div[@class="stage-wrapper_stage-wrapper_2bejr box_box_2jjDp"]');
|
||||
let gfOverlayDisplayed = await gfOverlay.isDisplayed();
|
||||
await expect(gfOverlayDisplayed).toBe(true);
|
||||
});
|
||||
|
||||
test('Featured Studios row title', async () => {
|
||||
let studios = await findByXpath('//div[@class="box"][2]/div[@class="box-header"]/h4');
|
||||
let studiosText = await studios.getText();
|
||||
await expect(studiosText).toEqual('Featured Studios');
|
||||
});
|
||||
|
||||
test('Featured Studios link', async () => {
|
||||
await clickXpath('//div[@class="box"][descendant::text()="Featured Studios"]' +
|
||||
'//div[contains(@class, "thumbnail")][1]/a[@class="thumbnail-image"]');
|
||||
let galleryInfo = await findByXpath('//div[contains(@class, "gallery-info")]');
|
||||
let galleryInfoDisplayed = await galleryInfo.isDisplayed();
|
||||
await expect(galleryInfoDisplayed).toBe(true);
|
||||
});
|
||||
});
|
Loading…
Add table
Reference in a new issue