mirror of
https://git.cloudron.io/cloudron/peertube-app.git
synced 2024-11-10 19:21:52 +00:00
Some test fixes
This commit is contained in:
parent
d1ff7ac764
commit
0827c34273
2 changed files with 34 additions and 49 deletions
79
test/test.js
79
test/test.js
|
@ -15,15 +15,9 @@ var execSync = require('child_process').execSync,
|
||||||
expect = require('expect.js'),
|
expect = require('expect.js'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
superagent = require('superagent'),
|
superagent = require('superagent'),
|
||||||
webdriver = require('selenium-webdriver'),
|
util = require('util'),
|
||||||
util = require('util');
|
{ Builder, By, Key, until } = require('selenium-webdriver'),
|
||||||
|
{ Options } = require('selenium-webdriver/chrome');
|
||||||
var by = webdriver.By,
|
|
||||||
Key = webdriver.Key,
|
|
||||||
until = webdriver.until,
|
|
||||||
Builder = require('selenium-webdriver').Builder;
|
|
||||||
|
|
||||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
||||||
|
|
||||||
if (!process.env.USERNAME || !process.env.PASSWORD || !process.env.EMAIL) {
|
if (!process.env.USERNAME || !process.env.PASSWORD || !process.env.EMAIL) {
|
||||||
console.log('USERNAME, EMAIL and PASSWORD env vars need to be set');
|
console.log('USERNAME, EMAIL and PASSWORD env vars need to be set');
|
||||||
|
@ -33,30 +27,23 @@ if (!process.env.USERNAME || !process.env.PASSWORD || !process.env.EMAIL) {
|
||||||
describe('Application life cycle test', function () {
|
describe('Application life cycle test', function () {
|
||||||
this.timeout(0);
|
this.timeout(0);
|
||||||
|
|
||||||
var server, browser = new Builder().forBrowser('chrome').build();
|
var LOCATION = 'test';
|
||||||
|
var TEST_TIMEOUT = parseInt(process.env.TEST_TIMEOUT, 10) || 30000;
|
||||||
|
|
||||||
|
var browser;
|
||||||
|
var app;
|
||||||
var username = process.env.USERNAME;
|
var username = process.env.USERNAME;
|
||||||
var password = process.env.PASSWORD;
|
var password = process.env.PASSWORD;
|
||||||
var email = process.env.EMAIL;
|
var email = process.env.EMAIL;
|
||||||
|
|
||||||
before(function (done) {
|
before(function () {
|
||||||
var seleniumJar= require('selenium-server-standalone-jar');
|
browser = new Builder().forBrowser('chrome').setChromeOptions(new Options().windowSize({ width: 1280, height: 1024 })).build();
|
||||||
var SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;
|
|
||||||
server = new SeleniumServer(seleniumJar.path, { port: 4444 });
|
|
||||||
server.start();
|
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function (done) {
|
after(function () {
|
||||||
browser.quit();
|
browser.quit();
|
||||||
server.stop();
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var LOCATION = 'test';
|
|
||||||
var TEST_TIMEOUT = parseInt(process.env.TEST_TIMEOUT, 10) || 30000;
|
|
||||||
var app;
|
|
||||||
|
|
||||||
function getAppInfo() {
|
function getAppInfo() {
|
||||||
var inspect = JSON.parse(execSync('cloudron inspect'));
|
var inspect = JSON.parse(execSync('cloudron inspect'));
|
||||||
app = inspect.apps.filter(function (a) { return a.location === LOCATION || a.location === LOCATION + '2'; })[0];
|
app = inspect.apps.filter(function (a) { return a.location === LOCATION || a.location === LOCATION + '2'; })[0];
|
||||||
|
@ -65,15 +52,15 @@ describe('Application life cycle test', function () {
|
||||||
|
|
||||||
function login(username, password, done) {
|
function login(username, password, done) {
|
||||||
browser.get('https://' + app.fqdn + '/login').then(function () {
|
browser.get('https://' + app.fqdn + '/login').then(function () {
|
||||||
return browser.wait(until.elementLocated(by.id('username')), TEST_TIMEOUT);
|
return browser.wait(until.elementLocated(By.id('username')), TEST_TIMEOUT);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return browser.findElement(by.id('username')).sendKeys(username);
|
return browser.findElement(By.id('username')).sendKeys(username);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return browser.findElement(by.id('password')).sendKeys(password);
|
return browser.findElement(By.id('password')).sendKeys(password);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return browser.findElement(by.xpath('//input[@value="Login"]')).click();
|
return browser.findElement(By.xpath('//input[@value="Login"]')).click();
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return browser.wait(until.elementLocated(by.xpath('//div[contains(text(), "MY LIBRARY")]')), TEST_TIMEOUT);
|
return browser.wait(until.elementLocated(By.xpath('//div[contains(text(), "MY LIBRARY")]')), TEST_TIMEOUT);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -81,15 +68,17 @@ describe('Application life cycle test', function () {
|
||||||
|
|
||||||
function logout(done) {
|
function logout(done) {
|
||||||
browser.get('https://' + app.fqdn + '/my-account/videos').then(function () {
|
browser.get('https://' + app.fqdn + '/my-account/videos').then(function () {
|
||||||
return browser.wait(until.elementLocated(by.xpath('//a[contains(text(), "My settings")]')), TEST_TIMEOUT);
|
return browser.wait(until.elementLocated(By.xpath('//div[@class="logged-in-display-name"]')), TEST_TIMEOUT);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return browser.findElement(by.xpath('//my-global-icon[@class="dropdown-toggle"]')).click();
|
return browser.sleep(2000);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return browser.sleep(4000);
|
return browser.findElement(By.xpath('//div[@class="logged-in-display-name"]')).click();
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return browser.findElement(by.xpath('//a[contains(text(), "Log out")]')).click();
|
return browser.sleep(2000);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return browser.sleep(4000);
|
return browser.findElement(By.xpath('//a[contains(text(), "Log out")]')).click();
|
||||||
|
}).then(function () {
|
||||||
|
return browser.sleep(2000);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -99,20 +88,20 @@ describe('Application life cycle test', function () {
|
||||||
var button;
|
var button;
|
||||||
|
|
||||||
browser.get('https://' + app.fqdn + '/admin/config/edit-custom').then(function () {
|
browser.get('https://' + app.fqdn + '/admin/config/edit-custom').then(function () {
|
||||||
return browser.wait(until.elementLocated(by.xpath('//a[contains(text(), "Configure my instance")]')), TEST_TIMEOUT);
|
return browser.wait(until.elementLocated(By.xpath('//a[contains(text(), "Configure my instance")]')), TEST_TIMEOUT);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return browser.findElement(by.xpath('//a[contains(text(), "Configure my instance")]')).click(); // this opens a new window
|
return browser.findElement(By.xpath('//a[contains(text(), "Configure my instance")]')).click(); // this opens a new window
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return browser.get('https://' + app.fqdn + '/admin/config/edit-custom');
|
return browser.get('https://' + app.fqdn + '/admin/config/edit-custom');
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return browser.wait(until.elementLocated(by.xpath('//input[contains(@value, "Update configuration")]')), TEST_TIMEOUT);
|
return browser.wait(until.elementLocated(By.xpath('//input[contains(@value, "Update configuration")]')), TEST_TIMEOUT);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
button = browser.findElement(by.xpath('//input[contains(@value, "Update configuration")]'));
|
button = browser.findElement(By.xpath('//input[contains(@value, "Update configuration")]'));
|
||||||
return browser.executeScript('arguments[0].scrollIntoView(true)', button);
|
return browser.executeScript('arguments[0].scrollIntoView(true)', button);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return button.click();
|
return button.click();
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return browser.wait(until.elementLocated(by.xpath('//h3[contains(text(), "Success")]')), TEST_TIMEOUT);
|
return browser.wait(until.elementLocated(By.xpath('//h3[contains(text(), "Success")]')), TEST_TIMEOUT);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
console.log('Close the newly opened tab. Will wait for 20 seconds');
|
console.log('Close the newly opened tab. Will wait for 20 seconds');
|
||||||
return browser.sleep(20000);
|
return browser.sleep(20000);
|
||||||
|
@ -123,15 +112,11 @@ describe('Application life cycle test', function () {
|
||||||
|
|
||||||
function uploadVideo(done) {
|
function uploadVideo(done) {
|
||||||
browser.get('https://' + app.fqdn + '/videos/upload').then(function () {
|
browser.get('https://' + app.fqdn + '/videos/upload').then(function () {
|
||||||
return browser.findElement(by.xpath('//input[@id="videofile" and @type="file"]')).sendKeys(path.resolve(__dirname, './video.mp4'));
|
return browser.findElement(By.xpath('//input[@id="videofile" and @type="file"]')).sendKeys(path.resolve(__dirname, './Cloudron Test Video.mp4'));
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return browser.sleep(20000); // wait for upload
|
return browser.sleep(20000); // wait for upload
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return browser.findElement(by.xpath('//input[@id="name"]')).sendKeys(Key.chord(Key.CONTROL, 'a'));
|
return browser.findElement(By.xpath('//span[text()="Publish"]')).click();
|
||||||
}).then(function () {
|
|
||||||
return browser.findElement(by.xpath('//input[@id="name"]')).sendKeys('Cloudron Test Video');
|
|
||||||
}).then(function () {
|
|
||||||
return browser.findElement(by.xpath('//span[text()="Publish"]')).click();
|
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return browser.sleep(2000);
|
return browser.sleep(2000);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
|
@ -141,7 +126,7 @@ describe('Application life cycle test', function () {
|
||||||
|
|
||||||
function videoExists(done) {
|
function videoExists(done) {
|
||||||
browser.get('https://' + app.fqdn + '/my-account/videos').then(function () {
|
browser.get('https://' + app.fqdn + '/my-account/videos').then(function () {
|
||||||
return browser.wait(until.elementLocated(by.xpath('//a[@title="Cloudron Test Video"]')), TEST_TIMEOUT);
|
return browser.wait(until.elementLocated(By.xpath('//a[@title="Cloudron Test Video"]')), TEST_TIMEOUT);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return done();
|
return done();
|
||||||
});
|
});
|
||||||
|
@ -158,7 +143,7 @@ describe('Application life cycle test', function () {
|
||||||
|
|
||||||
it('can get app information', getAppInfo);
|
it('can get app information', getAppInfo);
|
||||||
it('can root login', login.bind(null, 'root', 'changeme'));
|
it('can root login', login.bind(null, 'root', 'changeme'));
|
||||||
it('can complete setup', completeSetup);
|
xit('can complete setup', completeSetup);
|
||||||
it('can upload video', uploadVideo);
|
it('can upload video', uploadVideo);
|
||||||
it('video exists', videoExists);
|
it('video exists', videoExists);
|
||||||
it('logout', logout);
|
it('logout', logout);
|
||||||
|
|
Loading…
Reference in a new issue