mirror of
https://git.cloudron.io/cloudron/mastodon-app.git
synced 2024-11-25 09:11:00 +00:00
Fix tests
This commit is contained in:
parent
5deb8763a7
commit
184a246e6c
1 changed files with 13 additions and 22 deletions
33
test/test.js
33
test/test.js
|
@ -32,10 +32,8 @@ describe('Application life cycle test', function () {
|
|||
const EXEC_ARGS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' };
|
||||
|
||||
let browser, app;
|
||||
var athenticated_by_oidc = false;
|
||||
let username = process.env.USERNAME;
|
||||
let password = process.env.PASSWORD;
|
||||
let manifest = require('../CloudronManifest.json');
|
||||
const username = process.env.USERNAME;
|
||||
const password = process.env.PASSWORD;
|
||||
|
||||
before(function () {
|
||||
const chromeOptions = new Options().windowSize({ width: 1280, height: 1024 });
|
||||
|
@ -59,10 +57,6 @@ describe('Application life cycle test', function () {
|
|||
fs.writeFileSync(`./screenshots/${new Date().getTime()}-${this.currentTest.title.replaceAll(' ', '_')}.png`, screenshotData, 'base64');
|
||||
});
|
||||
|
||||
function sleep(millis) {
|
||||
return new Promise(resolve => setTimeout(resolve, millis));
|
||||
}
|
||||
|
||||
async function waitForElement(elem) {
|
||||
await browser.wait(until.elementLocated(elem), TEST_TIMEOUT);
|
||||
await browser.wait(until.elementIsVisible(browser.findElement(elem)), TEST_TIMEOUT);
|
||||
|
@ -98,7 +92,7 @@ describe('Application life cycle test', function () {
|
|||
await browser.sleep(3000); // can be wizard or timeline at this point
|
||||
}
|
||||
|
||||
async function loginOIDC(username, password) {
|
||||
async function loginOIDC(username, password, hasSession) {
|
||||
browser.manage().deleteAllCookies();
|
||||
await browser.get(`https://${app.fqdn}/auth/sign_in`);
|
||||
await browser.sleep(4000);
|
||||
|
@ -106,18 +100,16 @@ describe('Application life cycle test', function () {
|
|||
await browser.findElement(By.xpath('//a[contains(@class, "button") and text()="Cloudron"]')).click();
|
||||
await browser.sleep(4000);
|
||||
|
||||
if (!athenticated_by_oidc) {
|
||||
if (!hasSession) {
|
||||
await waitForElement(By.xpath('//input[@name="username"]'));
|
||||
await browser.findElement(By.xpath('//input[@name="username"]')).sendKeys(username);
|
||||
await browser.findElement(By.xpath('//input[@name="password"]')).sendKeys(password);
|
||||
await browser.sleep(2000);
|
||||
await browser.findElement(By.id('loginSubmitButton')).click();
|
||||
await browser.sleep(2000);
|
||||
|
||||
athenticated_by_oidc = true;
|
||||
}
|
||||
|
||||
await waitForElement(By.xpath('//a[contains(., "Edit profile")] | //strong[text()="Successfully authenticated from Cloudron account."]'));
|
||||
await waitForElement(By.xpath('//span[contains(., "Bookmarks")] | //strong[text()="Successfully authenticated from Cloudron account."]'));
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
|
@ -153,7 +145,7 @@ describe('Application life cycle test', function () {
|
|||
it('has registration open', checkRegistration.bind(null, 'none'));
|
||||
let testPassword;
|
||||
it('create a user with CLI', function () {
|
||||
let output = execSync('cloudron exec --app ' + LOCATION + ' -- bin/tootctl accounts create test --email=test@cloudron.io', { cwd: path.resolve(__dirname, '..'), encoding: 'utf8' });
|
||||
const output = execSync('cloudron exec --app ' + LOCATION + ' -- bin/tootctl accounts create test --email=test@cloudron.io', { cwd: path.resolve(__dirname, '..'), encoding: 'utf8' });
|
||||
console.log(output);
|
||||
testPassword = output.slice(output.indexOf('New password: ') + 'New password: '.length).trim();
|
||||
console.log(testPassword);
|
||||
|
@ -177,7 +169,7 @@ describe('Application life cycle test', function () {
|
|||
|
||||
it('can get app information', getAppInfo);
|
||||
it('registration is disabled', checkRegistration.bind(null, 'none'));
|
||||
it('can OIDC login', loginOIDC.bind(null, username, password));
|
||||
it('can OIDC login', loginOIDC.bind(null, username, password, false));
|
||||
it('can dismiss help', dismissHelp);
|
||||
it('can see timeline', checkTimeline);
|
||||
it('can logout', logout);
|
||||
|
@ -191,7 +183,7 @@ describe('Application life cycle test', function () {
|
|||
execSync(`cloudron restore --backup ${backups[0].id} --app ${app.id}`, EXEC_ARGS);
|
||||
});
|
||||
|
||||
it('can OIDC login', loginOIDC.bind(null, username, password));
|
||||
it('can OIDC login', loginOIDC.bind(null, username, password, true));
|
||||
it('can see timeline', checkTimeline);
|
||||
|
||||
it('can restart app', function () { execSync('cloudron restart --app ' + app.id, EXEC_ARGS); });
|
||||
|
@ -203,7 +195,7 @@ describe('Application life cycle test', function () {
|
|||
});
|
||||
it('can get app information', getAppInfo);
|
||||
|
||||
it('can OIDC login', loginOIDC.bind(null, username, password));
|
||||
it('can OIDC login', loginOIDC.bind(null, username, password, true));
|
||||
it('can see timeline', checkTimeline);
|
||||
|
||||
it('uninstall app', async function () {
|
||||
|
@ -212,10 +204,9 @@ describe('Application life cycle test', function () {
|
|||
});
|
||||
|
||||
// test update
|
||||
it('can install app', function () { execSync('cloudron install --appstore-id ' + manifest.id + ' --location ' + LOCATION, EXEC_ARGS); });
|
||||
it('can install app', function () { execSync('cloudron install --appstore-id org.joinmastodon.cloudronapp --location ' + LOCATION, EXEC_ARGS); });
|
||||
it('can get app information', getAppInfo);
|
||||
// needs to be changed to loginOIDC on the next release
|
||||
it('can OIDC login', loginOIDC.bind(null, username, password));
|
||||
it('can OIDC login', loginOIDC.bind(null, username, password, true));
|
||||
it('can logout', logout);
|
||||
|
||||
it('can update', async function () {
|
||||
|
@ -223,7 +214,7 @@ describe('Application life cycle test', function () {
|
|||
execSync('cloudron update --app ' + LOCATION, EXEC_ARGS);
|
||||
});
|
||||
|
||||
it('can OIDC login', loginOIDC.bind(null, username, password));
|
||||
it('can OIDC login', loginOIDC.bind(null, username, password, true));
|
||||
|
||||
it('uninstall app', function () { execSync('cloudron uninstall --app ' + app.id, EXEC_ARGS); });
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue