diff --git a/src/app/shared/mocks/mock-submission.ts b/src/app/shared/mocks/mock-submission.ts index d99eb52c86..a83f536858 100644 --- a/src/app/shared/mocks/mock-submission.ts +++ b/src/app/shared/mocks/mock-submission.ts @@ -257,7 +257,277 @@ export const submissionRestResponse = [ } } ]; - +export const mockSubmissionObject = { + collection: { + handle: '10673/2', + license: 'https://rest.api/dspace-spring-rest/api/core/collections/1c11f3f1-ba1f-4f36-908a-3f1ea9a557eb/license', + defaultAccessConditions: { + pageInfo: { + elementsPerPage: 1, + totalElements: 1, + totalPages: 1, + currentPage: 1 + }, + page: [ + { + name: null, + groupUUID: '11cc35e5-a11d-4b64-b5b9-0052a5d15509', + id: 20, + uuid: 'resource-policy-20', + self: 'https://rest.api/dspace-spring-rest/api/authz/resourcePolicies/20', + type: 'resourcePolicy', + _links: { + self: 'https://rest.api/dspace-spring-rest/api/authz/resourcePolicies/20' + } + } + ] + }, + logo: { + sizeBytes: 7451, + content: 'https://rest.api/dspace-spring-rest/api/core/bitstreams/3f859425-ffbd-4b0e-bf91-bfeb458a7425/content', + format: 'https://rest.api/dspace-spring-rest/api/core/bitstreams/3f859425-ffbd-4b0e-bf91-bfeb458a7425/format', + bundleName: null, + self: 'https://rest.api/dspace-spring-rest/api/core/bitstreams/3f859425-ffbd-4b0e-bf91-bfeb458a7425', + id: '3f859425-ffbd-4b0e-bf91-bfeb458a7425', + uuid: '3f859425-ffbd-4b0e-bf91-bfeb458a7425', + type: 'bitstream', + name: null, + metadata: [], + _links: { + content: 'https://rest.api/dspace-spring-rest/api/core/bitstreams/3f859425-ffbd-4b0e-bf91-bfeb458a7425/content', + format: 'https://rest.api/dspace-spring-rest/api/core/bitstreams/3f859425-ffbd-4b0e-bf91-bfeb458a7425/format', + self: 'https://rest.api/dspace-spring-rest/api/core/bitstreams/3f859425-ffbd-4b0e-bf91-bfeb458a7425' + } + }, + self: 'https://rest.api/dspace-spring-rest/api/core/collections/1c11f3f1-ba1f-4f36-908a-3f1ea9a557eb', + id: '1c11f3f1-ba1f-4f36-908a-3f1ea9a557eb', + uuid: '1c11f3f1-ba1f-4f36-908a-3f1ea9a557eb', + type: 'collection', + name: 'Collection of Sample Items', + metadata: [ + { + key: 'dc.provenance', + language: null, + value: 'This field is for private provenance information. It is only visible to Administrative users and is not displayed in the user interface by default.' + }, + { + key: 'dc.rights.license', + language: null, + value: '' + }, + { + key: 'dc.description', + language: null, + value: '
This is a DSpace Collection which contains sample DSpace Items.
\r\nCollections in DSpace may only contain Items.
\r\nThis particular Collection has its own logo (the Open Source Initiative logo).
\r\nThis introductory text is editable by System Administrators, Community Administrators (of a parent Community) or Collection Administrators (of this Collection).
' + }, + { + key: 'dc.description.abstract', + language: null, + value: 'This collection contains sample items.' + }, + { + key: 'dc.description.tableofcontents', + language: null, + value: 'This is the news section for this Collection. System Administrators, Community Administrators (of a parent Community) or Collection Administrators (of this Collection) can edit this News field.
' + }, + { + key: 'dc.rights', + language: null, + value: 'If this collection had a specific copyright statement, it would be placed here.
' + }, + { + key: 'dc.title', + language: null, + value: 'Collection of Sample Items' + } + ], + _links: { + license: 'https://rest.api/dspace-spring-rest/api/core/collections/1c11f3f1-ba1f-4f36-908a-3f1ea9a557eb/license', + defaultAccessConditions: 'https://rest.api/dspace-spring-rest/api/core/collections/1c11f3f1-ba1f-4f36-908a-3f1ea9a557eb/defaultAccessConditions', + logo: 'https://rest.api/dspace-spring-rest/api/core/collections/1c11f3f1-ba1f-4f36-908a-3f1ea9a557eb/logo', + self: 'https://rest.api/dspace-spring-rest/api/core/collections/1c11f3f1-ba1f-4f36-908a-3f1ea9a557eb' + } + }, + item: { + handle: null, + lastModified: '2019-01-09T10:17:33.722+0000', + isArchived: false, + isDiscoverable: true, + isWithdrawn: false, + owningCollection: 'https://rest.api/dspace-spring-rest/api/core/items/cae8af78-c874-4468-af79-e6c996aa8270/owningCollection', + bitstreams: { + pageInfo: { + elementsPerPage: 0, + totalElements: 0, + totalPages: 1, + currentPage: 1 + }, + page: [] + }, + self: 'https://rest.api/dspace-spring-rest/api/core/items/cae8af78-c874-4468-af79-e6c996aa8270', + id: 'cae8af78-c874-4468-af79-e6c996aa8270', + uuid: 'cae8af78-c874-4468-af79-e6c996aa8270', + type: 'item', + name: null, + metadata: [], + _links: { + bitstreams: 'https://rest.api/dspace-spring-rest/api/core/items/cae8af78-c874-4468-af79-e6c996aa8270/bitstreams', + owningCollection: 'https://rest.api/dspace-spring-rest/api/core/items/cae8af78-c874-4468-af79-e6c996aa8270/owningCollection', + templateItemOf: 'https://rest.api/dspace-spring-rest/api/core/items/cae8af78-c874-4468-af79-e6c996aa8270/templateItemOf', + self: 'https://rest.api/dspace-spring-rest/api/core/items/cae8af78-c874-4468-af79-e6c996aa8270' + } + }, + submissionDefinition: { + isDefault: true, + sections: { + pageInfo: { + elementsPerPage: 5, + totalElements: 5, + totalPages: 1, + currentPage: 1 + }, + page: [ + { + 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', + collections: { + pageInfo: { + elementsPerPage: 0, + totalElements: 0, + totalPages: 1, + currentPage: 1 + }, + page: [] + } + }, + submitter: { + handle: null, + groups: [], + netid: null, + lastActive: '2019-01-09T10:17:33.047+0000', + canLogIn: true, + email: 'dspacedemo+submit@gmail.com', + requireCertificate: false, + selfRegistered: false, + self: 'https://rest.api/dspace-spring-rest/api/eperson/epersons/99423c27-b642-4bb9-a9cd-6d910e68dca5', + id: '99423c27-b642-4bb9-a9cd-6d910e68dca5', + uuid: '99423c27-b642-4bb9-a9cd-6d910e68dca5', + type: 'eperson', + name: 'dspacedemo+submit@gmail.com', + metadata: [ + { + key: 'eperson.firstname', + language: null, + value: 'Demo' + }, + { + key: 'eperson.lastname', + language: null, + value: 'Submitter' + } + ], + _links: { + self: 'https://rest.api/dspace-spring-rest/api/eperson/epersons/99423c27-b642-4bb9-a9cd-6d910e68dca5' + } + }, + id: 826, + lastModified: '2019-01-09T10:17:33.738+0000', + sections: { + license: { + url: null, + acceptanceDate: null, + granted: false + }, + upload: { + files: [] + } + }, + errors: [ + { + message: 'error.validation.required', + paths: [ + '/sections/traditionalpageone/dc.title', + '/sections/traditionalpageone/dc.date.issued' + ] + } + ], + self: 'https://rest.api/dspace-spring-rest/api/submission/workspaceitems/269', + type: 'workspaceitem', + _links: { + collection: 'https://rest.api/dspace-spring-rest/api/submission/workspaceitems/269/collection', + item: 'https://rest.api/dspace-spring-rest/api/submission/workspaceitems/269/item', + submissionDefinition: 'https://rest.api/dspace-spring-rest/api/submission/workspaceitems/269/submissionDefinition', + submitter: 'https://rest.api/dspace-spring-rest/api/submission/workspaceitems/269/submitter', + self: 'https://rest.api/dspace-spring-rest/api/submission/workspaceitems/269' + } +} 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'; diff --git a/src/app/shared/testing/active-router-stub.ts b/src/app/shared/testing/active-router-stub.ts index 89a417149a..36a3f7de58 100644 --- a/src/app/shared/testing/active-router-stub.ts +++ b/src/app/shared/testing/active-router-stub.ts @@ -12,6 +12,7 @@ export class ActivatedRouteStub { params = this.subject.asObservable(); queryParams = this.subject.asObservable(); + paramMap = this.subject.asObservable().pipe(map((params: Params) => convertToParamMap(params)));; queryParamMap = this.subject.asObservable().pipe(map((params: Params) => convertToParamMap(params))); constructor(params?: Params) { diff --git a/src/app/submission/edit/submission-edit.component.spec.ts b/src/app/submission/edit/submission-edit.component.spec.ts new file mode 100644 index 0000000000..d64193501d --- /dev/null +++ b/src/app/submission/edit/submission-edit.component.spec.ts @@ -0,0 +1,105 @@ +import { async, ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing'; +import { RouterTestingModule } from '@angular/router/testing'; +import { ActivatedRoute, Router } from '@angular/router'; +import { NO_ERRORS_SCHEMA } from '@angular/core'; + +import { of as observableOf } from 'rxjs'; +import { TranslateModule, TranslateService } from '@ngx-translate/core'; + +import { SubmissionEditComponent } from './submission-edit.component'; +import { NotificationsService } from '../../shared/notifications/notifications.service'; +import { NotificationsServiceStub } from '../../shared/testing/notifications-service-stub'; +import { SubmissionService } from '../submission.service'; +import { SubmissionServiceStub } from '../../shared/testing/submission-service-stub'; +import { getMockTranslateService } from '../../shared/mocks/mock-translate.service'; + +import { RouterStub } from '../../shared/testing/router-stub'; +import { ActivatedRouteStub } from '../../shared/testing/active-router-stub'; +import { mockSubmissionObject } from '../../shared/mocks/mock-submission'; + +describe('SubmissionEditComponent Component', () => { + + let comp: SubmissionEditComponent; + let fixture: ComponentFixture