0bf99cc7ae
- Drop `await clearCache()` from login/auth helpers; clearing cache before every login is no longer necessary now that charlie isolates sessions. - Replace `logout` helpers with `clearCache` directly in `it()` calls; the helpers were either thin wrappers around `clearCache()` or did real navigation that is no longer worth the maintenance. - Simplify `xpath=//button[text()=...]` / `[contains(., ...)]` button text selectors to charlie's bare-string (or RegExp for OR-clauses) form.
96 lines
3.5 KiB
JavaScript
Executable File
96 lines
3.5 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
import { app, clearCache, click, cloudronCli, goto, loginOIDC, sendKeys, setupBrowser, takeScreenshot, teardownBrowser, waitFor } from '@cloudron/charlie';
|
|
|
|
/* global it, describe, before, after, afterEach */
|
|
|
|
describe('Application life cycle test', function () {
|
|
|
|
before(setupBrowser);
|
|
after(teardownBrowser);
|
|
|
|
afterEach(async function () {
|
|
await takeScreenshot(this.currentTest);
|
|
});
|
|
|
|
async function checkRegistrationClosed() {
|
|
await goto(`https://${app.fqdn}`, '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 click('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 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('xpath=//span[contains(., "Bookmarks")] | //strong[text()="Successfully authenticated from Cloudron account."]');
|
|
}
|
|
|
|
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', clearCache);
|
|
|
|
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 for update', cloudronCli.appstoreInstall);
|
|
it('can OIDC login', loginOidc);
|
|
it('can logout', clearCache);
|
|
|
|
it('can update', cloudronCli.update);
|
|
|
|
it('can OIDC login', loginOidc);
|
|
|
|
it('uninstall app', cloudronCli.uninstall);
|
|
});
|