mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 14:03:06 +00:00
solved bug where equal objects were't compared by their properties
This commit is contained in:
@@ -57,23 +57,24 @@ describe('RegistryService', () => {
|
||||
});
|
||||
|
||||
const mockSchemasList = [
|
||||
{
|
||||
|
||||
Object.assign(new MetadataSchema(), {
|
||||
id: 1,
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadataschemas/1',
|
||||
prefix: 'dc',
|
||||
namespace: 'http://dublincore.org/documents/dcmi-terms/',
|
||||
type: MetadataSchema.type
|
||||
},
|
||||
{
|
||||
}),
|
||||
Object.assign(new MetadataSchema(), {
|
||||
id: 2,
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadataschemas/2',
|
||||
prefix: 'mock',
|
||||
namespace: 'http://dspace.org/mockschema',
|
||||
type: MetadataSchema.type
|
||||
}
|
||||
})
|
||||
];
|
||||
const mockFieldsList = [
|
||||
{
|
||||
Object.assign(new MetadataField(), {
|
||||
id: 1,
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/8',
|
||||
element: 'contributor',
|
||||
@@ -81,8 +82,8 @@ describe('RegistryService', () => {
|
||||
scopeNote: null,
|
||||
schema: mockSchemasList[0],
|
||||
type: MetadataField.type
|
||||
},
|
||||
{
|
||||
}),
|
||||
Object.assign(new MetadataField(), {
|
||||
id: 2,
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/9',
|
||||
element: 'contributor',
|
||||
@@ -90,8 +91,8 @@ describe('RegistryService', () => {
|
||||
scopeNote: null,
|
||||
schema: mockSchemasList[0],
|
||||
type: MetadataField.type
|
||||
},
|
||||
{
|
||||
}),
|
||||
Object.assign(new MetadataField(), {
|
||||
id: 3,
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/10',
|
||||
element: 'contributor',
|
||||
@@ -99,8 +100,8 @@ describe('RegistryService', () => {
|
||||
scopeNote: 'test scope note',
|
||||
schema: mockSchemasList[1],
|
||||
type: MetadataField.type
|
||||
},
|
||||
{
|
||||
}),
|
||||
Object.assign(new MetadataField(), {
|
||||
id: 4,
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/11',
|
||||
element: 'contributor',
|
||||
@@ -108,7 +109,7 @@ describe('RegistryService', () => {
|
||||
scopeNote: null,
|
||||
schema: mockSchemasList[1],
|
||||
type: MetadataField.type
|
||||
}
|
||||
})
|
||||
];
|
||||
|
||||
const pageInfo = new PageInfo();
|
||||
|
@@ -19,6 +19,9 @@ function equalsByFields(object1, object2, fieldList): boolean {
|
||||
if (object1[key] instanceof EquatableObject) {
|
||||
return !object1[key].equals(object2[key]);
|
||||
}
|
||||
if (typeof object1[key] === 'object') {
|
||||
equalsByFields(object1[key], object2[key], Object.keys(object1))
|
||||
}
|
||||
return object1[key] !== object2[key];
|
||||
});
|
||||
return hasNoValue(unequalProperty);
|
||||
|
@@ -27,6 +27,8 @@ import { AuthorityConfidenceStateDirective } from '../../../../../authority-conf
|
||||
import { ObjNgFor } from '../../../../../utils/object-ngfor.pipe';
|
||||
import { GLOBAL_CONFIG, GlobalConfig } from '../../../../../../../config';
|
||||
import { MOCK_SUBMISSION_CONFIG } from '../../../../../testing/mock-submission-config';
|
||||
import { WorkspaceitemsEditPageModule } from '../../../../../../+workspaceitems-edit-page/workspaceitems-edit-page.module';
|
||||
import { WorkspaceItem } from '../../../../../../core/submission/models/workspaceitem.model';
|
||||
|
||||
let LOOKUP_TEST_MODEL_CONFIG = {
|
||||
authorityOptions: {
|
||||
@@ -47,7 +49,8 @@ let LOOKUP_TEST_MODEL_CONFIG = {
|
||||
repeatable: true,
|
||||
separator: ',',
|
||||
validators: { required: null },
|
||||
value: undefined
|
||||
value: undefined,
|
||||
workspaceItem: new WorkspaceItem()
|
||||
};
|
||||
|
||||
let LOOKUP_NAME_TEST_MODEL_CONFIG = {
|
||||
@@ -69,7 +72,8 @@ let LOOKUP_NAME_TEST_MODEL_CONFIG = {
|
||||
repeatable: true,
|
||||
separator: ',',
|
||||
validators: { required: null },
|
||||
value: undefined
|
||||
value: undefined,
|
||||
workspaceItem: new WorkspaceItem()
|
||||
};
|
||||
|
||||
let LOOKUP_TEST_GROUP = new FormGroup({
|
||||
@@ -100,7 +104,8 @@ describe('Dynamic Lookup component', () => {
|
||||
repeatable: true,
|
||||
separator: ',',
|
||||
validators: { required: null },
|
||||
value: undefined
|
||||
value: undefined,
|
||||
workspaceItem: new WorkspaceItem()
|
||||
};
|
||||
|
||||
LOOKUP_NAME_TEST_MODEL_CONFIG = {
|
||||
@@ -122,7 +127,8 @@ describe('Dynamic Lookup component', () => {
|
||||
repeatable: true,
|
||||
separator: ',',
|
||||
validators: { required: null },
|
||||
value: undefined
|
||||
value: undefined,
|
||||
workspaceItem: new WorkspaceItem()
|
||||
};
|
||||
|
||||
LOOKUP_TEST_GROUP = new FormGroup({
|
||||
|
@@ -26,6 +26,7 @@ import { MOCK_SUBMISSION_CONFIG } from '../../../../../testing/mock-submission-c
|
||||
import { Store, StoreModule } from '@ngrx/store';
|
||||
import { MockStore } from '../../../../../testing/mock-store';
|
||||
import { FormRowModel } from '../../../../../../core/config/models/config-submission-form.model';
|
||||
import { WorkspaceItem } from '../../../../../../core/submission/models/workspaceitem.model';
|
||||
|
||||
export let FORM_GROUP_TEST_MODEL_CONFIG;
|
||||
|
||||
@@ -77,7 +78,9 @@ function init() {
|
||||
required: true,
|
||||
scopeUUID: '43fe1f8c-09a6-4fcf-9c78-5d4fed8f2c8f',
|
||||
submissionScope: undefined,
|
||||
validators: { required: null }
|
||||
validators: { required: null },
|
||||
workspaceItem: new WorkspaceItem(),
|
||||
repeatable: false
|
||||
} as DynamicRelationGroupModelConfig;
|
||||
|
||||
FORM_GROUP_TEST_GROUP = new FormGroup({
|
||||
@@ -183,7 +186,7 @@ describe('DsDynamicRelationGroupComponent test suite', () => {
|
||||
|
||||
it('should init component properly', inject([FormBuilderService], (service: FormBuilderService) => {
|
||||
const formConfig = { rows: groupComp.model.formConfiguration } as SubmissionFormsModel;
|
||||
const formModel = service.modelFromConfiguration(formConfig, groupComp.model.scopeUUID, {}, groupComp.model.submissionScope, groupComp.model.readOnly);
|
||||
const formModel = service.modelFromConfiguration(formConfig, groupComp.model.scopeUUID, {}, new WorkspaceItem(), groupComp.model.submissionScope, groupComp.model.readOnly);
|
||||
const chips = new Chips([], 'value', 'dc.contributor.author');
|
||||
groupComp.formCollapsed.subscribe((value) => {
|
||||
expect(value).toEqual(false);
|
||||
@@ -257,11 +260,11 @@ describe('DsDynamicRelationGroupComponent test suite', () => {
|
||||
|
||||
it('should init component properly', inject([FormBuilderService], (service: FormBuilderService) => {
|
||||
const formConfig = { rows: groupComp.model.formConfiguration } as SubmissionFormsModel;
|
||||
const formModel = service.modelFromConfiguration(formConfig, groupComp.model.scopeUUID, {}, groupComp.model.submissionScope, groupComp.model.readOnly);
|
||||
const formModel = service.modelFromConfiguration(formConfig, groupComp.model.scopeUUID, {}, new WorkspaceItem(), groupComp.model.submissionScope, groupComp.model.readOnly);
|
||||
const chips = new Chips(modelValue, 'value', 'dc.contributor.author');
|
||||
groupComp.formCollapsed.subscribe((value) => {
|
||||
expect(value).toEqual(true);
|
||||
})
|
||||
});
|
||||
expect(groupComp.formModel.length).toEqual(formModel.length);
|
||||
expect(groupComp.chips.getChipsItems()).toEqual(chips.getChipsItems());
|
||||
}));
|
||||
|
@@ -16,6 +16,7 @@ import { DsDynamicScrollableDropdownComponent } from './dynamic-scrollable-dropd
|
||||
import { DynamicScrollableDropdownModel } from './dynamic-scrollable-dropdown.model';
|
||||
import { AuthorityValue } from '../../../../../../core/integration/models/authority.value';
|
||||
import { createTestComponent, hasClass } from '../../../../../testing/utils';
|
||||
import { WorkspaceItem } from '../../../../../../core/submission/models/workspaceitem.model';
|
||||
|
||||
export const SD_TEST_GROUP = new FormGroup({
|
||||
dropdown: new FormControl(),
|
||||
@@ -38,7 +39,8 @@ export const SD_TEST_MODEL_CONFIG = {
|
||||
readOnly: false,
|
||||
required: false,
|
||||
repeatable: false,
|
||||
value: undefined
|
||||
value: undefined,
|
||||
workspaceItem: new WorkspaceItem()
|
||||
};
|
||||
|
||||
describe('Dynamic Dynamic Scrollable Dropdown component', () => {
|
||||
|
@@ -49,6 +49,7 @@ import { DynamicConcatModel } from './ds-dynamic-form-ui/models/ds-dynamic-conca
|
||||
import { DynamicLookupNameModel } from './ds-dynamic-form-ui/models/lookup/dynamic-lookup-name.model';
|
||||
import { DynamicRowArrayModel } from './ds-dynamic-form-ui/models/ds-dynamic-row-array-model';
|
||||
import { FormRowModel } from '../../../core/config/models/config-submission-form.model';
|
||||
import { WorkspaceItem } from '../../../core/submission/models/workspaceitem.model';
|
||||
|
||||
describe('FormBuilderService test suite', () => {
|
||||
|
||||
@@ -193,11 +194,11 @@ describe('FormBuilderService test suite', () => {
|
||||
|
||||
new DynamicColorPickerModel({id: 'testColorPicker'}),
|
||||
|
||||
new DynamicTypeaheadModel({id: 'testTypeahead'}),
|
||||
new DynamicTypeaheadModel({id: 'testTypeahead', workspaceItem: new WorkspaceItem(), repeatable: false}),
|
||||
|
||||
new DynamicScrollableDropdownModel({id: 'testScrollableDropdown', authorityOptions: authorityOptions}),
|
||||
new DynamicScrollableDropdownModel({id: 'testScrollableDropdown', authorityOptions: authorityOptions, workspaceItem: new WorkspaceItem(), repeatable: false}),
|
||||
|
||||
new DynamicTagModel({id: 'testTag'}),
|
||||
new DynamicTagModel({id: 'testTag', workspaceItem: new WorkspaceItem(), repeatable: false}),
|
||||
|
||||
new DynamicListCheckboxGroupModel({id: 'testCheckboxList', authorityOptions: authorityOptions, repeatable: true}),
|
||||
|
||||
@@ -239,14 +240,16 @@ describe('FormBuilderService test suite', () => {
|
||||
name: 'testRelationGroup',
|
||||
relationFields: [],
|
||||
scopeUUID: '',
|
||||
submissionScope: ''
|
||||
submissionScope: '',
|
||||
workspaceItem: new WorkspaceItem(),
|
||||
repeatable: false
|
||||
}),
|
||||
|
||||
new DynamicDsDatePickerModel({id: 'testDate'}),
|
||||
|
||||
new DynamicLookupModel({id: 'testLookup'}),
|
||||
new DynamicLookupModel({id: 'testLookup', workspaceItem: new WorkspaceItem(), repeatable: false}),
|
||||
|
||||
new DynamicLookupNameModel({id: 'testLookupName'}),
|
||||
new DynamicLookupNameModel({id: 'testLookupName', workspaceItem: new WorkspaceItem(), repeatable: false}),
|
||||
|
||||
new DynamicQualdropModel({id: 'testCombobox', readOnly: false}),
|
||||
|
||||
@@ -406,7 +409,7 @@ describe('FormBuilderService test suite', () => {
|
||||
});
|
||||
|
||||
it('should create an array of form models', () => {
|
||||
const formModel = service.modelFromConfiguration(testFormConfiguration, 'testScopeUUID');
|
||||
const formModel = service.modelFromConfiguration(testFormConfiguration, 'testScopeUUID', {}, new WorkspaceItem());
|
||||
|
||||
expect(formModel[0] instanceof DynamicRowGroupModel).toBe(true);
|
||||
expect((formModel[0] as DynamicRowGroupModel).group.length).toBe(3);
|
||||
@@ -427,7 +430,7 @@ describe('FormBuilderService test suite', () => {
|
||||
});
|
||||
|
||||
it('should return form\'s fields value from form model', () => {
|
||||
const formModel = service.modelFromConfiguration(testFormConfiguration, 'testScopeUUID');
|
||||
const formModel = service.modelFromConfiguration(testFormConfiguration, 'testScopeUUID', {}, new WorkspaceItem());
|
||||
let value = {} as any;
|
||||
|
||||
expect(service.getValueFromModel(formModel)).toEqual(value);
|
||||
@@ -448,7 +451,7 @@ describe('FormBuilderService test suite', () => {
|
||||
});
|
||||
|
||||
it('should clear all form\'s fields value', () => {
|
||||
const formModel = service.modelFromConfiguration(testFormConfiguration, 'testScopeUUID');
|
||||
const formModel = service.modelFromConfiguration(testFormConfiguration, 'testScopeUUID', {}, new WorkspaceItem());
|
||||
const value = {} as any;
|
||||
|
||||
((formModel[0] as DynamicRowGroupModel).get(1) as DsDynamicInputModel).valueUpdates.next('test');
|
||||
@@ -460,7 +463,7 @@ describe('FormBuilderService test suite', () => {
|
||||
});
|
||||
|
||||
it('should return true when model has a custom group model as parent', () => {
|
||||
const formModel = service.modelFromConfiguration(testFormConfiguration, 'testScopeUUID');
|
||||
const formModel = service.modelFromConfiguration(testFormConfiguration, 'testScopeUUID', {}, new WorkspaceItem());
|
||||
let model = service.findById('dc_identifier_QUALDROP_VALUE', formModel);
|
||||
let modelParent = service.findById('dc_identifier_QUALDROP_GROUP', formModel);
|
||||
model.parent = modelParent;
|
||||
@@ -489,7 +492,7 @@ describe('FormBuilderService test suite', () => {
|
||||
});
|
||||
|
||||
it('should return true when model value is a map', () => {
|
||||
const formModel = service.modelFromConfiguration(testFormConfiguration, 'testScopeUUID');
|
||||
const formModel = service.modelFromConfiguration(testFormConfiguration, 'testScopeUUID', {}, new WorkspaceItem());
|
||||
const model = service.findById('dc_identifier_QUALDROP_VALUE', formModel);
|
||||
const modelParent = service.findById('dc_identifier_QUALDROP_GROUP', formModel);
|
||||
model.parent = modelParent;
|
||||
@@ -498,7 +501,7 @@ describe('FormBuilderService test suite', () => {
|
||||
});
|
||||
|
||||
it('should return true when model is a Qualdrop Group', () => {
|
||||
const formModel = service.modelFromConfiguration(testFormConfiguration, 'testScopeUUID');
|
||||
const formModel = service.modelFromConfiguration(testFormConfiguration, 'testScopeUUID', {}, new WorkspaceItem());
|
||||
let model = service.findById('dc_identifier_QUALDROP_GROUP', formModel);
|
||||
|
||||
expect(service.isQualdropGroup(model)).toBe(true);
|
||||
@@ -509,7 +512,7 @@ describe('FormBuilderService test suite', () => {
|
||||
});
|
||||
|
||||
it('should return true when model is a Custom or List Group', () => {
|
||||
const formModel = service.modelFromConfiguration(testFormConfiguration, 'testScopeUUID');
|
||||
const formModel = service.modelFromConfiguration(testFormConfiguration, 'testScopeUUID', {}, new WorkspaceItem());
|
||||
let model = service.findById('dc_identifier_QUALDROP_GROUP', formModel);
|
||||
|
||||
expect(service.isCustomOrListGroup(model)).toBe(true);
|
||||
@@ -528,7 +531,7 @@ describe('FormBuilderService test suite', () => {
|
||||
});
|
||||
|
||||
it('should return true when model is a Custom Group', () => {
|
||||
const formModel = service.modelFromConfiguration(testFormConfiguration, 'testScopeUUID');
|
||||
const formModel = service.modelFromConfiguration(testFormConfiguration, 'testScopeUUID', {}, new WorkspaceItem());
|
||||
let model = service.findById('dc_identifier_QUALDROP_GROUP', formModel);
|
||||
|
||||
expect(service.isCustomGroup(model)).toBe(true);
|
||||
|
@@ -18,4 +18,9 @@ export class SearchResult<T extends DSpaceObject> extends ListableObject {
|
||||
*/
|
||||
@excludeFromEquals
|
||||
hitHighlights: MetadataMap;
|
||||
|
||||
@excludeFromEquals
|
||||
_links: {};
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user