Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove entity stable ID from generic assay name #4852

Closed
wants to merge 1 commit into from
Closed
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
24 changes: 12 additions & 12 deletions src/shared/lib/GenericAssayUtils/GenericAssayCommonUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ISelectOption } from 'shared/lib/GenericAssayUtils/GenericAssaySelectio

describe('GenericAssayCommonUtils', () => {
describe('makeGenericAssayOption()', () => {
it('Includes entity_stable_id and description when present and unique', () => {
it('Includes description and hides stableId when present and unique', () => {
const genericAssayEntity: GenericAssayMeta = {
stableId: 'id_1',
entityType: 'GENERIC_ASSAY',
Expand All @@ -29,7 +29,7 @@ describe('GenericAssayCommonUtils', () => {

const expect = {
value: 'id_1',
label: 'name_1 (id_1): desc_1',
label: 'name_1: desc_1',
};
assert.deepEqual(
makeGenericAssayOption(genericAssayEntity),
Expand All @@ -49,7 +49,7 @@ describe('GenericAssayCommonUtils', () => {

const expect = {
value: 'id_1',
label: 'name_1 (id_1)',
label: 'name_1',
};
assert.deepEqual(
makeGenericAssayOption(genericAssayEntity),
Expand Down Expand Up @@ -77,7 +77,7 @@ describe('GenericAssayCommonUtils', () => {
);
});

it('Hides name and description when same as entity_stable_id', () => {
it('Hides stableId and description when same as name', () => {
const genericAssayEntity: GenericAssayMeta = {
stableId: 'id_1',
entityType: 'GENERIC_ASSAY',
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('GenericAssayCommonUtils', () => {
);
});

it('Shows entity_stable_id and name when description is missing in properties', () => {
it('Shows name and hides stableId when description is missing in properties', () => {
const genericAssayEntity: GenericAssayMeta = {
stableId: 'id_1',
entityType: 'GENERIC_ASSAY',
Expand All @@ -127,7 +127,7 @@ describe('GenericAssayCommonUtils', () => {

const expect = {
value: 'id_1',
label: 'name_1 (id_1)',
label: 'name_1',
};
assert.deepEqual(
makeGenericAssayOption(genericAssayEntity),
Expand Down Expand Up @@ -166,7 +166,7 @@ describe('GenericAssayCommonUtils', () => {

const expect = {
value: 'id_1',
label: 'name_1 (id_1): desc_1',
label: 'name_1: desc_1',
plotAxisLabel: 'name_1',
};
assert.deepEqual(
Expand All @@ -187,8 +187,8 @@ describe('GenericAssayCommonUtils', () => {

const expect = {
value: 'id_1',
label: 'name_1 (id_1): desc_1',
plotAxisLabel: 'name_1 (id_1)',
label: 'name_1: desc_1',
plotAxisLabel: 'name_1',
};
assert.deepEqual(
makeGenericAssayPlotsTabOption(genericAssayEntity, true),
Expand Down Expand Up @@ -295,20 +295,20 @@ describe('GenericAssayCommonUtils', () => {
});

describe('formatGenericAssayCompactLabelByNameAndId()', () => {
it('Hides name when same as stableId', () => {
it('Hides stableId when same as name', () => {
const stableId = 'STABLE_ID';
const name = stableId;
assert.equal(
formatGenericAssayCompactLabelByNameAndId(stableId, name),
stableId
);
});
it('shows name and stableId when they are unique', () => {
it('Only shows name when name and stableId are unique', () => {
const stableId = 'STABLE_ID';
const name = 'NAME';
assert.equal(
formatGenericAssayCompactLabelByNameAndId(stableId, name),
`${name} (${stableId})`
`${name}`
);
});
});
Expand Down
14 changes: 6 additions & 8 deletions src/shared/lib/GenericAssayUtils/GenericAssayCommonUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,12 @@ export function formatGenericAssayCommonLabel(meta: GenericAssayMeta) {
const uniqueDesc = description !== meta.stableId && description !== name;
// set stableId as default label
let label = meta.stableId;
if (!uniqueName && !uniqueDesc) {
label = meta.stableId;
} else if (!uniqueName) {
if (uniqueName && uniqueDesc) {
label = `${name}: ${description}`;
} else if (uniqueName) {
label = name;
} else if (uniqueDesc) {
label = `${meta.stableId}: ${description}`;
} else if (!uniqueDesc) {
label = `${name} (${meta.stableId})`;
} else {
label = `${name} (${meta.stableId}): ${description}`;
}
return label;
}
Expand All @@ -255,7 +253,7 @@ export function formatGenericAssayCompactLabelByNameAndId(
const uniqueName = name !== stableId;
let label = stableId;
if (uniqueName) {
label = `${name} (${stableId})`;
label = name;
}
return label;
}
Expand Down
Loading