mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-14 13:33:03 +00:00
Added tests
This commit is contained in:
@@ -138,7 +138,7 @@ describe('JsonPatchOperationsService test suite', () => {
|
||||
});
|
||||
|
||||
it('should dispatch a new StartTransactionPatchOperationsAction', () => {
|
||||
const expectedAction = new StartTransactionPatchOperationsAction(testJsonPatchResourceType, undefined, timestamp)
|
||||
const expectedAction = new StartTransactionPatchOperationsAction(testJsonPatchResourceType, undefined, timestamp);
|
||||
scheduler.schedule(() => service.jsonPatchByResourceType(resourceEndpoint, resourceScope, testJsonPatchResourceType).subscribe());
|
||||
scheduler.flush();
|
||||
|
||||
@@ -147,7 +147,7 @@ describe('JsonPatchOperationsService test suite', () => {
|
||||
|
||||
describe('when request is successful', () => {
|
||||
it('should dispatch a new CommitPatchOperationsAction', () => {
|
||||
const expectedAction = new CommitPatchOperationsAction(testJsonPatchResourceType, undefined)
|
||||
const expectedAction = new CommitPatchOperationsAction(testJsonPatchResourceType, undefined);
|
||||
scheduler.schedule(() => service.jsonPatchByResourceType(resourceEndpoint, resourceScope, testJsonPatchResourceType).subscribe());
|
||||
scheduler.flush();
|
||||
|
||||
@@ -171,7 +171,7 @@ describe('JsonPatchOperationsService test suite', () => {
|
||||
|
||||
it('should dispatch a new RollbacktPatchOperationsAction', () => {
|
||||
|
||||
const expectedAction = new RollbacktPatchOperationsAction(testJsonPatchResourceType, undefined)
|
||||
const expectedAction = new RollbacktPatchOperationsAction(testJsonPatchResourceType, undefined);
|
||||
scheduler.schedule(() => service.jsonPatchByResourceType(resourceEndpoint, resourceScope, testJsonPatchResourceType).subscribe());
|
||||
scheduler.flush();
|
||||
|
||||
@@ -200,7 +200,7 @@ describe('JsonPatchOperationsService test suite', () => {
|
||||
});
|
||||
|
||||
it('should dispatch a new StartTransactionPatchOperationsAction', () => {
|
||||
const expectedAction = new StartTransactionPatchOperationsAction(testJsonPatchResourceType, testJsonPatchResourceId, timestamp)
|
||||
const expectedAction = new StartTransactionPatchOperationsAction(testJsonPatchResourceType, testJsonPatchResourceId, timestamp);
|
||||
scheduler.schedule(() => service.jsonPatchByResourceID(resourceEndpoint, resourceScope, testJsonPatchResourceType, testJsonPatchResourceId).subscribe());
|
||||
scheduler.flush();
|
||||
|
||||
@@ -209,7 +209,7 @@ describe('JsonPatchOperationsService test suite', () => {
|
||||
|
||||
describe('when request is successful', () => {
|
||||
it('should dispatch a new CommitPatchOperationsAction', () => {
|
||||
const expectedAction = new CommitPatchOperationsAction(testJsonPatchResourceType, testJsonPatchResourceId)
|
||||
const expectedAction = new CommitPatchOperationsAction(testJsonPatchResourceType, testJsonPatchResourceId);
|
||||
scheduler.schedule(() => service.jsonPatchByResourceID(resourceEndpoint, resourceScope, testJsonPatchResourceType, testJsonPatchResourceId).subscribe());
|
||||
scheduler.flush();
|
||||
|
||||
@@ -233,7 +233,7 @@ describe('JsonPatchOperationsService test suite', () => {
|
||||
|
||||
it('should dispatch a new RollbacktPatchOperationsAction', () => {
|
||||
|
||||
const expectedAction = new RollbacktPatchOperationsAction(testJsonPatchResourceType, testJsonPatchResourceId)
|
||||
const expectedAction = new RollbacktPatchOperationsAction(testJsonPatchResourceType, testJsonPatchResourceId);
|
||||
scheduler.schedule(() => service.jsonPatchByResourceID(resourceEndpoint, resourceScope, testJsonPatchResourceType, testJsonPatchResourceId).subscribe());
|
||||
scheduler.flush();
|
||||
|
||||
|
@@ -1,4 +1,61 @@
|
||||
export const submissionRestREsponse = [
|
||||
import { SubmissionObjectState } from '../../submission/objects/submission-objects.reducer';
|
||||
import { SubmissionDefinitionsModel } from '../../core/config/models/config-submission-definitions.model';
|
||||
import { PaginatedList } from '../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../core/shared/page-info.model';
|
||||
import { FormFieldMetadataValueObject } from '../form/builder/models/form-field-metadata-value.model';
|
||||
|
||||
export const mockSectionsData = {
|
||||
traditionalpageone:{
|
||||
'dc.title': [
|
||||
new FormFieldMetadataValueObject('test', null, null, 'test' )
|
||||
]},
|
||||
license: {
|
||||
url: null,
|
||||
acceptanceDate: null,
|
||||
granted: false
|
||||
},
|
||||
upload: {
|
||||
files: []
|
||||
}
|
||||
};
|
||||
|
||||
export const mockSectionsDataTwo = {
|
||||
traditionalpageone:{
|
||||
'dc.title': [
|
||||
new FormFieldMetadataValueObject('test', null, null, 'test' )
|
||||
]},
|
||||
traditionalpagetwo:{
|
||||
'dc.relation': [
|
||||
new FormFieldMetadataValueObject('test', null, null, 'test' )
|
||||
]},
|
||||
license: {
|
||||
url: null,
|
||||
acceptanceDate: null,
|
||||
granted: false
|
||||
},
|
||||
upload: {
|
||||
files: []
|
||||
}
|
||||
};
|
||||
|
||||
export const mockSectionsErrors = [
|
||||
{
|
||||
message: 'error.validation.required',
|
||||
paths: [
|
||||
'/sections/traditionalpageone/dc.contributor.author',
|
||||
'/sections/traditionalpageone/dc.title',
|
||||
'/sections/traditionalpageone/dc.date.issued'
|
||||
]
|
||||
},
|
||||
{
|
||||
message: 'error.validation.license.notgranted',
|
||||
paths: [
|
||||
'/sections/license'
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
export const submissionRestResponse = [
|
||||
{
|
||||
id: 826,
|
||||
lastModified: '2018-08-03T12:49:45.268+0000',
|
||||
@@ -98,16 +155,7 @@ export const submissionRestREsponse = [
|
||||
}
|
||||
}
|
||||
],
|
||||
sections: {
|
||||
license: {
|
||||
url: null,
|
||||
acceptanceDate: null,
|
||||
granted: false
|
||||
},
|
||||
upload: {
|
||||
files: []
|
||||
}
|
||||
},
|
||||
sections: {},
|
||||
submissionDefinition: [
|
||||
{
|
||||
isDefault: true,
|
||||
@@ -151,7 +199,7 @@ export const submissionRestREsponse = [
|
||||
},
|
||||
{
|
||||
header: 'submit.progressbar.describe.steptwo',
|
||||
mandatory: true,
|
||||
mandatory: false,
|
||||
sectionType: 'submission-form',
|
||||
type: 'submissionsection',
|
||||
_links: {
|
||||
@@ -197,22 +245,7 @@ export const submissionRestREsponse = [
|
||||
}
|
||||
],
|
||||
submitter: [],
|
||||
errors: [
|
||||
{
|
||||
message: 'error.validation.required',
|
||||
paths: [
|
||||
'/sections/traditionalpageone/dc.contributor.author',
|
||||
'/sections/traditionalpageone/dc.title',
|
||||
'/sections/traditionalpageone/dc.date.issued'
|
||||
]
|
||||
},
|
||||
{
|
||||
message: 'error.validation.license.notgranted',
|
||||
paths: [
|
||||
'/sections/license'
|
||||
]
|
||||
}
|
||||
],
|
||||
errors: [],
|
||||
self: 'https://rest.api/dspace-spring-rest/api/submission/workspaceitems/826',
|
||||
type: 'workspaceitem',
|
||||
_links: {
|
||||
@@ -224,3 +257,277 @@ export const submissionRestREsponse = [
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
export const mockSubmissionCollectionId = '1c11f3f1-ba1f-4f36-908a-3f1ea9a557eb';
|
||||
export const mockSubmissionId = '826';
|
||||
export const mockSubmissionSelfUrl = 'https://rest.api/dspace-spring-rest/api/submission/workspaceitems/826';
|
||||
|
||||
export const mockSubmissionDefinitionResponse = {
|
||||
isDefault: true,
|
||||
sections: [
|
||||
{
|
||||
mandatory: true,
|
||||
sectionType: 'utils',
|
||||
visibility: {
|
||||
main: 'HIDDEN',
|
||||
other: 'HIDDEN'
|
||||
},
|
||||
type: 'submissionsection',
|
||||
_links: {
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/extraction'
|
||||
},
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/extraction'
|
||||
},
|
||||
{
|
||||
mandatory: true,
|
||||
sectionType: 'collection',
|
||||
visibility: {
|
||||
main: 'HIDDEN',
|
||||
other: 'HIDDEN'
|
||||
},
|
||||
type: 'submissionsection',
|
||||
_links: {
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/collection'
|
||||
},
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/collection'
|
||||
},
|
||||
{
|
||||
header: 'submit.progressbar.describe.stepone',
|
||||
mandatory: true,
|
||||
sectionType: 'submission-form',
|
||||
type: 'submissionsection',
|
||||
_links: {
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/traditionalpageone',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpageone'
|
||||
},
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/traditionalpageone'
|
||||
},
|
||||
{
|
||||
header: 'submit.progressbar.describe.steptwo',
|
||||
mandatory: false,
|
||||
sectionType: 'submission-form',
|
||||
type: 'submissionsection',
|
||||
_links: {
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/traditionalpagetwo',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpagetwo'
|
||||
},
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/traditionalpagetwo'
|
||||
},
|
||||
{
|
||||
header: 'submit.progressbar.upload',
|
||||
mandatory: true,
|
||||
sectionType: 'upload',
|
||||
type: 'submissionsection',
|
||||
_links: {
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/upload',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionuploads/upload'
|
||||
},
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/upload'
|
||||
},
|
||||
{
|
||||
header: 'submit.progressbar.license',
|
||||
mandatory: true,
|
||||
sectionType: 'license',
|
||||
visibility: {
|
||||
main: null,
|
||||
other: 'READONLY'
|
||||
},
|
||||
type: 'submissionsection',
|
||||
_links: {
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/license'
|
||||
},
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/license'
|
||||
}
|
||||
],
|
||||
name: 'traditional',
|
||||
type: 'submissiondefinition',
|
||||
_links: {
|
||||
collections: 'https://rest.api/dspace-spring-rest/api/config/submissiondefinitions/traditional/collections',
|
||||
sections: 'https://rest.api/dspace-spring-rest/api/config/submissiondefinitions/traditional/sections',
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissiondefinitions/traditional'
|
||||
},
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissiondefinitions/traditional'
|
||||
} as any;
|
||||
|
||||
export const mockSubmissionDefinition: SubmissionDefinitionsModel = {
|
||||
isDefault: true,
|
||||
sections: new PaginatedList(new PageInfo(),[
|
||||
{
|
||||
mandatory: true,
|
||||
sectionType: 'utils',
|
||||
visibility: {
|
||||
main: 'HIDDEN',
|
||||
other: 'HIDDEN'
|
||||
},
|
||||
type: 'submissionsection',
|
||||
_links: {
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/extraction'
|
||||
},
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/extraction'
|
||||
},
|
||||
{
|
||||
mandatory: true,
|
||||
sectionType: 'collection',
|
||||
visibility: {
|
||||
main: 'HIDDEN',
|
||||
other: 'HIDDEN'
|
||||
},
|
||||
type: 'submissionsection',
|
||||
_links: {
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/collection'
|
||||
},
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/collection'
|
||||
},
|
||||
{
|
||||
header: 'submit.progressbar.describe.stepone',
|
||||
mandatory: true,
|
||||
sectionType: 'submission-form',
|
||||
type: 'submissionsection',
|
||||
_links: {
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/traditionalpageone',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpageone'
|
||||
},
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/traditionalpageone'
|
||||
},
|
||||
{
|
||||
header: 'submit.progressbar.describe.steptwo',
|
||||
mandatory: false,
|
||||
sectionType: 'submission-form',
|
||||
type: 'submissionsection',
|
||||
_links: {
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/traditionalpagetwo',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpagetwo'
|
||||
},
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/traditionalpagetwo'
|
||||
},
|
||||
{
|
||||
header: 'submit.progressbar.upload',
|
||||
mandatory: true,
|
||||
sectionType: 'upload',
|
||||
type: 'submissionsection',
|
||||
_links: {
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/upload',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionuploads/upload'
|
||||
},
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/upload'
|
||||
},
|
||||
{
|
||||
header: 'submit.progressbar.license',
|
||||
mandatory: true,
|
||||
sectionType: 'license',
|
||||
visibility: {
|
||||
main: null,
|
||||
other: 'READONLY'
|
||||
},
|
||||
type: 'submissionsection',
|
||||
_links: {
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/license'
|
||||
},
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/license'
|
||||
}
|
||||
]),
|
||||
name: 'traditional',
|
||||
type: 'submissiondefinition',
|
||||
_links: {
|
||||
collections: 'https://rest.api/dspace-spring-rest/api/config/submissiondefinitions/traditional/collections',
|
||||
sections: 'https://rest.api/dspace-spring-rest/api/config/submissiondefinitions/traditional/sections',
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissiondefinitions/traditional'
|
||||
},
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissiondefinitions/traditional'
|
||||
} as any;
|
||||
|
||||
export const mockSubmissionState: SubmissionObjectState = {
|
||||
826: {
|
||||
collection: mockSubmissionCollectionId,
|
||||
definition: 'traditional',
|
||||
selfUrl: mockSubmissionSelfUrl,
|
||||
activeSection: null,
|
||||
sections: {
|
||||
extraction: {
|
||||
config: '',
|
||||
mandatory: true,
|
||||
sectionType: 'utils',
|
||||
visibility: {
|
||||
main: 'HIDDEN',
|
||||
other: 'HIDDEN'
|
||||
},
|
||||
collapsed: false,
|
||||
enabled: true,
|
||||
data: {},
|
||||
errors: [],
|
||||
isLoading: false,
|
||||
isValid: false
|
||||
} as any,
|
||||
collection: {
|
||||
config: '',
|
||||
mandatory: true,
|
||||
sectionType: 'collection',
|
||||
visibility: {
|
||||
main: 'HIDDEN',
|
||||
other: 'HIDDEN'
|
||||
},
|
||||
collapsed: false,
|
||||
enabled: true,
|
||||
data: {},
|
||||
errors: [],
|
||||
isLoading: false,
|
||||
isValid: false
|
||||
} as any,
|
||||
traditionalpageone: {
|
||||
header: 'submit.progressbar.describe.stepone',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpageone',
|
||||
mandatory: true,
|
||||
sectionType: 'submission-form',
|
||||
collapsed: false,
|
||||
enabled: true,
|
||||
data: {},
|
||||
errors: [],
|
||||
isLoading: false,
|
||||
isValid: false
|
||||
} as any,
|
||||
traditionalpagetwo: {
|
||||
header: 'submit.progressbar.describe.steptwo',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpagetwo',
|
||||
mandatory: false,
|
||||
sectionType: 'submission-form',
|
||||
collapsed: false,
|
||||
enabled: false,
|
||||
data: {},
|
||||
errors: [],
|
||||
isLoading: false,
|
||||
isValid: false
|
||||
} as any,
|
||||
upload: {
|
||||
header: 'submit.progressbar.upload',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionuploads/upload',
|
||||
mandatory: true,
|
||||
sectionType: 'upload',
|
||||
collapsed: false,
|
||||
enabled: true,
|
||||
data: {},
|
||||
errors: [],
|
||||
isLoading: false,
|
||||
isValid: false
|
||||
} as any,
|
||||
license: {
|
||||
header: 'submit.progressbar.license',
|
||||
config: '',
|
||||
mandatory: true,
|
||||
sectionType: 'license',
|
||||
visibility: {
|
||||
main: null,
|
||||
other: 'READONLY'
|
||||
},
|
||||
collapsed: false,
|
||||
enabled: true,
|
||||
data: {},
|
||||
errors: [],
|
||||
isLoading: false,
|
||||
isValid: false
|
||||
} as any
|
||||
},
|
||||
isLoading: false,
|
||||
savePending: false,
|
||||
depositPending: false
|
||||
}
|
||||
};
|
||||
|
@@ -1,44 +1,13 @@
|
||||
import {of as observableOf, Observable } from 'rxjs';
|
||||
import { INotification } from '../notifications/models/notification.model';
|
||||
import { NotificationOptions } from '../notifications/models/notification-options.model';
|
||||
|
||||
export class NotificationsServiceStub {
|
||||
|
||||
success(title: any = observableOf(''),
|
||||
content: any = observableOf(''),
|
||||
options: NotificationOptions = this.getDefaultOptions(),
|
||||
html?: any): INotification {
|
||||
return
|
||||
}
|
||||
|
||||
error(title: any = observableOf(''),
|
||||
content: any = observableOf(''),
|
||||
options: NotificationOptions = this.getDefaultOptions(),
|
||||
html?: any): INotification {
|
||||
return
|
||||
}
|
||||
|
||||
info(title: any = observableOf(''),
|
||||
content: any = observableOf(''),
|
||||
options: NotificationOptions = this.getDefaultOptions(),
|
||||
html?: any): INotification {
|
||||
return
|
||||
}
|
||||
|
||||
warning(title: any = observableOf(''),
|
||||
content: any = observableOf(''),
|
||||
options: NotificationOptions = this.getDefaultOptions(),
|
||||
html?: any): INotification {
|
||||
return
|
||||
}
|
||||
|
||||
remove(notification: INotification) {
|
||||
return
|
||||
}
|
||||
|
||||
removeAll() {
|
||||
return
|
||||
}
|
||||
success = jasmine.createSpy('success');
|
||||
error = jasmine.createSpy('error');
|
||||
info = jasmine.createSpy('info');
|
||||
warning = jasmine.createSpy('warning');
|
||||
remove = jasmine.createSpy('remove');
|
||||
removeAll = jasmine.createSpy('removeAll');
|
||||
|
||||
private getDefaultOptions(): NotificationOptions {
|
||||
return new NotificationOptions();
|
||||
|
18
src/app/shared/testing/sections-service-stub.ts
Normal file
18
src/app/shared/testing/sections-service-stub.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export class SectionsServiceStub {
|
||||
|
||||
checkSectionErrors = jasmine.createSpy('checkSectionErrors');
|
||||
dispatchRemoveSectionErrors = jasmine.createSpy('dispatchRemoveSectionErrors');
|
||||
getSectionData = jasmine.createSpy('getSectionData');
|
||||
getSectionErrors = jasmine.createSpy('getSectionErrors');
|
||||
getSectionState = jasmine.createSpy('getSectionState');
|
||||
isSectionValid = jasmine.createSpy('isSectionValid');
|
||||
isSectionEnabled = jasmine.createSpy('isSectionEnabled');
|
||||
isSectionReadOnly = jasmine.createSpy('isSectionReadOnly');
|
||||
isSectionAvailable = jasmine.createSpy('isSectionAvailable');
|
||||
addSection = jasmine.createSpy('addSection');
|
||||
removeSection = jasmine.createSpy('removeSection');
|
||||
updateSectionData = jasmine.createSpy('updateSectionData');
|
||||
setSectionError = jasmine.createSpy('setSectionError');
|
||||
setSectionStatus = jasmine.createSpy('setSectionStatus');
|
||||
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
import { SubmissionPatchRequest } from '../../core/data/request.models';
|
||||
|
||||
export class SubmissionJsonPatchOperationsServiceStub {
|
||||
protected linkPath = 'workspaceitems';
|
||||
protected patchRequestConstructor: SubmissionPatchRequest;
|
||||
|
||||
jsonPatchByResourceType = jasmine.createSpy('jsonPatchByResourceType');
|
||||
jsonPatchByResourceID = jasmine.createSpy('jsonPatchByResourceID');
|
||||
|
||||
}
|
33
src/app/shared/testing/submission-service-stub.ts
Normal file
33
src/app/shared/testing/submission-service-stub.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
export class SubmissionServiceStub {
|
||||
|
||||
changeSubmissionCollection = jasmine.createSpy('changeSubmissionCollection');
|
||||
createSubmission = jasmine.createSpy('createSubmission');
|
||||
depositSubmission = jasmine.createSpy('depositSubmission');
|
||||
discardSubmission = jasmine.createSpy('discardSubmission');
|
||||
dispatchInit = jasmine.createSpy('dispatchInit');
|
||||
dispatchDeposit = jasmine.createSpy('dispatchDeposit');
|
||||
dispatchDiscard = jasmine.createSpy('dispatchDiscard');
|
||||
dispatchSave = jasmine.createSpy('dispatchSave');
|
||||
dispatchSaveForLater = jasmine.createSpy('dispatchSaveForLater');
|
||||
dispatchSaveSection = jasmine.createSpy('dispatchSaveSection');
|
||||
getActiveSectionId = jasmine.createSpy('getActiveSectionId');
|
||||
getSubmissionObject = jasmine.createSpy('getSubmissionObject');
|
||||
getSubmissionSections = jasmine.createSpy('getSubmissionSections');
|
||||
getDisabledSectionsList = jasmine.createSpy('getDisabledSectionsList');
|
||||
getSubmissionObjectLinkName = jasmine.createSpy('getSubmissionObjectLinkName');
|
||||
getSubmissionScope = jasmine.createSpy('getSubmissionScope');
|
||||
getSubmissionStatus = jasmine.createSpy('getSubmissionStatus');
|
||||
getSubmissionSaveProcessingStatus = jasmine.createSpy('getSubmissionSaveProcessingStatus');
|
||||
getSubmissionDepositProcessingStatus = jasmine.createSpy('getSubmissionDepositProcessingStatus');
|
||||
isSectionHidden = jasmine.createSpy('isSectionHidden');
|
||||
isSubmissionLoading = jasmine.createSpy('isSubmissionLoading');
|
||||
notifyNewSection = jasmine.createSpy('notifyNewSection');
|
||||
redirectToMyDSpace = jasmine.createSpy('redirectToMyDSpace');
|
||||
resetAllSubmissionObjects = jasmine.createSpy('resetAllSubmissionObjects');
|
||||
resetSubmissionObject = jasmine.createSpy('resetSubmissionObject');
|
||||
retrieveSubmission = jasmine.createSpy('retrieveSubmission');
|
||||
setActiveSection = jasmine.createSpy('setActiveSection');
|
||||
startAutoSave = jasmine.createSpy('startAutoSave');
|
||||
stopAutoSave = jasmine.createSpy('stopAutoSave');
|
||||
|
||||
}
|
814
src/app/submission/objects/submission-objects.effects.spec.ts
Normal file
814
src/app/submission/objects/submission-objects.effects.spec.ts
Normal file
@@ -0,0 +1,814 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { cold, hot } from 'jasmine-marbles';
|
||||
import { provideMockActions } from '@ngrx/effects/testing';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { Observable, of as observableOf, throwError as observableThrowError } from 'rxjs';
|
||||
import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core';
|
||||
|
||||
import { SubmissionObjectEffects } from './submission-objects.effects';
|
||||
import {
|
||||
CompleteInitSubmissionFormAction,
|
||||
DepositSubmissionAction,
|
||||
DepositSubmissionErrorAction,
|
||||
DepositSubmissionSuccessAction, DiscardSubmissionErrorAction, DiscardSubmissionSuccessAction,
|
||||
InitSectionAction,
|
||||
InitSubmissionFormAction,
|
||||
SaveForLaterSubmissionFormSuccessAction,
|
||||
SaveSubmissionFormErrorAction,
|
||||
SaveSubmissionFormSuccessAction,
|
||||
SaveSubmissionSectionFormErrorAction,
|
||||
SaveSubmissionSectionFormSuccessAction,
|
||||
SubmissionObjectActionTypes,
|
||||
UpdateSectionDataAction
|
||||
} from './submission-objects.actions';
|
||||
import {
|
||||
mockSectionsData,
|
||||
mockSectionsDataTwo,
|
||||
mockSectionsErrors,
|
||||
mockSubmissionCollectionId,
|
||||
mockSubmissionDefinition,
|
||||
mockSubmissionDefinitionResponse,
|
||||
mockSubmissionId,
|
||||
mockSubmissionSelfUrl,
|
||||
mockSubmissionState,
|
||||
submissionRestResponse
|
||||
} from '../../shared/mocks/mock-submission';
|
||||
import { SubmissionSectionModel } from '../../core/config/models/config-submission-section.model';
|
||||
import { NotificationsServiceStub } from '../../shared/testing/notifications-service-stub';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
import { SubmissionJsonPatchOperationsServiceStub } from '../../shared/testing/submission-json-patch-operations-service-stub';
|
||||
import { SubmissionJsonPatchOperationsService } from '../../core/submission/submission-json-patch-operations.service';
|
||||
import { SectionsService } from '../sections/sections.service';
|
||||
import { SectionsServiceStub } from '../../shared/testing/sections-service-stub';
|
||||
import { SubmissionService } from '../submission.service';
|
||||
import { SubmissionServiceStub } from '../../shared/testing/submission-service-stub';
|
||||
import { MockTranslateLoader } from '../../shared/mocks/mock-translate-loader';
|
||||
import { MockStore } from '../../shared/testing/mock-store';
|
||||
import { AppState } from '../../app.reducer';
|
||||
import parseSectionErrors from '../utils/parseSectionErrors';
|
||||
|
||||
describe('SubmissionObjectEffects test suite', () => {
|
||||
let submissionObjectEffects: SubmissionObjectEffects;
|
||||
let actions: Observable<any>;
|
||||
let store: MockStore<AppState>;
|
||||
|
||||
const notificationsServiceStub = new NotificationsServiceStub();
|
||||
const submissionServiceStub = new SubmissionServiceStub();
|
||||
const submissionJsonPatchOperationsServiceStub = new SubmissionJsonPatchOperationsServiceStub();
|
||||
const collectionId: string = mockSubmissionCollectionId;
|
||||
const submissionId: string = mockSubmissionId;
|
||||
const submissionDefinitionResponse: any = mockSubmissionDefinitionResponse;
|
||||
const submissionDefinition: any = mockSubmissionDefinition;
|
||||
const selfUrl: string = mockSubmissionSelfUrl;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useClass: MockTranslateLoader
|
||||
}
|
||||
}),
|
||||
],
|
||||
providers: [
|
||||
SubmissionObjectEffects,
|
||||
TranslateService,
|
||||
{provide: Store, useValue: new MockStore({})},
|
||||
provideMockActions(() => actions),
|
||||
{provide: NotificationsService, useValue: notificationsServiceStub},
|
||||
{provide: SectionsService, useClass: SectionsServiceStub},
|
||||
{provide: SubmissionService, useValue: submissionServiceStub},
|
||||
{provide: SubmissionJsonPatchOperationsService, useValue: submissionJsonPatchOperationsServiceStub},
|
||||
],
|
||||
});
|
||||
|
||||
submissionObjectEffects = TestBed.get(SubmissionObjectEffects);
|
||||
});
|
||||
|
||||
describe('loadForm$', () => {
|
||||
it('should return a INIT_SECTION action for each defined section and a COMPLETE_INIT_SUBMISSION_FORM action', () => {
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.INIT_SUBMISSION_FORM,
|
||||
payload: {
|
||||
collectionId: collectionId,
|
||||
submissionId: submissionId,
|
||||
selfUrl: selfUrl,
|
||||
submissionDefinition: submissionDefinition,
|
||||
sections: {},
|
||||
errors: [],
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const mappedActions = [];
|
||||
(submissionDefinitionResponse.sections as SubmissionSectionModel[])
|
||||
.forEach((sectionDefinition: SubmissionSectionModel) => {
|
||||
const sectionId = sectionDefinition._links.self.substr(sectionDefinition._links.self.lastIndexOf('/') + 1);
|
||||
const config = sectionDefinition._links.config || '';
|
||||
const enabled = (sectionDefinition.mandatory);
|
||||
const sectionData = {};
|
||||
const sectionErrors = null;
|
||||
mappedActions.push(new InitSectionAction(
|
||||
submissionId,
|
||||
sectionId,
|
||||
sectionDefinition.header,
|
||||
config,
|
||||
sectionDefinition.mandatory,
|
||||
sectionDefinition.sectionType,
|
||||
sectionDefinition.visibility,
|
||||
enabled,
|
||||
sectionData,
|
||||
sectionErrors))
|
||||
});
|
||||
mappedActions.push(new CompleteInitSubmissionFormAction(submissionId));
|
||||
|
||||
const expected = cold('--(bcdefgh)', {
|
||||
b: mappedActions[0],
|
||||
c: mappedActions[1],
|
||||
d: mappedActions[2],
|
||||
e: mappedActions[3],
|
||||
f: mappedActions[4],
|
||||
g: mappedActions[5],
|
||||
h: mappedActions[6]
|
||||
});
|
||||
|
||||
expect(submissionObjectEffects.loadForm$).toBeObservable(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('resetForm$', () => {
|
||||
it('should return a INIT_SUBMISSION_FORM action', () => {
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.RESET_SUBMISSION_FORM,
|
||||
payload: {
|
||||
collectionId: collectionId,
|
||||
submissionId: submissionId,
|
||||
selfUrl: selfUrl,
|
||||
submissionDefinition: submissionDefinition,
|
||||
sections: {},
|
||||
errors: [],
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const expected = cold('--b-', {
|
||||
b: new InitSubmissionFormAction(
|
||||
collectionId,
|
||||
submissionId,
|
||||
selfUrl,
|
||||
submissionDefinition,
|
||||
{},
|
||||
null
|
||||
)
|
||||
});
|
||||
|
||||
expect(submissionObjectEffects.resetForm$).toBeObservable(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('saveSubmission$', () => {
|
||||
it('should return a SAVE_SUBMISSION_FORM_SUCCESS action on success', () => {
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.SAVE_SUBMISSION_FORM,
|
||||
payload: {
|
||||
submissionId: submissionId
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
submissionJsonPatchOperationsServiceStub.jsonPatchByResourceType.and.returnValue(observableOf(submissionRestResponse));
|
||||
const expected = cold('--b-', {
|
||||
b: new SaveSubmissionFormSuccessAction(
|
||||
submissionId,
|
||||
submissionRestResponse as any
|
||||
)
|
||||
});
|
||||
|
||||
expect(submissionObjectEffects.saveSubmission$).toBeObservable(expected);
|
||||
});
|
||||
|
||||
it('should return a SAVE_SUBMISSION_FORM_ERROR action on error', () => {
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.SAVE_SUBMISSION_FORM,
|
||||
payload: {
|
||||
submissionId: submissionId
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
submissionJsonPatchOperationsServiceStub.jsonPatchByResourceType.and.callFake(
|
||||
() => observableThrowError('Error')
|
||||
);
|
||||
const expected = cold('--b-', {
|
||||
b: new SaveSubmissionFormErrorAction(
|
||||
submissionId
|
||||
)
|
||||
});
|
||||
|
||||
expect(submissionObjectEffects.saveSubmission$).toBeObservable(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('saveForLaterSubmission$', () => {
|
||||
it('should return a SAVE_FOR_LATER_SUBMISSION_FORM_SUCCESS action on success', () => {
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.SAVE_FOR_LATER_SUBMISSION_FORM,
|
||||
payload: {
|
||||
submissionId: submissionId
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
submissionJsonPatchOperationsServiceStub.jsonPatchByResourceType.and.returnValue(observableOf(submissionRestResponse));
|
||||
const expected = cold('--b-', {
|
||||
b: new SaveForLaterSubmissionFormSuccessAction(
|
||||
submissionId,
|
||||
submissionRestResponse as any
|
||||
)
|
||||
});
|
||||
|
||||
expect(submissionObjectEffects.saveForLaterSubmission$).toBeObservable(expected);
|
||||
});
|
||||
|
||||
it('should return a SAVE_SUBMISSION_FORM_ERROR action on error', () => {
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.SAVE_FOR_LATER_SUBMISSION_FORM,
|
||||
payload: {
|
||||
submissionId: submissionId
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
submissionJsonPatchOperationsServiceStub.jsonPatchByResourceType.and.callFake(
|
||||
() => observableThrowError('Error')
|
||||
);
|
||||
const expected = cold('--b-', {
|
||||
b: new SaveSubmissionFormErrorAction(
|
||||
submissionId
|
||||
)
|
||||
});
|
||||
|
||||
expect(submissionObjectEffects.saveForLaterSubmission$).toBeObservable(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('saveSubmissionSuccess$', () => {
|
||||
|
||||
it('should return a UPLOAD_SECTION_DATA action for each updated section', () => {
|
||||
store = TestBed.get(Store);
|
||||
store.nextState({
|
||||
submission: {
|
||||
objects: mockSubmissionState
|
||||
}
|
||||
} as any);
|
||||
|
||||
const response = [Object.assign({}, submissionRestResponse[0], {
|
||||
sections: mockSectionsData,
|
||||
errors: mockSectionsErrors
|
||||
})];
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.SAVE_SUBMISSION_FORM_SUCCESS,
|
||||
payload: {
|
||||
submissionId: submissionId,
|
||||
submissionObject: response
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const errorsList = parseSectionErrors(mockSectionsErrors);
|
||||
const expected = cold('--(bcd)-', {
|
||||
b: new UpdateSectionDataAction(
|
||||
submissionId,
|
||||
'traditionalpageone',
|
||||
mockSectionsData.traditionalpageone as any,
|
||||
errorsList.traditionalpageone || []
|
||||
),
|
||||
c: new UpdateSectionDataAction(
|
||||
submissionId,
|
||||
'license',
|
||||
mockSectionsData.license as any,
|
||||
errorsList.license || []
|
||||
),
|
||||
d: new UpdateSectionDataAction(
|
||||
submissionId,
|
||||
'upload',
|
||||
mockSectionsData.upload as any,
|
||||
errorsList.upload || []
|
||||
),
|
||||
});
|
||||
|
||||
expect(submissionObjectEffects.saveSubmissionSuccess$).toBeObservable(expected);
|
||||
expect(notificationsServiceStub.success).toHaveBeenCalled();
|
||||
|
||||
});
|
||||
|
||||
it('should display a success notification', () => {
|
||||
store = TestBed.get(Store);
|
||||
store.nextState({
|
||||
submission: {
|
||||
objects: mockSubmissionState
|
||||
}
|
||||
} as any);
|
||||
|
||||
const response = [Object.assign({}, submissionRestResponse[0], {
|
||||
sections: mockSectionsData
|
||||
})];
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.SAVE_SUBMISSION_FORM_SUCCESS,
|
||||
payload: {
|
||||
submissionId: submissionId,
|
||||
submissionObject: response
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const expected = cold('--(bcd)-', {
|
||||
b: new UpdateSectionDataAction(
|
||||
submissionId,
|
||||
'traditionalpageone',
|
||||
mockSectionsData.traditionalpageone as any,
|
||||
[]
|
||||
),
|
||||
c: new UpdateSectionDataAction(
|
||||
submissionId,
|
||||
'license',
|
||||
mockSectionsData.license as any,
|
||||
[]
|
||||
),
|
||||
d: new UpdateSectionDataAction(
|
||||
submissionId,
|
||||
'upload',
|
||||
mockSectionsData.upload as any,
|
||||
[]
|
||||
),
|
||||
});
|
||||
|
||||
expect(submissionObjectEffects.saveSubmissionSuccess$).toBeObservable(expected);
|
||||
expect(notificationsServiceStub.success).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should display a warning notification when there are errors', () => {
|
||||
store = TestBed.get(Store);
|
||||
store.nextState({
|
||||
submission: {
|
||||
objects: mockSubmissionState
|
||||
}
|
||||
} as any);
|
||||
|
||||
const response = [Object.assign({}, submissionRestResponse[0], {
|
||||
sections: mockSectionsData,
|
||||
errors: mockSectionsErrors
|
||||
})];
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.SAVE_SUBMISSION_FORM_SUCCESS,
|
||||
payload: {
|
||||
submissionId: submissionId,
|
||||
submissionObject: response
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const errorsList = parseSectionErrors(mockSectionsErrors);
|
||||
const expected = cold('--(bcd)-', {
|
||||
b: new UpdateSectionDataAction(
|
||||
submissionId,
|
||||
'traditionalpageone',
|
||||
mockSectionsData.traditionalpageone as any,
|
||||
errorsList.traditionalpageone || []
|
||||
),
|
||||
c: new UpdateSectionDataAction(
|
||||
submissionId,
|
||||
'license',
|
||||
mockSectionsData.license as any,
|
||||
errorsList.license || []
|
||||
),
|
||||
d: new UpdateSectionDataAction(
|
||||
submissionId,
|
||||
'upload',
|
||||
mockSectionsData.upload as any,
|
||||
errorsList.upload || []
|
||||
),
|
||||
});
|
||||
|
||||
expect(submissionObjectEffects.saveSubmissionSuccess$).toBeObservable(expected);
|
||||
expect(notificationsServiceStub.warning).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should detect and notify a new section', () => {
|
||||
store = TestBed.get(Store);
|
||||
store.nextState({
|
||||
submission: {
|
||||
objects: mockSubmissionState
|
||||
}
|
||||
} as any);
|
||||
|
||||
const response = [Object.assign({}, submissionRestResponse[0], {
|
||||
sections: mockSectionsDataTwo,
|
||||
errors: mockSectionsErrors
|
||||
})];
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.SAVE_SUBMISSION_FORM_SUCCESS,
|
||||
payload: {
|
||||
submissionId: submissionId,
|
||||
submissionObject: response
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const errorsList = parseSectionErrors(mockSectionsErrors);
|
||||
const expected = cold('--(bcde)-', {
|
||||
b: new UpdateSectionDataAction(
|
||||
submissionId,
|
||||
'traditionalpageone',
|
||||
mockSectionsDataTwo.traditionalpageone as any,
|
||||
errorsList.traditionalpageone || []
|
||||
),
|
||||
c: new UpdateSectionDataAction(
|
||||
submissionId,
|
||||
'traditionalpagetwo',
|
||||
mockSectionsDataTwo.traditionalpagetwo as any,
|
||||
errorsList.traditionalpagetwo || []
|
||||
),
|
||||
d: new UpdateSectionDataAction(
|
||||
submissionId,
|
||||
'license',
|
||||
mockSectionsDataTwo.license as any,
|
||||
errorsList.license || []
|
||||
),
|
||||
e: new UpdateSectionDataAction(
|
||||
submissionId,
|
||||
'upload',
|
||||
mockSectionsDataTwo.upload as any,
|
||||
errorsList.upload || []
|
||||
),
|
||||
});
|
||||
|
||||
expect(submissionObjectEffects.saveSubmissionSuccess$).toBeObservable(expected);
|
||||
expect(submissionServiceStub.notifyNewSection).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('saveSection$', () => {
|
||||
it('should return a SAVE_SUBMISSION_SECTION_FORM_SUCCESS action on success', () => {
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.SAVE_SUBMISSION_SECTION_FORM,
|
||||
payload: {
|
||||
submissionId: submissionId,
|
||||
sectionId: 'traditionalpageone'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
submissionJsonPatchOperationsServiceStub.jsonPatchByResourceID.and.returnValue(observableOf(submissionRestResponse));
|
||||
const expected = cold('--b-', {
|
||||
b: new SaveSubmissionSectionFormSuccessAction(
|
||||
submissionId,
|
||||
submissionRestResponse as any
|
||||
)
|
||||
});
|
||||
|
||||
expect(submissionObjectEffects.saveSection$).toBeObservable(expected);
|
||||
});
|
||||
|
||||
it('should return a SAVE_SUBMISSION_SECTION_FORM_ERROR action on error', () => {
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.SAVE_SUBMISSION_SECTION_FORM,
|
||||
payload: {
|
||||
submissionId: submissionId,
|
||||
sectionId: 'traditionalpageone'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
submissionJsonPatchOperationsServiceStub.jsonPatchByResourceID.and.callFake(
|
||||
() => observableThrowError('Error')
|
||||
);
|
||||
const expected = cold('--b-', {
|
||||
b: new SaveSubmissionSectionFormErrorAction(
|
||||
submissionId
|
||||
)
|
||||
});
|
||||
|
||||
expect(submissionObjectEffects.saveSection$).toBeObservable(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('saveAndDepositSection$', () => {
|
||||
it('should return a DEPOSIT_SUBMISSION action on success', () => {
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.SAVE_AND_DEPOSIT_SUBMISSION,
|
||||
payload: {
|
||||
submissionId: submissionId
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const response = [Object.assign({}, submissionRestResponse[0], {
|
||||
sections: mockSectionsDataTwo
|
||||
})];
|
||||
|
||||
submissionJsonPatchOperationsServiceStub.jsonPatchByResourceType.and.returnValue(observableOf(response));
|
||||
const expected = cold('--b-', {
|
||||
b: new DepositSubmissionAction(
|
||||
submissionId
|
||||
)
|
||||
});
|
||||
|
||||
expect(submissionObjectEffects.saveAndDeposit$).toBeObservable(expected);
|
||||
});
|
||||
|
||||
it('should not allow to deposit when there are errors', () => {
|
||||
store = TestBed.get(Store);
|
||||
store.nextState({
|
||||
submission: {
|
||||
objects: mockSubmissionState
|
||||
}
|
||||
} as any);
|
||||
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.SAVE_AND_DEPOSIT_SUBMISSION,
|
||||
payload: {
|
||||
submissionId: submissionId
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const response = [Object.assign({}, submissionRestResponse[0], {
|
||||
sections: mockSectionsData,
|
||||
errors: mockSectionsErrors
|
||||
})];
|
||||
|
||||
submissionJsonPatchOperationsServiceStub.jsonPatchByResourceType.and.returnValue(observableOf(response));
|
||||
|
||||
const errorsList = parseSectionErrors(mockSectionsErrors);
|
||||
const expected = cold('--b-', {
|
||||
b: [
|
||||
new UpdateSectionDataAction(
|
||||
submissionId,
|
||||
'traditionalpageone',
|
||||
mockSectionsData.traditionalpageone as any,
|
||||
errorsList.traditionalpageone || []
|
||||
),
|
||||
new UpdateSectionDataAction(
|
||||
submissionId,
|
||||
'license',
|
||||
mockSectionsData.license as any,
|
||||
errorsList.license || []
|
||||
),
|
||||
new UpdateSectionDataAction(
|
||||
submissionId,
|
||||
'upload',
|
||||
mockSectionsData.upload as any,
|
||||
errorsList.upload || []
|
||||
)
|
||||
]
|
||||
});
|
||||
|
||||
expect(submissionObjectEffects.saveAndDeposit$).toBeObservable(expected);
|
||||
});
|
||||
|
||||
it('should catch errors and return a SAVE_SUBMISSION_FORM_ERROR', () => {
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.SAVE_AND_DEPOSIT_SUBMISSION,
|
||||
payload: {
|
||||
submissionId: submissionId
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
submissionJsonPatchOperationsServiceStub.jsonPatchByResourceType.and.callFake(
|
||||
() => observableThrowError('Error')
|
||||
);
|
||||
const expected = cold('--b-', {
|
||||
b: new SaveSubmissionFormErrorAction(
|
||||
submissionId
|
||||
)
|
||||
});
|
||||
|
||||
expect(submissionObjectEffects.saveAndDeposit$).toBeObservable(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('depositSubmission$', () => {
|
||||
it('should return a DEPOSIT_SUBMISSION_SUCCESS action on success', () => {
|
||||
store = TestBed.get(Store);
|
||||
store.nextState({
|
||||
submission: {
|
||||
objects: mockSubmissionState
|
||||
}
|
||||
} as any);
|
||||
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.DEPOSIT_SUBMISSION,
|
||||
payload: {
|
||||
submissionId: submissionId
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
submissionServiceStub.depositSubmission.and.returnValue(observableOf(submissionRestResponse));
|
||||
const expected = cold('--b-', {
|
||||
b: new DepositSubmissionSuccessAction(
|
||||
submissionId
|
||||
)
|
||||
});
|
||||
|
||||
expect(submissionObjectEffects.depositSubmission$).toBeObservable(expected);
|
||||
});
|
||||
|
||||
it('should return a DEPOSIT_SUBMISSION_ERROR action on error', () => {
|
||||
store = TestBed.get(Store);
|
||||
store.nextState({
|
||||
submission: {
|
||||
objects: mockSubmissionState
|
||||
}
|
||||
} as any);
|
||||
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.DEPOSIT_SUBMISSION,
|
||||
payload: {
|
||||
submissionId: submissionId
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
submissionServiceStub.depositSubmission.and.callFake(
|
||||
() => observableThrowError('Error')
|
||||
);
|
||||
const expected = cold('--b-', {
|
||||
b: new DepositSubmissionErrorAction(
|
||||
submissionId
|
||||
)
|
||||
});
|
||||
|
||||
expect(submissionObjectEffects.depositSubmission$).toBeObservable(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('saveForLaterSubmissionSuccess$', () => {
|
||||
it('should display a new success notification and redirect to mydspace', () => {
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.SAVE_FOR_LATER_SUBMISSION_FORM_SUCCESS,
|
||||
payload: {
|
||||
submissionId: submissionId,
|
||||
submissionObject: submissionRestResponse
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
submissionObjectEffects.saveForLaterSubmissionSuccess$.subscribe(() => {
|
||||
expect(notificationsServiceStub.success).toHaveBeenCalled();
|
||||
expect(submissionServiceStub.redirectToMyDSpace).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('depositSubmissionSuccess$', () => {
|
||||
it('should display a new success notification and redirect to mydspace', () => {
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.DEPOSIT_SUBMISSION_SUCCESS,
|
||||
payload: {
|
||||
submissionId: submissionId
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
submissionObjectEffects.depositSubmissionSuccess$.subscribe(() => {
|
||||
expect(notificationsServiceStub.success).toHaveBeenCalled();
|
||||
expect(submissionServiceStub.redirectToMyDSpace).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('depositSubmissionError$', () => {
|
||||
it('should display a new error notification', () => {
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.DEPOSIT_SUBMISSION_ERROR,
|
||||
payload: {
|
||||
submissionId: submissionId
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
submissionObjectEffects.depositSubmissionError$.subscribe(() => {
|
||||
expect(notificationsServiceStub.error).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('discardSubmission$', () => {
|
||||
it('should return a DISCARD_SUBMISSION_SUCCESS action on success', () => {
|
||||
store = TestBed.get(Store);
|
||||
store.nextState({
|
||||
submission: {
|
||||
objects: mockSubmissionState
|
||||
}
|
||||
} as any);
|
||||
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.DISCARD_SUBMISSION,
|
||||
payload: {
|
||||
submissionId: submissionId
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
submissionServiceStub.discardSubmission.and.returnValue(observableOf(submissionRestResponse));
|
||||
const expected = cold('--b-', {
|
||||
b: new DiscardSubmissionSuccessAction(
|
||||
submissionId
|
||||
)
|
||||
});
|
||||
|
||||
expect(submissionObjectEffects.discardSubmission$).toBeObservable(expected);
|
||||
});
|
||||
|
||||
it('should return a DISCARD_SUBMISSION_ERROR action on error', () => {
|
||||
store = TestBed.get(Store);
|
||||
store.nextState({
|
||||
submission: {
|
||||
objects: mockSubmissionState
|
||||
}
|
||||
} as any);
|
||||
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.DISCARD_SUBMISSION,
|
||||
payload: {
|
||||
submissionId: submissionId
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
submissionServiceStub.discardSubmission.and.callFake(
|
||||
() => observableThrowError('Error')
|
||||
);
|
||||
const expected = cold('--b-', {
|
||||
b: new DiscardSubmissionErrorAction(
|
||||
submissionId
|
||||
)
|
||||
});
|
||||
|
||||
expect(submissionObjectEffects.discardSubmission$).toBeObservable(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('discardSubmissionSuccess$', () => {
|
||||
it('should display a new success notification and redirect to mydspace', () => {
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.DISCARD_SUBMISSION_SUCCESS,
|
||||
payload: {
|
||||
submissionId: submissionId
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
submissionObjectEffects.discardSubmissionSuccess$.subscribe(() => {
|
||||
expect(notificationsServiceStub.success).toHaveBeenCalled();
|
||||
expect(submissionServiceStub.redirectToMyDSpace).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('discardSubmissionError$', () => {
|
||||
it('should display a new error notification', () => {
|
||||
actions = hot('--a-', {
|
||||
a: {
|
||||
type: SubmissionObjectActionTypes.DISCARD_SUBMISSION_ERROR,
|
||||
payload: {
|
||||
submissionId: submissionId
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
submissionObjectEffects.discardSubmissionError$.subscribe(() => {
|
||||
expect(notificationsServiceStub.error).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@@ -137,7 +137,7 @@ export class SubmissionObjectEffects {
|
||||
catchError(() => observableOf(new SaveSubmissionSectionFormErrorAction(action.payload.submissionId))));
|
||||
}));
|
||||
|
||||
@Effect() saveAndDepositSection$ = this.actions$.pipe(
|
||||
@Effect() saveAndDeposit$ = this.actions$.pipe(
|
||||
ofType(SubmissionObjectActionTypes.SAVE_AND_DEPOSIT_SUBMISSION),
|
||||
withLatestFrom(this.store$),
|
||||
switchMap(([action, currentState]: [SaveAndDepositSubmissionAction, any]) => {
|
||||
@@ -153,7 +153,7 @@ export class SubmissionObjectEffects {
|
||||
return this.parseSaveResponse((currentState.submission as SubmissionState).objects[action.payload.submissionId], response, action.payload.submissionId);
|
||||
}
|
||||
}),
|
||||
catchError(() => observableOf(new SaveSubmissionSectionFormErrorAction(action.payload.submissionId))));
|
||||
catchError(() => observableOf(new SaveSubmissionFormErrorAction(action.payload.submissionId))));
|
||||
}));
|
||||
|
||||
@Effect() depositSubmission$ = this.actions$.pipe(
|
||||
@@ -165,7 +165,7 @@ export class SubmissionObjectEffects {
|
||||
catchError(() => observableOf(new DepositSubmissionErrorAction(action.payload.submissionId))));
|
||||
}));
|
||||
|
||||
@Effect({dispatch: false}) SaveForLaterSubmissionSuccess$ = this.actions$.pipe(
|
||||
@Effect({dispatch: false}) saveForLaterSubmissionSuccess$ = this.actions$.pipe(
|
||||
ofType(SubmissionObjectActionTypes.SAVE_FOR_LATER_SUBMISSION_FORM_SUCCESS),
|
||||
tap(() => this.notificationsService.success(null, this.translate.get('submission.sections.general.save_success_notice'))),
|
||||
tap(() => this.submissionService.redirectToMyDSpace()));
|
||||
@@ -228,13 +228,13 @@ export class SubmissionObjectEffects {
|
||||
this.notificationsService.success(null, this.translate.get('submission.sections.general.save_success_notice'));
|
||||
}
|
||||
|
||||
// to avoid dispatching an action for every error, create an array of errors per section
|
||||
response.forEach((item: Workspaceitem | Workflowitem) => {
|
||||
|
||||
let errorsList = Object.create({});
|
||||
const {errors} = item;
|
||||
|
||||
if (errors && !isEmpty(errors)) {
|
||||
// to avoid dispatching an action for every error, create an array of errors per section
|
||||
errorsList = parseSectionErrors(errors);
|
||||
if (notify) {
|
||||
this.notificationsService.warning(null, this.translate.get('submission.sections.general.sections_not_valid'));
|
||||
|
@@ -30,194 +30,21 @@ import {
|
||||
UpdateSectionDataAction
|
||||
} from './submission-objects.actions';
|
||||
import { SectionsType } from '../sections/sections-type';
|
||||
import {
|
||||
mockSubmissionCollectionId,
|
||||
mockSubmissionDefinitionResponse, mockSubmissionId,
|
||||
mockSubmissionSelfUrl,
|
||||
mockSubmissionState
|
||||
} from '../../shared/mocks/mock-submission';
|
||||
|
||||
describe('submissionReducer', () => {
|
||||
describe('submissionReducer test suite', () => {
|
||||
|
||||
const collectionId = '1c11f3f1-ba1f-4f36-908a-3f1ea9a557eb';
|
||||
const submissionId = '826';
|
||||
const submissionDefinition = {
|
||||
isDefault: true,
|
||||
sections: [
|
||||
{
|
||||
mandatory: true,
|
||||
sectionType: 'utils',
|
||||
visibility: {
|
||||
main: 'HIDDEN',
|
||||
other: 'HIDDEN'
|
||||
},
|
||||
type: 'submissionsection',
|
||||
_links: {
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/extraction'
|
||||
},
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/extraction'
|
||||
},
|
||||
{
|
||||
mandatory: true,
|
||||
sectionType: 'collection',
|
||||
visibility: {
|
||||
main: 'HIDDEN',
|
||||
other: 'HIDDEN'
|
||||
},
|
||||
type: 'submissionsection',
|
||||
_links: {
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/collection'
|
||||
},
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/collection'
|
||||
},
|
||||
{
|
||||
header: 'submit.progressbar.describe.stepone',
|
||||
mandatory: true,
|
||||
sectionType: 'submission-form',
|
||||
type: 'submissionsection',
|
||||
_links: {
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/traditionalpageone',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpageone'
|
||||
},
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/traditionalpageone'
|
||||
},
|
||||
{
|
||||
header: 'submit.progressbar.describe.steptwo',
|
||||
mandatory: true,
|
||||
sectionType: 'submission-form',
|
||||
type: 'submissionsection',
|
||||
_links: {
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/traditionalpagetwo',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpagetwo'
|
||||
},
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/traditionalpagetwo'
|
||||
},
|
||||
{
|
||||
header: 'submit.progressbar.upload',
|
||||
mandatory: true,
|
||||
sectionType: 'upload',
|
||||
type: 'submissionsection',
|
||||
_links: {
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/upload',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionuploads/upload'
|
||||
},
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/upload'
|
||||
},
|
||||
{
|
||||
header: 'submit.progressbar.license',
|
||||
mandatory: true,
|
||||
sectionType: 'license',
|
||||
visibility: {
|
||||
main: null,
|
||||
other: 'READONLY'
|
||||
},
|
||||
type: 'submissionsection',
|
||||
_links: {
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/license'
|
||||
},
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissionsections/license'
|
||||
}
|
||||
],
|
||||
name: 'traditional',
|
||||
type: 'submissiondefinition',
|
||||
_links: {
|
||||
collections: 'https://rest.api/dspace-spring-rest/api/config/submissiondefinitions/traditional/collections',
|
||||
sections: 'https://rest.api/dspace-spring-rest/api/config/submissiondefinitions/traditional/sections',
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissiondefinitions/traditional'
|
||||
},
|
||||
self: 'https://rest.api/dspace-spring-rest/api/config/submissiondefinitions/traditional'
|
||||
} as any;
|
||||
const selfUrl = 'https://rest.api/dspace-spring-rest/api/submission/workspaceitems/826';
|
||||
const collectionId = mockSubmissionCollectionId;
|
||||
const submissionId = mockSubmissionId;
|
||||
const submissionDefinition = mockSubmissionDefinitionResponse;
|
||||
const selfUrl = mockSubmissionSelfUrl;
|
||||
|
||||
const initState: SubmissionObjectState = {
|
||||
826: {
|
||||
collection: collectionId,
|
||||
definition: 'traditional',
|
||||
selfUrl: selfUrl,
|
||||
activeSection: null,
|
||||
sections: {
|
||||
extraction: {
|
||||
config: '',
|
||||
mandatory: true,
|
||||
sectionType: 'utils',
|
||||
visibility: {
|
||||
main: 'HIDDEN',
|
||||
other: 'HIDDEN'
|
||||
},
|
||||
collapsed: false,
|
||||
enabled: true,
|
||||
data: {},
|
||||
errors: [],
|
||||
isLoading: false,
|
||||
isValid: false
|
||||
} as any,
|
||||
collection: {
|
||||
config: '',
|
||||
mandatory: true,
|
||||
sectionType: 'collection',
|
||||
visibility: {
|
||||
main: 'HIDDEN',
|
||||
other: 'HIDDEN'
|
||||
},
|
||||
collapsed: false,
|
||||
enabled: true,
|
||||
data: {},
|
||||
errors: [],
|
||||
isLoading: false,
|
||||
isValid: false
|
||||
} as any,
|
||||
traditionalpageone: {
|
||||
header: 'submit.progressbar.describe.stepone',
|
||||
config: 'https://dspace7.4science.it/or2018/api/config/submissionforms/traditionalpageone',
|
||||
mandatory: true,
|
||||
sectionType: 'submission-form',
|
||||
collapsed: false,
|
||||
enabled: true,
|
||||
data: {},
|
||||
errors: [],
|
||||
isLoading: false,
|
||||
isValid: false
|
||||
} as any,
|
||||
traditionalpagetwo: {
|
||||
header: 'submit.progressbar.describe.steptwo',
|
||||
config: 'https://dspace7.4science.it/or2018/api/config/submissionforms/traditionalpagetwo',
|
||||
mandatory: false,
|
||||
sectionType: 'submission-form',
|
||||
collapsed: false,
|
||||
enabled: false,
|
||||
data: {},
|
||||
errors: [],
|
||||
isLoading: false,
|
||||
isValid: false
|
||||
} as any,
|
||||
upload: {
|
||||
header: 'submit.progressbar.upload',
|
||||
config: 'https://dspace7.4science.it/or2018/api/config/submissionuploads/upload',
|
||||
mandatory: true,
|
||||
sectionType: 'upload',
|
||||
collapsed: false,
|
||||
enabled: true,
|
||||
data: {},
|
||||
errors: [],
|
||||
isLoading: false,
|
||||
isValid: false
|
||||
} as any,
|
||||
license: {
|
||||
header: 'submit.progressbar.license',
|
||||
config: '',
|
||||
mandatory: true,
|
||||
sectionType: 'license',
|
||||
visibility: {
|
||||
main: null,
|
||||
other: 'READONLY'
|
||||
},
|
||||
collapsed: false,
|
||||
enabled: true,
|
||||
data: {},
|
||||
errors: [],
|
||||
isLoading: false,
|
||||
isValid: false
|
||||
} as any
|
||||
},
|
||||
isLoading: false,
|
||||
savePending: false,
|
||||
depositPending: false
|
||||
}
|
||||
};
|
||||
const initState: SubmissionObjectState = mockSubmissionState;
|
||||
|
||||
it('should init submission state properly', () => {
|
||||
const expectedState = {
|
||||
@@ -279,7 +106,7 @@ describe('submissionReducer', () => {
|
||||
} as any,
|
||||
traditionalpageone: {
|
||||
header: 'submit.progressbar.describe.stepone',
|
||||
config: 'https://dspace7.4science.it/or2018/api/config/submissionforms/traditionalpageone',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpageone',
|
||||
mandatory: true,
|
||||
sectionType: 'submission-form',
|
||||
collapsed: false,
|
||||
@@ -291,7 +118,7 @@ describe('submissionReducer', () => {
|
||||
} as any,
|
||||
traditionalpagetwo: {
|
||||
header: 'submit.progressbar.describe.steptwo',
|
||||
config: 'https://dspace7.4science.it/or2018/api/config/submissionforms/traditionalpagetwo',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpagetwo',
|
||||
mandatory: false,
|
||||
sectionType: 'submission-form',
|
||||
collapsed: false,
|
||||
@@ -303,7 +130,7 @@ describe('submissionReducer', () => {
|
||||
} as any,
|
||||
upload: {
|
||||
header: 'submit.progressbar.upload',
|
||||
config: 'https://dspace7.4science.it/or2018/api/config/submissionuploads/upload',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionuploads/upload',
|
||||
mandatory: true,
|
||||
sectionType: 'upload',
|
||||
collapsed: false,
|
||||
@@ -371,8 +198,6 @@ describe('submissionReducer', () => {
|
||||
});
|
||||
|
||||
it('should set to true savePendig flag on save', () => {
|
||||
const expectedState = Object.create({});
|
||||
|
||||
let action = new SaveSubmissionFormAction(submissionId);
|
||||
let newState = submissionObjectReducer(initState, action);
|
||||
|
||||
@@ -434,7 +259,7 @@ describe('submissionReducer', () => {
|
||||
} as any,
|
||||
traditionalpageone: {
|
||||
header: 'submit.progressbar.describe.stepone',
|
||||
config: 'https://dspace7.4science.it/or2018/api/config/submissionforms/traditionalpageone',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpageone',
|
||||
mandatory: true,
|
||||
sectionType: 'submission-form',
|
||||
collapsed: false,
|
||||
@@ -446,7 +271,7 @@ describe('submissionReducer', () => {
|
||||
} as any,
|
||||
traditionalpagetwo: {
|
||||
header: 'submit.progressbar.describe.steptwo',
|
||||
config: 'https://dspace7.4science.it/or2018/api/config/submissionforms/traditionalpagetwo',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpagetwo',
|
||||
mandatory: true,
|
||||
sectionType: 'submission-form',
|
||||
collapsed: false,
|
||||
@@ -458,7 +283,7 @@ describe('submissionReducer', () => {
|
||||
} as any,
|
||||
upload: {
|
||||
header: 'submit.progressbar.upload',
|
||||
config: 'https://dspace7.4science.it/or2018/api/config/submissionuploads/upload',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionuploads/upload',
|
||||
mandatory: true,
|
||||
sectionType: 'upload',
|
||||
collapsed: false,
|
||||
@@ -531,7 +356,6 @@ describe('submissionReducer', () => {
|
||||
});
|
||||
|
||||
it('should set to true depositPending flag on deposit', () => {
|
||||
const newCollection = '43fe1f8c-09a6-4fcf-9c78-5d4fed8f2c8f';
|
||||
const action = new DepositSubmissionAction('826');
|
||||
const newState = submissionObjectReducer(initState, action);
|
||||
|
||||
@@ -578,7 +402,7 @@ describe('submissionReducer', () => {
|
||||
} as any,
|
||||
traditionalpageone: {
|
||||
header: 'submit.progressbar.describe.stepone',
|
||||
config: 'https://dspace7.4science.it/or2018/api/config/submissionforms/traditionalpageone',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpageone',
|
||||
mandatory: true,
|
||||
sectionType: 'submission-form',
|
||||
collapsed: false,
|
||||
@@ -590,7 +414,7 @@ describe('submissionReducer', () => {
|
||||
} as any,
|
||||
traditionalpagetwo: {
|
||||
header: 'submit.progressbar.describe.steptwo',
|
||||
config: 'https://dspace7.4science.it/or2018/api/config/submissionforms/traditionalpagetwo',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpagetwo',
|
||||
mandatory: true,
|
||||
sectionType: 'submission-form',
|
||||
collapsed: false,
|
||||
@@ -602,7 +426,7 @@ describe('submissionReducer', () => {
|
||||
} as any,
|
||||
upload: {
|
||||
header: 'submit.progressbar.upload',
|
||||
config: 'https://dspace7.4science.it/or2018/api/config/submissionuploads/upload',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionuploads/upload',
|
||||
mandatory: true,
|
||||
sectionType: 'upload',
|
||||
collapsed: false,
|
||||
@@ -642,7 +466,6 @@ describe('submissionReducer', () => {
|
||||
});
|
||||
|
||||
it('should set to false depositPending flag once the deposit is completed unsuccessfully', () => {
|
||||
const newCollection = '43fe1f8c-09a6-4fcf-9c78-5d4fed8f2c8f';
|
||||
const action = new DepositSubmissionErrorAction('826');
|
||||
const newState = submissionObjectReducer(initState, action);
|
||||
|
||||
@@ -742,20 +565,20 @@ describe('submissionReducer', () => {
|
||||
const data = {
|
||||
'dc.contributor.author': [
|
||||
{
|
||||
value: 'Bergamini, Giuseppe',
|
||||
value: 'Author, Test',
|
||||
language: null,
|
||||
authority: null,
|
||||
display: 'Bergamini, Giuseppe',
|
||||
display: 'Author, Test',
|
||||
confidence: -1,
|
||||
place: 0
|
||||
}
|
||||
],
|
||||
'dc.title': [
|
||||
{
|
||||
value: 'Uno sconosciuto ritratto di Giovanni da Udine',
|
||||
value: 'Title Test',
|
||||
language: null,
|
||||
authority: null,
|
||||
display: 'Uno sconosciuto ritratto di Giovanni da Udine',
|
||||
display: 'Title Test',
|
||||
confidence: -1,
|
||||
place: 0
|
||||
}
|
||||
@@ -801,7 +624,7 @@ describe('submissionReducer', () => {
|
||||
];
|
||||
|
||||
let action: any = new UpdateSectionDataAction(submissionId, 'traditionalpageone', {}, errors);
|
||||
let newState = submissionObjectReducer(initState, action);
|
||||
let newState;
|
||||
|
||||
action = new RemoveSectionErrorsAction(submissionId, 'traditionalpageone');
|
||||
newState = submissionObjectReducer(initState, action);
|
||||
@@ -911,10 +734,10 @@ describe('submissionReducer', () => {
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
value: '28297_389341539060_6452876_n.jpg',
|
||||
value: 'image_test.jpg',
|
||||
language: null,
|
||||
authority: null,
|
||||
display: '28297_389341539060_6452876_n.jpg',
|
||||
display: 'image_test.jpg',
|
||||
confidence: -1,
|
||||
place: 0
|
||||
}
|
||||
@@ -943,10 +766,10 @@ describe('submissionReducer', () => {
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
value: '28297_389341539060_6452876_n.jpg',
|
||||
value: 'image_test.jpg',
|
||||
language: null,
|
||||
authority: null,
|
||||
display: '28297_389341539060_6452876_n.jpg',
|
||||
display: 'image_test.jpg',
|
||||
confidence: -1,
|
||||
place: 0
|
||||
}
|
||||
@@ -1009,7 +832,7 @@ describe('submissionReducer', () => {
|
||||
} as any,
|
||||
traditionalpageone: {
|
||||
header: 'submit.progressbar.describe.stepone',
|
||||
config: 'https://dspace7.4science.it/or2018/api/config/submissionforms/traditionalpageone',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpageone',
|
||||
mandatory: true,
|
||||
sectionType: 'submission-form',
|
||||
collapsed: false,
|
||||
@@ -1021,7 +844,7 @@ describe('submissionReducer', () => {
|
||||
} as any,
|
||||
traditionalpagetwo: {
|
||||
header: 'submit.progressbar.describe.steptwo',
|
||||
config: 'https://dspace7.4science.it/or2018/api/config/submissionforms/traditionalpagetwo',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpagetwo',
|
||||
mandatory: false,
|
||||
sectionType: 'submission-form',
|
||||
collapsed: false,
|
||||
@@ -1033,7 +856,7 @@ describe('submissionReducer', () => {
|
||||
} as any,
|
||||
upload: {
|
||||
header: 'submit.progressbar.upload',
|
||||
config: 'https://dspace7.4science.it/or2018/api/config/submissionuploads/upload',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionuploads/upload',
|
||||
mandatory: true,
|
||||
sectionType: 'upload',
|
||||
collapsed: false,
|
||||
@@ -1084,10 +907,10 @@ describe('submissionReducer', () => {
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
value: '28297_389341539060_6452876_n.jpg',
|
||||
value: 'image_test.jpg',
|
||||
language: null,
|
||||
authority: null,
|
||||
display: '28297_389341539060_6452876_n.jpg',
|
||||
display: 'image_test.jpg',
|
||||
confidence: -1,
|
||||
place: 0
|
||||
}
|
||||
@@ -1183,7 +1006,7 @@ describe('submissionReducer', () => {
|
||||
} as any,
|
||||
traditionalpageone: {
|
||||
header: 'submit.progressbar.describe.stepone',
|
||||
config: 'https://dspace7.4science.it/or2018/api/config/submissionforms/traditionalpageone',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpageone',
|
||||
mandatory: true,
|
||||
sectionType: 'submission-form',
|
||||
collapsed: false,
|
||||
@@ -1195,7 +1018,7 @@ describe('submissionReducer', () => {
|
||||
} as any,
|
||||
traditionalpagetwo: {
|
||||
header: 'submit.progressbar.describe.steptwo',
|
||||
config: 'https://dspace7.4science.it/or2018/api/config/submissionforms/traditionalpagetwo',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpagetwo',
|
||||
mandatory: false,
|
||||
sectionType: 'submission-form',
|
||||
collapsed: false,
|
||||
@@ -1207,7 +1030,7 @@ describe('submissionReducer', () => {
|
||||
} as any,
|
||||
upload: {
|
||||
header: 'submit.progressbar.upload',
|
||||
config: 'https://dspace7.4science.it/or2018/api/config/submissionuploads/upload',
|
||||
config: 'https://rest.api/dspace-spring-rest/api/config/submissionuploads/upload',
|
||||
mandatory: true,
|
||||
sectionType: 'upload',
|
||||
collapsed: false,
|
||||
|
@@ -17,7 +17,7 @@ import { MockActivatedRoute } from '../shared/mocks/mock-active-router';
|
||||
import { GLOBAL_CONFIG } from '../../config';
|
||||
import { HttpOptions } from '../core/dspace-rest-v2/dspace-rest-v2.service';
|
||||
import { SubmissionScopeType } from '../core/submission/submission-scope-type';
|
||||
import { submissionRestREsponse } from '../shared/mocks/mock-submission';
|
||||
import { submissionRestResponse } from '../shared/mocks/mock-submission';
|
||||
import { NotificationsService } from '../shared/notifications/notifications.service';
|
||||
import { MockTranslateLoader } from '../shared/mocks/mock-translate-loader';
|
||||
import { MOCK_SUBMISSION_CONFIG } from '../shared/testing/mock-submission-config';
|
||||
@@ -643,12 +643,12 @@ describe('SubmissionService test suite', () => {
|
||||
|
||||
it('should retrieve submission from REST endpoint', () => {
|
||||
(service as any).restService.getDataById.and.returnValue(hot('a|', {
|
||||
a: submissionRestREsponse
|
||||
a: submissionRestResponse
|
||||
}));
|
||||
|
||||
const result = service.retrieveSubmission('826');
|
||||
const expected = cold('(b|)', {
|
||||
b: submissionRestREsponse[0]
|
||||
b: submissionRestResponse[0]
|
||||
});
|
||||
|
||||
expect(result).toBeObservable(expected);
|
||||
|
Reference in New Issue
Block a user