Skip to content

Commit

Permalink
[ADD] pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
af-ofr committed May 21, 2024
1 parent 7afd756 commit 7403f25
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ describe('ProposalContractingController', () => {
id: 'mongoId',
};
const input = new RevertLocationVoteDto();
jest.spyOn(proposalContractingService, 'handleLocationVote');
jest.spyOn(proposalContractingService, 'revertLocationVote');

await proposalContractingController.revertLocationVote(params, input, request);
expect(proposalContractingService.handleLocationVote).toHaveBeenCalledWith(
expect(proposalContractingService.revertLocationVote).toHaveBeenCalledWith(
params.id,
input.location,
request.user,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ describe('ProposalUploadController', () => {
jest.spyOn(proposalUploadService, 'deleteUpload');

await proposalUploadController.deleteUpload(params, request);
expect(proposalUploadService.saveDeletedUpload).toHaveBeenCalledWith(params.mainId, params.subId, request.user);
expect(proposalUploadService.deleteUploadAndSaveProposal).toHaveBeenCalledWith(
params.mainId,
params.subId,
request.user,
);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class ProposalContractingController {
}

@Auth(Role.FdpgMember)
@Put(':id/revertLocationVote')
@Post(':id/revertLocationVote')
@UsePipes(ValidationPipe)
@ApiNotFoundResponse({ description: 'Proposal could not be found' })
@ApiOperation({ summary: 'FDPG member reverts locations vote ' })
Expand All @@ -80,7 +80,7 @@ export class ProposalContractingController {
@Body() { location }: RevertLocationVoteDto,
@Request() { user }: FdpgRequest,
): Promise<void> {
return await this.proposalContractingService.handleLocationVote(id, location, user);
return await this.proposalContractingService.revertLocationVote(id, location, user);
}

@Auth(Role.FdpgMember)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ export class ProposalUploadController {
@HttpCode(204)
@ApiOperation({ summary: 'Deletes a proposal upload' })
async deleteUpload(@Param() { mainId, subId }: MongoTwoIdsParamDto, @Request() { user }: FdpgRequest): Promise<void> {
return await this.proposalUploadService.saveDeletedUpload(mainId, subId, user);
return await this.proposalUploadService.deleteUploadAndSaveProposal(mainId, subId, user);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const ExposeHistory = () => (target: Object, propertyKey: string) => {
const isFdpgMember = user.singleKnownRole === 'FdpgMember';

const filteredEvents = params.obj[propertyKey].filter((event: HistoryEvent) => {
const isRevertEvent = event.type === HistoryEventType.FdpgRevertedLocationVote;
const isRevertEvent = event.type === HistoryEventType.FdpgLocationVoteReverted;

if (isRevertEvent && isFdpgMember) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/proposal/enums/history-event.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export enum HistoryEventType {
FdpgApprovedLocationRemoved = 'FDPG_APPROVED_LOCATION_REMOVED',

/** FDPG reverts DIZ and UAC vote */
FdpgRevertedLocationVote = 'FDPG_REVERTED_LOCATION_VOTE',
FdpgLocationVoteReverted = 'FDPG_REVERTED_LOCATION_VOTE',

/** Data Delivery */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ describe('ProposalContractingService', () => {
handleProposalUacApproval: jest.fn(),
handleProposalStatusChange: jest.fn(),
handleProposalContractSign: jest.fn(),
handleLocationVote: jest.fn(),
},
},
{
Expand Down Expand Up @@ -251,7 +250,7 @@ describe('ProposalContractingService', () => {
const location = MiiLocation.UKL;
jest.spyOn(proposalCrudService, 'findDocument').mockResolvedValueOnce(proposalDocument);

await proposalContractingService.handleLocationVote(proposalId, request.user.miiLocation, request.user);
await proposalContractingService.revertLocationVote(proposalId, request.user.miiLocation, request.user);

expect(validateRevertLocationVote).toHaveBeenCalledWith(proposalDocument, location);
expect(revertLocationVote).toHaveBeenCalledWith(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class ProposalContractingService {
await this.eventEngineService.handleProposalUacApproval(saveResult, vote.value, user.miiLocation);
}

async handleLocationVote(proposalId: string, location: MiiLocation, user: IRequestUser): Promise<void> {
async revertLocationVote(proposalId: string, location: MiiLocation, user: IRequestUser): Promise<void> {
const toBeUpdated = await this.proposalCrudService.findDocument(proposalId, user, undefined, true);
validateRevertLocationVote(toBeUpdated, location);

Expand Down
2 changes: 1 addition & 1 deletion src/modules/proposal/services/proposal-upload.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class ProposalUploadService {
proposal.uploads.splice(uploadIndex, 1);
}

async saveDeletedUpload(proposalId: string, uploadId: string, user: IRequestUser): Promise<void> {
async deleteUploadAndSaveProposal(proposalId: string, uploadId: string, user: IRequestUser): Promise<void> {
const proposal = await this.proposalCrudService.findDocument(proposalId, user, undefined, true);

await this.deleteUpload(proposal, uploadId, user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { clearLocationsVotes } from '../location-flow.util';

jest.mock('../location-flow.util', () => ({
clearLocationsVotes: jest.fn(),
deleteConditionalUpload: jest.fn(),
}));

jest.mock('../add-fdpg-task.util', () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ describe('ProposalHistoryUtil', () => {
it('should add history item for reverted location vote', () => {
const request = getRequest();
const proposal = getProposalDocument();
const location = MiiLocation.UKRUB;
const location = MiiLocation.UKL;

addHistoryItemForRevertLocationVote(proposal, request.user, location);
expect(proposal.history.length).toBe(1);

const expectedType = HistoryEventType.FdpgRevertedLocationVote;
const expectedType = HistoryEventType.FdpgLocationVoteReverted;
expect(proposal.history[0].type).toBe(expectedType);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('revertLocationVoteUtil', () => {
await revertLocationVote(proposal, declineReason.location, request.user, proposalUploadServiceMock);

expect(getLocationStateMock).toBeCalledWith(proposal, request.user);
expect(proposal.declineReasons).not.toEqual([declineReason]);
expect(proposal.declineReasons).toEqual([declineReason]);
expect(proposal.declineReasons.length).toEqual(0);
expect(clearLocationsVotes).toBeCalledWith(proposal, declineReason.location);
expect(proposal.requestedButExcludedLocations).not.toEqual([request.user.miiLocation]);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/proposal/utils/proposal-history.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export const addHistoryItemForRevertLocationVote = (
user: IRequestUser,
location: MiiLocation,
): void => {
const type = HistoryEventType.FdpgRevertedLocationVote;
const type = HistoryEventType.FdpgLocationVoteReverted;

pushHistoryItem(proposalAfterChanges, user, type, location);
};
Expand Down
4 changes: 1 addition & 3 deletions src/modules/proposal/utils/revert-location-vote.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ export const revertLocationVote = async (
proposal.totalPromisedDataAmount = proposal.totalPromisedDataAmount - locationDataAmount;
const isDataAmountReached = proposal.totalPromisedDataAmount >= (proposal.requestedData.desiredDataAmount ?? 0);

if (locationState.requestedButExcluded) {
proposal.declineReasons = proposal.declineReasons.filter((reason) => reason.location !== location);
}
proposal.declineReasons = proposal.declineReasons.filter((reason) => reason.location !== location);

if (locationState.uacApproved) {
proposal.uacApprovals = proposal.uacApprovals.filter((approval) => approval.location !== location);
Expand Down

0 comments on commit 7403f25

Please sign in to comment.