diff --git a/src/common/constants.js b/src/common/constants.js index 4933723..4e13b4f 100644 --- a/src/common/constants.js +++ b/src/common/constants.js @@ -150,10 +150,11 @@ module.exports = { created: { title: 'Your project has been created, and we\'re ready for your specification', content: data => `Hello, Coder here! Your project '${data.projectName}' has been created successfully. For your next step, please head over to the Specification section and answer all of the required questions. If you already have a document with your requirements, just verify it against our checklist and then upload it. Once you're done, hit the "Submit for Review" button on the Specification. Get stuck or need help? Email us at support@topcoder.com.`, + disabled: true, }, submittedForReview: { - title: 'Your project has been submitted for review', - content: data => `Hello, it's Coder again. Thanks for submitting your project ${data.projectName}! I've used my super computational powers to route it to one of our trusty humans. They'll get back to you in 1-2 business days.`, + title: 'Your project is being reviewed. Provide additional info if you have it.', + content: data => `Hello, Coder here! Thanks for submitting your project ${data.projectName}! I've used my super computational powers to route it to one of our trusty humans. They'll get back to you in 1-2 business days. Meanwhile, if have any additional project information or documents to upload, please head over to the Specification section. Get stuck or need help? Email us at support@topcoder.com.`, }, activated: { title: 'Work on your project has begun', diff --git a/src/handlers/projectEvents.js b/src/handlers/projectEvents.js index 81a7412..4f9405d 100644 --- a/src/handlers/projectEvents.js +++ b/src/handlers/projectEvents.js @@ -18,19 +18,22 @@ const util = require('./util'); * @return {Array} the array of notifications */ function projectDraftCreated(logger, project) { + const notifications = { + discourse: [], + }; const topic = constants.notifications.discourse.project.created; const topicData = { projectName: project.name, projectUrl: `https://connect.${config.get('AUTH_DOMAIN')}/projects/${project.id}/`, }; - // return notificaiton object with discourse data - const notifications = { - discourse: [{ + if (topic && !topic.disabled) { + // return notificaiton object with discourse data + notifications.discourse.push({ projectId: project.id, title: topic.title, content: topic.content(topicData), - }], - }; + }); + } return notifications; } @@ -88,8 +91,8 @@ function* projectUpdated(logger, data) { topic = constants.notifications.discourse.project.completed; } - // post to discourse if topic is set - if (topic) { + // post to discourse if topic is set and is not disabled + if (topic && !topic.disabled) { const topicData = { projectName: project.name, projectUrl: `https://connect.${config.get('AUTH_DOMAIN')}/projects/${project.id}/`, diff --git a/src/test/app.test.js b/src/test/app.test.js index fec3579..e75f18d 100644 --- a/src/test/app.test.js +++ b/src/test/app.test.js @@ -237,14 +237,10 @@ describe('app', () => { }); describe('`project.draft-created` event', () => { - it('should create `Project.Created` notification', (done) => { + it('should not create `Project.Created` notification as it is disabled now', (done) => { sendTestEvent(sampleEvents.draftCreated, 'project.draft-created'); setTimeout(() => { - const expectedTitle = 'Your project has been created, and we\'re ready for your specification'; - const expectedBody = 'Hello, Coder here! Your project \'test\' has been created successfully. For your next step, please head over to the Specification section and answer all of the required questions. If you already have a document with your requirements, just verify it against our checklist and then upload it. Once you\'re done, hit the "Submit for Review" button on the Specification. Get stuck or need help? Email us at support@topcoder.com.'; - const params = spy.lastCall.args; - assert.equal(params[2], expectedTitle); - assert.equal(params[3], expectedBody); + sinon.assert.notCalled(spy); done(); }, testTimeout); }); @@ -262,8 +258,8 @@ describe('app', () => { sendTestEvent(sampleEvents.updatedInReview, 'project.updated'); setTimeout(() => { assertCount += 1; - const expectedTitle = 'Your project has been submitted for review'; - const expectedBody = 'Hello, it\'s Coder again. Thanks for submitting your project test! I\'ve used my super computational powers to route it to one of our trusty humans. They\'ll get back to you in 1-2 business days.'; + const expectedTitle = 'Your project is being reviewed. Provide additional info if you have it.'; + const expectedBody = 'Hello, Coder here! Thanks for submitting your project test! I\'ve used my super computational powers to route it to one of our trusty humans. They\'ll get back to you in 1-2 business days. Meanwhile, if have any additional project information or documents to upload, please head over to the Specification section. Get stuck or need help? Email us at support@topcoder.com.'; let params = spy.lastCall.args; assert.equal(params[2], expectedTitle); assert.equal(params[3], expectedBody);