mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
tests: Use plugin_defs
to get plugin frontend test spec paths
This commit is contained in:
parent
1b7b96f57e
commit
617267ce71
1 changed files with 5 additions and 4 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fsp = require('fs').promises;
|
const fsp = require('fs').promises;
|
||||||
|
const plugins = require('../../../static/js/pluginfw/plugin_defs');
|
||||||
const sanitizePathname = require('../../utils/sanitizePathname');
|
const sanitizePathname = require('../../utils/sanitizePathname');
|
||||||
const settings = require('../../utils/Settings');
|
const settings = require('../../utils/Settings');
|
||||||
|
|
||||||
|
@ -53,12 +54,12 @@ exports.expressCreateServer = (hookName, args, cb) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getPluginTests = async (callback) => {
|
const getPluginTests = async (callback) => {
|
||||||
const moduleDir = 'node_modules/';
|
|
||||||
const specPath = 'static/tests/frontend/specs';
|
const specPath = 'static/tests/frontend/specs';
|
||||||
const plugins = await fsp.readdir(moduleDir);
|
const specLists = await Promise.all(Object.entries(plugins.plugins).map(async ([plugin, def]) => {
|
||||||
const specLists = await Promise.all(plugins.map(async (plugin) => {
|
if (plugin === 'ep_etherpad-lite') return [];
|
||||||
|
const {package: {path: pluginPath}} = def;
|
||||||
try {
|
try {
|
||||||
const specs = await fsp.readdir(path.join(moduleDir, plugin, specPath));
|
const specs = await fsp.readdir(path.join(pluginPath, specPath));
|
||||||
return specs.map((spec) => `/static/plugins/${plugin}/${specPath}/${spec}`);
|
return specs.map((spec) => `/static/plugins/${plugin}/${specPath}/${spec}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (['ENOENT', 'ENOTDIR'].includes(err.code)) return [];
|
if (['ENOENT', 'ENOTDIR'].includes(err.code)) return [];
|
||||||
|
|
Loading…
Reference in a new issue