mirror of
https://git.cloudron.io/cloudron/mastodon-app.git
synced 2025-02-16 15:25:13 +00:00
Fixup tests
This commit is contained in:
parent
3a3de92ae9
commit
47277f165d
1 changed files with 40 additions and 59 deletions
93
test/test.js
93
test/test.js
|
@ -10,11 +10,10 @@
|
||||||
|
|
||||||
require('chromedriver');
|
require('chromedriver');
|
||||||
|
|
||||||
var execSync = require('child_process').execSync,
|
const execSync = require('child_process').execSync,
|
||||||
expect = require('expect.js'),
|
expect = require('expect.js'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
fs = require('fs'),
|
{ Builder, By, until } = require('selenium-webdriver'),
|
||||||
{ Builder, By, Key, until } = require('selenium-webdriver'),
|
|
||||||
{ Options } = require('selenium-webdriver/chrome');
|
{ Options } = require('selenium-webdriver/chrome');
|
||||||
|
|
||||||
if (!process.env.USERNAME || !process.env.PASSWORD) {
|
if (!process.env.USERNAME || !process.env.PASSWORD) {
|
||||||
|
@ -42,68 +41,45 @@ describe('Application life cycle test', function () {
|
||||||
browser.quit();
|
browser.quit();
|
||||||
});
|
});
|
||||||
|
|
||||||
function checkRegistration(mode, done) {
|
async function checkRegistration(mode) {
|
||||||
browser.get('https://' + app.fqdn).then(function () {
|
await browser.get('https://' + app.fqdn);
|
||||||
return browser.sleep(2000);
|
await browser.sleep(2000);
|
||||||
}).then(function () {
|
|
||||||
if (mode === 'none') {
|
if (mode === 'none') {
|
||||||
return browser.wait(until.elementLocated(By.xpath('//button[contains(text(), "is not accepting new members")]')), TEST_TIMEOUT);
|
await browser.wait(until.elementLocated(By.xpath('//button[contains(text(), "is not accepting new members")]')), TEST_TIMEOUT);
|
||||||
} else if (mode === 'open') {
|
} else if (mode === 'open') {
|
||||||
return browser.wait(until.elementLocated(By.xpath('//button[contains(text(), "Sign up")]')), TEST_TIMEOUT);
|
await browser.wait(until.elementLocated(By.xpath('//button[contains(text(), "Sign up")]')), TEST_TIMEOUT);
|
||||||
}
|
}
|
||||||
}).then(function () {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function login(username, password, done) {
|
async function login(username, password) {
|
||||||
browser.get('https://' + app.fqdn + '/auth/sign_in').then(function () { // there is also separate login page at /users/sign_in
|
await browser.get('https://' + app.fqdn + '/auth/sign_in'); // there is also separate login page at /users/sign_in
|
||||||
return browser.wait(until.elementLocated(By.xpath('//button[contains(text(), "Log in")]')), TEST_TIMEOUT);
|
await browser.wait(until.elementLocated(By.xpath('//button[contains(text(), "Log in")]')), TEST_TIMEOUT);
|
||||||
}).then(function () {
|
await browser.findElement(By.id('user_email')).sendKeys(username);
|
||||||
return browser.findElement(By.id('user_email')).sendKeys(username);
|
await browser.findElement(By.id('user_password')).sendKeys(password);
|
||||||
}).then(function () {
|
await browser.findElement(By.xpath('//button[contains(text(), "Log in")]')).click();
|
||||||
return browser.findElement(By.id('user_password')).sendKeys(password);
|
await browser.sleep(3000); // can be wizard or timeline at this point
|
||||||
}).then(function () {
|
|
||||||
return browser.findElement(By.xpath('//button[contains(text(), "Log in")]')).click();
|
|
||||||
}).then(function () {
|
|
||||||
return browser.sleep(3000); // can be wizard or timeline at this point
|
|
||||||
}).then(function () {
|
|
||||||
return done();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function logout(done) {
|
async function logout() {
|
||||||
browser.get('https://' + app.fqdn + '/settings/preferences/appearance').then(function () { // there is also separate login page at /users/sign_in
|
await browser.get('https://' + app.fqdn + '/settings/preferences/appearance'); // there is also separate login page at /users/sign_in
|
||||||
return browser.wait(until.elementLocated(By.id('logout')), TEST_TIMEOUT);
|
await browser.wait(until.elementLocated(By.id('logout')), TEST_TIMEOUT);
|
||||||
}).then(function () {
|
await browser.findElement(By.id('logout')).click();
|
||||||
return browser.findElement(By.id('logout')).click();
|
await browser.wait(until.elementLocated(By.id('user_email')), TEST_TIMEOUT);
|
||||||
}).then(function () {
|
|
||||||
return browser.wait(until.elementLocated(By.id('user_email')), TEST_TIMEOUT);
|
|
||||||
}).then(function () {
|
|
||||||
return done();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function skipTutorial(done) {
|
async function skipTutorial() {
|
||||||
browser.get('https://' + app.fqdn + '/web/start').then(function () {
|
await browser.get('https://' + app.fqdn + '/web/start');
|
||||||
return browser.wait(until.elementLocated(By.xpath('//span[text() = "Done"]')), TEST_TIMEOUT);
|
await browser.wait(until.elementLocated(By.xpath('//button/span[text() = "Done"]')), TEST_TIMEOUT);
|
||||||
}).then(function () {
|
await browser.findElement(By.xpath('//button/span[text() = "Done"]')).click();
|
||||||
return browser.findElement(By.xpath('//span[text() = "Done"]')).click();
|
await browser.sleep(5000); // can be wizard or timeline at this point
|
||||||
}).then(function () {
|
await browser.wait(until.elementLocated(By.xpath('//span[text() = "See some suggestions"]')), TEST_TIMEOUT);
|
||||||
return browser.sleep(3000); // can be wizard or timeline at this point
|
await browser.sleep(5000);
|
||||||
}).then(function () {
|
|
||||||
return browser.wait(until.elementLocated(By.xpath('//span[text() = "See some suggestions"]')), TEST_TIMEOUT);
|
|
||||||
}).then(function () {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkTimeline(done) {
|
async function checkTimeline() {
|
||||||
browser.get('https://' + app.fqdn + '/web/timelines/home').then(function () {
|
await browser.get('https://' + app.fqdn + '/web/timelines/home');
|
||||||
return browser.wait(until.elementLocated(By.xpath('//span[text() = "See some suggestions"]')), TEST_TIMEOUT);
|
await browser.sleep(2000);
|
||||||
}).then(function () {
|
await browser.wait(until.elementLocated(By.xpath('//span[text() = "See some suggestions"]')), TEST_TIMEOUT);
|
||||||
done();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAppInfo() {
|
function getAppInfo() {
|
||||||
|
@ -121,8 +97,13 @@ describe('Application life cycle test', function () {
|
||||||
it('can skip tutorial', skipTutorial);
|
it('can skip tutorial', skipTutorial);
|
||||||
it('can see timeline', checkTimeline);
|
it('can see timeline', checkTimeline);
|
||||||
|
|
||||||
it('backup app', function () { execSync('cloudron backup create --app ' + app.id, EXEC_ARGS); });
|
it('restore app', function () {
|
||||||
it('restore app', function () { execSync('cloudron restore --app ' + app.id, EXEC_ARGS); });
|
const backups = JSON.parse(execSync('cloudron backup list --raw'));
|
||||||
|
execSync('cloudron uninstall --app ' + app.id, EXEC_ARGS);
|
||||||
|
execSync('cloudron install --location ' + LOCATION, EXEC_ARGS);
|
||||||
|
getAppInfo();
|
||||||
|
execSync(`cloudron restore --backup ${backups[0].id} --app ${app.id}`, EXEC_ARGS);
|
||||||
|
});
|
||||||
|
|
||||||
it('can see timeline', checkTimeline);
|
it('can see timeline', checkTimeline);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue