mirror of
https://git.cloudron.io/cloudron/freshrss-app
synced 2026-04-25 12:13:02 +00:00
b08f62e4e2
Made-with: Cursor
140 lines
5.2 KiB
JavaScript
140 lines
5.2 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import assert from 'node:assert/strict';
|
|
import superagent from '@cloudron/superagent';
|
|
|
|
import { app, clearCache, click, cloudronCli, 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.title);
|
|
});
|
|
|
|
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}`, 'css=#loginButton');
|
|
await sendKeys('css=#username', uname);
|
|
await sendKeys('css=#passwordPlain', pass);
|
|
await click('css=#loginButton');
|
|
await waitFor('css=#btn-subscription');
|
|
}
|
|
|
|
async function loginViaOIDC() {
|
|
await clearCache();
|
|
await goto(`https://${app.fqdn}/i/`);
|
|
await loginOIDC('css=#btn-subscription');
|
|
}
|
|
|
|
async function logout() {
|
|
await goto(`https://${app.fqdn}`, 'css=#stream');
|
|
await click('css=.dropdown-toggle');
|
|
await click('xpath=//li/*[contains(@class,"signout")]');
|
|
await waitFor('css=#loginButton');
|
|
}
|
|
|
|
async function addSubscription() {
|
|
const url = 'https://blog.cloudron.io/rss/';
|
|
const addUrl = app.manifest.version === '1.10.0' ? `${baseUrl()}/i/?c=subscription` : `${baseUrl()}/i/?c=subscription&a=add`;
|
|
|
|
await goto(addUrl, 'xpath=//input[@name="url_rss"]');
|
|
await sendKeys('xpath=//input[@name="url_rss"]', url);
|
|
await click('xpath=//form[@id="add_rss"]//button[text()="Add"]');
|
|
await waitFor('xpath=//div[@id="notification" and contains(@class, "good")]');
|
|
}
|
|
|
|
async function enableApi(relogin = true) {
|
|
await goto(`${baseUrl()}/i/?c=auth`);
|
|
|
|
if (relogin) {
|
|
await sendKeys('css=#passwordPlain', admin_password);
|
|
await click('xpath=//button[contains(.,"Login")]');
|
|
}
|
|
|
|
await click('css=#api_enabled');
|
|
await click('xpath=//button[text()="Submit"]');
|
|
}
|
|
|
|
async function checkApiConfiguration() {
|
|
await goto(`${baseUrl()}/api/`, 'xpath=//dd[@id="greaderOutput" and contains(text(), "PASS")]');
|
|
await waitFor('xpath=//dd[@id="feverOutput" and contains(text(), "PASS")]');
|
|
}
|
|
|
|
async function subscriptionExists() {
|
|
await goto(`${baseUrl()}/i/?get=c_1`, 'Cloudron');
|
|
}
|
|
|
|
async function getStaticExtensionFile() {
|
|
const response = await superagent.get(`${baseUrl()}/ext.php?f=xExtension-StickyFeeds/static/script.js&t=js`)
|
|
.buffer(true)
|
|
.ok(() => true);
|
|
assert.strictEqual(response.status, 200);
|
|
assert.ok(response.text.includes('sticky_feeds'));
|
|
}
|
|
|
|
// 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.bind(null, true /* relogin */));
|
|
it('can check configuration', checkApiConfiguration);
|
|
it('subscription exists', subscriptionExists);
|
|
it('can get static extension file', getStaticExtensionFile);
|
|
it('can logout', logout);
|
|
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.bind(null, false /* relogin */));
|
|
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('subscription exists', subscriptionExists);
|
|
it('can get static extension file', getStaticExtensionFile);
|
|
|
|
it('uninstall app', cloudronCli.uninstall);
|
|
});
|