Files
mastodon-app/test/test.js
T
Elias Hackradt 89a6177023 test: migrate xpath selectors to text/regex locators
Replace xpath-based selectors in test.js with charlie's bare-text and
regex locators per the app-test migration guide. Fixes mocha-app CI
failures from xpath escape-hatch enforcement and exact-text mismatches
on Mastodon's banner and timeline copy.
2026-05-13 11:10:44 +02:00

96 lines
3.0 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}`, 'Create account');
await click('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`, 'Cloudron');
await click('Cloudron');
await loginOIDC(/Bookmarks|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('css=a[href="/auth/confirmation/new"], form#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);
});