Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/bot/__tests__/getReviewInfo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ describe('getReviewInfo', () => {
languages: ['Java'],
requestedAt: new Date(1650504468906),
dueBy: Deadline.END_OF_DAY,
reviewType: 'HackerRank',
candidateIdentifier: 'some-id',
reviewersNeededCount: 1,
acceptedReviewers: [],
Expand Down
64 changes: 11 additions & 53 deletions src/bot/__tests__/requestReview.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { ShortcutParam } from '@/slackTypes';
import { ActionId, Deadline, Interaction } from '@bot/enums';
import { requestReview } from '@bot/requestReview';
import { languageRepo } from '@repos/languageRepo';
import { reviewTypesRepo } from '@repos/reviewTypesRepo';
import { App, SlackViewAction, UploadedFile, ViewStateValue } from '@slack/bolt';
import {
buildMockCallbackParam,
Expand Down Expand Up @@ -78,9 +77,6 @@ describe('requestReview', () => {
describe('when no errors occur', () => {
beforeEach(async () => {
languageRepo.listAll = jest.fn().mockResolvedValueOnce(['Javascript', 'Go', 'Other']);
reviewTypesRepo.listAll = jest
.fn()
.mockResolvedValueOnce(['HackerRank', 'Moby Dick Project']);

await requestReview.shortcut(param);
});
Expand All @@ -107,34 +103,10 @@ describe('requestReview', () => {
});
});

it('should setup the first response block for the review type', () => {
it('should setup the first response block for the languages used', () => {
const { mock } = param.client.views.open as jest.Mock;
const blocks = mock.calls[0][0].view.blocks;
expect(blocks[0]).toEqual({
block_id: ActionId.REVIEW_TYPE,
type: 'input',
label: {
text: 'What type of submission needs reviewed?',
type: 'plain_text',
},
element: {
type: 'static_select',
action_id: ActionId.REVIEW_TYPE,
options: [
{ text: { text: 'HackerRank', type: 'plain_text' }, value: 'HackerRank' },
{
text: { text: 'Moby Dick Project', type: 'plain_text' },
value: 'Moby Dick Project',
},
],
},
});
});

it('should setup the second response block for the languages used', () => {
const { mock } = param.client.views.open as jest.Mock;
const blocks = mock.calls[0][0].view.blocks;
expect(blocks[1]).toEqual({
block_id: ActionId.LANGUAGE_SELECTIONS,
type: 'input',
label: {
Expand All @@ -153,10 +125,10 @@ describe('requestReview', () => {
});
});

it('should setup the third response block for when the reviews are needed by', () => {
it('should setup the second response block for when the reviews are needed by', () => {
const { mock } = param.client.views.open as jest.Mock;
const blocks = mock.calls[0][0].view.blocks;
expect(blocks[2]).toEqual({
expect(blocks[1]).toEqual({
block_id: ActionId.REVIEW_DEADLINE,
type: 'input',
label: {
Expand All @@ -178,10 +150,10 @@ describe('requestReview', () => {
});
});

it('should setup the forth response block for the number of reviewers necessary', () => {
it('should setup the third response block for the number of reviewers necessary', () => {
const { mock } = param.client.views.open as jest.Mock;
const blocks = mock.calls[0][0].view.blocks;
expect(blocks[3]).toEqual({
expect(blocks[2]).toEqual({
block_id: ActionId.NUMBER_OF_REVIEWERS,
type: 'input',
label: {
Expand All @@ -200,13 +172,13 @@ describe('requestReview', () => {
it('should default the number of reviewers to 2, the number required for a new hire', () => {
const { mock } = param.client.views.open as jest.Mock;
const blocks = mock.calls[0][0].view.blocks;
expect(blocks[3].element.initial_value).toEqual('2');
expect(blocks[2].element.initial_value).toEqual('2');
});

it('should setup the sixth response block for the PDF file input', () => {
it('should setup the fifth response block for the PDF file input', () => {
const { mock } = param.client.views.open as jest.Mock;
const blocks = mock.calls[0][0].view.blocks;
expect(blocks[5]).toEqual({
expect(blocks[4]).toEqual({
type: 'input',
block_id: ActionId.PDF_IDENTIFIER,
label: {
Expand All @@ -222,19 +194,16 @@ describe('requestReview', () => {
});
});

it('should not setup the sixth response block for the PDF file input when HackParser is not enabled', async () => {
it('should not setup the fifth response block for the PDF file input when HackParser is not enabled', async () => {
process.env.HACK_PARSER_BUCKET_NAME = '';

languageRepo.listAll = jest.fn().mockResolvedValueOnce(['Javascript', 'Go', 'Other']);
reviewTypesRepo.listAll = jest
.fn()
.mockResolvedValueOnce(['HackerRank', 'Moby Dick Project']);

await requestReview.shortcut(param);

const { mock } = param.client.views.open as jest.Mock;
const blocks = mock.calls[1][0].view.blocks;
expect(blocks[5]).toBeUndefined();
expect(blocks[4]).toBeUndefined();
});
});

Expand Down Expand Up @@ -265,7 +234,6 @@ describe('requestReview', () => {
beforeEach(async () => {
param.client.views.open = jest.fn().mockRejectedValueOnce('Dialog failed');
languageRepo.listAll = jest.fn().mockResolvedValueOnce([]);
reviewTypesRepo.listAll = jest.fn().mockResolvedValueOnce([]);

await requestReview.shortcut(param);
});
Expand Down Expand Up @@ -313,15 +281,6 @@ describe('requestReview', () => {
},
},
},
[ActionId.REVIEW_TYPE]: {
[ActionId.REVIEW_TYPE]: {
type: 'static_select',
selected_option: {
text: { type: 'plain_text', text: 'Moby Dick Project' },
value: 'Moby Dick Project',
},
},
},
[ActionId.NUMBER_OF_REVIEWERS]: {
[ActionId.NUMBER_OF_REVIEWERS]: {
type: 'plain_text_input',
Expand Down Expand Up @@ -400,7 +359,7 @@ describe('requestReview', () => {
expect(param.client.chat.postMessage).toBeCalledWith({
channel: 'some-channel-id',
text: `
<@${param.body.user.id}> has requested 1 reviews for a Moby Dick Project done in the following languages:
<@${param.body.user.id}> has requested 1 reviews for a HackerRank done in the following languages:

• Go
• Javascript
Expand All @@ -427,7 +386,6 @@ _Candidate Identifier: some-identifier_
languages: ['Go', 'Javascript'],
requestedAt: expect.any(Date),
dueBy: Deadline.MONDAY,
reviewType: 'Moby Dick Project',
candidateIdentifier: 'some-identifier',
reviewersNeededCount: '1',
acceptedReviewers: [],
Expand Down
1 change: 0 additions & 1 deletion src/bot/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const enum ActionId {
CANDIDATE_IDENTIFIER = 'candidate-identifier',
REVIEWER_DM_ACCEPT = 'reviewer-dm-accept',
REVIEWER_DM_DECLINE = 'reviewer-dm-deny',
REVIEW_TYPE = 'review-type',
PDF_IDENTIFIER = 'pdf-identifier',
}

Expand Down
31 changes: 3 additions & 28 deletions src/bot/requestReview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { CallbackParam, ShortcutParam } from '@/slackTypes';
import { isViewSubmitActionParam } from '@/typeGuards';
import { activeReviewRepo } from '@repos/activeReviewsRepo';
import { languageRepo } from '@repos/languageRepo';
import { reviewTypesRepo } from '@repos/reviewTypesRepo';
import { QueueService } from '@services';
import { App, Block, KnownBlock, PlainTextOption, View } from '@slack/bolt';
import { blockUtils } from '@utils/blocks';
Expand All @@ -28,21 +27,8 @@ export const requestReview = {
app.view(Interaction.SUBMIT_REQUEST_REVIEW, this.callback.bind(this));
},

dialog(languages: string[], reviewTypes: string[]): View {
dialog(languages: string[]): View {
const blocks: (Block | KnownBlock)[] = [
{
type: 'input',
block_id: ActionId.REVIEW_TYPE,
label: {
text: 'What type of submission needs reviewed?',
type: 'plain_text',
},
element: {
type: 'static_select',
action_id: ActionId.REVIEW_TYPE,
options: buildReviewTypeOptions(reviewTypes),
},
},
{
type: 'input',
block_id: ActionId.LANGUAGE_SELECTIONS,
Expand Down Expand Up @@ -146,11 +132,10 @@ export const requestReview = {

try {
const languages = await languageRepo.listAll();
const reviewTypes = await reviewTypesRepo.listAll();

await client.views.open({
trigger_id: shortcut.trigger_id,
view: this.dialog(languages, reviewTypes),
view: this.dialog(languages),
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
Expand Down Expand Up @@ -178,8 +163,6 @@ export const requestReview = {
const deadline = blockUtils.getBlockValue(body, ActionId.REVIEW_DEADLINE);
const numberOfReviewers = blockUtils.getBlockValue(body, ActionId.NUMBER_OF_REVIEWERS);
const candidateIdentifier = blockUtils.getBlockValue(body, ActionId.CANDIDATE_IDENTIFIER);
const reviewType = blockUtils.getBlockValue(body, ActionId.REVIEW_TYPE).selected_option.text
.text;

let pdfIdentifier = '';
// if HackParser is enabled AND the user uploaded a PDF file: download it from slack, and upload it to the HackParser S3 bucket
Expand Down Expand Up @@ -225,7 +208,7 @@ export const requestReview = {
compose(
`${mention(
user,
)} has requested ${numberOfReviewersValue} reviews for a ${reviewType} done in the following languages:`,
)} has requested ${numberOfReviewersValue} reviews for a HackerRank done in the following languages:`,
ul(...languages),
bold(`The review is needed by end of day ${deadlineDisplay}`),
candidateIdentifierValue ? italic(`Candidate Identifier: ${candidateIdentifierValue}`) : '',
Expand Down Expand Up @@ -263,7 +246,6 @@ export const requestReview = {
{ id: user.id },
languages,
deadlineDisplay,
reviewType,
);
const pendingReviewer: PendingReviewer = {
userId: reviewer.id,
Expand All @@ -279,7 +261,6 @@ export const requestReview = {
languages,
requestedAt: new Date(),
dueBy: deadlineValue,
reviewType: reviewType,
candidateIdentifier: candidateIdentifierValue,
reviewersNeededCount: numberOfReviewersValue,
acceptedReviewers: [],
Expand All @@ -301,12 +282,6 @@ function buildDeadlineOptions(): PlainTextOption[] {
];
}

function buildReviewTypeOptions(reviewTypes: string[]): PlainTextOption[] {
return reviewTypes.map(reviewType => {
return { text: { text: reviewType, type: 'plain_text' }, value: reviewType };
});
}

function buildOption(deadline: Deadline): PlainTextOption {
return { text: { text: DeadlineLabel.get(deadline) || '', type: 'plain_text' }, value: deadline };
}
1 change: 0 additions & 1 deletion src/cron/__tests__/reviewProcessor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ function mockReview(pendingReviewers: PendingReviewer[]): ActiveReview {
threadId: Math.random().toString(),
acceptedReviewers: [],
dueBy: Deadline.MONDAY,
reviewType: 'HackerRank',
candidateIdentifier: '',
languages: [],
pendingReviewers,
Expand Down
1 change: 0 additions & 1 deletion src/database/models/ActiveReview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export interface ActiveReview {
languages: string[];
requestedAt: Date;
dueBy: Deadline;
reviewType: string;
candidateIdentifier: string;
/**
* The number of reviewers requested for this review. It should not change over the life of the
Expand Down
3 changes: 0 additions & 3 deletions src/database/repos/activeReviewsRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ enum Column {
LANGUAGES = 'languages',
REQUESTED_AT = 'requestedAt',
DUE_BY = 'dueBy',
REVIEW_TYPE = 'reviewType',
CANDIDATE_IDENTIFIER = 'candidateIdentifier',
REVIEWERS_NEEDED_COUNT = 'reviewersNeededCount',
ACCEPTED_REVIEWERS = 'acceptedReviewers',
Expand All @@ -33,7 +32,6 @@ function mapRowToActiveReview(row: GoogleSpreadsheetRow): ActiveReview {
languages: row[Column.LANGUAGES].split(','),
requestedAt: parseDateRow(row[Column.REQUESTED_AT]),
dueBy: row[Column.DUE_BY],
reviewType: row[Column.REVIEW_TYPE],
candidateIdentifier: row[Column.CANDIDATE_IDENTIFIER],
reviewersNeededCount: Number(row[Column.REVIEWERS_NEEDED_COUNT]),
acceptedReviewers: JSON.parse(row[Column.ACCEPTED_REVIEWERS]),
Expand All @@ -51,7 +49,6 @@ function mapActiveReviewToRow(activeReview: ActiveReview): Record<string, any> {
[Column.LANGUAGES]: activeReview.languages.join(','),
[Column.REQUESTED_AT]: activeReview.requestedAt.getTime(),
[Column.DUE_BY]: activeReview.dueBy,
[Column.REVIEW_TYPE]: activeReview.reviewType,
[Column.CANDIDATE_IDENTIFIER]: activeReview.candidateIdentifier,
[Column.REVIEWERS_NEEDED_COUNT]: activeReview.reviewersNeededCount,
[Column.ACCEPTED_REVIEWERS]: JSON.stringify(activeReview.acceptedReviewers),
Expand Down
34 changes: 0 additions & 34 deletions src/database/repos/reviewTypesRepo.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/services/ChatService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,13 @@ export const chatService = {
requestor: { id: string },
languages: string[],
deadlineDisplay: string,
reviewType: string,
): Promise<string> {
const request = requestBuilder.buildReviewRequest(
reviewerId,
threadId,
requestor,
languages,
deadlineDisplay,
reviewType,
);
const requestWithToken = {
...request,
Expand Down
2 changes: 0 additions & 2 deletions src/services/RequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ function moveOntoNextPerson(closeMessage: string) {
{ id: updatedReview.requestorId },
updatedReview.languages,
DeadlineLabel.get(updatedReview.dueBy) || 'Unknown',
updatedReview.reviewType,
);
const closeMessageBlock = textBlock(closeMessage);
await chatService.updateDirectMessage(
Expand Down Expand Up @@ -81,7 +80,6 @@ async function requestNextUserReview(review: ActiveReview, _client: WebClient):
{ id: review.requestorId },
review.languages,
DeadlineLabel.get(review.dueBy) || '',
review.reviewType,
);
const pendingReviewer: PendingReviewer = {
...nextUser,
Expand Down
1 change: 0 additions & 1 deletion src/services/__tests__/ChatService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ describe('ChatService', () => {
{ id: requestorId },
languages,
DeadlineLabel.get(Deadline.END_OF_DAY) || '',
'HackerRank',
);

expect(client.chat.postMessage).toHaveBeenCalledWith({
Expand Down
1 change: 0 additions & 1 deletion src/services/__tests__/QueueService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ describe('Queue Service', () => {
languages: ['Java'],
requestedAt: new Date(),
dueBy: Deadline.END_OF_DAY,
reviewType: 'HackerRank',
candidateIdentifier: '123',
reviewersNeededCount: 2,
acceptedReviewers: [],
Expand Down
Loading