Skip to content

Commit 748bfb2

Browse files
committed
refactor: update URI properties to use uriBFLite and remove unused constants
1 parent 20d23f6 commit 748bfb2

12 files changed

Lines changed: 43 additions & 92 deletions

File tree

src/common/constants/complexLookup.constants.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@ export enum SearchableIndexQuerySelector {
2525
export const COMPLEX_LOOKUPS_LINKED_FIELDS_MAPPING = {
2626
subclass: {
2727
PERSON: {
28-
bfLiteUri: 'http://bibfra.me/vocab/lite/Person',
28+
uriBFLite: 'http://bibfra.me/vocab/lite/Person',
2929
labelId: 'ld.person',
3030
},
3131
FAMILY: {
32-
bfLiteUri: 'http://bibfra.me/vocab/lite/Family',
32+
uriBFLite: 'http://bibfra.me/vocab/lite/Family',
3333
labelId: 'ld.family',
3434
},
3535
ORGANIZATION: {
36-
bfLiteUri: 'http://bibfra.me/vocab/lite/Organization',
36+
uriBFLite: 'http://bibfra.me/vocab/lite/Organization',
3737
labelId: 'ld.organization',
3838
},
3939
MEETING: {
40-
bfLiteUri: 'http://bibfra.me/vocab/lite/Meeting',
40+
uriBFLite: 'http://bibfra.me/vocab/lite/Meeting',
4141
labelId: 'ld.meeting',
4242
},
4343
JURISDICTION: {
44-
bfLiteUri: 'http://bibfra.me/vocab/lite/Jurisdiction',
44+
uriBFLite: 'http://bibfra.me/vocab/lite/Jurisdiction',
4545
labelId: 'ld.jurisdiction',
4646
},
4747
},

src/common/constants/feature.constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ export const SIMPLE_LOOKUPS_ENABLED = true;
44
export const LOCALE_SELECT_ENABLED = false;
55
export const SEARCH_FILTERS_ENABLED = false;
66
export const IS_DISABLED_FOR_ALPHA = true;
7-
export const CUSTOM_PROFILE_ENABLED = false;

src/common/helpers/complexLookup.helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const updateLinkedFieldValue = ({
3030
const linkedFieldValueTyped =
3131
linkedFieldValue as keyof (typeof COMPLEX_LOOKUPS_LINKED_FIELDS_MAPPING)[typeof linkedFieldTyped];
3232
const linkedFieldValueUri =
33-
COMPLEX_LOOKUPS_LINKED_FIELDS_MAPPING?.[linkedFieldTyped]?.[linkedFieldValueTyped]?.bfLiteUri;
33+
COMPLEX_LOOKUPS_LINKED_FIELDS_MAPPING?.[linkedFieldTyped]?.[linkedFieldValueTyped]?.uriBFLite;
3434

3535
let updatedValue: SchemaEntry | undefined;
3636

src/common/services/schema/schemaWithDuplicates.service.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,15 @@ export class SchemaWithDuplicatesService implements ISchemaWithDuplicatesService
195195
}
196196

197197
private removeFromParentTwinChildren(entry: SchemaEntry, parentEntry: SchemaEntry): void {
198-
const hasTwinChildren = parentEntry.twinChildren && entry.uri && parentEntry.twinChildren[entry.uri];
198+
const hasTwinChildren = parentEntry.twinChildren && entry.uriBFLite && parentEntry.twinChildren[entry.uriBFLite];
199199

200-
if (!hasTwinChildren || !parentEntry.twinChildren || !entry.uri) {
200+
if (!hasTwinChildren || !parentEntry.twinChildren || !entry.uriBFLite) {
201201
return;
202202
}
203203

204-
parentEntry.twinChildren[entry.uri] = parentEntry.twinChildren[entry.uri].filter(twinId => twinId !== entry.uuid);
204+
parentEntry.twinChildren[entry.uriBFLite] = parentEntry.twinChildren[entry.uriBFLite].filter(
205+
twinId => twinId !== entry.uuid,
206+
);
205207
}
206208

207209
private updateTwinChildrenEntry(entry: SchemaEntry, updatedEntryUuid: string, parentEntry?: SchemaEntry) {
@@ -231,8 +233,8 @@ export class SchemaWithDuplicatesService implements ISchemaWithDuplicatesService
231233
const updatedParentEntry = cloneDeep(parentEntry);
232234
const { children } = updatedParentEntry;
233235
const originalEntryIndex = children?.indexOf(originalEntry.uuid);
234-
const { uri } = originalEntry;
235-
const childEntryId = uri ?? '';
236+
const { uriBFLite } = originalEntry;
237+
const childEntryId = uriBFLite ?? '';
236238

237239
if (childEntryId) {
238240
const twinChildrenKey = generateTwinChildrenKey(originalEntry);

src/test/__tests__/common/helpers/complexLookup.helper.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { AuthorityValidationTarget } from '@common/constants/complexLookup.const
1313
const mockImportedConstant = getMockedImportedConstant(ComplexLookupConstants, 'COMPLEX_LOOKUPS_LINKED_FIELDS_MAPPING');
1414
mockImportedConstant({
1515
testField: {
16-
testValue: { bf2Uri: 'testUri' },
16+
testValue: { uriBFLite: 'testUri' },
1717
},
1818
});
1919

@@ -66,7 +66,7 @@ describe('complexLookup.helper', () => {
6666
path: ['childUuid'],
6767
uuid: 'childUuid',
6868
type: AdvancedFieldType.dropdownOption,
69-
uri: 'testUri',
69+
uriBFLite: 'testUri',
7070
},
7171
],
7272
]);

src/test/__tests__/common/helpers/schema.helper.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe('schema.helper', () => {
110110
describe('getHtmlIdForEntry', () => {
111111
const schema = new Map([
112112
['blockUuid', { uuid: 'blockUuid', path: ['blockUuid'], uriBFLite: 'mockUriBFLite', bfid: 'mockBfid' }],
113-
['groupUuid', { uuid: 'groupUuid', path: ['blockUuid', 'groupUuid'], uri: 'mockUri' }],
113+
['groupUuid', { uuid: 'groupUuid', path: ['blockUuid', 'groupUuid'], uriBFLite: 'mockUri' }],
114114
[
115115
'fieldUuid',
116116
{
@@ -132,7 +132,7 @@ describe('schema.helper', () => {
132132
describe('generateTwinChildrenKey', () => {
133133
test('returns just URI when no valueDataType exists', () => {
134134
const entry = {
135-
uri: 'test:uri',
135+
uriBFLite: 'test:uri',
136136
constraints: {},
137137
} as SchemaEntry;
138138

@@ -143,7 +143,7 @@ describe('schema.helper', () => {
143143

144144
test('returns concatenated string with valueDataType when present', () => {
145145
const entry = {
146-
uri: 'test:uri',
146+
uriBFLite: 'test:uri',
147147
constraints: {
148148
valueDataType: {
149149
dataTypeURI: 'test:dataType',
@@ -158,7 +158,7 @@ describe('schema.helper', () => {
158158

159159
test('returns URI when constraints is undefined', () => {
160160
const entry = {
161-
uri: 'test:uri',
161+
uriBFLite: 'test:uri',
162162
} as SchemaEntry;
163163

164164
const result = generateTwinChildrenKey(entry);
@@ -168,7 +168,7 @@ describe('schema.helper', () => {
168168

169169
test('returns URI when valueDataType is empty object', () => {
170170
const entry = {
171-
uri: 'test:uri',
171+
uriBFLite: 'test:uri',
172172
constraints: {
173173
valueDataType: {},
174174
},

src/test/__tests__/common/hooks/useConfig.hook.test.ts

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,9 @@ import { renderHook } from '@testing-library/react';
44
import { useConfig } from '@common/hooks/useConfig.hook';
55
import { fetchProfiles } from '@common/api/profiles.api';
66
import * as SchemaService from '@common/services/schema';
7-
import * as FeatureConstants from '@common/constants/feature.constants';
87
import { useInputsStore, useProfileStore } from '@src/store';
9-
import { getMockedImportedConstant } from '@src/test/__mocks__/common/constants/constants.mock';
108
import CUSTOM_PROFILE_MONOGRAPH from '@src/data/customProfile.json';
119

12-
const profiles = [
13-
{
14-
id: 'profileId_1',
15-
name: 'Profile 1',
16-
json: {
17-
Profile: {
18-
resourceTemplates: [
19-
{
20-
id: 'templateId_1',
21-
name: 'Template 1',
22-
},
23-
],
24-
},
25-
},
26-
},
27-
] as unknown as ProfileEntry[];
28-
2910
const lookupCacheService = jest.fn();
3011
const commonStatusService = jest.fn();
3112

@@ -114,40 +95,9 @@ describe('useConfig', () => {
11495
const record = {
11596
resource: {},
11697
} as RecordEntry;
117-
const mockCustomProfileConstant = getMockedImportedConstant(FeatureConstants, 'CUSTOM_PROFILE_ENABLED');
118-
119-
afterEach(() => {
120-
mockCustomProfileConstant(false);
121-
});
122-
123-
test('calls "fetchProfiles" and "setProfiles" and returns an array of profiles when CUSTOM_PROFILE_ENABLED is false', async () => {
124-
mockUseGlobalState();
125-
mockCustomProfileConstant(false);
126-
(fetchProfiles as jest.Mock).mockImplementation(() => profiles);
127-
128-
const { result } = renderHook(useConfig);
129-
const resultProfiles = await result.current.getProfiles({ record, recordId: '' });
130-
131-
expect(fetchProfiles).toHaveBeenCalled();
132-
expect(setProfiles).toHaveBeenCalledWith(profiles);
133-
expect(resultProfiles).toEqual(profiles);
134-
});
135-
136-
test('does not call "fetchProfiles" and "setProfiles" and returns a stored array of profiles when CUSTOM_PROFILE_ENABLED is false', async () => {
137-
mockUseGlobalState(profiles);
138-
mockCustomProfileConstant(false);
139-
140-
const { result } = renderHook(useConfig);
141-
const resultProfiles = await result.current.getProfiles({ record, recordId: '' });
142-
143-
expect(fetchProfiles).not.toHaveBeenCalled();
144-
expect(setProfiles).not.toHaveBeenCalled();
145-
expect(resultProfiles).toEqual(profiles);
146-
});
14798

148-
test('returns CUSTOM_PROFILE_MONOGRAPH and does not call fetchProfiles when CUSTOM_PROFILE_ENABLED is true', async () => {
99+
test('returns CUSTOM_PROFILE_MONOGRAPH and does not call fetchProfiles', async () => {
149100
mockUseGlobalState();
150-
mockCustomProfileConstant(true);
151101

152102
const { result } = renderHook(useConfig);
153103
const resultProfiles = await result.current.getProfiles({ record, recordId: '' });

src/test/__tests__/common/services/recordNormalizing/recordProcessingCases.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ describe('recordProcessingCases', () => {
1414
const groupKey = 'group_1';
1515
const testLabel = 'testLabel';
1616
const fieldName = 'testFieldName';
17-
const noteBFLiteUri = 'noteBFLiteUri';
1817
const linkBFLiteUri = 'linkBFLiteUri';
1918
const labelBFLiteUri = 'labelBFLiteUri';
2019
const creatorBFLiteUri = 'creatorBFLiteUri';
2120
const noteNonBFUri = '_notes';
2221

23-
mockedBFLiteUris({ NOTE: noteBFLiteUri, LINK: linkBFLiteUri, LABEL: labelBFLiteUri, CREATOR: creatorBFLiteUri });
22+
mockedBFLiteUris({ LINK: linkBFLiteUri, LABEL: labelBFLiteUri, CREATOR: creatorBFLiteUri });
2423

2524
describe('wrapWithContainer', () => {
2625
const container = 'groupContainer_1';
@@ -123,7 +122,7 @@ describe('recordProcessingCases', () => {
123122
type: [
124123
{
125124
[linkBFLiteUri]: ['testNoteType_1'],
126-
[testLabel]: [''],
125+
[labelBFLiteUri]: [''],
127126
},
128127
],
129128
},
@@ -132,7 +131,7 @@ describe('recordProcessingCases', () => {
132131
type: [
133132
{
134133
[linkBFLiteUri]: ['testNoteType_2'],
135-
[testLabel]: [''],
134+
[labelBFLiteUri]: [''],
136135
},
137136
],
138137
},

src/test/__tests__/common/services/schema/schemaWithDuplicates.service.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('SchemaWithDuplicatesService', () => {
3737
const entry = {
3838
path: ['testKey-0', 'testKey-2', 'testKey-4'],
3939
uuid: 'testKey-4',
40-
uri: 'mockUri',
40+
uriBFLite: 'mockUri',
4141
children: ['testKey-5'],
4242
constraints,
4343
};
@@ -87,7 +87,7 @@ describe('SchemaWithDuplicatesService', () => {
8787
{
8888
path: ['testKey-0', 'testKey-2', 'testKey-7'],
8989
uuid: 'testKey-7',
90-
uri: 'mockUri',
90+
uriBFLite: 'mockUri',
9191
cloneIndex: 1,
9292
children: ['testKey-8'],
9393
deletable: true,
@@ -129,7 +129,7 @@ describe('SchemaWithDuplicatesService', () => {
129129

130130
describe('deleteEntry', () => {
131131
const entry = {
132-
uri: 'mockUri',
132+
uriBFLite: 'mockUri',
133133
path: ['testKey-0', 'testKey-2', 'testKey-4', 'testKey-6'],
134134
uuid: 'testKey-6',
135135
children: ['nonExistent', 'testKey-7'],
@@ -154,7 +154,7 @@ describe('SchemaWithDuplicatesService', () => {
154154
[
155155
'testKey-5',
156156
{
157-
uri: 'mockUri',
157+
uriBFLite: 'mockUri',
158158
path: ['testKey-0', 'testKey-2', 'testKey-4', 'testKey-5'],
159159
uuid: 'testKey-5',
160160
children: [],
@@ -196,7 +196,7 @@ describe('SchemaWithDuplicatesService', () => {
196196
[
197197
'testKey-5',
198198
{
199-
uri: 'mockUri',
199+
uriBFLite: 'mockUri',
200200
path: ['testKey-0', 'testKey-2', 'testKey-4', 'testKey-5'],
201201
uuid: 'testKey-5',
202202
children: [],
@@ -206,7 +206,7 @@ describe('SchemaWithDuplicatesService', () => {
206206
[
207207
'testKey-5',
208208
{
209-
uri: 'mockUri',
209+
uriBFLite: 'mockUri',
210210
path: ['testKey-0', 'testKey-2', 'testKey-4', 'testKey-5'],
211211
uuid: 'testKey-5',
212212
children: [],
@@ -245,7 +245,7 @@ describe('SchemaWithDuplicatesService', () => {
245245
};
246246

247247
const childEntry = {
248-
uri: 'mockUri',
248+
uriBFLite: 'mockUri',
249249
uuid: 'testKey-2',
250250
path: ['testKey-1', 'testKey-2'],
251251
children: ['testKey-3'],
@@ -284,7 +284,7 @@ describe('SchemaWithDuplicatesService', () => {
284284
};
285285

286286
const childEntry = {
287-
uri: 'mockUri',
287+
uriBFLite: 'mockUri',
288288
uuid: 'testKey-2',
289289
path: ['testKey-1', 'testKey-2'],
290290
deletable: true,
@@ -313,7 +313,7 @@ describe('SchemaWithDuplicatesService', () => {
313313
{
314314
uuid: 'parent',
315315
path: ['parent'],
316-
uri: 'parent-uri',
316+
uriBFLite: 'parent-uri',
317317
children: ['child-1', 'child-2'],
318318
constraints: { repeatable: true },
319319
twinChildren: {
@@ -326,7 +326,7 @@ describe('SchemaWithDuplicatesService', () => {
326326
{
327327
uuid: 'child-1',
328328
path: ['parent', 'child-1'],
329-
uri: 'child-uri',
329+
uriBFLite: 'child-uri',
330330
cloneIndex: 0,
331331
children: [],
332332
},
@@ -336,7 +336,7 @@ describe('SchemaWithDuplicatesService', () => {
336336
{
337337
uuid: 'child-2',
338338
path: ['parent', 'child-2'],
339-
uri: 'child-uri',
339+
uriBFLite: 'child-uri',
340340
cloneIndex: 1,
341341
children: [],
342342
},

src/test/__tests__/common/services/userValues/userValueTypes/simpleLookup.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { waitFor } from '@testing-library/react';
12
import { AdvancedFieldType as AdvancedFieldTypeEnum } from '@common/constants/uiControls.constants';
23
import { SimpleLookupUserValueService } from '@common/services/userValues/userValueTypes';
34
import { IUserValueType } from '@common/services/userValues/userValueTypes/userValueType.interface';
@@ -25,7 +26,7 @@ describe('SimpleLookupUserValueService', () => {
2526
fieldUri: 'testFieldUri_1',
2627
} as UserValueDTO;
2728

28-
const result = await simpleLookupUserValueService.generate(value);
29+
const result = await waitFor(() => simpleLookupUserValueService.generate(value));
2930

3031
expect(result).toEqual(testResult);
3132
}

0 commit comments

Comments
 (0)