mirror of
https://git.cloudron.io/cloudron/peertube-app.git
synced 2024-11-22 01:21:10 +00:00
Add tests
This commit is contained in:
parent
2effab3922
commit
e62edc778e
4 changed files with 1409 additions and 674 deletions
1989
test/package-lock.json
generated
1989
test/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -9,17 +9,17 @@
|
|||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"ejs": "^2.3.4",
|
||||
"ejs": "^3.1.3",
|
||||
"expect.js": "^0.3.1",
|
||||
"mkdirp": "^0.5.1",
|
||||
"mocha": "^2.3.4",
|
||||
"rimraf": "^2.4.4",
|
||||
"superagent": "^1.4.0"
|
||||
"mkdirp": "^1.0.4",
|
||||
"mocha": "^8.0.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"superagent": "^5.3.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"chromedriver": "^2.38.3",
|
||||
"selenium-server-standalone-jar": "^3.3.1",
|
||||
"selenium-webdriver": "^3.3.0",
|
||||
"chromedriver": "^84.0.0",
|
||||
"selenium-server-standalone-jar": "^3.141.59",
|
||||
"selenium-webdriver": "^3.6.0",
|
||||
"superagent": "^1.8.5"
|
||||
}
|
||||
}
|
||||
|
|
78
test/test.js
78
test/test.js
|
@ -19,7 +19,7 @@ var execSync = require('child_process').execSync,
|
|||
util = require('util');
|
||||
|
||||
var by = webdriver.By,
|
||||
Keys = webdriver.Key,
|
||||
Key = webdriver.Key,
|
||||
until = webdriver.until,
|
||||
Builder = require('selenium-webdriver').Builder;
|
||||
|
||||
|
@ -67,28 +67,84 @@ describe('Application life cycle test', function () {
|
|||
browser.get('https://' + app.fqdn + '/login').then(function () {
|
||||
return browser.wait(until.elementLocated(by.id('username')), TEST_TIMEOUT);
|
||||
}).then(function () {
|
||||
return browser.findElement(by.name('username')).sendKeys(username);
|
||||
return browser.findElement(by.id('username')).sendKeys(username);
|
||||
}).then(function () {
|
||||
return browser.findElement(by.name('password')).sendKeys(password);
|
||||
return browser.findElement(by.id('password')).sendKeys(password);
|
||||
}).then(function () {
|
||||
return browser.findElement(by.xpath('//input[@value="Login"]')).click();
|
||||
}).then(function () {
|
||||
return browser.wait(until.elementLocated(by.xpath('//h2[contains(text(), "Welcome to PeerTube")]')), TEST_TIMEOUT);
|
||||
return browser.wait(until.elementLocated(by.xpath('//div[contains(text(), "MY LIBRARY")]')), TEST_TIMEOUT);
|
||||
}).then(function () {
|
||||
done();
|
||||
});
|
||||
}
|
||||
|
||||
function completeSetup(done) {
|
||||
var button;
|
||||
|
||||
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);
|
||||
}).then(function () {
|
||||
return browser.findElement(by.xpath('//a[contains(text(), "Configure my instance")]')).click(); // this opens a new window
|
||||
}).then(function () {
|
||||
return browser.get('https://' + app.fqdn + '/admin/config/edit-custom');
|
||||
}).then(function () {
|
||||
return browser.wait(until.elementLocated(by.xpath('//input[contains(@value, "Update configuration")]')), TEST_TIMEOUT);
|
||||
}).then(function () {
|
||||
button = browser.findElement(by.xpath('//input[contains(@value, "Update configuration")]'));
|
||||
return browser.executeScript('arguments[0].scrollIntoView(true)', button);
|
||||
}).then(function () {
|
||||
return button.click();
|
||||
}).then(function () {
|
||||
return browser.wait(until.elementLocated(by.xpath('//h3[contains(text(), "Success")]')), TEST_TIMEOUT);
|
||||
}).then(function () {
|
||||
console.log('Close the newly opened tab. Will wait for 20 seconds');
|
||||
return browser.sleep(20000);
|
||||
}).then(function () {
|
||||
done();
|
||||
});
|
||||
}
|
||||
|
||||
function uploadVideo(done) {
|
||||
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'));
|
||||
}).then(function () {
|
||||
return browser.sleep(20000); // wait for upload
|
||||
}).then(function () {
|
||||
return browser.findElement(by.xpath('//input[@id="name"]')).sendKeys(Key.chord(Key.CONTROL, 'a'));
|
||||
}).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 () {
|
||||
return browser.sleep(2000);
|
||||
}).then(function () {
|
||||
done();
|
||||
});
|
||||
}
|
||||
|
||||
function videoExists(done) {
|
||||
browser.get('https://' + app.fqdn + '/my-account/videos').then(function () {
|
||||
return browser.wait(until.elementLocated(by.xpath('//a[@title="Cloudron Test Video"]')), TEST_TIMEOUT);
|
||||
}).then(function () {
|
||||
return done();
|
||||
});
|
||||
}
|
||||
|
||||
xit('build app', function () {
|
||||
execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
});
|
||||
|
||||
it('install app', function () {
|
||||
it('install app', function (done) {
|
||||
execSync('cloudron install --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
setTimeout(done, 10000); // takes a bit to create root user in background
|
||||
});
|
||||
|
||||
it('can get app information', getAppInfo);
|
||||
it('can login', login);
|
||||
it('can complete setup', completeSetup);
|
||||
it('can upload video', uploadVideo);
|
||||
it('video exists', videoExists);
|
||||
|
||||
it('backup app', function () {
|
||||
execSync('cloudron backup create --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
|
@ -103,13 +159,15 @@ describe('Application life cycle test', function () {
|
|||
});
|
||||
|
||||
it('can login', login);
|
||||
it('video exists', videoExists);
|
||||
|
||||
it('can restart app', function () {
|
||||
execSync('cloudron restart --app ' + app.id);
|
||||
});
|
||||
|
||||
it('can login', login);
|
||||
it('video exists', videoExists);
|
||||
|
||||
// this is not supported for federation
|
||||
it('move to different location', function (done) {
|
||||
execSync('cloudron configure --location ' + LOCATION + '2 --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
done();
|
||||
|
@ -117,6 +175,7 @@ describe('Application life cycle test', function () {
|
|||
|
||||
it('can get app information', getAppInfo);
|
||||
it('can login', login);
|
||||
it('video exists', videoExists);
|
||||
|
||||
it('uninstall app', function () {
|
||||
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
|
@ -128,11 +187,16 @@ describe('Application life cycle test', function () {
|
|||
});
|
||||
|
||||
it('can get app information', getAppInfo);
|
||||
it('can login', login);
|
||||
it('can login', login);
|
||||
it('can complete setup', completeSetup);
|
||||
it('can upload video', uploadVideo);
|
||||
it('video exists', videoExists);
|
||||
|
||||
it('can update', function () {
|
||||
execSync('cloudron update --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
});
|
||||
it('can login', login);
|
||||
it('video exists', videoExists);
|
||||
|
||||
it('uninstall app', function () {
|
||||
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
|
|
BIN
test/video.mp4
Normal file
BIN
test/video.mp4
Normal file
Binary file not shown.
Loading…
Reference in a new issue