2017-07-19 12:58:50 -04:00
|
|
|
/*
|
|
|
|
* Tests signing in & My Stuff according to smoke-tests at:
|
|
|
|
*
|
|
|
|
* https://github.com/LLK/scratchr2/wiki/Smoke-Testing-Test-Cases
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-06-27 10:11:12 -04:00
|
|
|
const SeleniumHelper = require('../selenium-helpers.js');
|
|
|
|
const helper = new SeleniumHelper();
|
|
|
|
|
|
|
|
var tap = require('tap');
|
|
|
|
const test = tap.test;
|
|
|
|
|
|
|
|
const driver = helper.buildDriver('www-smoke test-my-stuff');
|
|
|
|
|
2017-08-11 16:13:52 -04:00
|
|
|
const {
|
|
|
|
clickText,
|
|
|
|
findByXpath,
|
|
|
|
clickXpath,
|
2018-06-27 10:11:12 -04:00
|
|
|
clickButton
|
|
|
|
} = helper;
|
2017-08-11 16:13:52 -04:00
|
|
|
|
2017-07-19 12:58:50 -04:00
|
|
|
var username = process.env.SMOKE_USERNAME;
|
|
|
|
var password = process.env.SMOKE_PASSWORD;
|
|
|
|
|
|
|
|
var rootUrl = process.env.ROOT_URL || 'https://scratch.ly';
|
2018-05-08 16:29:35 -04:00
|
|
|
var url = rootUrl + '/users/' + username;
|
2017-07-19 12:58:50 -04:00
|
|
|
|
2019-06-06 17:34:20 -04:00
|
|
|
tap.plan(7);
|
|
|
|
|
2017-07-19 12:58:50 -04:00
|
|
|
tap.tearDown(function () {
|
|
|
|
driver.quit();
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.beforeEach(function () {
|
|
|
|
return driver.get(url);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Sign in to Scratch using scratchr2 navbar', t => {
|
|
|
|
clickText('Sign in')
|
2018-01-30 11:53:12 -05:00
|
|
|
.then(() => findByXpath('//input[@id="login_dropdown_username"]'))
|
|
|
|
.then((element) => element.sendKeys(username))
|
|
|
|
.then(() => findByXpath('//input[@name="password"]'))
|
|
|
|
.then((element) => element.sendKeys(password))
|
|
|
|
.then(() => clickButton('Sign in'))
|
|
|
|
.then(() => findByXpath('//li[contains(@class, "logged-in-user")' +
|
|
|
|
'and contains(@class, "dropdown")]/span'))
|
|
|
|
.then((element) => element.getText('span'))
|
|
|
|
.then((text) => t.match(text.toLowerCase(), username.substring(0, 10).toLowerCase(),
|
2017-07-19 12:58:50 -04:00
|
|
|
'first part of username should be displayed in navbar'))
|
2018-01-30 11:53:12 -05:00
|
|
|
.then(() => t.end());
|
2017-07-19 12:58:50 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test('Sign in to Scratch & verify My Stuff structure (tabs, title)', t => {
|
2018-09-25 09:29:06 -04:00
|
|
|
clickXpath('//a[contains(@class, "mystuff-icon")]')
|
2018-01-30 11:53:12 -05:00
|
|
|
.then(() => findByXpath('//div[@class="box-head"]/h2'))
|
|
|
|
.then((element) => element.getText('h2'))
|
|
|
|
.then((text) => t.equal('My Stuff', text, 'title should be My Stuff'))
|
|
|
|
.then(() => findByXpath('//li[@data-tab="projects"]/a'))
|
|
|
|
.then((element) => element.getText('a'))
|
|
|
|
.then((text) => t.match(text, 'All Projects', 'All Projects tab should be present'))
|
|
|
|
.then(() => findByXpath('//li[@data-tab="shared"]/a'))
|
|
|
|
.then((element) => element.getText('a'))
|
|
|
|
.then((text) => t.match(text, 'Shared Projects', 'Shared Projects tab should be present'))
|
|
|
|
.then(() => findByXpath('//li[@data-tab="unshared"]/a'))
|
|
|
|
.then((element) => element.getText('a'))
|
|
|
|
.then((text) => t.match(text, 'Unshared Projects', 'Unshared Projects tab should be present'))
|
|
|
|
.then(() => findByXpath('//li[@data-tab="galleries"]/a'))
|
|
|
|
.then((element) => element.getText('a'))
|
|
|
|
.then((text) => t.match(text, 'My Studios', 'My Studios tab should be present'))
|
|
|
|
.then(() => findByXpath('//li[@data-tab="trash"]/a'))
|
|
|
|
.then((element) => element.getText('a'))
|
|
|
|
.then((text) => t.match(text, 'Trash', 'Trash tab should be present'))
|
|
|
|
.then(() => t.end());
|
2017-07-19 12:58:50 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test('clicking See Inside should take you to the editor', t => {
|
2018-09-25 09:29:06 -04:00
|
|
|
clickXpath('//a[contains(@class, "mystuff-icon")]')
|
2018-01-30 11:53:12 -05:00
|
|
|
.then(() => findByXpath('//a[@data-control="edit"]'))
|
|
|
|
.then((element) => element.getText('span'))
|
|
|
|
.then((text) => t.equal(text, 'See inside', 'there should be a "See inside" button'))
|
|
|
|
.then(() => clickXpath('//a[@data-control="edit"]'))
|
|
|
|
.then(() => driver.getCurrentUrl())
|
|
|
|
.then(function (u) {
|
2018-11-27 11:37:22 -05:00
|
|
|
var expectedUrl = '/editor';
|
2018-01-30 11:53:12 -05:00
|
|
|
t.equal(u.substr(-expectedUrl.length), expectedUrl, 'after clicking, the URL should end in #editor');
|
|
|
|
})
|
|
|
|
.then(() => t.end());
|
2017-07-19 12:58:50 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test('clicking a project title should take you to the project page', t => {
|
2018-09-25 09:29:06 -04:00
|
|
|
clickXpath('//a[contains(@class, "mystuff-icon")]')
|
2018-01-30 11:53:12 -05:00
|
|
|
.then(() => clickXpath('//a[@data-control="edit"]'))
|
|
|
|
.then(() => driver.getCurrentUrl())
|
|
|
|
.then(function (u) {
|
|
|
|
var expectedUrlRegExp = new RegExp('/projects/.*[0-9].*/?');
|
|
|
|
t.match(u, expectedUrlRegExp, 'after clicking, the URL should end in projects/PROJECT_ID/');
|
|
|
|
})
|
|
|
|
.then(() => t.end());
|
2017-07-19 12:58:50 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test('Add To button should bring up a list of studios', t => {
|
2018-09-25 09:29:06 -04:00
|
|
|
clickXpath('//a[contains(@class, "mystuff-icon")]')
|
2019-05-16 11:45:29 -04:00
|
|
|
.then(() => clickXpath('//div[@id="sidebar"]/ul/li[@data-tab="shared"]'))
|
2018-01-30 11:53:12 -05:00
|
|
|
.then(() => findByXpath('//div[@data-control="add-to"]'))
|
|
|
|
.then((element) => element.getText('span'))
|
|
|
|
.then((text) => t.equal(text, 'Add to', 'there should be an "Add to" button'))
|
|
|
|
.then(() => clickXpath('//div[@data-control="add-to"]'))
|
|
|
|
.then(() => findByXpath('//div[@class="dropdown-menu"]/ul/li'))
|
|
|
|
.then((element) => element.getText('span'))
|
|
|
|
.then(function (text) {
|
|
|
|
var expectedRegExp = new RegExp('.+');
|
|
|
|
t.match(text, expectedRegExp, 'the dropdown menu should have at least 1 text item in it');
|
|
|
|
})
|
|
|
|
.then(() => t.end());
|
2017-07-19 12:58:50 -04:00
|
|
|
});
|
2017-08-22 16:58:23 -04:00
|
|
|
|
2019-06-03 16:26:02 -04:00
|
|
|
test('+ New Studio button should take you to the studio page', {skip: true}, t => {
|
2018-09-25 09:29:06 -04:00
|
|
|
clickXpath('//a[contains(@class, "mystuff-icon")]')
|
2018-01-30 11:53:12 -05:00
|
|
|
.then(() => clickXpath('//form[@id="new_studio"]/button[@type="submit"]'))
|
|
|
|
.then(() => findByXpath('//div[@id="show-add-project"]'))
|
|
|
|
.then((element) => element.getText('span'))
|
|
|
|
.then((text) => t.equal(text, 'Add projects', 'there should be an "Add projects" button'))
|
|
|
|
.then(() => driver.getCurrentUrl())
|
|
|
|
.then(function (u) {
|
|
|
|
var expectedUrlRegExp = new RegExp('/studios/.*[0-9].*/?');
|
|
|
|
t.match(u, expectedUrlRegExp,
|
|
|
|
'after clicking the + New Studio, the URL should end in studios/STUDIO_ID');
|
|
|
|
})
|
|
|
|
.then(() => t.end());
|
2017-08-22 16:58:23 -04:00
|
|
|
});
|
|
|
|
|
2019-06-26 11:16:56 -04:00
|
|
|
test('+ New Project button should open the editor', {skip: true}, t => {
|
2018-09-25 09:29:06 -04:00
|
|
|
clickXpath('//a[contains(@class, "mystuff-icon")]')
|
2018-01-30 11:53:12 -05:00
|
|
|
.then(() => clickText('+ New Project'))
|
|
|
|
.then(() => driver.getCurrentUrl())
|
|
|
|
.then(function (u) {
|
|
|
|
var expectedUrlRegExp = new RegExp('/projects/editor');
|
|
|
|
t.match(u, expectedUrlRegExp,
|
|
|
|
'after clicking, the URL should end in projects/editor');
|
|
|
|
})
|
|
|
|
.then(() => t.end());
|
2017-08-22 16:58:23 -04:00
|
|
|
});
|