mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 10:34:15 +00:00
[835] Auto-save in new Item Submission form breaks the form
Section Metadata field tested. Form Touched filter tested.
This commit is contained in:
@@ -60,6 +60,21 @@ export const mockSectionsErrors = [
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const mockSectionsErrorsTwo = [
|
||||||
|
{
|
||||||
|
message: 'error.validation.required',
|
||||||
|
paths: [
|
||||||
|
'/sections/traditionalpageone/dc.title',
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
message: 'error.validation.license.notgranted',
|
||||||
|
paths: [
|
||||||
|
'/sections/license'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
export const mockUploadResponse1Errors = {
|
export const mockUploadResponse1Errors = {
|
||||||
errors: [
|
errors: [
|
||||||
{
|
{
|
||||||
@@ -1033,6 +1048,7 @@ export const mockSubmissionState: SubmissionObjectState = Object.assign({}, {
|
|||||||
enabled: true,
|
enabled: true,
|
||||||
data: {},
|
data: {},
|
||||||
errors: [],
|
errors: [],
|
||||||
|
formId: '2_traditionalpageone',
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
isValid: false
|
isValid: false
|
||||||
} as any,
|
} as any,
|
||||||
|
@@ -32,7 +32,7 @@ import {
|
|||||||
mockSubmissionId,
|
mockSubmissionId,
|
||||||
mockSubmissionSelfUrl,
|
mockSubmissionSelfUrl,
|
||||||
mockSubmissionState,
|
mockSubmissionState,
|
||||||
mockSubmissionRestResponse
|
mockSubmissionRestResponse, mockSectionsErrorsTwo
|
||||||
} from '../../shared/mocks/submission.mock';
|
} from '../../shared/mocks/submission.mock';
|
||||||
import { SubmissionSectionModel } from '../../core/config/models/config-submission-section.model';
|
import { SubmissionSectionModel } from '../../core/config/models/config-submission-section.model';
|
||||||
import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub';
|
import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub';
|
||||||
@@ -51,6 +51,7 @@ import { Item } from '../../core/shared/item.model';
|
|||||||
import { WorkspaceitemDataService } from '../../core/submission/workspaceitem-data.service';
|
import { WorkspaceitemDataService } from '../../core/submission/workspaceitem-data.service';
|
||||||
import { WorkflowItemDataService } from '../../core/submission/workflowitem-data.service';
|
import { WorkflowItemDataService } from '../../core/submission/workflowitem-data.service';
|
||||||
import { HALEndpointService } from '../../core/shared/hal-endpoint.service';
|
import { HALEndpointService } from '../../core/shared/hal-endpoint.service';
|
||||||
|
import {formStateSelector} from '../../shared/form/selectors';
|
||||||
|
|
||||||
describe('SubmissionObjectEffects test suite', () => {
|
describe('SubmissionObjectEffects test suite', () => {
|
||||||
let submissionObjectEffects: SubmissionObjectEffects;
|
let submissionObjectEffects: SubmissionObjectEffects;
|
||||||
@@ -343,7 +344,8 @@ describe('SubmissionObjectEffects test suite', () => {
|
|||||||
type: SubmissionObjectActionTypes.SAVE_SUBMISSION_FORM_SUCCESS,
|
type: SubmissionObjectActionTypes.SAVE_SUBMISSION_FORM_SUCCESS,
|
||||||
payload: {
|
payload: {
|
||||||
submissionId: submissionId,
|
submissionId: submissionId,
|
||||||
submissionObject: response
|
submissionObject: response,
|
||||||
|
notify: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -375,6 +377,63 @@ describe('SubmissionObjectEffects test suite', () => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not display errors when notification are disabled and field are not touched', () => {
|
||||||
|
store.nextState({
|
||||||
|
submission: {
|
||||||
|
objects: submissionState
|
||||||
|
},
|
||||||
|
forms: {
|
||||||
|
'2_traditionalpageone': {
|
||||||
|
additional: {
|
||||||
|
touched: {
|
||||||
|
'dc.title': true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} as any);
|
||||||
|
|
||||||
|
const response = [Object.assign({}, mockSubmissionRestResponse[0], {
|
||||||
|
sections: mockSectionsData,
|
||||||
|
errors: mockSectionsErrors
|
||||||
|
})];
|
||||||
|
actions = hot('--a-', {
|
||||||
|
a: {
|
||||||
|
type: SubmissionObjectActionTypes.SAVE_SUBMISSION_SECTION_FORM_SUCCESS,
|
||||||
|
payload: {
|
||||||
|
submissionId: submissionId,
|
||||||
|
submissionObject: response,
|
||||||
|
notify: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const errorsList = parseSectionErrors(mockSectionsErrorsTwo);
|
||||||
|
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.saveSubmissionSectionSuccess$).toBeObservable(expected);
|
||||||
|
expect(notificationsServiceStub.warning).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
it('should display a success notification', () => {
|
it('should display a success notification', () => {
|
||||||
store.nextState({
|
store.nextState({
|
||||||
submission: {
|
submission: {
|
||||||
|
@@ -335,6 +335,17 @@ describe('submissionReducer test suite', () => {
|
|||||||
expect(newState[826].sections.traditionalpageone.data).toEqual(data);
|
expect(newState[826].sections.traditionalpageone.data).toEqual(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should update submission section metadata properly', () => {
|
||||||
|
const data = {
|
||||||
|
} as any;
|
||||||
|
const metadata = ['dc.title', 'dc.contributor.author'];
|
||||||
|
|
||||||
|
const action = new UpdateSectionDataAction(submissionId, 'traditionalpageone', data, [], metadata);
|
||||||
|
const newState = submissionObjectReducer(initState, action);
|
||||||
|
|
||||||
|
expect(newState[826].sections.traditionalpageone.metadata).toEqual(metadata);
|
||||||
|
});
|
||||||
|
|
||||||
it('should add submission section errors properly', () => {
|
it('should add submission section errors properly', () => {
|
||||||
const errors = [
|
const errors = [
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user