mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-22 08:20:36 +01:00
feat: Allow defining active plugins in config (#10767)
* Revert "Revert "feat: cross origin opener policy options (#10710)"" This reverts commit46050ace1a. * Revert "Revert "chore(i18n): fallback strings for new resources: nodebb.admin-settings-advanced"" This reverts commit9f291c07d3. * feat: closes #10719, don't trim children if category is marked section * feat: fire hook to allow plugins to filter the pids returned in a user profile /cc julianlam/nodebb-plugin-support-forum#14 * fix: use `user.hidePrivateData();` more consistently across user retrieval endpoints * feat: Allow defining active plugins in config resolves #10766 * fix: assign the db result to files properly * test: add tests with plugins in config * feat: better theme change handling * feat: add visual indication that plugins can't be activated * test: correct hooks * test: fix test definitions * test: remove instead of resetting nconf to avoid affecting other tests * test: ... I forgot how nconf worked * fix: remove negation * docs: improve wording of error message * feat: reduce code duplication * style: remove a redundant space * fix: remove unused imports * fix: use nconf instead of requiring config.json * fix: await... * fix: second missed await * fix: move back from getActiveIds to getActive * fix: use paths again? * fix: typo * fix: move require into the function * fix: forgot to change back to getActive * test: getActive returns only id * test: accedently commented out some stuff * feat: added note to top of plugins page if \!canChangeState Co-authored-by: Julian Lam <julian@nodebb.org> Co-authored-by: Barış Soner Uşaklı <barisusakli@gmail.com>
This commit is contained in:
@@ -319,6 +319,85 @@ describe('Plugins', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('plugin state set in configuration', () => {
|
||||
const activePlugins = [
|
||||
'nodebb-plugin-markdown',
|
||||
'nodebb-plugin-mentions',
|
||||
];
|
||||
const inactivePlugin = 'nodebb-plugin-emoji';
|
||||
beforeEach((done) => {
|
||||
nconf.set('plugins:active', activePlugins);
|
||||
done();
|
||||
});
|
||||
afterEach((done) => {
|
||||
nconf.set('plugins:active', undefined);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return active plugin state from configuration', (done) => {
|
||||
plugins.isActive(activePlugins[0], (err, isActive) => {
|
||||
assert.ifError(err);
|
||||
assert(isActive);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return inactive plugin state if not in configuration', (done) => {
|
||||
plugins.isActive(inactivePlugin, (err, isActive) => {
|
||||
assert.ifError(err);
|
||||
assert(!isActive);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should get a list of plugins from configuration', (done) => {
|
||||
plugins.list((err, data) => {
|
||||
assert.ifError(err);
|
||||
const keys = ['id', 'name', 'url', 'description', 'latest', 'installed', 'active', 'latest'];
|
||||
assert(Array.isArray(data));
|
||||
keys.forEach((key) => {
|
||||
assert(data[0].hasOwnProperty(key));
|
||||
});
|
||||
data.forEach((pluginData) => {
|
||||
assert.equal(pluginData.active, activePlugins.includes(pluginData.id));
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return a list of only active plugins from configuration', (done) => {
|
||||
plugins.getActive((err, data) => {
|
||||
assert.ifError(err);
|
||||
assert(Array.isArray(data));
|
||||
data.forEach((pluginData) => {
|
||||
console.log(pluginData);
|
||||
assert(activePlugins.includes(pluginData));
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not deactivate a plugin if active plugins are set in configuration', (done) => {
|
||||
assert.rejects(plugins.toggleActive(activePlugins[0]), Error).then(() => {
|
||||
plugins.isActive(activePlugins[0], (err, isActive) => {
|
||||
assert.ifError(err);
|
||||
assert(isActive);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should not activate a plugin if active plugins are set in configuration', (done) => {
|
||||
assert.rejects(plugins.toggleActive(inactivePlugin), Error).then(() => {
|
||||
plugins.isActive(inactivePlugin, (err, isActive) => {
|
||||
assert.ifError(err);
|
||||
assert(!isActive);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user