mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
test: update tag tests, fix linux symlink error
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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' },
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user