diff --git a/src/commands/__test__/tarea.test.ts b/src/commands/__test__/tarea.test.ts index abe083e..afaf84e 100644 --- a/src/commands/__test__/tarea.test.ts +++ b/src/commands/__test__/tarea.test.ts @@ -120,21 +120,20 @@ describe('tareaCommandFunction', () => { }); it("should not send a cheatsheet as part of the response if the lesson doesn't have one", async () => { - const typeCodeText = 'console.log("Hello World!!!")'; - const fullMessage = - 'Hola, aca dejo la tarea\n\n```console.log("Hello World!!!")```'; + const typeLinkText = 'https://github.com/r-argentina-programa/robotina'; + const fullMessage = `Hola, aca dejo la tarea ${typeLinkText}`; commandMock.command = { text: fullMessage, - channel_name: 'clase-3', + channel_name: 'clase-9999', user_id: 'mockId', }; const submissionResponseMock = { completed: false, - delivery: typeCodeText, + delivery: typeLinkText, fkStudentId: 1, - fkTaskId: 3, + fkTaskId: 9999, id: 1, isActive: true, viewer: undefined, @@ -164,8 +163,8 @@ describe('tareaCommandFunction', () => { expect(uploadTareaMock).toBeCalledTimes(1); expect(uploadTareaMock).toHaveBeenCalledWith({ - classNumber: '3', - delivery: typeCodeText, + classNumber: '9999', + delivery: typeLinkText, slackId: usersInfoResponse.user.id, firstName: usersInfoResponse.user.profile.first_name, lastName: usersInfoResponse.user.profile.last_name, diff --git a/src/events/message/messageNew.ts b/src/events/message/messageNew.ts index 532cc4d..30e2661 100644 --- a/src/events/message/messageNew.ts +++ b/src/events/message/messageNew.ts @@ -9,15 +9,12 @@ export const handleSubmissionReplyNew: Middleware< SlackEventMiddlewareArgs<'message'>, StringIndexed > = async ({ client, message, logger }) => { - console.log('HERE START HANDLE SUBMISSION REPLY NEW'); if ( message.subtype === undefined && message.thread_ts && message.parent_user_id === env.BOT_ID ) { - console.log('Conditional data: ', message); try { - console.log('HERE ENTERS IN TRY BLOCK'); const { messages: messagesFromChannel } = await client.conversations.history({ latest: message.thread_ts, @@ -26,14 +23,10 @@ export const handleSubmissionReplyNew: Middleware< inclusive: true, }); - console.log('messages from channel: ', messagesFromChannel); - const isSubmissionThread = isTaskSubmission( messagesFromChannel![0].text! ); - console.log('isSubmissionThread: ', isSubmissionThread); - if (!isSubmissionThread) { return; } @@ -42,9 +35,6 @@ export const handleSubmissionReplyNew: Middleware< user: message.user, }); - console.log('slackUser: ', slackUser); - console.log('client.users.info property "user": ', message.user); - const createReplyDto: ICreateReplyDto = { authorId: slackUser!.id!, text: message.text!, @@ -55,34 +45,14 @@ export const handleSubmissionReplyNew: Middleware< (slackUser!.profile!.real_name as string), }; - console.log('createReplyDto: ', createReplyDto); - console.log('createReplyDto property "authorId": ', slackUser!.id); - console.log('createReplyDto property "text": ', message.text); - console.log('createReplyDto property "threadTS": ', message.thread_ts); - console.log('createReplyDto property "timestamp": ', message.ts); - console.log( - 'createReplyDto property "username" (first option, display_name): ', - slackUser!.profile!.display_name - ); - console.log( - 'createReplyDto property "username" (second option, real_name): ', - slackUser!.profile!.real_name - ); - const reply = await replyApi.create(createReplyDto); - console.log('reply: ', reply); - await client.reactions.add({ channel: message.channel, name: 'white_check_mark', timestamp: message.ts, }); - console.log('client.reactions.add property "channel": ', message.channel); - console.log('client.reactions.add property "name": ', 'white_check_mark'); - console.log('client.reactions.add property "timestamp": ', message.ts); - logger.info( `Reply with ID "${reply.id}" from user "${ slackUser!.id diff --git a/src/events/reaction/__test__/handleRobotFaceReaction.spec.ts b/src/events/reaction/__test__/handleRobotFaceReaction.spec.ts index cea9159..dc38fc5 100644 --- a/src/events/reaction/__test__/handleRobotFaceReaction.spec.ts +++ b/src/events/reaction/__test__/handleRobotFaceReaction.spec.ts @@ -277,22 +277,28 @@ describe('handleRobotFaceReaction', () => { }); it("should not send a cheatsheet as part of the response if the lesson doesn't have one", async () => { - const typeCodeText = 'console.log("Hello World!!!")'; + const typeLinkText = 'https://github.com/r-argentina-programa/robotina'; const submissionResponseMock = { completed: false, - delivery: typeCodeText, + delivery: typeLinkText, studentId: 1, - taskId: 3, + taskId: 9999, id: 1, isActive: true, viewer: undefined, } as ISubmissionResponse; - clientMock.conversations.history.mockResolvedValueOnce( - // @ts-ignore - conversationsHistoryResponse - ); + clientMock.conversations.history.mockResolvedValueOnce({ + ...conversationsHistoryResponse, + messages: [ + // @ts-ignore + { + ...conversationsHistoryResponse.messages[0], + text: `Hola, aca dejo la tarea ${typeLinkText}`, + }, + ], + }); clientMock.users.info.mockResolvedValueOnce( // @ts-ignore @@ -304,8 +310,8 @@ describe('handleRobotFaceReaction', () => { { channel: { ...conversationsInfoResponse, - name: 'clase-3', - name_normalized: 'clase-3', + name: 'clase-9999', + name_normalized: 'clase-9999', }, } ); @@ -331,8 +337,8 @@ describe('handleRobotFaceReaction', () => { expect(uploadTareaMock).toBeCalledTimes(1); expect(uploadTareaMock).toHaveBeenCalledWith({ - classNumber: '3', - delivery: typeCodeText, + classNumber: '9999', + delivery: typeLinkText, slackId: messageAuthorEvent.item_user, firstName: usersInfoResponse.user.profile.first_name, lastName: usersInfoResponse.user.profile.last_name, diff --git a/src/utils/assignmentCheatsheet.ts b/src/utils/assignmentCheatsheet.ts index 997f5a4..8ef8685 100644 --- a/src/utils/assignmentCheatsheet.ts +++ b/src/utils/assignmentCheatsheet.ts @@ -1,3 +1,5 @@ export const assignmentCheatsheet = { '1': 'https://docs.google.com/document/d/1Yj8xDa8-5K2um3qJotn6-s_XM5_q5OwZKP7yHf4mW2c', + '3': 'https://docs.google.com/document/d/1mzsLyNhSsH2wDn9ImoikhJo-MoKyCLCMHpuXzWHQHoM', + '4': 'https://docs.google.com/document/d/1zDtxRerNuHHVito80_8_h_XvP1rWBXowPDuXhrW19xU', };