test: fix one more test

remove 500-embed.tpl
This commit is contained in:
Barış Soner Uşaklı
2022-02-17 20:36:49 -05:00
parent 9dccd439f9
commit 1803c29ec9
5 changed files with 21 additions and 26 deletions

View File

@@ -15,6 +15,7 @@ logs/
*.iws
/coverage
/build
/dist
.eslintrc
test/files
*.min.js

View File

@@ -434,7 +434,12 @@ ajaxify.widgets = { render: render };
});
};
let template500Function = null;
ajaxify.loadTemplate = function (template, callback) {
if (template === "500" && template500Function) {
return callback(template500Function);
}
$.ajax({
url: `${config.asset_base_url}/templates/${template}.js`,
dataType: 'text',
@@ -462,6 +467,9 @@ ajaxify.widgets = { render: render };
translator.translate(`[[global:reconnecting-message, ${config.siteTitle}]]`);
Benchpress.registerLoader(ajaxify.loadTemplate);
Benchpress.setGlobal('config', config);
ajaxify.loadTemplate('500', function (renderFunction) {
template500Function = renderFunction;
});
});
}());

View File

@@ -1,15 +0,0 @@
<script>
// TODO: figure out how to embed this, maybe import static tpl into partials/footer/js.tpl
// window.addEventListener('load', function () {
// define(config.relative_path + '/assets/templates/500.js', function () {
// function compiled(helpers, context, get, iter, helper) {
// return '<div class="alert alert-danger">\n\t<strong>[[global:500.title]]</strong>\n\t<p>[[global:500.message]]</p>\n\t<p>' +
// helpers.__escape(get(context && context['path'])) + '</p>\n\t' +
// (get(context && context['error']) ? '<p>' + helpers.__escape(get(context && context['error'])) + '</p>' : '') + '\n\n\t' +
// (get(context && context['returnLink']) ? '\n\t<p>[[error:goback]]</p>\n\t' : '') + '\n</div>\n';
// }
// return compiled;
// });
// });
</script>

View File

@@ -191,17 +191,17 @@ describe('Build', () => {
});
// TODO: doesn't work because plugins js modules are not loaded into build/public/src/modules
// it('should build bundle files', async () => {
// await build.buildAll();
// assert(file.existsSync(path.join(__dirname, '../dist/app.bundle.js')));
// assert(file.existsSync(path.join(__dirname, '../dist/admin.bundle.js')));
// const { res1, body1 } = await helpers.request('GET', `${nconf.get('url')}/dist/app.bundle.js`, {});
// assert(res1.statusCode, 200);
// assert(body1);
// const { res2, body2 } = await helpers.request('GET', `${nconf.get('url')}/dist/admin.bundle.js`, {});
// assert(res2.statusCode, 200);
// assert(body2);
// });
it('should build bundle files', async () => {
await build.buildAll();
assert(file.existsSync(path.join(__dirname, '../dist/app.bundle.js')));
assert(file.existsSync(path.join(__dirname, '../dist/admin.bundle.js')));
let { res, body } = await helpers.request('GET', `/dist/app.bundle.js`, {});
assert(res.statusCode, 200);
assert(body);
({ res, body } = await helpers.request('GET', `/dist/admin.bundle.js`, {}));
assert(res.statusCode, 200);
assert(body);
});
it('should build templates', function (done) {
this.timeout(0);

View File

@@ -252,6 +252,7 @@ async function enableDefaultPlugins() {
const defaultEnabled = [
'nodebb-plugin-dbsearch',
'nodebb-widget-essentials',
'nodebb-plugin-composer-default',
].concat(testPlugins);
winston.info('[install/enableDefaultPlugins] activating default plugins', defaultEnabled);