From 6ba562f62d5870450047ab04979d1833647506ba Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 27 Oct 2024 14:27:20 +0330 Subject: [PATCH 01/14] throw error on un-vouching the givbackseligible projects --- src/server/adminJs/tabs/projectsTab.ts | 47 +++++++++++++++++++------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/src/server/adminJs/tabs/projectsTab.ts b/src/server/adminJs/tabs/projectsTab.ts index b52aa85b8..7a5eaa959 100644 --- a/src/server/adminJs/tabs/projectsTab.ts +++ b/src/server/adminJs/tabs/projectsTab.ts @@ -194,6 +194,18 @@ export const verifyProjects = async ( ?.split(',') ?.map(strId => Number(strId)) as number[]; const projectsBeforeUpdating = await findProjectsByIdArray(projectIds); + + // Check if any project is Givback eligible and vouchedStatus is false\ + if (!vouchedStatus) { + for (const project of projectsBeforeUpdating) { + if (project.isGivbackEligible) { + throw new Error( + `Project with ID ${project.id} is Givback eligible and cannot be unvouched.`, + ); + } + } + } + const updateParams = { verified: vouchedStatus }; const projects = await Project.createQueryBuilder('project') @@ -231,22 +243,31 @@ export const verifyProjects = async ( refreshProjectPowerView(), refreshProjectFuturePowerView(), ]); + return { + redirectUrl: '/admin/resources/Project', + records: records.map(record => { + record.toJSON(context.currentAdmin); + }), + notice: { + message: `Project(s) successfully ${ + vouchedStatus ? 'vouched' : 'unvouched' + }`, + type: 'success', + }, + }; } catch (error) { logger.error('verifyProjects() error', error); - throw error; + return { + redirectUrl: '/admin/resources/Project', + records: records.map(record => { + record.toJSON(context.currentAdmin); + }), + notice: { + message: error.message, + type: 'error', + }, + }; } - return { - redirectUrl: '/admin/resources/Project', - records: records.map(record => { - record.toJSON(context.currentAdmin); - }), - notice: { - message: `Project(s) successfully ${ - vouchedStatus ? 'vouched' : 'unvouched' - }`, - type: 'success', - }, - }; }; export const updateStatusOfProjects = async ( From 55657676101e918595a84faa078876b0ce8ad075 Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 27 Oct 2024 14:45:47 +0330 Subject: [PATCH 02/14] update message --- src/server/adminJs/tabs/projectVerificationTab.ts | 2 +- src/server/adminJs/tabs/projectsTab.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/adminJs/tabs/projectVerificationTab.ts b/src/server/adminJs/tabs/projectVerificationTab.ts index 5ba5d14f1..387e35d0d 100644 --- a/src/server/adminJs/tabs/projectVerificationTab.ts +++ b/src/server/adminJs/tabs/projectVerificationTab.ts @@ -261,7 +261,7 @@ export const approveVerificationForms = async ( return project.id; }); - // need to requery them as the RAW is not an entity + // need to re-query them as the RAW is not an entity const verificationForms = await ProjectVerificationForm.createQueryBuilder( 'projectVerificationForm', ) diff --git a/src/server/adminJs/tabs/projectsTab.ts b/src/server/adminJs/tabs/projectsTab.ts index 7a5eaa959..6c57d3c9a 100644 --- a/src/server/adminJs/tabs/projectsTab.ts +++ b/src/server/adminJs/tabs/projectsTab.ts @@ -200,7 +200,7 @@ export const verifyProjects = async ( for (const project of projectsBeforeUpdating) { if (project.isGivbackEligible) { throw new Error( - `Project with ID ${project.id} is Givback eligible and cannot be unvouched.`, + `The project with ID ${project.id} is Givback-eligible, so the Vouched badge cannot be revoked.`, ); } } From a744af6337d67a60f06141b90e0290e83571e942 Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 27 Oct 2024 15:10:44 +0330 Subject: [PATCH 03/14] optimize the approveMultipleProjects --- .../projectVerificationRepository.ts | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/repositories/projectVerificationRepository.ts b/src/repositories/projectVerificationRepository.ts index 7324b22e8..d3b6ecd67 100644 --- a/src/repositories/projectVerificationRepository.ts +++ b/src/repositories/projectVerificationRepository.ts @@ -393,24 +393,20 @@ export const approveProject = async (params: { return project.save(); }; -export const approveMultipleProjects = async (params: { +export const approveMultipleProjects = async ({ + approved, + projectsIds, +}: { approved: boolean; projectsIds: string[] | number[]; }): Promise => { - if (params.approved) { - await Project.query(` - UPDATE project - SET "verificationStatus" = NULL - WHERE id IN (${params.projectsIds?.join(',')}) - `); - } - return Project.createQueryBuilder('project') - .update(Project, { - isGivbackEligible: params.approved, + .update(Project) + .set({ + isGivbackEligible: approved, + verificationStatus: approved ? null : () => '"verificationStatus"', // Keeps current value if not approved }) - .where('project.id IN (:...ids)') - .setParameter('ids', params.projectsIds) + .where('project.id IN (:...ids)', { ids: projectsIds }) .returning('*') .updateEntity(true) .execute(); From 8d017d18c9d243394a61cb044340dd45b7aebf0b Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 27 Oct 2024 16:51:52 +0330 Subject: [PATCH 04/14] make projects verified if they become givbacksEligible --- src/repositories/projectVerificationRepository.ts | 3 ++- src/server/adminJs/tabs/projectVerificationTab.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/repositories/projectVerificationRepository.ts b/src/repositories/projectVerificationRepository.ts index d3b6ecd67..c19562b77 100644 --- a/src/repositories/projectVerificationRepository.ts +++ b/src/repositories/projectVerificationRepository.ts @@ -404,7 +404,8 @@ export const approveMultipleProjects = async ({ .update(Project) .set({ isGivbackEligible: approved, - verificationStatus: approved ? null : () => '"verificationStatus"', // Keeps current value if not approved + verified: approved ? true : () => 'verified', + verificationStatus: approved ? null : () => '"verificationStatus"', }) .where('project.id IN (:...ids)', { ids: projectsIds }) .returning('*') diff --git a/src/server/adminJs/tabs/projectVerificationTab.ts b/src/server/adminJs/tabs/projectVerificationTab.ts index 387e35d0d..bc30ae2e9 100644 --- a/src/server/adminJs/tabs/projectVerificationTab.ts +++ b/src/server/adminJs/tabs/projectVerificationTab.ts @@ -246,6 +246,7 @@ export const approveVerificationForms = async ( ? PROJECT_VERIFICATION_STATUSES.VERIFIED : PROJECT_VERIFICATION_STATUSES.REJECTED; const formIds = request?.query?.recordIds?.split(','); + // call repositories const projectsForms = await verifyMultipleForms({ verificationStatus, From 7db802f7ca3ceade818053c7a3a83f86c19437d4 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 28 Oct 2024 10:25:30 +0330 Subject: [PATCH 05/14] prevent approve or reject draft projects --- .../adminJs/tabs/projectVerificationTab.ts | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/server/adminJs/tabs/projectVerificationTab.ts b/src/server/adminJs/tabs/projectVerificationTab.ts index bc30ae2e9..2a06b67b5 100644 --- a/src/server/adminJs/tabs/projectVerificationTab.ts +++ b/src/server/adminJs/tabs/projectVerificationTab.ts @@ -247,6 +247,24 @@ export const approveVerificationForms = async ( : PROJECT_VERIFICATION_STATUSES.REJECTED; const formIds = request?.query?.recordIds?.split(','); + logger.info('approveVerificationForms() formIds', formIds); + + // Preliminary check for DRAFT status + const draftProjects = await ProjectVerificationForm.createQueryBuilder( + 'form', + ) + .where('form.id IN (:...formIds)', { formIds }) + .andWhere('form.status = :status', { + status: PROJECT_VERIFICATION_STATUSES.DRAFT, + }) + .getMany(); + + if (draftProjects.length > 0) { + throw new Error( + `Cannot ${approved ? 'approve' : 'reject'} project${draftProjects.length > 1 ? 's' : ''} in DRAFT status.`, + ); + } + // call repositories const projectsForms = await verifyMultipleForms({ verificationStatus, @@ -295,7 +313,7 @@ export const approveVerificationForms = async ( }`; } catch (error) { logger.error('verifyVerificationForm() error', error); - responseMessage = `Bulk verify failed ${error.message}`; + responseMessage = `Bulk verify failed: ${error.message}`; responseType = 'danger'; } return { From f33cb33254f95eb73dda5bcd02fe1c723735c4ba Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 29 Oct 2024 14:42:41 +0330 Subject: [PATCH 06/14] fix records --- src/server/adminJs/tabs/projectsTab.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/server/adminJs/tabs/projectsTab.ts b/src/server/adminJs/tabs/projectsTab.ts index 3b8bb0d6f..b53177008 100644 --- a/src/server/adminJs/tabs/projectsTab.ts +++ b/src/server/adminJs/tabs/projectsTab.ts @@ -247,9 +247,7 @@ export const verifyProjects = async ( ]); return { redirectUrl: '/admin/resources/Project', - records: records.map(record => { - record.toJSON(context.currentAdmin); - }), + records: records.map(record => record.toJSON(context.currentAdmin)), notice: { message: `Project(s) successfully ${ vouchedStatus ? 'vouched' : 'unvouched' @@ -261,9 +259,7 @@ export const verifyProjects = async ( logger.error('verifyProjects() error', error); return { redirectUrl: '/admin/resources/Project', - records: records.map(record => { - record.toJSON(context.currentAdmin); - }), + records: records.map(record => record.toJSON(context.currentAdmin)), notice: { message: error.message, type: 'error', From 7c23f758edba5e3d78303270339ee04e3e8b9674 Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 29 Oct 2024 14:44:38 +0330 Subject: [PATCH 07/14] fix conditions --- src/repositories/projectVerificationRepository.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/repositories/projectVerificationRepository.ts b/src/repositories/projectVerificationRepository.ts index c19562b77..d27ef1354 100644 --- a/src/repositories/projectVerificationRepository.ts +++ b/src/repositories/projectVerificationRepository.ts @@ -404,8 +404,7 @@ export const approveMultipleProjects = async ({ .update(Project) .set({ isGivbackEligible: approved, - verified: approved ? true : () => 'verified', - verificationStatus: approved ? null : () => '"verificationStatus"', + ...(approved && { verificationStatus: null, verified: true }), }) .where('project.id IN (:...ids)', { ids: projectsIds }) .returning('*') From 102ce11e3f22ad6a44f138a4fea7f03d7dbb1f28 Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 29 Oct 2024 14:46:18 +0330 Subject: [PATCH 08/14] use redirectUrl --- src/server/adminJs/tabs/projectsTab.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/adminJs/tabs/projectsTab.ts b/src/server/adminJs/tabs/projectsTab.ts index b53177008..e183826ef 100644 --- a/src/server/adminJs/tabs/projectsTab.ts +++ b/src/server/adminJs/tabs/projectsTab.ts @@ -246,7 +246,7 @@ export const verifyProjects = async ( refreshProjectFuturePowerView(), ]); return { - redirectUrl: '/admin/resources/Project', + redirectUrl: redirectUrl, records: records.map(record => record.toJSON(context.currentAdmin)), notice: { message: `Project(s) successfully ${ @@ -258,7 +258,7 @@ export const verifyProjects = async ( } catch (error) { logger.error('verifyProjects() error', error); return { - redirectUrl: '/admin/resources/Project', + redirectUrl: redirectUrl, records: records.map(record => record.toJSON(context.currentAdmin)), notice: { message: error.message, From d23a58a89c7ab5146f67644116b8bd1dfcd27fe7 Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 29 Oct 2024 16:29:15 +0330 Subject: [PATCH 09/14] fix tests --- src/server/adminJs/tabs/projectsTab.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/server/adminJs/tabs/projectsTab.test.ts b/src/server/adminJs/tabs/projectsTab.test.ts index 49083065c..866b58a8b 100644 --- a/src/server/adminJs/tabs/projectsTab.test.ts +++ b/src/server/adminJs/tabs/projectsTab.test.ts @@ -422,7 +422,7 @@ function listDelistTestCases() { }); } function verifyProjectsTestCases() { - it('should unverify projects when the badge is revoked and set verification form as draft', async () => { + it('should not change verification status of projects when the badge is revoked and set verification form as draft', async () => { const project = await saveProjectDirectlyToDb({ ...createProjectData(), title: String(new Date().getTime()), @@ -474,7 +474,7 @@ function verifyProjectsTestCases() { project.id, ); assert.isOk(updatedProject); - assert.isFalse(updatedProject?.verified); + assert.isTrue(updatedProject?.verified); assert.isTrue(updatedProject?.listed); assert.equal(updatedProject?.reviewStatus, ReviewStatus.Listed); assert.equal( @@ -598,6 +598,7 @@ function verifyProjectsTestCases() { listed: true, reviewStatus: ReviewStatus.Listed, verificationStatus: RevokeSteps.Revoked, + isGivbackEligible: false, }); const projectVerificationForm = await createProjectVerificationForm({ projectId: project.id, @@ -654,6 +655,7 @@ function verifyProjectsTestCases() { verified: true, listed: false, reviewStatus: ReviewStatus.NotListed, + isGivbackEligible: false, }); const adminUser = await findUserById(SEED_DATA.ADMIN_USER.id); await verifyProjects( @@ -724,6 +726,7 @@ function verifyProjectsTestCases() { title: String(new Date().getTime()), slug: String(new Date().getTime()), verified: true, + isGivbackEligible: false, }); const adminUser = await findUserById(SEED_DATA.ADMIN_USER.id); await verifyProjects( From 4d8b591dd97f52f943894b31764c8727505cfcd4 Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 29 Oct 2024 16:54:54 +0330 Subject: [PATCH 10/14] add unverifyProjectsTestCases --- src/server/adminJs/tabs/projectsTab.test.ts | 73 +++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/src/server/adminJs/tabs/projectsTab.test.ts b/src/server/adminJs/tabs/projectsTab.test.ts index 866b58a8b..3a936ef09 100644 --- a/src/server/adminJs/tabs/projectsTab.test.ts +++ b/src/server/adminJs/tabs/projectsTab.test.ts @@ -48,11 +48,14 @@ describe( ); describe('verifyProjects() test cases', verifyProjectsTestCases); + describe('listDelist() test cases', listDelistTestCases); + describe( 'addToFeaturedProjectUpdate() TestCases', addToFeaturedProjectUpdateTestCases, ); + describe( 'exportProjectsWithFiltersToCsv() test cases', exportProjectsWithFiltersToCsvTestCases, @@ -63,6 +66,74 @@ describe( updateStatusOfProjectsTestCases, ); +describe('unverifyProjects() test cases', unverifyProjectsTestCases); + +function unverifyProjectsTestCases() { + it('Should unverify project if isGivbacksEligible is false', async () => { + const project = await saveProjectDirectlyToDb({ + ...createProjectData(), + title: String(new Date().getTime()), + verified: true, + listed: true, + reviewStatus: ReviewStatus.Listed, + isGivbackEligible: false, + }); + const adminUser = await findUserById(SEED_DATA.ADMIN_USER.id); + await verifyProjects( + { + currentAdmin: adminUser as User, + h: {}, + resource: {}, + records: [], + }, + { + query: { + recordIds: String(project.id), + }, + }, + false, + ); + + const updatedProject = await findProjectById(project.id); + assert.isOk(updatedProject); + assert.isFalse(updatedProject?.verified); + assert.isTrue(updatedProject?.listed); + assert.equal(updatedProject?.reviewStatus, ReviewStatus.Listed); + }); + + it('Should not unverify project if isGivbacksEligible is true', async () => { + const project = await saveProjectDirectlyToDb({ + ...createProjectData(), + slug: String(new Date().getTime()), + verified: true, + listed: true, + reviewStatus: ReviewStatus.Listed, + isGivbackEligible: true, + }); + const adminUser = await findUserById(SEED_DATA.ADMIN_USER.id); + await verifyProjects( + { + currentAdmin: adminUser as User, + h: {}, + resource: {}, + records: [], + }, + { + query: { + recordIds: String(project.id), + }, + }, + false, + ); + + const updatedProject = await findProjectById(project.id); + assert.isOk(updatedProject); + assert.isTrue(updatedProject?.verified); + assert.isTrue(updatedProject?.listed); + assert.equal(updatedProject?.reviewStatus, ReviewStatus.Listed); + }); +} + function updateStatusOfProjectsTestCases() { it('should deList and unverified project, when changing status of one project to cancelled', async () => { const project = await saveProjectDirectlyToDb({ @@ -421,6 +492,7 @@ function listDelistTestCases() { ); }); } + function verifyProjectsTestCases() { it('should not change verification status of projects when the badge is revoked and set verification form as draft', async () => { const project = await saveProjectDirectlyToDb({ @@ -496,6 +568,7 @@ function verifyProjectsTestCases() { ); assert.equal(updatedProject?.verificationStatus, RevokeSteps.Revoked); }); + it('should not change listed(true) status when verifying project and set verification form as verified', async () => { const project = await saveProjectDirectlyToDb({ ...createProjectData(), From 9d99aff20bb87bbd1433cc58a284ea78fc1a3b99 Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 29 Oct 2024 19:16:57 +0330 Subject: [PATCH 11/14] add test:projectVerificationTab --- package.json | 1 + .../tabs/projectVerificationTab.test.ts | 151 ++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 src/server/adminJs/tabs/projectVerificationTab.test.ts diff --git a/package.json b/package.json index 17349eadc..dcc849d62 100644 --- a/package.json +++ b/package.json @@ -136,6 +136,7 @@ "test:qfRoundService": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/services/qfRoundService.test.ts", "test:project": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/entities/project.test.ts", "test:projectsTab": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/server/adminJs/tabs/projectsTab.test.ts", + "test:projectVerificationTab": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/server/adminJs/tabs/projectVerificationTab.test.ts", "test:syncUsersModelScore": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/services/cronJobs/syncUsersModelScore.test.ts", "test:notifyDonationsWithSegment": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/services/cronJobs/notifyDonationsWithSegment.test.ts", "test:checkProjectVerificationStatus": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/services/cronJobs/checkProjectVerificationStatus.test.ts", diff --git a/src/server/adminJs/tabs/projectVerificationTab.test.ts b/src/server/adminJs/tabs/projectVerificationTab.test.ts new file mode 100644 index 000000000..7a2d4ad45 --- /dev/null +++ b/src/server/adminJs/tabs/projectVerificationTab.test.ts @@ -0,0 +1,151 @@ +import { assert } from 'chai'; +import { + createProjectData, + saveProjectDirectlyToDb, + SEED_DATA, +} from '../../../../test/testUtils'; +import { PROJECT_VERIFICATION_STATUSES } from '../../../entities/projectVerificationForm'; +import { User } from '../../../entities/user'; +import { + createProjectVerificationForm, + findProjectVerificationFormById, +} from '../../../repositories/projectVerificationRepository'; +import { findUserById } from '../../../repositories/userRepository'; +import { approveVerificationForms } from './projectVerificationTab'; +import { findProjectById } from '../../../repositories/projectRepository'; + +describe( + 'approveGivbacksEligibilityForm() TestCases', + approveGivbacksEligibilityFormTestCases, +); + +function approveGivbacksEligibilityFormTestCases() { + it('Should throw error if Givback Eligibility Form is on draft', async () => { + const project = await saveProjectDirectlyToDb({ + ...createProjectData(), + title: String(new Date().getTime()), + slug: String(new Date().getTime()), + verified: true, + listed: true, + }); + + const projectVerificationForm = await createProjectVerificationForm({ + projectId: project.id, + userId: project.adminUserId, + }); + + projectVerificationForm.status = PROJECT_VERIFICATION_STATUSES.DRAFT; + await projectVerificationForm.save(); + + const adminUser = await findUserById(SEED_DATA.ADMIN_USER.id); + + await approveVerificationForms( + { + currentAdmin: adminUser as User, + h: {}, + resource: {}, + records: [], + }, + { + query: { + recordIds: String(projectVerificationForm.id), + }, + }, + true, + ); + + const updatedForm = await findProjectVerificationFormById( + projectVerificationForm.id, + ); + assert.isOk(updatedForm); + assert.equal(updatedForm?.status, PROJECT_VERIFICATION_STATUSES.DRAFT); + }); + + it('Should be able approve Givback Eligibility Form for not draft form', async () => { + const project = await saveProjectDirectlyToDb({ + ...createProjectData(), + title: String(new Date().getTime()), + slug: String(new Date().getTime()), + verified: true, + listed: true, + isGivbackEligible: false, + }); + + const projectVerificationForm = await createProjectVerificationForm({ + projectId: project.id, + userId: project.adminUserId, + }); + projectVerificationForm.status = PROJECT_VERIFICATION_STATUSES.SUBMITTED; + await projectVerificationForm.save(); + + const adminUser = await findUserById(SEED_DATA.ADMIN_USER.id); + + await approveVerificationForms( + { + currentAdmin: adminUser as User, + h: {}, + resource: {}, + records: [], + }, + { + query: { + recordIds: String(projectVerificationForm.id), + }, + }, + true, + ); + + const updatedForm = await findProjectVerificationFormById( + projectVerificationForm.id, + ); + const updatedPorject = await findProjectById(project.id); + assert.isOk(updatedForm); + assert.equal(updatedForm?.status, PROJECT_VERIFICATION_STATUSES.VERIFIED); + assert.isTrue(updatedPorject?.isGivbackEligible); + assert.equal(updatedPorject?.verificationFormStatus); + }); + + it('Should be able to reject Givback Eligibility Form for not draft form', async () => { + const project = await saveProjectDirectlyToDb({ + ...createProjectData(), + title: String(new Date().getTime()), + slug: String(new Date().getTime()), + verified: true, + listed: true, + isGivbackEligible: false, + }); + + const projectVerificationForm = await createProjectVerificationForm({ + projectId: project.id, + userId: project.adminUserId, + }); + projectVerificationForm.status = PROJECT_VERIFICATION_STATUSES.SUBMITTED; + await projectVerificationForm.save(); + + const adminUser = await findUserById(SEED_DATA.ADMIN_USER.id); + + await approveVerificationForms( + { + currentAdmin: adminUser as User, + h: {}, + resource: {}, + records: [], + }, + { + query: { + recordIds: String(projectVerificationForm.id), + }, + }, + false, + ); + + const updatedForm = await findProjectVerificationFormById( + projectVerificationForm.id, + ); + const updatedPorject = await findProjectById(project.id); + + assert.isOk(updatedForm); + assert.equal(updatedForm?.status, PROJECT_VERIFICATION_STATUSES.REJECTED); + assert.isFalse(updatedPorject?.isGivbackEligible); + }); +} From 4d823027361eb52d6014d97e38816bad2fcee32b Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 29 Oct 2024 19:23:17 +0330 Subject: [PATCH 12/14] temporary comment --- src/server/adminJs/tabs/projectVerificationTab.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/adminJs/tabs/projectVerificationTab.test.ts b/src/server/adminJs/tabs/projectVerificationTab.test.ts index 7a2d4ad45..b31e0f45c 100644 --- a/src/server/adminJs/tabs/projectVerificationTab.test.ts +++ b/src/server/adminJs/tabs/projectVerificationTab.test.ts @@ -102,7 +102,7 @@ function approveGivbacksEligibilityFormTestCases() { assert.isOk(updatedForm); assert.equal(updatedForm?.status, PROJECT_VERIFICATION_STATUSES.VERIFIED); assert.isTrue(updatedPorject?.isGivbackEligible); - assert.equal(updatedPorject?.verificationFormStatus); + // assert.equal(updatedPorject?.verificationFormStatus); }); it('Should be able to reject Givback Eligibility Form for not draft form', async () => { From 52cfb82f4ac53f9769eecd805b1878f39845982c Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 4 Nov 2024 09:12:25 +0330 Subject: [PATCH 13/14] fix typo --- src/server/adminJs/tabs/projectVerificationTab.test.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/server/adminJs/tabs/projectVerificationTab.test.ts b/src/server/adminJs/tabs/projectVerificationTab.test.ts index b31e0f45c..d1858a443 100644 --- a/src/server/adminJs/tabs/projectVerificationTab.test.ts +++ b/src/server/adminJs/tabs/projectVerificationTab.test.ts @@ -98,11 +98,11 @@ function approveGivbacksEligibilityFormTestCases() { const updatedForm = await findProjectVerificationFormById( projectVerificationForm.id, ); - const updatedPorject = await findProjectById(project.id); + const updatedProject = await findProjectById(project.id); assert.isOk(updatedForm); assert.equal(updatedForm?.status, PROJECT_VERIFICATION_STATUSES.VERIFIED); - assert.isTrue(updatedPorject?.isGivbackEligible); - // assert.equal(updatedPorject?.verificationFormStatus); + assert.isTrue(updatedProject?.isGivbackEligible); + // assert.equal(updatedProject?.verificationFormStatus); }); it('Should be able to reject Givback Eligibility Form for not draft form', async () => { @@ -142,10 +142,10 @@ function approveGivbacksEligibilityFormTestCases() { const updatedForm = await findProjectVerificationFormById( projectVerificationForm.id, ); - const updatedPorject = await findProjectById(project.id); + const updatedProject = await findProjectById(project.id); assert.isOk(updatedForm); assert.equal(updatedForm?.status, PROJECT_VERIFICATION_STATUSES.REJECTED); - assert.isFalse(updatedPorject?.isGivbackEligible); + assert.isFalse(updatedProject?.isGivbackEligible); }); } From b3dfb594bee67afabc6e697aa4343454c680cef5 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 4 Nov 2024 10:48:17 +0330 Subject: [PATCH 14/14] send email when project verification status changed --- src/server/adminJs/tabs/projectsTab.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/server/adminJs/tabs/projectsTab.ts b/src/server/adminJs/tabs/projectsTab.ts index e183826ef..c46aeab75 100644 --- a/src/server/adminJs/tabs/projectsTab.ts +++ b/src/server/adminJs/tabs/projectsTab.ts @@ -238,6 +238,15 @@ export const verifyProjects = async ( ? HISTORY_DESCRIPTIONS.CHANGED_TO_VERIFIED : HISTORY_DESCRIPTIONS.CHANGED_TO_UNVERIFIED, }); + if (vouchedStatus) { + await getNotificationAdapter().projectVerified({ + project: project, + }); + } else { + await getNotificationAdapter().projectUnVerified({ + project: project, + }); + } } await Promise.all([