mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-12 04:23:04 +00:00
Merge branch 'main' into w2p-87382_circular-dependency-fixes
This commit is contained in:
@@ -12,7 +12,7 @@ import { SubmissionServiceStub } from '../../../shared/testing/submission-servic
|
||||
import { getMockTranslateService } from '../../../shared/mocks/translate.service.mock';
|
||||
import { SectionsService } from '../sections.service';
|
||||
import { SectionsServiceStub } from '../../../shared/testing/sections-service.stub';
|
||||
import { SubmissionSectionformComponent } from './section-form.component';
|
||||
import { SubmissionSectionFormComponent } from './section-form.component';
|
||||
import { FormBuilderService } from '../../../shared/form/builder/form-builder.service';
|
||||
import { getMockFormBuilderService } from '../../../shared/mocks/form-builder-service.mock';
|
||||
import { getMockFormOperationsService } from '../../../shared/mocks/form-operations-service.mock';
|
||||
@@ -23,9 +23,7 @@ import { SubmissionFormsConfigService } from '../../../core/config/submission-fo
|
||||
import { SectionDataObject } from '../models/section-data.model';
|
||||
import { SectionsType } from '../sections-type';
|
||||
import {
|
||||
mockSubmissionCollectionId,
|
||||
mockSubmissionId,
|
||||
mockUploadResponse1ParsedErrors
|
||||
mockSubmissionCollectionId, mockSubmissionId, mockUploadResponse1ParsedErrors,
|
||||
} from '../../../shared/mocks/submission.mock';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { CommonModule } from '@angular/common';
|
||||
@@ -44,6 +42,7 @@ import { ObjectCacheService } from '../../../core/cache/object-cache.service';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
||||
import { cold } from 'jasmine-marbles';
|
||||
import { WorkflowItem } from '../../../core/submission/models/workflowitem.model';
|
||||
import { SubmissionSectionError } from '../../objects/submission-section-error.model';
|
||||
|
||||
function getMockSubmissionFormsConfigService(): SubmissionFormsConfigService {
|
||||
@@ -137,11 +136,11 @@ const dynamicFormControlEvent: DynamicFormControlEvent = {
|
||||
type: DynamicFormControlEventType.Change
|
||||
};
|
||||
|
||||
describe('SubmissionSectionformComponent test suite', () => {
|
||||
describe('SubmissionSectionFormComponent test suite', () => {
|
||||
|
||||
let comp: SubmissionSectionformComponent;
|
||||
let comp: SubmissionSectionFormComponent;
|
||||
let compAsAny: any;
|
||||
let fixture: ComponentFixture<SubmissionSectionformComponent>;
|
||||
let fixture: ComponentFixture<SubmissionSectionFormComponent>;
|
||||
let submissionServiceStub: SubmissionServiceStub;
|
||||
let notificationsServiceStub: NotificationsServiceStub;
|
||||
let formService: any = getMockFormService();
|
||||
@@ -167,7 +166,7 @@ describe('SubmissionSectionformComponent test suite', () => {
|
||||
],
|
||||
declarations: [
|
||||
FormComponent,
|
||||
SubmissionSectionformComponent,
|
||||
SubmissionSectionFormComponent,
|
||||
TestComponent
|
||||
],
|
||||
providers: [
|
||||
@@ -186,7 +185,7 @@ describe('SubmissionSectionformComponent test suite', () => {
|
||||
{ provide: 'submissionIdProvider', useValue: submissionId },
|
||||
{ provide: SubmissionObjectDataService, useValue: { getHrefByID: () => observableOf('testUrl'), findById: () => createSuccessfulRemoteDataObject$(new WorkspaceItem()) } },
|
||||
ChangeDetectorRef,
|
||||
SubmissionSectionformComponent
|
||||
SubmissionSectionFormComponent
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents().then();
|
||||
@@ -215,7 +214,7 @@ describe('SubmissionSectionformComponent test suite', () => {
|
||||
testFixture.destroy();
|
||||
});
|
||||
|
||||
it('should create SubmissionSectionformComponent', inject([SubmissionSectionformComponent], (app: SubmissionSectionformComponent) => {
|
||||
it('should create SubmissionSectionFormComponent', inject([SubmissionSectionFormComponent], (app: SubmissionSectionFormComponent) => {
|
||||
|
||||
expect(app).toBeDefined();
|
||||
|
||||
@@ -224,7 +223,7 @@ describe('SubmissionSectionformComponent test suite', () => {
|
||||
|
||||
describe('', () => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(SubmissionSectionformComponent);
|
||||
fixture = TestBed.createComponent(SubmissionSectionFormComponent);
|
||||
comp = fixture.componentInstance;
|
||||
compAsAny = comp;
|
||||
submissionServiceStub = TestBed.inject(SubmissionService as any);
|
||||
@@ -296,8 +295,10 @@ describe('SubmissionSectionformComponent test suite', () => {
|
||||
};
|
||||
compAsAny.formData = {};
|
||||
compAsAny.sectionMetadata = ['dc.title'];
|
||||
spyOn(compAsAny, 'inCurrentSubmissionScope').and.callThrough();
|
||||
|
||||
expect(comp.hasMetadataEnrichment(newSectionData)).toBeTruthy();
|
||||
expect(compAsAny.inCurrentSubmissionScope).toHaveBeenCalledWith('dc.title');
|
||||
});
|
||||
|
||||
it('should return false when has not Metadata Enrichment', () => {
|
||||
@@ -306,7 +307,10 @@ describe('SubmissionSectionformComponent test suite', () => {
|
||||
};
|
||||
compAsAny.formData = newSectionData;
|
||||
compAsAny.sectionMetadata = ['dc.title'];
|
||||
spyOn(compAsAny, 'inCurrentSubmissionScope').and.callThrough();
|
||||
|
||||
expect(comp.hasMetadataEnrichment(newSectionData)).toBeFalsy();
|
||||
expect(compAsAny.inCurrentSubmissionScope).toHaveBeenCalledWith('dc.title');
|
||||
});
|
||||
|
||||
it('should return false when metadata has Metadata Enrichment but not belonging to sectionMetadata', () => {
|
||||
@@ -318,6 +322,77 @@ describe('SubmissionSectionformComponent test suite', () => {
|
||||
expect(comp.hasMetadataEnrichment(newSectionData)).toBeFalsy();
|
||||
});
|
||||
|
||||
describe('inCurrentSubmissionScope', () => {
|
||||
beforeEach(() => {
|
||||
// @ts-ignore
|
||||
comp.formConfig = {
|
||||
rows: [
|
||||
{
|
||||
fields: [
|
||||
{
|
||||
selectableMetadata: [{ metadata: 'scoped.workflow' }],
|
||||
scope: 'WORKFLOW',
|
||||
} as FormFieldModel
|
||||
]
|
||||
},
|
||||
{
|
||||
fields: [
|
||||
{
|
||||
selectableMetadata: [{ metadata: 'scoped.workspace' }],
|
||||
scope: 'WORKSPACE',
|
||||
} as FormFieldModel
|
||||
]
|
||||
},
|
||||
{
|
||||
fields: [
|
||||
{
|
||||
selectableMetadata: [{ metadata: 'dc.title' }],
|
||||
} as FormFieldModel
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
});
|
||||
|
||||
describe('in workspace scope', () => {
|
||||
beforeEach(() => {
|
||||
// @ts-ignore
|
||||
comp.submissionObject = { type: WorkspaceItem.type };
|
||||
});
|
||||
|
||||
it('should return true for unscoped fields', () => {
|
||||
expect((comp as any).inCurrentSubmissionScope('dc.title')).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true for fields scoped to workspace', () => {
|
||||
expect((comp as any).inCurrentSubmissionScope('scoped.workspace')).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for fields scoped to workflow', () => {
|
||||
expect((comp as any).inCurrentSubmissionScope('scoped.workflow')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('in workflow scope', () => {
|
||||
beforeEach(() => {
|
||||
// @ts-ignore
|
||||
comp.submissionObject = { type: WorkflowItem.type };
|
||||
});
|
||||
|
||||
it('should return true when field is unscoped', () => {
|
||||
expect((comp as any).inCurrentSubmissionScope('dc.title')).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true for fields scoped to workflow', () => {
|
||||
expect((comp as any).inCurrentSubmissionScope('scoped.workflow')).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for fields scoped to workspace', () => {
|
||||
expect((comp as any).inCurrentSubmissionScope('scoped.workspace')).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should update form properly', () => {
|
||||
spyOn(comp, 'initForm');
|
||||
spyOn(comp, 'checksForErrors');
|
||||
|
Reference in New Issue
Block a user