diff --git a/test/api.js b/test/api.js index e4c28cfcef..7401b152ea 100644 --- a/test/api.js +++ b/test/api.js @@ -135,6 +135,12 @@ describe('API', async () => { title: 'Test Topic 2', content: 'Test topic 2 content', }); + await topics.post({ + uid: unprivUid, + cid: testCategory.cid, + title: 'Test Topic 3', + content: 'Test topic 3 content', + }); // Create a sample flag await flags.create('post', 1, unprivUid, 'sample reasons', Date.now()); @@ -332,7 +338,7 @@ describe('API', async () => { } }); - it('should resolve with a 200 when called', async () => { + it('should not error out when called', async () => { await setupData(); if (csrfToken) { @@ -372,7 +378,7 @@ describe('API', async () => { }); } } catch (e) { - assert(!e, `${method.toUpperCase()} ${path} resolved with ${e.message}`); + assert(!e, `${method.toUpperCase()} ${path} errored with: ${e.message}`); } }); diff --git a/test/authentication.js b/test/authentication.js index 6a1d255bac..35be6ad0c2 100644 --- a/test/authentication.js +++ b/test/authentication.js @@ -422,7 +422,7 @@ describe('authentication', function () { loginUser('ginger@nodebb.org', '123456', function (err, response, body) { meta.config.allowLoginWith = 'username-email'; assert.ifError(err); - assert.equal(response.statusCode, 500); + assert.equal(response.statusCode, 400); assert.equal(body, '[[error:wrong-login-type-username]]'); done(); }); diff --git a/test/controllers.js b/test/controllers.js index 670ab3be34..382e1ccd62 100644 --- a/test/controllers.js +++ b/test/controllers.js @@ -95,17 +95,17 @@ describe('Controllers', function () { assert(hookData.res); assert(hookData.next); - hookData.res.render('custom', { + hookData.res.render('mycustompage', { works: true, }); } var message = utils.generateUUID(); - var name = 'custom.tpl'; + var name = 'mycustompage.tpl'; var tplPath = path.join(nconf.get('views_dir'), name); before(async () => { plugins.registerHook('myTestPlugin', { - hook: 'action:homepage.get:custom', + hook: 'action:homepage.get:mycustompage', method: hookMethod, }); @@ -224,14 +224,14 @@ describe('Controllers', function () { }); it('api should work with hook', function (done) { - meta.configs.set('homePageRoute', 'custom', function (err) { + meta.configs.set('homePageRoute', 'mycustompage', function (err) { assert.ifError(err); request(nconf.get('url') + '/api', { json: true }, function (err, res, body) { assert.ifError(err); assert.equal(res.statusCode, 200); assert.equal(body.works, true); - assert.equal(body.template.custom, true); + assert.equal(body.template.mycustompage, true); done(); }); @@ -239,7 +239,7 @@ describe('Controllers', function () { }); it('should render with hook', function (done) { - meta.configs.set('homePageRoute', 'custom', function (err) { + meta.configs.set('homePageRoute', 'mycustompage', function (err) { assert.ifError(err); request(nconf.get('url'), function (err, res, body) { diff --git a/test/topicThumbs.js b/test/topicThumbs.js index 7be9e56f89..bc952139d3 100644 --- a/test/topicThumbs.js +++ b/test/topicThumbs.js @@ -94,7 +94,7 @@ describe('Topic thumbs', () => { assert.deepStrictEqual(thumbs, [{ id: 1, name: 'test.png', - url: `${nconf.get('upload_url')}${relativeThumbPaths[0]}`, + url: `${nconf.get('relative_path')}${nconf.get('upload_url')}${relativeThumbPaths[0]}`, }]); }); @@ -104,7 +104,7 @@ describe('Topic thumbs', () => { [{ id: 1, name: 'test.png', - url: `${nconf.get('upload_url')}${relativeThumbPaths[0]}`, + url: `${nconf.get('relative_path')}${nconf.get('upload_url')}${relativeThumbPaths[0]}`, }], [], ]); @@ -153,7 +153,7 @@ describe('Topic thumbs', () => { { id: 2, name: 'test.png', - url: `${nconf.get('upload_url')}${relativeThumbPaths[0]}`, + url: `${nconf.get('relative_path')}${nconf.get('upload_url')}${relativeThumbPaths[0]}`, }, { id: 2, @@ -163,7 +163,7 @@ describe('Topic thumbs', () => { { id: 2, name: 'test2.png', - url: `${nconf.get('upload_url')}${relativeThumbPaths[1]}`, + url: `${nconf.get('relative_path')}${nconf.get('upload_url')}${relativeThumbPaths[1]}`, }, ]); }); diff --git a/test/translator.js b/test/translator.js index 1776c06b9b..bd6d0f0fbb 100644 --- a/test/translator.js +++ b/test/translator.js @@ -135,6 +135,16 @@ describe('new Translator(language)', function () { }); }); + it('should translate escaped translation arguments properly', function () { + // https://github.com/NodeBB/NodeBB/issues/9206 + var translator = Translator.create('en-GB'); + + var key = '[[notifications:upvoted_your_post_in, test1, error: Error: [[error:group-name-too-long]] on NodeBB Upgrade]]'; + return translator.translate(key).then(function (translated) { + assert.strictEqual(translated, 'test1 has upvoted your post in error: Error: [[error:group-name-too-long]] on NodeBB Upgrade.'); + }); + }); + it('should properly escape and ignore % and \\, in arguments', function () { var translator = Translator.create('en-GB');