mirror of
https://git.cloudron.io/cloudron/freshrss-app
synced 2026-06-20 07:05:50 +00:00
132 lines
4.8 KiB
JavaScript
132 lines
4.8 KiB
JavaScript
|
|
import assert from 'node:assert/strict';
|
|
import superagent from '@cloudron/superagent';
|
|
|
|
import { app, clearCache, click, cloudronCli, press, goto, loginOIDC, password, sendKeys, setupBrowser, takeScreenshot, teardownBrowser, username, waitFor } from '@cloudron/charlie';
|
|
|
|
/* global it, describe, before, after, afterEach */
|
|
|
|
describe('Application life cycle test', function () {
|
|
const admin_username = 'admin';
|
|
const admin_password = 'changeme';
|
|
|
|
before(setupBrowser);
|
|
after(teardownBrowser);
|
|
|
|
afterEach(async function () {
|
|
await takeScreenshot(this.currentTest);
|
|
});
|
|
|
|
function baseUrl() {
|
|
if (app.manifest.version === '1.4.0') return `https://${app.fqdn}/p`;
|
|
return `https://${app.fqdn}`;
|
|
}
|
|
|
|
async function login(uname, pass) {
|
|
await goto(`https://${app.fqdn}`, 'label=Username');
|
|
await sendKeys('label=Username', uname);
|
|
await sendKeys('label=Password', pass);
|
|
await click('Login', { role: 'button' }); // there is a link at the top
|
|
await waitFor('Subscription management');
|
|
}
|
|
|
|
async function loginViaOIDC() {
|
|
await goto(`https://${app.fqdn}/i/`);
|
|
await loginOIDC('css=#btn-subscription');
|
|
}
|
|
|
|
async function addSubscription() {
|
|
await goto(`${baseUrl()}/i/?c=subscription&a=add`, 'label=Feed URL');
|
|
await sendKeys('label=Feed URL', 'https://blog.cloudron.io/rss/');
|
|
await press('label=Feed URL', 'Enter'); // there are multiple "Add" buttons on that page
|
|
await waitFor('RSS feed Cloudron has been added');
|
|
}
|
|
|
|
async function enableApi({ relogin = true } = {}) {
|
|
await goto(`${baseUrl()}/i/?c=auth`);
|
|
|
|
if (relogin) {
|
|
await sendKeys('label=Password', admin_password);
|
|
await click('Login');
|
|
}
|
|
|
|
await click(/Allow API access/);
|
|
await click('Submit');
|
|
await waitFor(/Configuration has been updated/);
|
|
}
|
|
|
|
async function checkApiConfiguration() {
|
|
await goto(`${baseUrl()}/api/`, /PASS/);
|
|
await waitFor(/PASS/);
|
|
}
|
|
|
|
async function subscriptionExists() {
|
|
await goto(`${baseUrl()}/i/?get=c_1`, 'Cloudron');
|
|
}
|
|
|
|
async function getStaticExtensionFile() {
|
|
const url = `${baseUrl()}/ext.php?f=xExtension-StickyFeeds/static/script.js&t=js`;
|
|
const response = await superagent.get(url)
|
|
.set('Cache-Control', 'no-store')
|
|
.set('Pragma', 'no-cache')
|
|
.ok(() => true);
|
|
assert.strictEqual(response.status, 200);
|
|
assert.ok(response.body.toString('utf8').includes('sticky_feeds')); // content-type is application/javascript, so body is a buffer
|
|
}
|
|
|
|
// No SSO
|
|
it('install app (no sso)', () => cloudronCli.install({ noSso: true }));
|
|
|
|
it('can login', login.bind(null, admin_username, admin_password));
|
|
it('can subscribe', addSubscription);
|
|
it('can enable API', () => enableApi({ relogin: true }));
|
|
it('can check configuration', checkApiConfiguration);
|
|
it('subscription exists', subscriptionExists);
|
|
it('can get static extension file', getStaticExtensionFile);
|
|
it('can logout', clearCache);
|
|
it('uninstall app', cloudronCli.uninstall);
|
|
|
|
// SSO
|
|
it('install app (sso)', cloudronCli.install);
|
|
|
|
it('can make user Administrator', () => cloudronCli.exec(`bash -c "php cli/reconfigure.php --default-user ${username}"`));
|
|
it('can login OIDC', () => loginViaOIDC(username, password));
|
|
it('can subscribe', addSubscription);
|
|
it('can enable API', () => enableApi({ relogin: false }));
|
|
it('can check configuration', checkApiConfiguration);
|
|
it('subscription exists', subscriptionExists);
|
|
it('can get static extension file', getStaticExtensionFile);
|
|
|
|
it('backup app', cloudronCli.createBackup);
|
|
it('restore app', cloudronCli.restoreFromLatestBackup);
|
|
|
|
it('can login OIDC', loginViaOIDC);
|
|
it('can check configuration', checkApiConfiguration);
|
|
it('subscription exists', subscriptionExists);
|
|
it('can get static extension file', getStaticExtensionFile);
|
|
|
|
it('move to different location', cloudronCli.changeLocation);
|
|
|
|
it('can login OIDC', loginViaOIDC);
|
|
it('can check configuration', checkApiConfiguration);
|
|
it('subscription exists', subscriptionExists);
|
|
it('can get static extension file', getStaticExtensionFile);
|
|
|
|
it('uninstall app', cloudronCli.uninstall);
|
|
|
|
// test update
|
|
it('can install app for update', cloudronCli.appstoreInstall);
|
|
|
|
it('can login OIDC', loginViaOIDC);
|
|
it('can make user Administrator', () => cloudronCli.exec(`bash -c "php cli/reconfigure.php --default-user ${username}"`));
|
|
it('can subscribe', addSubscription);
|
|
|
|
it('can update', cloudronCli.update);
|
|
|
|
it('can login OIDC', loginViaOIDC);
|
|
it('subscription exists', subscriptionExists);
|
|
it('can get static extension file', getStaticExtensionFile);
|
|
|
|
it('uninstall app', cloudronCli.uninstall);
|
|
});
|