From 9b75b1ede29ffc13dd052c62030e758bbe049ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 10 Jan 2022 18:41:07 -0500 Subject: [PATCH] test: update tag tests, fix linux symlink error --- src/meta/js.js | 10 ++++------ test/topics.js | 30 +++++++++++++++--------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/meta/js.js b/src/meta/js.js index 34804fedf1..f2ab733741 100644 --- a/src/meta/js.js +++ b/src/meta/js.js @@ -155,15 +155,13 @@ async function minifyModules(modules, fork) { async function linkModules() { const { modules } = JS.scripts; - const uniqDirs = _.uniq( - Object.keys(modules).map(relPath => path.dirname(path.join(__dirname, '../../build/public/src/modules', relPath))) - ); - await Promise.all(uniqDirs.map(mkdirp)); - await Promise.all(Object.keys(modules).map(async (relPath) => { const srcPath = path.join(__dirname, '../../', modules[relPath]); const destPath = path.join(__dirname, '../../build/public/src/modules', relPath); - const stats = await fs.promises.stat(srcPath); + const [stats] = await Promise.all([ + fs.promises.stat(srcPath), + mkdirp(path.dirname(destPath)), + ]); if (stats.isDirectory()) { await file.linkDirs(srcPath, destPath, true); return; diff --git a/test/topics.js b/test/topics.js index 851ac3fd44..b53e90f69e 100644 --- a/test/topics.js +++ b/test/topics.js @@ -1769,10 +1769,10 @@ describe('Topic\'s', () => { assert.equal(data.matchCount, 4); assert.equal(data.pageCount, 1); const tagData = [ - { value: 'nodebb', valueEscaped: 'nodebb', score: 3, class: 'nodebb' }, - { value: 'node icon', valueEscaped: 'node icon', score: 1, class: 'node-icon' }, - { value: 'nodejs', valueEscaped: 'nodejs', score: 1, class: 'nodejs' }, - { value: 'nosql', valueEscaped: 'nosql', score: 1, class: 'nosql' }, + { value: 'nodebb', valueEscaped: 'nodebb', valueEncoded: 'nodebb', score: 3, class: 'nodebb' }, + { value: 'node icon', valueEscaped: 'node icon', valueEncoded: 'node%20icon', score: 1, class: 'node-icon' }, + { value: 'nodejs', valueEscaped: 'nodejs', valueEncoded: 'nodejs', score: 1, class: 'nodejs' }, + { value: 'nosql', valueEscaped: 'nosql', valueEncoded: 'nosql', score: 1, class: 'nosql' }, ]; assert.deepEqual(data.tags, tagData); @@ -2012,17 +2012,17 @@ describe('Topic\'s', () => { await topics.post({ uid: adminUid, tags: ['cattag1'], title: title, content: 'topic 1 content', cid: cid }); let result = await topics.getCategoryTagsData(cid, 0, -1); assert.deepStrictEqual(result, [ - { value: 'cattag1', score: 3, valueEscaped: 'cattag1', class: 'cattag1' }, - { value: 'cattag2', score: 2, valueEscaped: 'cattag2', class: 'cattag2' }, - { value: 'cattag3', score: 1, valueEscaped: 'cattag3', class: 'cattag3' }, + { value: 'cattag1', score: 3, valueEscaped: 'cattag1', valueEncoded: 'cattag1', class: 'cattag1' }, + { value: 'cattag2', score: 2, valueEscaped: 'cattag2', valueEncoded: 'cattag2', class: 'cattag2' }, + { value: 'cattag3', score: 1, valueEscaped: 'cattag3', valueEncoded: 'cattag3', class: 'cattag3' }, ]); // after purging values should update properly await topics.purge(postResult.topicData.tid, adminUid); result = await topics.getCategoryTagsData(cid, 0, -1); assert.deepStrictEqual(result, [ - { value: 'cattag1', score: 2, valueEscaped: 'cattag1', class: 'cattag1' }, - { value: 'cattag2', score: 1, valueEscaped: 'cattag2', class: 'cattag2' }, + { value: 'cattag1', score: 2, valueEscaped: 'cattag1', valueEncoded: 'cattag1', class: 'cattag1' }, + { value: 'cattag2', score: 1, valueEscaped: 'cattag2', valueEncoded: 'cattag2', class: 'cattag2' }, ]); }); @@ -2041,11 +2041,11 @@ describe('Topic\'s', () => { let result1 = await topics.getCategoryTagsData(cid1, 0, -1); let result2 = await topics.getCategoryTagsData(cid2, 0, -1); assert.deepStrictEqual(result1, [ - { value: 'movedtag1', score: 2, valueEscaped: 'movedtag1', class: 'movedtag1' }, - { value: 'movedtag2', score: 1, valueEscaped: 'movedtag2', class: 'movedtag2' }, + { value: 'movedtag1', score: 2, valueEscaped: 'movedtag1', valueEncoded: 'movedtag1', class: 'movedtag1' }, + { value: 'movedtag2', score: 1, valueEscaped: 'movedtag2', valueEncoded: 'movedtag2', class: 'movedtag2' }, ]); assert.deepStrictEqual(result2, [ - { value: 'movedtag2', score: 1, valueEscaped: 'movedtag2', class: 'movedtag2' }, + { value: 'movedtag2', score: 1, valueEscaped: 'movedtag2', valueEncoded: 'movedtag2', class: 'movedtag2' }, ]); // after moving values should update properly @@ -2054,11 +2054,11 @@ describe('Topic\'s', () => { result1 = await topics.getCategoryTagsData(cid1, 0, -1); result2 = await topics.getCategoryTagsData(cid2, 0, -1); assert.deepStrictEqual(result1, [ - { value: 'movedtag1', score: 1, valueEscaped: 'movedtag1', class: 'movedtag1' }, + { value: 'movedtag1', score: 1, valueEscaped: 'movedtag1', valueEncoded: 'movedtag1', class: 'movedtag1' }, ]); assert.deepStrictEqual(result2, [ - { value: 'movedtag2', score: 2, valueEscaped: 'movedtag2', class: 'movedtag2' }, - { value: 'movedtag1', score: 1, valueEscaped: 'movedtag1', class: 'movedtag1' }, + { value: 'movedtag2', score: 2, valueEscaped: 'movedtag2', valueEncoded: 'movedtag2', class: 'movedtag2' }, + { value: 'movedtag1', score: 1, valueEscaped: 'movedtag1', valueEncoded: 'movedtag1', class: 'movedtag1' }, ]); });