tests: logic to allow express for admin UI tests
parent
d8c6472583
commit
51b04c9afd
|
@ -4,6 +4,7 @@ const path = require('path');
|
||||||
const npm = require('npm');
|
const npm = require('npm');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
|
const settings = require('../../utils/Settings');
|
||||||
|
|
||||||
exports.expressCreateServer = (hookName, args, cb) => {
|
exports.expressCreateServer = (hookName, args, cb) => {
|
||||||
args.app.get('/tests/frontend/specs_list.js', async (req, res) => {
|
args.app.get('/tests/frontend/specs_list.js', async (req, res) => {
|
||||||
|
@ -18,6 +19,11 @@ exports.expressCreateServer = (hookName, args, cb) => {
|
||||||
// Keep only *.js files
|
// Keep only *.js files
|
||||||
files = files.filter((f) => f.endsWith('.js'));
|
files = files.filter((f) => f.endsWith('.js'));
|
||||||
|
|
||||||
|
// remove admin tests if the setting to enable them isn't in settings.json
|
||||||
|
if (!settings.enableAdminUITests) {
|
||||||
|
files = files.filter((file) => file.indexOf('admin') !== 0);
|
||||||
|
}
|
||||||
|
|
||||||
console.debug('Sent browser the following test specs:', files);
|
console.debug('Sent browser the following test specs:', files);
|
||||||
res.setHeader('content-type', 'application/javascript');
|
res.setHeader('content-type', 'application/javascript');
|
||||||
res.end(`var specs_list = ${JSON.stringify(files)};\n`);
|
res.end(`var specs_list = ${JSON.stringify(files)};\n`);
|
||||||
|
@ -49,7 +55,7 @@ exports.expressCreateServer = (hookName, args, cb) => {
|
||||||
fs.readFile(specFilePath, (err, content) => {
|
fs.readFile(specFilePath, (err, content) => {
|
||||||
if (err) { return res.send(500); }
|
if (err) { return res.send(500); }
|
||||||
|
|
||||||
content = `describe(${JSON.stringify(specFileName)}, function(){ ${content} });`;
|
content = `describe(${JSON.stringify(specFileName)}, function(){${content}});`;
|
||||||
|
|
||||||
if (!specFilePath.endsWith('index.html')) {
|
if (!specFilePath.endsWith('index.html')) {
|
||||||
res.setHeader('content-type', 'application/javascript');
|
res.setHeader('content-type', 'application/javascript');
|
||||||
|
|
Loading…
Reference in New Issue