From 4691b1a2a173cacaf9ec17cbb2acdadd8dbabd74 Mon Sep 17 00:00:00 2001 From: mrahmed2026 Date: Tue, 3 Sep 2024 14:03:50 +0300 Subject: [PATCH 01/10] complexity from 16 to 15 test 1 --- src/install.js | 62 +++++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/src/install.js b/src/install.js index 89b40d7b39..d5100b2c64 100644 --- a/src/install.js +++ b/src/install.js @@ -123,33 +123,49 @@ function checkSetupFlagEnv() { } function checkCIFlag() { - let ciVals; - try { - ciVals = JSON.parse(nconf.get('ci')); - } catch (e) { - ciVals = undefined; - } + let ciVals = getCIVals(); + + if (isValidCIVals(ciVals)) { + install.ciVals = ciVals; + } else { + handleMissingCIValues(ciVals); + } +} - if (ciVals && ciVals instanceof Object) { - if (ciVals.hasOwnProperty('host') && ciVals.hasOwnProperty('port') && ciVals.hasOwnProperty('database')) { - install.ciVals = ciVals; - } else { - winston.error('[install/checkCIFlag] required values are missing for automated CI integration:'); - if (!ciVals.hasOwnProperty('host')) { - winston.error(' host'); - } - if (!ciVals.hasOwnProperty('port')) { - winston.error(' port'); - } - if (!ciVals.hasOwnProperty('database')) { - winston.error(' database'); - } +function getCIVals() { + try { + return JSON.parse(nconf.get('ci')); + } catch (e) { + return undefined; + } +} - process.exit(); - } - } +function isValidCIVals(ciVals) { + return ciVals && ciVals instanceof Object && + ciVals.hasOwnProperty('host') && + ciVals.hasOwnProperty('port') && + ciVals.hasOwnProperty('database'); } +function handleMissingCIValues(ciVals) { + winston.error('[install/checkCIFlag] required values are missing for automated CI integration:'); + + if (!ciVals.hasOwnProperty('host')) { + winston.error(' host'); + } + + if (!ciVals.hasOwnProperty('port')) { + winston.error(' port'); + } + + if (!ciVals.hasOwnProperty('database')) { + winston.error(' database'); + } + + process.exit(); +} + + async function setupConfig() { const configureDatabases = require('../install/databases'); From 35f6a7f2b52983acfda639003e7ea3db5e9f56d1 Mon Sep 17 00:00:00 2001 From: mrahmed2026 Date: Tue, 3 Sep 2024 14:16:09 +0300 Subject: [PATCH 02/10] trying to solve 22 to 15 complexity issue, other is solved i think --- src/install.js | 149 +++++++++++++++++++++++++++---------------------- 1 file changed, 82 insertions(+), 67 deletions(-) diff --git a/src/install.js b/src/install.js index d5100b2c64..2e24d9980e 100644 --- a/src/install.js +++ b/src/install.js @@ -48,80 +48,95 @@ questions.optional = [ ]; function checkSetupFlagEnv() { - let setupVal = install.values; - - const envConfMap = { - CONFIG: 'config', - NODEBB_CONFIG: 'config', - NODEBB_URL: 'url', - NODEBB_PORT: 'port', - NODEBB_ADMIN_USERNAME: 'admin:username', - NODEBB_ADMIN_PASSWORD: 'admin:password', - NODEBB_ADMIN_EMAIL: 'admin:email', - NODEBB_DB: 'database', - NODEBB_DB_HOST: 'host', - NODEBB_DB_PORT: 'port', - NODEBB_DB_USER: 'username', - NODEBB_DB_PASSWORD: 'password', - NODEBB_DB_NAME: 'database', - NODEBB_DB_SSL: 'ssl', - }; + let setupVal = install.values; + const envConfMap = getEnvConfMap(); - // Set setup values from env vars (if set) - const envKeys = Object.keys(process.env); - if (Object.keys(envConfMap).some(key => envKeys.includes(key))) { - winston.info('[install/checkSetupFlagEnv] checking env vars for setup info...'); - setupVal = setupVal || {}; - - Object.entries(process.env).forEach(([evName, evValue]) => { // get setup values from env - if (evName.startsWith('NODEBB_DB_')) { - setupVal[`${process.env.NODEBB_DB}:${envConfMap[evName]}`] = evValue; - } else if (evName.startsWith('NODEBB_')) { - setupVal[envConfMap[evName]] = evValue; - } - }); + if (hasRelevantEnvVars(envConfMap)) { + winston.info('[install/checkSetupFlagEnv] checking env vars for setup info...'); + setupVal = setUpValuesFromEnv(setupVal, envConfMap); + } - setupVal['admin:password:confirm'] = setupVal['admin:password']; - } + setupVal = getSetupValuesFromJson(setupVal); - // try to get setup values from json, if successful this overwrites all values set by env - // TODO: better behaviour would be to support overrides per value, i.e. in order of priority (generic pattern): - // flag, env, config file, default - try { - if (nconf.get('setup')) { - const setupJSON = JSON.parse(nconf.get('setup')); - setupVal = { ...setupVal, ...setupJSON }; - } - } catch (err) { - winston.error('[install/checkSetupFlagEnv] invalid json in nconf.get(\'setup\'), ignoring setup values from json'); - } + if (setupVal && typeof setupVal === 'object') { + validateSetupValues(setupVal); + } else if (nconf.get('database')) { + setDatabaseValues(); + } +} - if (setupVal && typeof setupVal === 'object') { - if (setupVal['admin:username'] && setupVal['admin:password'] && setupVal['admin:password:confirm'] && setupVal['admin:email']) { - install.values = setupVal; - } else { - winston.error('[install/checkSetupFlagEnv] required values are missing for automated setup:'); - if (!setupVal['admin:username']) { - winston.error(' admin:username'); - } - if (!setupVal['admin:password']) { - winston.error(' admin:password'); - } - if (!setupVal['admin:password:confirm']) { - winston.error(' admin:password:confirm'); - } - if (!setupVal['admin:email']) { - winston.error(' admin:email'); - } +function getEnvConfMap() { + return { + CONFIG: 'config', + NODEBB_CONFIG: 'config', + NODEBB_URL: 'url', + NODEBB_PORT: 'port', + NODEBB_ADMIN_USERNAME: 'admin:username', + NODEBB_ADMIN_PASSWORD: 'admin:password', + NODEBB_ADMIN_EMAIL: 'admin:email', + NODEBB_DB: 'database', + NODEBB_DB_HOST: 'host', + NODEBB_DB_PORT: 'port', + NODEBB_DB_USER: 'username', + NODEBB_DB_PASSWORD: 'password', + NODEBB_DB_NAME: 'database', + NODEBB_DB_SSL: 'ssl', + }; +} - process.exit(); - } - } else if (nconf.get('database')) { - install.values = install.values || {}; - install.values.database = nconf.get('database'); - } +function hasRelevantEnvVars(envConfMap) { + const envKeys = Object.keys(process.env); + return Object.keys(envConfMap).some(key => envKeys.includes(key)); +} + +function setUpValuesFromEnv(setupVal, envConfMap) { + setupVal = setupVal || {}; + Object.entries(process.env).forEach(([evName, evValue]) => { + if (evName.startsWith('NODEBB_DB_')) { + setupVal[`${process.env.NODEBB_DB}:${envConfMap[evName]}`] = evValue; + } else if (evName.startsWith('NODEBB_')) { + setupVal[envConfMap[evName]] = evValue; + } + }); + setupVal['admin:password:confirm'] = setupVal['admin:password']; + return setupVal; +} + +function getSetupValuesFromJson(setupVal) { + try { + if (nconf.get('setup')) { + const setupJSON = JSON.parse(nconf.get('setup')); + return { ...setupVal, ...setupJSON }; + } + } catch (err) { + winston.error('[install/checkSetupFlagEnv] invalid json in nconf.get(\'setup\'), ignoring setup values from json'); + } + return setupVal; +} + +function validateSetupValues(setupVal) { + if (setupVal['admin:username'] && setupVal['admin:password'] && setupVal['admin:password:confirm'] && setupVal['admin:email']) { + install.values = setupVal; + } else { + winston.error('[install/checkSetupFlagEnv] required values are missing for automated setup:'); + logMissingSetupValues(setupVal); + process.exit(); + } +} + +function logMissingSetupValues(setupVal) { + if (!setupVal['admin:username']) winston.error(' admin:username'); + if (!setupVal['admin:password']) winston.error(' admin:password'); + if (!setupVal['admin:password:confirm']) winston.error(' admin:password:confirm'); + if (!setupVal['admin:email']) winston.error(' admin:email'); +} + +function setDatabaseValues() { + install.values = install.values || {}; + install.values.database = nconf.get('database'); } +// GPT assisted code function checkCIFlag() { let ciVals = getCIVals(); From 24c05e24fc9d647b30927b7de6cf06bf919f25ef Mon Sep 17 00:00:00 2001 From: mrahmed2026 Date: Tue, 3 Sep 2024 18:11:33 +0300 Subject: [PATCH 03/10] fixing elint errors --- src/install.js | 182 ++++++++++++++++++++++++------------------------- 1 file changed, 90 insertions(+), 92 deletions(-) diff --git a/src/install.js b/src/install.js index 2e24d9980e..67104e5e71 100644 --- a/src/install.js +++ b/src/install.js @@ -48,136 +48,134 @@ questions.optional = [ ]; function checkSetupFlagEnv() { - let setupVal = install.values; - const envConfMap = getEnvConfMap(); - - if (hasRelevantEnvVars(envConfMap)) { - winston.info('[install/checkSetupFlagEnv] checking env vars for setup info...'); - setupVal = setUpValuesFromEnv(setupVal, envConfMap); - } - - setupVal = getSetupValuesFromJson(setupVal); + let setupVal = install.values; + const envConfMap = getEnvConfMap(); + if (hasRelevantEnvVars(envConfMap)) { + winston.info('[install/checkSetupFlagEnv] checking env vars for setup info...'); + setupVal = setUpValuesFromEnv(setupVal, envConfMap); + } + setupVal = getSetupValuesFromJson(setupVal); - if (setupVal && typeof setupVal === 'object') { - validateSetupValues(setupVal); - } else if (nconf.get('database')) { - setDatabaseValues(); - } + if (setupVal && typeof setupVal === 'object') { + validateSetupValues(setupVal); + } else if (nconf.get('database')) { + setDatabaseValues(); + } } function getEnvConfMap() { - return { - CONFIG: 'config', - NODEBB_CONFIG: 'config', - NODEBB_URL: 'url', - NODEBB_PORT: 'port', - NODEBB_ADMIN_USERNAME: 'admin:username', - NODEBB_ADMIN_PASSWORD: 'admin:password', - NODEBB_ADMIN_EMAIL: 'admin:email', - NODEBB_DB: 'database', - NODEBB_DB_HOST: 'host', - NODEBB_DB_PORT: 'port', - NODEBB_DB_USER: 'username', - NODEBB_DB_PASSWORD: 'password', - NODEBB_DB_NAME: 'database', - NODEBB_DB_SSL: 'ssl', - }; + return { + CONFIG: 'config', + NODEBB_CONFIG: 'config', + NODEBB_URL: 'url', + NODEBB_PORT: 'port', + NODEBB_ADMIN_USERNAME: 'admin:username', + NODEBB_ADMIN_PASSWORD: 'admin:password', + NODEBB_ADMIN_EMAIL: 'admin:email', + NODEBB_DB: 'database', + NODEBB_DB_HOST: 'host', + NODEBB_DB_PORT: 'port', + NODEBB_DB_USER: 'username', + NODEBB_DB_PASSWORD: 'password', + NODEBB_DB_NAME: 'database', + NODEBB_DB_SSL: 'ssl', + }; } function hasRelevantEnvVars(envConfMap) { - const envKeys = Object.keys(process.env); - return Object.keys(envConfMap).some(key => envKeys.includes(key)); + const envKeys = Object.keys(process.env); + return Object.keys(envConfMap).some(key => envKeys.includes(key)); } function setUpValuesFromEnv(setupVal, envConfMap) { - setupVal = setupVal || {}; - Object.entries(process.env).forEach(([evName, evValue]) => { - if (evName.startsWith('NODEBB_DB_')) { - setupVal[`${process.env.NODEBB_DB}:${envConfMap[evName]}`] = evValue; - } else if (evName.startsWith('NODEBB_')) { - setupVal[envConfMap[evName]] = evValue; - } - }); - setupVal['admin:password:confirm'] = setupVal['admin:password']; - return setupVal; + setupVal = setupVal || {}; + Object.entries(process.env).forEach(([evName, evValue]) => { + if (evName.startsWith('NODEBB_DB_')) { + setupVal[`${process.env.NODEBB_DB}:${envConfMap[evName]}`] = evValue; + } else if (evName.startsWith('NODEBB_')) { + setupVal[envConfMap[evName]] = evValue; + } + }); + setupVal['admin:password:confirm'] = setupVal['admin:password']; + return setupVal; } function getSetupValuesFromJson(setupVal) { - try { - if (nconf.get('setup')) { - const setupJSON = JSON.parse(nconf.get('setup')); - return { ...setupVal, ...setupJSON }; - } - } catch (err) { - winston.error('[install/checkSetupFlagEnv] invalid json in nconf.get(\'setup\'), ignoring setup values from json'); - } - return setupVal; + try { + if (nconf.get('setup')) { + const setupJSON = JSON.parse(nconf.get('setup')); + return { ...setupVal, ...setupJSON }; + } + } catch (err) { + winston.error('[install/checkSetupFlagEnv] invalid json in nconf.get(\'setup\'), ignoring setup values from json'); + } + return setupVal; } function validateSetupValues(setupVal) { - if (setupVal['admin:username'] && setupVal['admin:password'] && setupVal['admin:password:confirm'] && setupVal['admin:email']) { - install.values = setupVal; - } else { - winston.error('[install/checkSetupFlagEnv] required values are missing for automated setup:'); - logMissingSetupValues(setupVal); - process.exit(); - } + if (setupVal['admin:username'] && setupVal['admin:password'] && setupVal['admin:password:confirm'] && setupVal['admin:email']) { + install.values = setupVal; + } else { + winston.error('[install/checkSetupFlagEnv] required values are missing for automated setup:'); + logMissingSetupValues(setupVal); + process.exit(); + } } function logMissingSetupValues(setupVal) { - if (!setupVal['admin:username']) winston.error(' admin:username'); - if (!setupVal['admin:password']) winston.error(' admin:password'); - if (!setupVal['admin:password:confirm']) winston.error(' admin:password:confirm'); - if (!setupVal['admin:email']) winston.error(' admin:email'); + if (!setupVal['admin:username']) winston.error(' admin:username'); + if (!setupVal['admin:password']) winston.error(' admin:password'); + if (!setupVal['admin:password:confirm']) winston.error(' admin:password:confirm'); + if (!setupVal['admin:email']) winston.error(' admin:email'); } function setDatabaseValues() { - install.values = install.values || {}; - install.values.database = nconf.get('database'); + install.values = install.values || {}; + install.values.database = nconf.get('database'); } // GPT assisted code function checkCIFlag() { - let ciVals = getCIVals(); - - if (isValidCIVals(ciVals)) { - install.ciVals = ciVals; - } else { - handleMissingCIValues(ciVals); - } + const ciVals = getCIVals(); + + if (isValidCIVals(ciVals)) { + install.ciVals = ciVals; + } else { + handleMissingCIValues(ciVals); + } } function getCIVals() { - try { - return JSON.parse(nconf.get('ci')); - } catch (e) { - return undefined; - } + try { + return JSON.parse(nconf.get('ci')); + } catch (e) { + return undefined; + } } function isValidCIVals(ciVals) { - return ciVals && ciVals instanceof Object && + return ciVals && ciVals instanceof Object && ciVals.hasOwnProperty('host') && ciVals.hasOwnProperty('port') && ciVals.hasOwnProperty('database'); } function handleMissingCIValues(ciVals) { - winston.error('[install/checkCIFlag] required values are missing for automated CI integration:'); - - if (!ciVals.hasOwnProperty('host')) { - winston.error(' host'); - } - - if (!ciVals.hasOwnProperty('port')) { - winston.error(' port'); - } - - if (!ciVals.hasOwnProperty('database')) { - winston.error(' database'); - } - - process.exit(); + winston.error('[install/checkCIFlag] required values are missing for automated CI integration:'); + + if (!ciVals.hasOwnProperty('host')) { + winston.error(' host'); + } + + if (!ciVals.hasOwnProperty('port')) { + winston.error(' port'); + } + + if (!ciVals.hasOwnProperty('database')) { + winston.error(' database'); + } + + process.exit(); } From 437eeab36881115d5163ce38a316564e5ccdaff0 Mon Sep 17 00:00:00 2001 From: mrahmed2026 Date: Tue, 3 Sep 2024 18:50:26 +0300 Subject: [PATCH 04/10] sonar cloud and lint issues all fixed, completely done. --- src/install.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/install.js b/src/install.js index 67104e5e71..4d8904820c 100644 --- a/src/install.js +++ b/src/install.js @@ -47,6 +47,7 @@ questions.optional = [ }, ]; +// gpt assisted code function checkSetupFlagEnv() { let setupVal = install.values; const envConfMap = getEnvConfMap(); From 4c271801ae4b8161b83082ad9185cf509191f9a2 Mon Sep 17 00:00:00 2001 From: mrahmed2026 Date: Wed, 4 Sep 2024 18:58:03 +0300 Subject: [PATCH 05/10] added a test for testing the getFlagsIdByTarget function --- test/flags.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/flags.js b/test/flags.js index ee150a10c4..7304bad15a 100644 --- a/test/flags.js +++ b/test/flags.js @@ -1169,6 +1169,36 @@ describe('Flags', () => { assert.strictEqual(statusCode, 200, `${opts.method.toUpperCase()} ${opts.uri} => ${statusCode}`); } }); + const Flags = require('../src/flags'); + const posts = require('../src/posts'); + const user = require('../src/user'); + + jest.mock('../src/posts'); + jest.mock('../src/user'); + + describe('Flags.getFlagIdByTarget', () => { + it('should call posts.getPostField when type is post', async () => { + posts.getPostField.mockResolvedValue('flagId123'); + + const result = await Flags.getFlagIdByTarget('post', 'postId123'); + + expect(posts.getPostField).toHaveBeenCalledWith('postId123', 'flagId'); + expect(result).toBe('flagId123'); + }); + + it('should call user.getUserField when type is user', async () => { + user.getUserField.mockResolvedValue('flagId456'); + + const result = await Flags.getFlagIdByTarget('user', 'userId456'); + + expect(user.getUserField).toHaveBeenCalledWith('userId456', 'flagId'); + expect(result).toBe('flagId456'); + }); + + it('should throw an error when type is invalid', async () => { + await expect(Flags.getFlagIdByTarget('invalidType', 'someId')).rejects.toThrow('[[error:invalid-data]]'); + }); + }); it('should NOT allow access to privileged endpoints to moderators if the flag target is a post in a cid they DO NOT moderate', async () => { // This is a new category the user will moderate, but the flagged post is in a different category From 6432a0c6c463621e46f262aee6b464ec0c55ad76 Mon Sep 17 00:00:00 2001 From: mrahmed2026 Date: Wed, 4 Sep 2024 19:23:10 +0300 Subject: [PATCH 06/10] npm run test fully compiles and shows increased overall coverage of flag.js file --- test/flags.js | 60 ++++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/test/flags.js b/test/flags.js index 7304bad15a..55765bd97a 100644 --- a/test/flags.js +++ b/test/flags.js @@ -1169,35 +1169,37 @@ describe('Flags', () => { assert.strictEqual(statusCode, 200, `${opts.method.toUpperCase()} ${opts.uri} => ${statusCode}`); } }); - const Flags = require('../src/flags'); - const posts = require('../src/posts'); - const user = require('../src/user'); - - jest.mock('../src/posts'); - jest.mock('../src/user'); - - describe('Flags.getFlagIdByTarget', () => { - it('should call posts.getPostField when type is post', async () => { - posts.getPostField.mockResolvedValue('flagId123'); - - const result = await Flags.getFlagIdByTarget('post', 'postId123'); - - expect(posts.getPostField).toHaveBeenCalledWith('postId123', 'flagId'); - expect(result).toBe('flagId123'); - }); - - it('should call user.getUserField when type is user', async () => { - user.getUserField.mockResolvedValue('flagId456'); - - const result = await Flags.getFlagIdByTarget('user', 'userId456'); - - expect(user.getUserField).toHaveBeenCalledWith('userId456', 'flagId'); - expect(result).toBe('flagId456'); - }); - - it('should throw an error when type is invalid', async () => { - await expect(Flags.getFlagIdByTarget('invalidType', 'someId')).rejects.toThrow('[[error:invalid-data]]'); - }); + describe('.getFlagIdByTarget()', () => { + it('should return the flagId for a post', async () => { + // Create a new post + const { postData } = await Topics.post({ + cid: category.cid, + uid: uid1, + title: utils.generateUUID(), + content: utils.generateUUID(), + }); + const postId = postData.pid; + + const flagId = await Flags.create('post', postId, uid1, 'Test flag'); + const result = await Flags.getFlagIdByTarget('post', postId); + assert.strictEqual(result, flagId.flagId); + await Flags.purge([flagId.flagId]); // Cleanup + }); + + it('should return the flagId for a user', async () => { + const userId = uid1; + const flagId = await Flags.create('user', userId, uid1, 'Test flag'); + const result = await Flags.getFlagIdByTarget('user', userId); + assert.strictEqual(result, flagId.flagId); + await Flags.purge([flagId.flagId]); // Cleanup + }); + + it('should throw an error when type is invalid', async () => { + await assert.rejects( + Flags.getFlagIdByTarget('invalidType', 'someId'), + new Error('[[error:invalid-data]]') + ); + }); }); it('should NOT allow access to privileged endpoints to moderators if the flag target is a post in a cid they DO NOT moderate', async () => { From 50d19c0a456197f0db3e4bfa6ab48b3199ab29e4 Mon Sep 17 00:00:00 2001 From: mrahmed2026 Date: Wed, 4 Sep 2024 19:27:47 +0300 Subject: [PATCH 07/10] fixed elint errors --- test/flags.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/flags.js b/test/flags.js index 55765bd97a..07b60a4426 100644 --- a/test/flags.js +++ b/test/flags.js @@ -1179,13 +1179,13 @@ describe('Flags', () => { content: utils.generateUUID(), }); const postId = postData.pid; - + const flagId = await Flags.create('post', postId, uid1, 'Test flag'); const result = await Flags.getFlagIdByTarget('post', postId); assert.strictEqual(result, flagId.flagId); await Flags.purge([flagId.flagId]); // Cleanup }); - + it('should return the flagId for a user', async () => { const userId = uid1; const flagId = await Flags.create('user', userId, uid1, 'Test flag'); @@ -1193,7 +1193,7 @@ describe('Flags', () => { assert.strictEqual(result, flagId.flagId); await Flags.purge([flagId.flagId]); // Cleanup }); - + it('should throw an error when type is invalid', async () => { await assert.rejects( Flags.getFlagIdByTarget('invalidType', 'someId'), From f87b58983b4492b470b697aacaa19a96a65de7f2 Mon Sep 17 00:00:00 2001 From: mrahmed2026 Date: Thu, 5 Sep 2024 11:45:41 +0300 Subject: [PATCH 08/10] added a console log statement to flags --- src/flags.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/flags.js b/src/flags.js index 00bce1d9bd..6045c1aa71 100644 --- a/src/flags.js +++ b/src/flags.js @@ -390,6 +390,7 @@ Flags.deleteNote = async function (flagId, datetime) { }; Flags.create = async function (type, id, uid, reason, timestamp, forceFlag = false) { + console.log('Flags.created RAYYAN'); let doHistoryAppend = false; if (!timestamp) { timestamp = Date.now(); From 142cac2e577f3b17a31ce71d666671315e99bab0 Mon Sep 17 00:00:00 2001 From: mrahmed2026 Date: Thu, 5 Sep 2024 14:03:59 +0300 Subject: [PATCH 09/10] the console log statment prints, shown to steve CA and screenshot on gradescope. --- src/flags.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/flags.js b/src/flags.js index 6045c1aa71..a57a5cfd1a 100644 --- a/src/flags.js +++ b/src/flags.js @@ -19,7 +19,6 @@ const utils = require('./utils'); const batch = require('./batch'); const Flags = module.exports; - Flags._states = new Map([ ['open', { label: '[[flags:state-open]]', From 96d0ea71f8c85bbb469d5172d6c701ab7211741c Mon Sep 17 00:00:00 2001 From: mrahmed2026 Date: Thu, 5 Sep 2024 14:48:24 +0300 Subject: [PATCH 10/10] added comments to testcase --- test/flags.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/flags.js b/test/flags.js index 07b60a4426..67f571fec5 100644 --- a/test/flags.js +++ b/test/flags.js @@ -1169,6 +1169,7 @@ describe('Flags', () => { assert.strictEqual(statusCode, 200, `${opts.method.toUpperCase()} ${opts.uri} => ${statusCode}`); } }); + // COPILOT ASSISTED CODE describe('.getFlagIdByTarget()', () => { it('should return the flagId for a post', async () => { // Create a new post @@ -1203,7 +1204,6 @@ describe('Flags', () => { }); it('should NOT allow access to privileged endpoints to moderators if the flag target is a post in a cid they DO NOT moderate', async () => { - // This is a new category the user will moderate, but the flagged post is in a different category const { cid } = await Categories.create({ name: utils.generateUUID(), });