diff --git a/end-to-end-test/remote/specs/core/oncoprint.screenshot.spec.js b/end-to-end-test/remote/specs/core/oncoprint.screenshot.spec.js index 1244a017a54..a945d3ee69e 100644 --- a/end-to-end-test/remote/specs/core/oncoprint.screenshot.spec.js +++ b/end-to-end-test/remote/specs/core/oncoprint.screenshot.spec.js @@ -11,6 +11,20 @@ const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ""); const ONCOPRINT_TIMEOUT = 60000; +function getNthTrackOptionsElements(n) { + // n is one-indexed + + const button_selector = "#oncoprintDiv .oncoprintjs__track_options__toggle_btn_img.nth-"+n; + const dropdown_selector = "#oncoprintDiv .oncoprintjs__track_options__dropdown.nth-"+n; + + return { + button: $(button_selector), + button_selector, + dropdown: $(dropdown_selector), + dropdown_selector + }; +} + describe("oncoprint screenshot tests", function() { it("coadread_tcga_pub with clinical and heatmap tracks", function(){ var url = `${CBIOPORTAL_URL}/index.do?cancer_study_id=coadread_tcga_pub&Z_SCORE_THRESHOLD=1&RPPA_SCORE_THRESHOLD=2&data_priority=0&case_set_id=coadread_tcga_pub_nonhypermut&gene_list=KRAS%20NRAS%20BRAF&geneset_list=%20&tab_index=tab_visualize&Action=Submit&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=coadread_tcga_pub_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=coadread_tcga_pub_gistic&genetic_profile_ids_PROFILE_MRNA_EXPRESSION=coadread_tcga_pub_rna_seq_mrna_median_Zscores&show_samples=false&clinicallist=0%2C2%2CMETHYLATION_SUBTYPE&heatmap_track_groups=coadread_tcga_pub_rna_seq_mrna_median_Zscores%2CKRAS%2CNRAS%2CBRAF&`; @@ -93,6 +107,18 @@ describe("oncoprint screenshot tests", function() { var res = checkOncoprintElement('.oncoprintContainer'); assertScreenShotMatch(res); }); + it("removes top treatment track successfully", function() { + goToUrlAndSetLocalStorage(`${CBIOPORTAL_URL}/results/oncoprint?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=ccle_broad_2019&case_set_id=ccle_broad_2019_cnaseq&data_priority=0&gene_list=TP53&geneset_list=%20&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=ccle_broad_2019_cna&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=ccle_broad_2019_mutations&profileFilter=0&tab_index=tab_visualize&heatmap_track_groups=ccle_broad_2019_CCLE_drug_treatment_IC50%2CAfatinib-2%2CAKTinhibitorVIII-1&treatment_list=Afatinib-2%3BAKTinhibitorVIII-1`); + waitForOncoprint(ONCOPRINT_TIMEOUT); + + const elements = getNthTrackOptionsElements(2); + setDropdownOpen(true, elements.button_selector, elements.dropdown_selector, "Couldnt open top treatment track options"); + browser.click(elements.dropdown_selector + ' li:nth-child(3)'); // Click Remove + waitForOncoprint(ONCOPRINT_TIMEOUT); + + var res = checkOncoprintElement('.oncoprintContainer'); + assertScreenShotMatch(res); + }); }); describe("track group headers", function() { @@ -153,21 +179,6 @@ describe("track group headers", function() { }); describe("sorting", function(){ - - function getNthTrackOptionsElements(n) { - // n is one-indexed - - const button_selector = "#oncoprintDiv .oncoprintjs__track_options__toggle_btn_img.nth-"+n; - const dropdown_selector = "#oncoprintDiv .oncoprintjs__track_options__dropdown.nth-"+n; - - return { - button: $(button_selector), - button_selector, - dropdown: $(dropdown_selector), - dropdown_selector - }; - } - it("oncoprint should sort patients correctly in coadread_tcga_pub", function(){ goToUrlAndSetLocalStorage(CBIOPORTAL_URL); diff --git a/package.json b/package.json index 14c13a84488..82fa85db6d9 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,10 @@ "private": true, "version": "0.0.0", "workspaces": { - "packages": [".", "packages/*"] + "packages": [ + ".", + "packages/*" + ] }, "description": "", "scripts": { @@ -172,7 +175,7 @@ "node-sass": "^4.9.3", "numeral": "^2.0.6", "object-sizeof": "^1.2.0", - "oncoprintjs": "4.0.9", + "oncoprintjs": "4.1.3", "parameter-validator": "^1.0.2", "pdfobject": "^2.0.201604172", "pegjs": "^0.10.0", diff --git a/src/shared/components/oncoprint/DeltaUtils.ts b/src/shared/components/oncoprint/DeltaUtils.ts index 302d4680692..3b869f69f60 100644 --- a/src/shared/components/oncoprint/DeltaUtils.ts +++ b/src/shared/components/oncoprint/DeltaUtils.ts @@ -653,7 +653,9 @@ function tryRemoveTrack( // removeCallback to forget its track ID const trackId = trackSpecKeyToTrackId[prevSpec.key]; if (typeof trackId !== "undefined") { - oncoprint.removeTrack(trackId); + if (oncoprint.getTracks().includes(trackId)) { + oncoprint.removeTrack(trackId); + } delete trackSpecKeyToTrackId[prevSpec.key]; } return true; @@ -864,8 +866,10 @@ function transitionClinicalTrack( label: nextSpec.label, description: ((nextSpec.label || "").trim() === (nextSpec.description || "").trim()) ? undefined : nextSpec.description, removable: true, - removeCallback: ()=>{ + removeCallback: () => { delete getTrackSpecKeyToTrackId()[nextSpec.key]; + }, + onClickRemoveInTrackMenu: ()=>{ nextProps.onDeleteClinicalTrack && nextProps.onDeleteClinicalTrack(nextSpec.key); }, sort_direction_changeable: true, @@ -1015,7 +1019,10 @@ export function transitionHeatmapTrack( na_legend_label: nextSpec.naLegendLabel, removeCallback: ()=>{ delete getTrackSpecKeyToTrackId()[nextSpec.key]; - if (nextSpec.onRemove) nextSpec.onRemove(); + nextSpec.onRemove && nextSpec.onRemove(); + }, + onClickRemoveInTrackMenu:()=>{ + nextSpec.onClickRemoveInTrackMenu && nextSpec.onClickRemoveInTrackMenu(); }, sort_direction_changeable: ifNotDefined(nextSpec.sortDirectionChangeable, true), sortCmpFn: heatmapTrackSortComparator, diff --git a/src/shared/components/oncoprint/Oncoprint.tsx b/src/shared/components/oncoprint/Oncoprint.tsx index 801043fe40e..ed5f7fd8477 100644 --- a/src/shared/components/oncoprint/Oncoprint.tsx +++ b/src/shared/components/oncoprint/Oncoprint.tsx @@ -120,7 +120,6 @@ export interface IBaseHeatmapTrackSpec { export interface IHeatmapTrackSpec extends IBaseHeatmapTrackSpec { data: IBaseHeatmapTrackDatum[]; // can be IGeneHeatmapTrackDatum or ITreatmentHeatmapTrackDatum naLegendLabel?:string; - onRemove?: () => void; info?: string; labelColor?: string; labelCircleColor?: string; @@ -131,6 +130,8 @@ export interface IHeatmapTrackSpec extends IBaseHeatmapTrackSpec { movable?:boolean; sortDirectionChangeable?:boolean; // never updated trackLinkUrl?: string | undefined; + onRemove?:()=>void; + onClickRemoveInTrackMenu?: ()=>void; molecularProfileName?: string; pivotThreshold?: number; sortOrder?: string; diff --git a/src/shared/components/oncoprint/OncoprintUtils.ts b/src/shared/components/oncoprint/OncoprintUtils.ts index e7a824546f5..7deef012233 100644 --- a/src/shared/components/oncoprint/OncoprintUtils.ts +++ b/src/shared/components/oncoprint/OncoprintUtils.ts @@ -714,7 +714,7 @@ export function makeHeatmapTracksMobxPromise(oncoprint:ResultsViewOncoprint, sam data ), trackGroupIndex: molecularProfileIdToHeatmapTracks[molecularProfileId].trackGroupIndex, - onRemove:action(()=>{ + onClickRemoveInTrackMenu:action(()=>{ const trackGroup = oncoprint.molecularProfileIdToHeatmapTracks[molecularProfileId]; if (trackGroup) { const newEntities = _.keys(trackGroup.entities).filter((entity)=>entity!==gene); @@ -799,8 +799,7 @@ export function makeTreatmentProfileHeatmapTracksMobxPromise(oncoprint:ResultsVi sortOrder: sortOrder, trackLinkUrl: treatmentLinkMap[treatmentId], trackGroupIndex: molecularProfileIdToHeatmapTracks[molecularProfileId]!.trackGroupIndex, - onRemove:action(()=>{ - + onClickRemoveInTrackMenu:action(()=>{ const trackGroup = oncoprint.molecularProfileIdToHeatmapTracks[molecularProfileId]!; if (trackGroup){ const newEntities = _.keys(trackGroup.entities).filter((entity)=>entity!==treatmentId); diff --git a/yarn.lock b/yarn.lock index cea7a10a54a..9a59abc2b93 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15699,10 +15699,10 @@ oncokb-styles@~0.1.2: resolved "https://registry.yarnpkg.com/oncokb-styles/-/oncokb-styles-0.1.2.tgz#8b26c0a0829787cdc1b595d3a021b3266607102b" integrity sha512-tuy5s3qFxgf1ogMATQSRPNgLlAMrvOOTCAN1dm/wJ+VZoStbJ7g36/qHwc99UPfh3vrB05broLodF+k58p5tUw== -oncoprintjs@4.0.9: - version "4.0.9" - resolved "https://registry.yarnpkg.com/oncoprintjs/-/oncoprintjs-4.0.9.tgz#d4b7bb673e50c571a435a4a27e82247dfd2d0249" - integrity sha512-T6VutMr3g+hx8e6E/873CrnuWS3s+3rfSqfU0sjgboV3N6hajU3WX/PMe3WNFBCSRHYLIi1SQV9bWcwdouZNkw== +oncoprintjs@4.1.3: + version "4.1.3" + resolved "https://registry.yarnpkg.com/oncoprintjs/-/oncoprintjs-4.1.3.tgz#aca0528fc18d04e5c505333d603f871b1f40dec9" + integrity sha512-iP3mXiokJT5j1M3vsRaU9lxQUyt9zY57RSATlFa1rpegbZGyVwMwdZawZRd+Gov9P49JHNPvKeM/qagYo1Gglg== dependencies: gl-matrix "2.3.2" jquery "^3.0.0"