Skip to content

Commit

Permalink
Fix reject cancer type name review (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinlu3 authored Aug 23, 2024
1 parent 565bc5b commit f661d40
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { FirebaseVusService } from './firebase-vus-service';
import { Gene, HistoryOperationType, Mutation, Review, Tumor } from 'app/shared/model/firebase/firebase.model';
import { mock, mockReset } from 'jest-mock-extended';
import { SentryError } from 'app/config/sentry-error';
import { ReviewLevel } from 'app/shared/util/firebase/firebase-review-utils';
import { getTumorNameUuid, ReviewLevel, TumorReviewLevel } from 'app/shared/util/firebase/firebase-review-utils';
import { ReviewAction } from 'app/config/constants/firebase';
import _ from 'lodash';
import { ActionType } from 'app/pages/curation/collapsible/ReviewCollapsible';
Expand Down Expand Up @@ -395,6 +395,65 @@ describe('Firebase Gene Review Service', () => {
});
});

it('should reject initial excluded cancer type', async () => {
const mutation = new Mutation('V600E');
const tumor = new Tumor();
tumor.cancerTypes = [{ code: '', subtype: '', mainType: 'Melanoma' }];
tumor.cancerTypes_review = new Review('User');
tumor.excludedCancerTypes = [{ code: 'OCM', subtype: 'Ocular Melanoma', mainType: 'Melanoma' }];
tumor.excludedCancerTypes_review = new Review('User', undefined, false, false, true);
tumor.excludedCancerTypes_uuid = generateUuid();
mutation.tumors.push(tumor);

const reviewLevel = new TumorReviewLevel({
titleParts: ['Oncogenic Mutations', 'Breast Cancer {excluding Metaplastic Breast Cancer}', 'Name'],
valuePath: 'mutations/0/tumors/0/cancerTypes',
historyLocation: 'Oncogenic Mutations, Breast Cancer {excluding Metaplastic Breast Cancer}',
children: [],
historyInfo: {},
currentVal: 'Breast Cancer {excluding Metaplastic Breast Cancer}',
reviewInfo: {
reviewPath: 'mutations/0/tumors/0/cancerTypes_review',
review: tumor.cancerTypes_review,
lastReviewedString: 'Breast Cancer',
uuid: getTumorNameUuid(tumor.cancerTypes_uuid, tumor.excludedCancerTypes_uuid),
reviewAction: 3,
},
historyData: {
oldState: 'Breast Cancer',
newState: 'Breast Cancer {excluding Metaplastic Breast Cancer}',
},
excludedCancerTypesReviewInfo: {
reviewPath: 'mutations/0/tumors/0/excludedCancerTypes_review',
review: tumor.excludedCancerTypes_review,
lastReviewedString: undefined,
uuid: tumor.excludedCancerTypes_uuid,
},
currentExcludedCancerTypes: [
{
code: 'MBC',
mainType: 'Breast Cancer',
subtype: 'Metaplastic Breast Cancer',
},
],
});

await firebaseGeneReviewService.rejectChanges('BRAF', [reviewLevel], false);
expect(mockFirebaseRepository.update.mock.calls[0][0]).toEqual('/');
expect(mockFirebaseRepository.update.mock.calls[0][1]).toMatchObject({
'Genes/BRAF/mutations/0/tumors/0/cancerTypes_review': {
updateTime: DEFAULT_DATE.getTime(),
updatedBy: mockAuthStore.fullName,
},
'Genes/BRAF/mutations/0/tumors/0/excludedCancerTypes': null,
'Meta/BRAF/lastModifiedAt': DEFAULT_DATETIME_STRING,
'Meta/BRAF/lastModifiedBy': mockAuthStore.fullName,
[`Meta/BRAF/review/${getTumorNameUuid(tumor.cancerTypes_uuid, tumor.excludedCancerTypes_uuid)}`]: null,
[`Meta/BRAF/review/${tumor.cancerTypes_uuid}`]: null,
[`Meta/BRAF/review/${tumor.excludedCancerTypes_uuid}`]: null,
});
});

it('should reject initial excluded RCT', async () => {
const mutation = new Mutation('V600E');
const tumor = new Tumor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,17 @@ export class FirebaseGeneReviewService {
const reviewLevelUpdateObject = {
[`${firebaseGenePath}/${reviewPath}`]: resetReview,
// When user rejects the initial excludedRCTs, then excludedRCTs field should be cleared.
[`${firebaseGenePath}/${fieldPath}`]: review.initialUpdate ? null : review.lastReviewed,
[`${firebaseGenePath}/${fieldPath}`]: review.initialUpdate || review.lastReviewed === undefined ? null : review.lastReviewed,
};
updateObject = { ...updateObject, ...reviewLevelUpdateObject };
if ('excludedCancerTypesReviewInfo' in reviewLevel && 'currentExcludedCancerTypes' in reviewLevel) {
const tumorReviewLevel = reviewLevel as TumorReviewLevel;
const excludedCtReviewPath = tumorReviewLevel.excludedCancerTypesReviewInfo?.reviewPath;
const excludedCtPath = excludedCtReviewPath?.replace('_review', '');
updateObject[`${firebaseGenePath}/${excludedCtReviewPath}`] = resetReview;
updateObject[`${firebaseGenePath}/${excludedCtPath}`] = tumorReviewLevel.excludedCancerTypesReviewInfo?.review.lastReviewed;
updateObject[`${firebaseGenePath}/${excludedCtPath}`] = tumorReviewLevel.excludedCancerTypesReviewInfo?.review.initialUpdate
? null
: tumorReviewLevel.excludedCancerTypesReviewInfo?.review.lastReviewed;
}
} else if (isDeleteReview(reviewLevel)) {
updateObject[`${firebaseGenePath}/${reviewPath}`] = resetReview;
Expand Down

0 comments on commit f661d40

Please sign in to comment.