Skip to content

Commit

Permalink
Remove entity stable ID from generic assay name
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthijsPon committed Feb 19, 2024
1 parent 6cc6ec1 commit 8d6c82a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
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

0 comments on commit 8d6c82a

Please sign in to comment.