2021-02-07 11:32:57 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
describe('Plugins page', function () {
|
|
|
|
function timeout(ms) {
|
|
|
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
|
|
}
|
|
|
|
|
|
|
|
before(async function () {
|
|
|
|
let success = false;
|
|
|
|
$.ajax({
|
|
|
|
url: `${location.protocol}//admin:changeme@${location.hostname}:${location.port}/admin`,
|
|
|
|
type: 'GET',
|
|
|
|
success: () => success = true,
|
|
|
|
});
|
|
|
|
await helper.waitForPromise(() => success === true);
|
|
|
|
});
|
|
|
|
|
|
|
|
// create a new pad before each test run
|
|
|
|
beforeEach(async function () {
|
|
|
|
helper.newAdmin('plugins');
|
2023-07-01 17:59:59 +02:00
|
|
|
// menu is plugins, settings, help - so at least three entries atm
|
2021-02-07 11:32:57 +00:00
|
|
|
await helper.waitForPromise(
|
2021-02-12 20:04:42 +00:00
|
|
|
() => helper.admin$ && helper.admin$('.menu').find('li').length >= 3, 30000);
|
2021-02-07 11:32:57 +00:00
|
|
|
});
|
|
|
|
|
2023-07-01 17:59:59 +02:00
|
|
|
it('Lists some plugins assuming more than 50 available plugins', async function () {
|
2021-02-12 20:04:42 +00:00
|
|
|
await helper.waitForPromise(() => helper.admin$('.results').children().length > 50, 20000);
|
2021-02-07 11:32:57 +00:00
|
|
|
});
|
|
|
|
|
2023-07-01 17:59:59 +02:00
|
|
|
it('Searches for plugin ep_font_color', async function () {
|
2021-02-07 11:32:57 +00:00
|
|
|
helper.admin$('#search-query').val('ep_font_color');
|
2021-07-19 07:39:49 +02:00
|
|
|
await helper.waitForPromise(() => helper.admin$('.results').children().length > 0, 10000);
|
2023-07-01 17:59:59 +02:00
|
|
|
// multiple packages may be found
|
|
|
|
await helper.waitForPromise(() => helper.admin$('.results').children().length < 20, 10000);
|
|
|
|
await helper.waitForPromise(() => helper.admin$('.results .ep_font_color').length === 1, 10000);
|
2021-02-07 11:32:57 +00:00
|
|
|
});
|
|
|
|
|
2023-07-01 17:59:59 +02:00
|
|
|
it('Second search for ep_font_size does not return old result', async function () {
|
|
|
|
helper.admin$('#search-query').val('ep_font_size');
|
|
|
|
await helper.waitForPromise(() => helper.admin$('.results').children().length > 0, 10000);
|
|
|
|
// multiple packages may be found
|
|
|
|
await helper.waitForPromise(() => helper.admin$('.results').children().length < 20, 10000);
|
|
|
|
await helper.waitForPromise(() => helper.admin$('.results .ep_font_size').length === 1, 10000);
|
|
|
|
await helper.waitForPromise(() => helper.admin$('.results .ep_font_color').length === 0, 10000);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Searches for plugins ep_font_ (partial match)', async function () {
|
|
|
|
helper.admin$('#search-query').val('ep_font');
|
|
|
|
await helper.waitForPromise(() => helper.admin$('.results').children().length > 0, 10000);
|
|
|
|
// multiple packages may be found
|
|
|
|
await helper.waitForPromise(() => helper.admin$('.results').children().length < 50, 10000);
|
|
|
|
await helper.waitForPromise(() => helper.admin$('.results .ep_font_size').length === 1, 10000);
|
|
|
|
await helper.waitForPromise(() => helper.admin$('.results .ep_font_color').length === 1, 10000);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Attempt to Update a plugin (minor version update)', async function () {
|
2021-02-12 20:04:42 +00:00
|
|
|
this.timeout(280000);
|
|
|
|
|
2023-07-01 17:59:59 +02:00
|
|
|
// available plugin list should load
|
2021-02-12 20:04:42 +00:00
|
|
|
await helper.waitForPromise(() => helper.admin$('.results').children().length > 50, 20000);
|
2021-02-07 11:32:57 +00:00
|
|
|
|
2023-07-01 17:59:59 +02:00
|
|
|
// ep_align should be installed (via step in workflow)
|
|
|
|
await helper.waitForPromise(() => helper.admin$('#installed-plugins .ep_align').length >= 1, 10000);
|
2021-02-07 11:32:57 +00:00
|
|
|
|
2023-07-01 17:59:59 +02:00
|
|
|
let latestVersion;
|
2021-02-07 11:32:57 +00:00
|
|
|
await helper.waitForPromise(
|
2023-07-01 17:59:59 +02:00
|
|
|
() => {
|
|
|
|
latestVersion = helper.admin$('#installed-plugins .ep_align .version').text();
|
|
|
|
return latestVersion === '0.2.27';
|
|
|
|
}
|
|
|
|
);
|
2021-02-07 11:32:57 +00:00
|
|
|
|
|
|
|
const minorVersionBefore =
|
2023-07-01 17:59:59 +02:00
|
|
|
parseInt(latestVersion.split('.')[1]);
|
2021-02-07 11:32:57 +00:00
|
|
|
|
2023-07-01 17:59:59 +02:00
|
|
|
await helper.waitForPromise(
|
|
|
|
() => helper.admin$('#installed-plugins .ep_align .do-update').length === 1);
|
2021-02-07 11:32:57 +00:00
|
|
|
|
2023-07-01 17:59:59 +02:00
|
|
|
helper.admin$('#installed-plugins .ep_align .do-update').click();
|
2021-02-07 11:32:57 +00:00
|
|
|
|
|
|
|
// ensure its showing as Updating
|
2023-07-01 17:59:59 +02:00
|
|
|
// this assumes that updating will take some time, so there is a message showing up
|
|
|
|
// in the mean time
|
2021-02-07 11:32:57 +00:00
|
|
|
await helper.waitForPromise(
|
2023-07-01 17:59:59 +02:00
|
|
|
() => {
|
|
|
|
const message = helper.admin$('#installed-plugins .ep_align .message').text();
|
|
|
|
return message === 'Updating';
|
|
|
|
}, 120000)
|
2021-02-07 11:32:57 +00:00
|
|
|
|
|
|
|
// Ensure it's a higher minor version IE 0.3.x as 0.2.x was installed
|
|
|
|
// Coverage for https://github.com/ether/etherpad-lite/issues/4536
|
2023-07-01 17:59:59 +02:00
|
|
|
await helper.waitForPromise(() => parseInt(helper.admin$('#installed-plugins .ep_align .version')
|
2021-02-07 11:32:57 +00:00
|
|
|
.text()
|
|
|
|
.split('.')[1]) > minorVersionBefore, 60000, 1000);
|
2023-07-01 17:59:59 +02:00
|
|
|
|
|
|
|
// ensure it's the latest version
|
|
|
|
await helper.waitForPromise(
|
|
|
|
() => helper.admin$('.ep_align .do-update').length === 0);
|
2021-02-07 11:32:57 +00:00
|
|
|
});
|
2023-07-01 17:59:59 +02:00
|
|
|
|
2021-02-07 11:32:57 +00:00
|
|
|
it('Attempt to Install a plugin', async function () {
|
2021-02-12 20:04:42 +00:00
|
|
|
this.timeout(280000);
|
2021-02-07 11:32:57 +00:00
|
|
|
|
2021-02-12 20:04:42 +00:00
|
|
|
helper.admin$('#search-query').val('ep_headings2');
|
2023-07-01 17:59:59 +02:00
|
|
|
await helper.waitForPromise(() => helper.admin$('.results').children().length > 0, 10000);
|
|
|
|
await helper.waitForPromise(() => helper.admin$('.results').children().length < 50, 10000);
|
2021-02-07 11:32:57 +00:00
|
|
|
|
2023-08-08 18:26:25 +02:00
|
|
|
helper.admin$('.ep_headings2 .do-install').trigger('click');
|
2021-02-07 11:32:57 +00:00
|
|
|
// ensure install has attempted to be started
|
|
|
|
await helper.waitForPromise(
|
2023-07-01 17:59:59 +02:00
|
|
|
() => helper.admin$('.ep_headings2 .do-install').length > 0, 120000);
|
2021-02-07 11:32:57 +00:00
|
|
|
// ensure its not showing installing any more
|
|
|
|
await helper.waitForPromise(
|
2021-02-12 20:04:42 +00:00
|
|
|
() => helper.admin$('.ep_headings2 .message').text() === '', 180000);
|
2021-02-07 11:32:57 +00:00
|
|
|
// ensure uninstall button is visible
|
|
|
|
await helper.waitForPromise(
|
2023-07-01 17:59:59 +02:00
|
|
|
() => helper.admin$('#installed-plugins .ep_headings2 .do-uninstall').length > 0, 120000);
|
2021-02-07 11:32:57 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Attempt to Uninstall a plugin', async function () {
|
2023-07-01 17:59:59 +02:00
|
|
|
this.timeout(280000);
|
|
|
|
|
2021-02-07 11:32:57 +00:00
|
|
|
await helper.waitForPromise(
|
2023-07-01 17:59:59 +02:00
|
|
|
() => helper.admin$('#installed-plugins .ep_headings2 .do-uninstall').length > 0, 120000);
|
2021-02-07 11:32:57 +00:00
|
|
|
|
2023-07-01 17:59:59 +02:00
|
|
|
helper.admin$('#installed-plugins .ep_headings2 .do-uninstall').click();
|
2021-02-07 11:32:57 +00:00
|
|
|
|
|
|
|
// ensure its showing uninstalling
|
2023-07-01 17:59:59 +02:00
|
|
|
// this assumes that uninstalling will take some time, so there is a message showing up
|
|
|
|
// in the mean time
|
2021-02-07 11:32:57 +00:00
|
|
|
await helper.waitForPromise(
|
2023-07-01 17:59:59 +02:00
|
|
|
() => helper.admin$('#installed-plugins .ep_headings2 .message')
|
2021-02-07 11:32:57 +00:00
|
|
|
.text() === 'Uninstalling', 120000);
|
|
|
|
// ensure its gone
|
2023-07-01 17:59:59 +02:00
|
|
|
await helper.waitForPromise(() => helper.admin$('#installed-plugins .ep_headings2').length === 0, 200000);
|
2021-02-07 11:32:57 +00:00
|
|
|
|
2023-07-01 17:59:59 +02:00
|
|
|
// ensure search still works
|
2021-02-07 11:32:57 +00:00
|
|
|
helper.admin$('#search-query').val('ep_font');
|
2023-07-01 17:59:59 +02:00
|
|
|
await helper.waitForPromise(() => helper.admin$('.results').children().length < 50, 240000);
|
2021-02-07 11:32:57 +00:00
|
|
|
await helper.waitForPromise(() => helper.admin$('.results').children().length > 0, 1000);
|
2023-07-01 17:59:59 +02:00
|
|
|
await helper.waitForPromise(() => helper.admin$('.results .ep_font_size').length === 1, 10000);
|
|
|
|
await helper.waitForPromise(() => helper.admin$('.results .ep_font_color').length === 1, 10000);
|
2021-02-07 11:32:57 +00:00
|
|
|
});
|
|
|
|
});
|