tests: Send frontend test spec list as JSON

pull/5050/head
Richard Hansen 2021-05-09 19:02:15 -04:00
parent 20df34bb67
commit d9782ac628
3 changed files with 3 additions and 6 deletions

View File

@ -30,7 +30,7 @@ const findSpecs = async (specDir) => {
}; };
exports.expressCreateServer = (hookName, args, cb) => { exports.expressCreateServer = (hookName, args, cb) => {
args.app.get('/tests/frontend/frontendTestSpecs.js', (req, res, next) => { args.app.get('/tests/frontend/frontendTestSpecs.json', (req, res, next) => {
(async () => { (async () => {
const modules = []; const modules = [];
await Promise.all(Object.entries(plugins.plugins).map(async ([plugin, def]) => { await Promise.all(Object.entries(plugins.plugins).map(async ([plugin, def]) => {
@ -53,8 +53,7 @@ exports.expressCreateServer = (hookName, args, cb) => {
return aCore ? 1 : -1; return aCore ? 1 : -1;
}); });
console.debug('Sent browser the following test spec modules:', modules); console.debug('Sent browser the following test spec modules:', modules);
res.setHeader('content-type', 'application/javascript'); res.json(modules);
res.end(`window.frontendTestSpecs = ${JSON.stringify(modules, null, 2)};\n`);
})().catch((err) => next(err || new Error(err))); })().catch((err) => next(err || new Error(err)));
}); });

View File

@ -23,7 +23,5 @@
<script src="helper/methods.js"></script> <script src="helper/methods.js"></script>
<script src="helper/ui.js"></script> <script src="helper/ui.js"></script>
<script src="helper/multipleUsers.js"></script> <script src="helper/multipleUsers.js"></script>
<script src="frontendTestSpecs.js"></script>
<script src="runner.js"></script> <script src="runner.js"></script>
</html> </html>

View File

@ -149,7 +149,7 @@ $(() => (async () => {
// asynchronous form of require()). In addition, the performance gains would be minimal because // asynchronous form of require()). In addition, the performance gains would be minimal because
// require-kernel only loads 2 at a time by default. (Increasing the default could cause problems // require-kernel only loads 2 at a time by default. (Increasing the default could cause problems
// because browsers like to limit the number of concurrent fetches.) // because browsers like to limit the number of concurrent fetches.)
for (const spec of window.frontendTestSpecs) { for (const spec of await $.getJSON('frontendTestSpecs.json')) {
const desc = spec const desc = spec
.replace(/^ep_etherpad-lite\/tests\/frontend\/specs\//, '<core> ') .replace(/^ep_etherpad-lite\/tests\/frontend\/specs\//, '<core> ')
.replace(/^([^/ ]*)\/static\/tests\/frontend\/specs\//, '<$1> '); .replace(/^([^/ ]*)\/static\/tests\/frontend\/specs\//, '<$1> ');