104 lines
3.6 KiB
JavaScript
Executable File
104 lines
3.6 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
import { app, click, cloudronCli, goto, loginOIDC, sendKeys, setupBrowser, takeScreenshot, teardownBrowser, waitFor } from '@cloudron/charlie';
|
|
|
|
/* global it, describe, before, after, afterEach */
|
|
|
|
describe('Application life cycle test', function () {
|
|
const POST_LOGIN_LOCATOR = 'xpath=//span[contains(., "Bookmarks")] | //strong[text()="Successfully authenticated from Cloudron account."]';
|
|
|
|
before(setupBrowser);
|
|
after(teardownBrowser);
|
|
|
|
afterEach(async function () {
|
|
await takeScreenshot(this.currentTest);
|
|
});
|
|
|
|
async function checkRegistrationClosed() {
|
|
const createBtn = 'xpath=//div[@class="sign-in-banner"]/descendant::button/span[contains(text(), "Create account")] | //div[@class="sign-in-banner"]/descendant::a/span[contains(text(), "Create account")]';
|
|
await goto(`https://${app.fqdn}`, createBtn);
|
|
await click(createBtn);
|
|
await waitFor('is currently not possible');
|
|
}
|
|
|
|
async function login(addr, pass) {
|
|
await goto(`https://${app.fqdn}/auth/sign_in`, 'Log in');
|
|
await sendKeys('css=#user_email', addr);
|
|
await sendKeys('css=#user_password', pass);
|
|
await click('Log in');
|
|
}
|
|
|
|
async function loginOidc() {
|
|
await goto(`https://${app.fqdn}/auth/sign_in`, 'xpath=//a[contains(@class, "button") and text()="Cloudron"]');
|
|
await click('xpath=//a[contains(@class, "button") and text()="Cloudron"]');
|
|
await loginOIDC(POST_LOGIN_LOCATOR);
|
|
}
|
|
|
|
async function logout() {
|
|
await goto(`https://${app.fqdn}/settings/preferences/appearance`, 'css=#logout');
|
|
await click('css=#logout');
|
|
await waitFor('css=#user_email');
|
|
}
|
|
|
|
async function checkTimeline() {
|
|
await goto(`https://${app.fqdn}/home`, 'Your home timeline is empty');
|
|
}
|
|
|
|
// No SSO
|
|
it('install app (no sso)', function () { cloudronCli.install({ noSso: true }); });
|
|
|
|
it('has registration closed', checkRegistrationClosed);
|
|
let testPassword;
|
|
it('create a user with CLI', function () {
|
|
const output = cloudronCli.exec('bin/tootctl accounts create test --email=test@cloudron.io').toString();
|
|
console.log(output);
|
|
testPassword = output.slice(output.indexOf('New password: ') + 'New password: '.length).trim();
|
|
console.log(testPassword);
|
|
});
|
|
|
|
it('can login (no sso)', async function () {
|
|
await login('test@cloudron.io', testPassword);
|
|
});
|
|
|
|
it('shows confirmation page', async function () {
|
|
await waitFor('xpath=//a[@href="/auth/confirmation/new"] | //form[@id="edit_user_1"]');
|
|
});
|
|
|
|
it('uninstall app (no sso)', cloudronCli.uninstall);
|
|
|
|
// SSO
|
|
it('install app (sso)', cloudronCli.install);
|
|
|
|
it('registration is disabled', checkRegistrationClosed);
|
|
it('can OIDC login', loginOidc);
|
|
it('can see timeline', checkTimeline);
|
|
it('can logout', logout);
|
|
|
|
it('backup app', cloudronCli.createBackup);
|
|
it('restore app', cloudronCli.restoreFromLatestBackup);
|
|
|
|
it('can OIDC login', loginOidc);
|
|
it('can see timeline', checkTimeline);
|
|
|
|
it('can restart app', cloudronCli.restart);
|
|
it('can see timeline', checkTimeline);
|
|
|
|
it('move to different location', cloudronCli.changeLocation);
|
|
|
|
it('can OIDC login', loginOidc);
|
|
it('can see timeline', checkTimeline);
|
|
|
|
it('uninstall app', cloudronCli.uninstall);
|
|
|
|
// test update
|
|
it('can install app', cloudronCli.appstoreInstall);
|
|
it('can OIDC login', loginOidc);
|
|
it('can logout', logout);
|
|
|
|
it('can update', cloudronCli.update);
|
|
|
|
it('can OIDC login', loginOidc);
|
|
|
|
it('uninstall app', cloudronCli.uninstall);
|
|
});
|