Skip to content

Commit

Permalink
Fix circular dependency in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alisman committed May 25, 2022
1 parent a4aaf9f commit 6ccb8cf
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ import {
IMutationalSignature,
IMutationalSignatureMeta,
} from 'shared/model/MutationalSignature';
import { GenericAssayTypeConstants } from 'shared/lib/GenericAssayUtils/GenericAssayCommonUtils';
import { GenericAssayTypeConstants } from 'shared/lib/GenericAssayUtils/GenericAssayConfig';

import {
MutationalSignaturesVersion,
MutationalSignatureStableIdKeyWord,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/resultsView/plots/PlotsTabUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
import { getServerConfig } from 'config/config';
import ServerConfigDefaults from 'config/serverConfigDefaults';
import _ from 'lodash';
import { GenericAssayTypeConstants } from 'shared/lib/GenericAssayUtils/GenericAssayCommonUtils';
import { GenericAssayTypeConstants } from 'shared/lib/GenericAssayUtils/GenericAssayConfig';

describe('PlotsTabUtils', () => {
describe('makeClinicalAttributeOptions', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/resultsView/plots/QuickPlots.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { PlotsTabOption, PlotsTabDataSource } from './PlotsTab';
import { generateQuickPlots, ButtonInfo, TypeSourcePair } from './QuickPlots';
import { GenericAssayTypeConstants } from 'shared/lib/GenericAssayUtils/GenericAssayCommonUtils';
import { GenericAssayTypeConstants } from 'shared/lib/GenericAssayUtils/GenericAssayConfig';

describe('Quick Plot Links in the Plots Tab', () => {
describe('generateQuickplots', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/resultsView/plots/QuickPlots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { AlterationTypeConstants } from '../ResultsViewPageStore';
import { SpecialAttribute } from 'shared/cache/ClinicalDataCache';
import { CLIN_ATTR_DATA_TYPE } from './PlotsTabUtils';
import { GenericAssayTypeConstants } from 'shared/lib/GenericAssayUtils/GenericAssayCommonUtils';
import { GenericAssayTypeConstants } from 'shared/lib/GenericAssayUtils/GenericAssayConfig';

export type ButtonInfo = {
selected: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/components/oncoprint/DeltaUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
IHeatmapTrackSpec,
IOncoprintProps,
} from './Oncoprint';
import { GenericAssayTypeConstants } from 'shared/lib/GenericAssayUtils/GenericAssayCommonUtils';
import { GenericAssayTypeConstants } from 'shared/lib/GenericAssayUtils/GenericAssayConfig';

describe('Oncoprint DeltaUtils', () => {
describe('numTracksWhoseDataChanged', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
makeProfiledInClinicalAttributes,
} from './ResultsViewOncoprintUtils';
import { SpecialAttribute } from '../../cache/ClinicalDataCache';
import { GenericAssayTypeConstants } from 'shared/lib/GenericAssayUtils/GenericAssayCommonUtils';
import { GenericAssayTypeConstants } from 'shared/lib/GenericAssayUtils/GenericAssayConfig';

describe('ResultsViewOncoprintUtils', () => {
describe('makeProfiledInClinicalAttributes', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import {
getGenericAssayMetaPropertyOrDefault,
COMMON_GENERIC_ASSAY_PROPERTY,
deriveDisplayTextFromGenericAssayType,
GenericAssayTypeConstants,
formatGenericAssayCompactLabelByNameAndId,
filterGenericAssayEntitiesByGenes,
makeGenericAssayPlotsTabOption,
} from './GenericAssayCommonUtils';
import { getServerConfig } from 'config/config';
import ServerConfigDefaults from 'config/serverConfigDefaults';
import { GenericAssayTypeConstants } from 'shared/lib/GenericAssayUtils/GenericAssayConfig';

describe('GenericAssayCommonUtils', () => {
describe('makeGenericAssayOption()', () => {
Expand Down Expand Up @@ -373,8 +373,8 @@ describe('GenericAssayCommonUtils', () => {
filterGenericAssayEntitiesByGenes(
[genericAssayEntity],
TARGET_GENE_LIST
),
[]
).length,
0
);
});
});
Expand Down
26 changes: 9 additions & 17 deletions src/shared/lib/GenericAssayUtils/GenericAssayCommonUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { AlterationTypeConstants } from '../../../pages/resultsView/ResultsViewPageStore';
import client from 'shared/api/cbioportalClientInstance';
import {
GenericAssayMetaFilter,
Expand All @@ -13,8 +12,11 @@ import {
doesOptionMatchSearchText,
ISelectOption,
} from './GenericAssaySelectionUtils';
import { GENERIC_ASSAY_CONFIG } from './GenericAssayConfig';
import Pluralize from 'pluralize';
import {
GENERIC_ASSAY_CONFIG,
GenericAssayTypeConstants,
} from 'shared/lib/GenericAssayUtils/GenericAssayConfig';
import * as Pluralize from 'pluralize';

export const NOT_APPLICABLE_VALUE = 'NA';
export const COMMON_GENERIC_ASSAY_PROPERTY = {
Expand All @@ -23,13 +25,6 @@ export const COMMON_GENERIC_ASSAY_PROPERTY = {
URL: 'URL',
};

export const GenericAssayTypeConstants: { [s: string]: string } = {
TREATMENT_RESPONSE: 'TREATMENT_RESPONSE',
MUTATIONAL_SIGNATURE: 'MUTATIONAL_SIGNATURE',
ARMLEVEL_CNA: 'ARMLEVEL_CNA',
METHYLATION: 'METHYLATION',
};

export const RESERVED_CATEGORY_ORDER_DICT: {
[genericAssayType: string]: string[];
} = {
Expand All @@ -51,10 +46,10 @@ export enum GenericAssayDataType {
export async function fetchGenericAssayMetaByMolecularProfileIdsGroupedByGenericAssayType(
molecularProfiles: MolecularProfile[]
) {
// TODO: use AlterationTypeContants here instead of string for GENERIC_ASSAY
// we removed it because importing from page store was causing circular dependency
const genericAssayProfiles = molecularProfiles.filter(
profile =>
profile.molecularAlterationType ===
AlterationTypeConstants.GENERIC_ASSAY
profile => profile.molecularAlterationType === 'GENERIC_ASSAY'
);

const genericAssayProfilesGroupedByGenericAssayType = _.groupBy(
Expand Down Expand Up @@ -92,10 +87,7 @@ export async function fetchGenericAssayMetaByMolecularProfileIdsGroupByMolecular
molecularProfiles: MolecularProfile[]
) {
const genericAssayProfiles = molecularProfiles.filter(profile => {
return (
profile.molecularAlterationType ===
AlterationTypeConstants.GENERIC_ASSAY
);
return profile.molecularAlterationType === 'GENERIC_ASSAY';
});

const genericAssayMetaGroupByMolecularProfileId: {
Expand Down
8 changes: 7 additions & 1 deletion src/shared/lib/GenericAssayUtils/GenericAssayConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { getServerConfig } from 'config/config';
import _ from 'lodash';
import { GenericAssayTypeConstants } from './GenericAssayCommonUtils';

export type GenericAssayConfig = {
genericAssayConfigByType: {
Expand All @@ -9,6 +8,13 @@ export type GenericAssayConfig = {
// Add more Generic Assay global config from here
};

export const GenericAssayTypeConstants: { [s: string]: string } = {
TREATMENT_RESPONSE: 'TREATMENT_RESPONSE',
MUTATIONAL_SIGNATURE: 'MUTATIONAL_SIGNATURE',
ARMLEVEL_CNA: 'ARMLEVEL_CNA',
METHYLATION: 'METHYLATION',
};

export type GenericAssayTypeConfig = {
// Add more Generic Assay type specific config at here
displayTitleText?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import * as React from 'react';
import _ from 'lodash';
import { IMutationalSignature } from '../../model/MutationalSignature';
import {
deriveDisplayTextFromGenericAssayType,
GenericAssayTypeConstants,
} from './GenericAssayCommonUtils';
import { deriveDisplayTextFromGenericAssayType } from './GenericAssayCommonUtils';
import { GenericAssayData } from 'cbioportal-ts-api-client';
import { GenericAssayTypeConstants } from 'shared/lib/GenericAssayUtils/GenericAssayConfig';

export enum MutationalSignaturesVersion {
V2 = 'v2',
Expand Down

0 comments on commit 6ccb8cf

Please sign in to comment.