mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 18:44:14 +00:00
Added more tests
This commit is contained in:
@@ -2,7 +2,17 @@ import { Observable } from 'rxjs/Observable';
|
|||||||
|
|
||||||
export class MockRouter {
|
export class MockRouter {
|
||||||
public events = Observable.of({});
|
public events = Observable.of({});
|
||||||
|
public routerState = {
|
||||||
|
snapshot: {
|
||||||
|
url: ''
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// noinspection TypeScriptUnresolvedFunction
|
// noinspection TypeScriptUnresolvedFunction
|
||||||
navigate = jasmine.createSpy('navigate');
|
navigate = jasmine.createSpy('navigate');
|
||||||
|
navigateByUrl = jasmine.createSpy('navigateByUrl');
|
||||||
|
|
||||||
|
setRoute(route) {
|
||||||
|
this.routerState.snapshot.url = route;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
226
src/app/shared/mocks/mock-submission.ts
Normal file
226
src/app/shared/mocks/mock-submission.ts
Normal file
@@ -0,0 +1,226 @@
|
|||||||
|
export const submissionRestREsponse = [
|
||||||
|
{
|
||||||
|
id: 826,
|
||||||
|
lastModified: '2018-08-03T12:49:45.268+0000',
|
||||||
|
collection: [
|
||||||
|
{
|
||||||
|
handle: '10673/2',
|
||||||
|
license: 'https://rest.api/dspace-spring-rest/api/core/collections/1c11f3f1-ba1f-4f36-908a-3f1ea9a557eb/license',
|
||||||
|
defaultAccessConditions: [],
|
||||||
|
logo: [
|
||||||
|
{
|
||||||
|
sizeBytes: 7451,
|
||||||
|
content: 'https://rest.api/dspace-spring-rest/api/core/bitstreams/3f859425-ffbd-4b0e-bf91-bfeb458a7425/content',
|
||||||
|
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: '<p>This is a <em>DSpace Collection</em> which contains sample DSpace Items.</p>\r\n<p><strong>Collections in DSpace may only contain Items.</strong></p>\r\n<p>This particular Collection has its own logo (the <a href=\'http://www.opensource.org/\'>Open Source Initiative</a> logo).</p>\r\n<p>This introductory text is editable by System Administrators, Community Administrators (of a parent Community) or Collection Administrators (of this Collection).</p>'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'dc.description.abstract',
|
||||||
|
language: null,
|
||||||
|
value: 'This collection contains sample items.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'dc.description.tableofcontents',
|
||||||
|
language: null,
|
||||||
|
value: '<p>This is the <strong>news</strong> section for this Collection. System Administrators, Community Administrators (of a parent Community) or Collection Administrators (of this Collection) can edit this News field.</p>'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'dc.rights',
|
||||||
|
language: null,
|
||||||
|
value: '<p><em>If this collection had a specific copyright statement, it would be placed here.</em></p>'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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: '2018-07-25T14:08:28.750+0000',
|
||||||
|
isArchived: false,
|
||||||
|
isDiscoverable: true,
|
||||||
|
isWithdrawn: false,
|
||||||
|
bitstreams: 'https://rest.api/dspace-spring-rest/api/core/items/6f344222-6980-4738-8192-b808d79af8a5/bitstreams',
|
||||||
|
self: 'https://rest.api/dspace-spring-rest/api/core/items/6f344222-6980-4738-8192-b808d79af8a5',
|
||||||
|
id: '6f344222-6980-4738-8192-b808d79af8a5',
|
||||||
|
uuid: '6f344222-6980-4738-8192-b808d79af8a5',
|
||||||
|
type: 'item',
|
||||||
|
name: null,
|
||||||
|
metadata: [],
|
||||||
|
_links: {
|
||||||
|
bitstreams: 'https://rest.api/dspace-spring-rest/api/core/items/6f344222-6980-4738-8192-b808d79af8a5/bitstreams',
|
||||||
|
owningCollection: 'https://rest.api/dspace-spring-rest/api/core/items/6f344222-6980-4738-8192-b808d79af8a5/owningCollection',
|
||||||
|
templateItemOf: 'https://rest.api/dspace-spring-rest/api/core/items/6f344222-6980-4738-8192-b808d79af8a5/templateItemOf',
|
||||||
|
self: 'https://rest.api/dspace-spring-rest/api/core/items/6f344222-6980-4738-8192-b808d79af8a5'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
sections: {
|
||||||
|
license: {
|
||||||
|
url: null,
|
||||||
|
acceptanceDate: null,
|
||||||
|
granted: false
|
||||||
|
},
|
||||||
|
upload: {
|
||||||
|
files: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
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'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
self: 'https://rest.api/dspace-spring-rest/api/submission/workspaceitems/826',
|
||||||
|
type: 'workspaceitem',
|
||||||
|
_links: {
|
||||||
|
collection: 'https://rest.api/dspace-spring-rest/api/submission/workspaceitems/826/collection',
|
||||||
|
item: 'https://rest.api/dspace-spring-rest/api/submission/workspaceitems/826/item',
|
||||||
|
submissionDefinition: 'https://rest.api/dspace-spring-rest/api/submission/workspaceitems/826/submissionDefinition',
|
||||||
|
submitter: 'https://rest.api/dspace-spring-rest/api/submission/workspaceitems/826/submitter',
|
||||||
|
self: 'https://rest.api/dspace-spring-rest/api/submission/workspaceitems/826'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
@@ -96,7 +96,7 @@ describe('NotificationComponent', () => {
|
|||||||
expect(elType).toBeDefined();
|
expect(elType).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shuld has html content', () => {
|
it('should has html content', () => {
|
||||||
fixture = TestBed.createComponent(NotificationComponent);
|
fixture = TestBed.createComponent(NotificationComponent);
|
||||||
comp = fixture.componentInstance;
|
comp = fixture.componentInstance;
|
||||||
const htmlContent = `<a class="btn btn-link p-0 m-0 pb-1" href="/test"><strong>test</strong></a>`
|
const htmlContent = `<a class="btn btn-link p-0 m-0 pb-1" href="/test"><strong>test</strong></a>`
|
||||||
|
@@ -45,7 +45,6 @@ export class RouteService {
|
|||||||
.pipe(filter((event) => event instanceof NavigationEnd))
|
.pipe(filter((event) => event instanceof NavigationEnd))
|
||||||
.subscribe(({urlAfterRedirects}: NavigationEnd) => {
|
.subscribe(({urlAfterRedirects}: NavigationEnd) => {
|
||||||
this.history = [...this.history, urlAfterRedirects];
|
this.history = [...this.history, urlAfterRedirects];
|
||||||
console.log(this.history);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,12 +0,0 @@
|
|||||||
|
|
||||||
// declare a stub service
|
|
||||||
export class PlatformServiceStub {
|
|
||||||
|
|
||||||
public get isBrowser(): boolean {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public get isServer(): boolean {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
23
src/app/shared/testing/submission-rest-service-stub.ts
Normal file
23
src/app/shared/testing/submission-rest-service-stub.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { ResponseCacheService } from '../../core/cache/response-cache.service';
|
||||||
|
import { RequestService } from '../../core/data/request.service';
|
||||||
|
import { Store } from '@ngrx/store';
|
||||||
|
import { CoreState } from '../../core/core.reducers';
|
||||||
|
import { HALEndpointService } from '../../core/shared/hal-endpoint.service';
|
||||||
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
|
||||||
|
export class SubmissionRestServiceStub {
|
||||||
|
protected linkPath = 'workspaceitems';
|
||||||
|
protected responseCache: ResponseCacheService;
|
||||||
|
protected requestService: RequestService;
|
||||||
|
protected store: Store<CoreState>;
|
||||||
|
protected halService: HALEndpointService;
|
||||||
|
|
||||||
|
deleteById = jasmine.createSpy('deleteById');
|
||||||
|
fetchRequest = jasmine.createSpy('fetchRequest');
|
||||||
|
getDataById = jasmine.createSpy('getDataById');
|
||||||
|
getDataByHref = jasmine.createSpy('getDataByHref');
|
||||||
|
getEndpointByIDHref = jasmine.createSpy('getEndpointByIDHref');
|
||||||
|
patchToEndpoint = jasmine.createSpy('patchToEndpoint');
|
||||||
|
postToEndpoint = jasmine.createSpy('postToEndpoint').and.returnValue(Observable.of({}));
|
||||||
|
submitData = jasmine.createSpy('submitData');
|
||||||
|
}
|
@@ -35,7 +35,7 @@ export class SubmissionFormFooterComponent implements OnChanges {
|
|||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
if (!!this.submissionId) {
|
if (!!this.submissionId) {
|
||||||
this.submissionService.getSectionsState(this.submissionId)
|
this.submissionService.getSubmissionStatus(this.submissionId)
|
||||||
.subscribe((isValid) => {
|
.subscribe((isValid) => {
|
||||||
this.submissionIsInvalid = isValid === false;
|
this.submissionIsInvalid = isValid === false;
|
||||||
});
|
});
|
||||||
|
@@ -30,7 +30,6 @@ import { HALEndpointService } from '../core/shared/hal-endpoint.service';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class SubmissionRestService {
|
export class SubmissionRestService {
|
||||||
protected linkPath = 'workspaceitems';
|
protected linkPath = 'workspaceitems';
|
||||||
protected overrideRequest = true;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected responseCache: ResponseCacheService,
|
protected responseCache: ResponseCacheService,
|
||||||
|
697
src/app/submission/submission.service.spec.ts
Normal file
697
src/app/submission/submission.service.spec.ts
Normal file
@@ -0,0 +1,697 @@
|
|||||||
|
import { StoreModule } from '@ngrx/store';
|
||||||
|
import { async, fakeAsync, flush, TestBed, tick } from '@angular/core/testing';
|
||||||
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
import { HttpHeaders } from '@angular/common/http';
|
||||||
|
|
||||||
|
import { cold, hot } from 'jasmine-marbles';
|
||||||
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
import 'rxjs/add/observable/of'
|
||||||
|
import 'rxjs/add/observable/timer'
|
||||||
|
|
||||||
|
import { MockRouter } from '../shared/mocks/mock-router';
|
||||||
|
import { SubmissionService } from './submission.service';
|
||||||
|
import { submissionReducers } from './submission.reducers';
|
||||||
|
import { SubmissionRestService } from './submission-rest.service';
|
||||||
|
import { RouteService } from '../shared/services/route.service';
|
||||||
|
import { SubmissionRestServiceStub } from '../shared/testing/submission-rest-service-stub';
|
||||||
|
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';
|
||||||
|
|
||||||
|
describe('SubmissionService test suite', () => {
|
||||||
|
const config = {
|
||||||
|
submission: {
|
||||||
|
autosave: {
|
||||||
|
metadata: ['dc.title', 'dc.identifier.doi', 'dc.identifier.pmid', 'dc.identifier.arxiv'],
|
||||||
|
timer: 5
|
||||||
|
},
|
||||||
|
metadata: {
|
||||||
|
icons: [
|
||||||
|
{
|
||||||
|
name: 'dc.contributor.author',
|
||||||
|
config: {
|
||||||
|
withAuthority: {
|
||||||
|
style: 'fa-user'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'local.contributor.affiliation',
|
||||||
|
config: {
|
||||||
|
withAuthority: {
|
||||||
|
style: 'fa-university'
|
||||||
|
},
|
||||||
|
withoutAuthority: {
|
||||||
|
style: 'fa-university text-muted'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'default',
|
||||||
|
config: {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
} as any;
|
||||||
|
|
||||||
|
const subState = {
|
||||||
|
objects: {
|
||||||
|
826: {
|
||||||
|
collection: '43fe1f8c-09a6-4fcf-9c78-5d4fed8f2c8f',
|
||||||
|
definition: 'traditional',
|
||||||
|
selfUrl: 'https://rest.api/dspace-spring-rest/api/submission/workspaceitems/826',
|
||||||
|
activeSection: 'keyinformation',
|
||||||
|
sections: {
|
||||||
|
extraction: {
|
||||||
|
config: '',
|
||||||
|
mandatory: true,
|
||||||
|
sectionType: 'utils',
|
||||||
|
visibility: {
|
||||||
|
main: 'HIDDEN',
|
||||||
|
other: 'HIDDEN'
|
||||||
|
},
|
||||||
|
collapsed: false,
|
||||||
|
enabled: true,
|
||||||
|
data: {},
|
||||||
|
errors: [],
|
||||||
|
isLoading: false,
|
||||||
|
isValid: false
|
||||||
|
},
|
||||||
|
collection: {
|
||||||
|
config: '',
|
||||||
|
mandatory: true,
|
||||||
|
sectionType: 'collection',
|
||||||
|
visibility: {
|
||||||
|
main: 'HIDDEN',
|
||||||
|
other: 'HIDDEN'
|
||||||
|
},
|
||||||
|
collapsed: false,
|
||||||
|
enabled: true,
|
||||||
|
data: {},
|
||||||
|
errors: [],
|
||||||
|
isLoading: false,
|
||||||
|
isValid: false
|
||||||
|
},
|
||||||
|
keyinformation: {
|
||||||
|
header: 'submit.progressbar.describe.keyinformation',
|
||||||
|
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/keyinformation',
|
||||||
|
mandatory: true,
|
||||||
|
sectionType: 'submission-form',
|
||||||
|
collapsed: false,
|
||||||
|
enabled: true,
|
||||||
|
data: {},
|
||||||
|
errors: [],
|
||||||
|
isLoading: false,
|
||||||
|
isValid: false
|
||||||
|
},
|
||||||
|
indexing: {
|
||||||
|
header: 'submit.progressbar.describe.indexing',
|
||||||
|
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/indexing',
|
||||||
|
mandatory: false,
|
||||||
|
sectionType: 'submission-form',
|
||||||
|
collapsed: false,
|
||||||
|
enabled: false,
|
||||||
|
data: {},
|
||||||
|
errors: [],
|
||||||
|
isLoading: false,
|
||||||
|
isValid: false
|
||||||
|
},
|
||||||
|
publicationchannel: {
|
||||||
|
header: 'submit.progressbar.describe.publicationchannel',
|
||||||
|
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/publicationchannel',
|
||||||
|
mandatory: true,
|
||||||
|
sectionType: 'submission-form',
|
||||||
|
collapsed: false,
|
||||||
|
enabled: true,
|
||||||
|
data: {},
|
||||||
|
errors: [],
|
||||||
|
isLoading: false,
|
||||||
|
isValid: true
|
||||||
|
},
|
||||||
|
acknowledgement: {
|
||||||
|
header: 'submit.progressbar.describe.acknowledgement',
|
||||||
|
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/acknowledgement',
|
||||||
|
mandatory: false,
|
||||||
|
sectionType: 'submission-form',
|
||||||
|
collapsed: false,
|
||||||
|
enabled: false,
|
||||||
|
data: {},
|
||||||
|
errors: [],
|
||||||
|
isLoading: false,
|
||||||
|
isValid: false
|
||||||
|
},
|
||||||
|
identifiers: {
|
||||||
|
header: 'submit.progressbar.describe.identifiers',
|
||||||
|
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/identifiers',
|
||||||
|
mandatory: false,
|
||||||
|
sectionType: 'submission-form',
|
||||||
|
collapsed: false,
|
||||||
|
enabled: false,
|
||||||
|
data: {},
|
||||||
|
errors: [],
|
||||||
|
isLoading: false,
|
||||||
|
isValid: false
|
||||||
|
},
|
||||||
|
references: {
|
||||||
|
header: 'submit.progressbar.describe.references',
|
||||||
|
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/references',
|
||||||
|
mandatory: false,
|
||||||
|
sectionType: 'submission-form',
|
||||||
|
collapsed: false,
|
||||||
|
enabled: false,
|
||||||
|
data: {},
|
||||||
|
errors: [],
|
||||||
|
isLoading: false,
|
||||||
|
isValid: false
|
||||||
|
},
|
||||||
|
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
|
||||||
|
},
|
||||||
|
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
|
||||||
|
}
|
||||||
|
},
|
||||||
|
isLoading: false,
|
||||||
|
savePending: false,
|
||||||
|
depositPending: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const validSubState = {
|
||||||
|
objects: {
|
||||||
|
826: {
|
||||||
|
collection: '43fe1f8c-09a6-4fcf-9c78-5d4fed8f2c8f',
|
||||||
|
definition: 'traditional',
|
||||||
|
selfUrl: 'https://rest.api/dspace-spring-rest/api/submission/workspaceitems/826',
|
||||||
|
activeSection: 'keyinformation',
|
||||||
|
sections: {
|
||||||
|
extraction: {
|
||||||
|
config: '',
|
||||||
|
mandatory: true,
|
||||||
|
sectionType: 'utils',
|
||||||
|
visibility: {
|
||||||
|
main: 'HIDDEN',
|
||||||
|
other: 'HIDDEN'
|
||||||
|
},
|
||||||
|
collapsed: false,
|
||||||
|
enabled: true,
|
||||||
|
data: {},
|
||||||
|
errors: [],
|
||||||
|
isLoading: false,
|
||||||
|
isValid: false
|
||||||
|
},
|
||||||
|
collection: {
|
||||||
|
config: '',
|
||||||
|
mandatory: true,
|
||||||
|
sectionType: 'collection',
|
||||||
|
visibility: {
|
||||||
|
main: 'HIDDEN',
|
||||||
|
other: 'HIDDEN'
|
||||||
|
},
|
||||||
|
collapsed: false,
|
||||||
|
enabled: true,
|
||||||
|
data: {},
|
||||||
|
errors: [],
|
||||||
|
isLoading: false,
|
||||||
|
isValid: false
|
||||||
|
},
|
||||||
|
keyinformation: {
|
||||||
|
header: 'submit.progressbar.describe.keyinformation',
|
||||||
|
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/keyinformation',
|
||||||
|
mandatory: true,
|
||||||
|
sectionType: 'submission-form',
|
||||||
|
collapsed: false,
|
||||||
|
enabled: true,
|
||||||
|
data: {},
|
||||||
|
errors: [],
|
||||||
|
isLoading: false,
|
||||||
|
isValid: true
|
||||||
|
},
|
||||||
|
indexing: {
|
||||||
|
header: 'submit.progressbar.describe.indexing',
|
||||||
|
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/indexing',
|
||||||
|
mandatory: false,
|
||||||
|
sectionType: 'submission-form',
|
||||||
|
collapsed: false,
|
||||||
|
enabled: false,
|
||||||
|
data: {},
|
||||||
|
errors: [],
|
||||||
|
isLoading: false,
|
||||||
|
isValid: false
|
||||||
|
},
|
||||||
|
publicationchannel: {
|
||||||
|
header: 'submit.progressbar.describe.publicationchannel',
|
||||||
|
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/publicationchannel',
|
||||||
|
mandatory: true,
|
||||||
|
sectionType: 'submission-form',
|
||||||
|
collapsed: false,
|
||||||
|
enabled: true,
|
||||||
|
data: {},
|
||||||
|
errors: [],
|
||||||
|
isLoading: false,
|
||||||
|
isValid: true
|
||||||
|
},
|
||||||
|
acknowledgement: {
|
||||||
|
header: 'submit.progressbar.describe.acknowledgement',
|
||||||
|
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/acknowledgement',
|
||||||
|
mandatory: false,
|
||||||
|
sectionType: 'submission-form',
|
||||||
|
collapsed: false,
|
||||||
|
enabled: false,
|
||||||
|
data: {},
|
||||||
|
errors: [],
|
||||||
|
isLoading: false,
|
||||||
|
isValid: false
|
||||||
|
},
|
||||||
|
identifiers: {
|
||||||
|
header: 'submit.progressbar.describe.identifiers',
|
||||||
|
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/identifiers',
|
||||||
|
mandatory: false,
|
||||||
|
sectionType: 'submission-form',
|
||||||
|
collapsed: false,
|
||||||
|
enabled: false,
|
||||||
|
data: {},
|
||||||
|
errors: [],
|
||||||
|
isLoading: false,
|
||||||
|
isValid: false
|
||||||
|
},
|
||||||
|
references: {
|
||||||
|
header: 'submit.progressbar.describe.references',
|
||||||
|
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/references',
|
||||||
|
mandatory: false,
|
||||||
|
sectionType: 'submission-form',
|
||||||
|
collapsed: false,
|
||||||
|
enabled: false,
|
||||||
|
data: {},
|
||||||
|
errors: [],
|
||||||
|
isLoading: false,
|
||||||
|
isValid: false
|
||||||
|
},
|
||||||
|
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: true
|
||||||
|
},
|
||||||
|
license: {
|
||||||
|
header: 'submit.progressbar.license',
|
||||||
|
config: '',
|
||||||
|
mandatory: true,
|
||||||
|
sectionType: 'license',
|
||||||
|
visibility: {
|
||||||
|
main: null,
|
||||||
|
other: 'READONLY'
|
||||||
|
},
|
||||||
|
collapsed: false,
|
||||||
|
enabled: true,
|
||||||
|
data: {},
|
||||||
|
errors: [],
|
||||||
|
isLoading: false,
|
||||||
|
isValid: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
isLoading: false,
|
||||||
|
savePending: false,
|
||||||
|
depositPending: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const restService = new SubmissionRestServiceStub();
|
||||||
|
const router = new MockRouter();
|
||||||
|
|
||||||
|
let service: SubmissionService;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
StoreModule.forRoot({ submissionReducers })
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
{ provide: GLOBAL_CONFIG, useValue: config },
|
||||||
|
{ provide: Router, useValue: router },
|
||||||
|
{ provide: SubmissionRestService, useValue: restService },
|
||||||
|
{ provide: ActivatedRoute, useValue: new MockActivatedRoute() },
|
||||||
|
RouteService,
|
||||||
|
SubmissionService
|
||||||
|
]
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
service = TestBed.get(SubmissionService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create a new submission', () => {
|
||||||
|
service.createSubmission();
|
||||||
|
|
||||||
|
expect((service as any).restService.postToEndpoint).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should deposit submission', () => {
|
||||||
|
|
||||||
|
const selfUrl = 'https://rest.api/dspace-spring-rest/api/submission/workspaceitems/826';
|
||||||
|
const options: HttpOptions = Object.create({});
|
||||||
|
let headers = new HttpHeaders();
|
||||||
|
headers = headers.append('Content-Type', 'text/uri-list');
|
||||||
|
options.headers = headers;
|
||||||
|
|
||||||
|
service.depositSubmission(selfUrl);
|
||||||
|
|
||||||
|
expect((service as any).restService.postToEndpoint).toHaveBeenCalledWith('workflowitems', selfUrl, null, options);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should discard submission', () => {
|
||||||
|
service.discardSubmission('826');
|
||||||
|
|
||||||
|
expect((service as any).restService.deleteById).toHaveBeenCalledWith('826');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return submission object state from the store', () => {
|
||||||
|
spyOn((service as any).store, 'select').and.returnValue(hot('a', {
|
||||||
|
a: subState.objects[826]
|
||||||
|
}));
|
||||||
|
|
||||||
|
const result = service.getSubmissionObject('826');
|
||||||
|
const expected = cold('b', { b: subState.objects[826] });
|
||||||
|
|
||||||
|
expect(result).toBeObservable(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return current active submission form section', () => {
|
||||||
|
spyOn((service as any).store, 'select').and.returnValue(hot('a', {
|
||||||
|
a: subState.objects[826]
|
||||||
|
}));
|
||||||
|
|
||||||
|
const result = service.getActiveSectionId('826');
|
||||||
|
const expected = cold('b', { b: 'keyinformation' });
|
||||||
|
|
||||||
|
expect(result).toBeObservable(expected);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return submission form sections', () => {
|
||||||
|
spyOn((service as any).store, 'select').and.returnValue(hot('a|', {
|
||||||
|
a: subState.objects[826]
|
||||||
|
}));
|
||||||
|
|
||||||
|
const result = service.getSubmissionSections('826');
|
||||||
|
const expected = cold('(bc|)', {
|
||||||
|
b: [],
|
||||||
|
c:
|
||||||
|
[
|
||||||
|
{
|
||||||
|
header: 'submit.progressbar.describe.keyinformation',
|
||||||
|
id: 'keyinformation',
|
||||||
|
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/keyinformation',
|
||||||
|
mandatory: true,
|
||||||
|
sectionType: 'submission-form',
|
||||||
|
data: {},
|
||||||
|
errors: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: 'submit.progressbar.describe.indexing',
|
||||||
|
id: 'indexing',
|
||||||
|
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/indexing',
|
||||||
|
mandatory: false,
|
||||||
|
sectionType: 'submission-form',
|
||||||
|
data: {},
|
||||||
|
errors: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: 'submit.progressbar.describe.publicationchannel',
|
||||||
|
id: 'publicationchannel',
|
||||||
|
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/publicationchannel',
|
||||||
|
mandatory: true,
|
||||||
|
sectionType: 'submission-form',
|
||||||
|
data: {},
|
||||||
|
errors: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: 'submit.progressbar.describe.acknowledgement',
|
||||||
|
id: 'acknowledgement',
|
||||||
|
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/acknowledgement',
|
||||||
|
mandatory: false,
|
||||||
|
sectionType: 'submission-form',
|
||||||
|
data: {},
|
||||||
|
errors: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: 'submit.progressbar.describe.identifiers',
|
||||||
|
id: 'identifiers',
|
||||||
|
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/identifiers',
|
||||||
|
mandatory: false,
|
||||||
|
sectionType: 'submission-form',
|
||||||
|
data: {},
|
||||||
|
errors: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: 'submit.progressbar.describe.references',
|
||||||
|
id: 'references',
|
||||||
|
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/references',
|
||||||
|
mandatory: false,
|
||||||
|
sectionType: 'submission-form',
|
||||||
|
data: {},
|
||||||
|
errors: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: 'submit.progressbar.upload',
|
||||||
|
id: 'upload',
|
||||||
|
config: 'https://rest.api/dspace-spring-rest/api/config/submissionuploads/upload',
|
||||||
|
mandatory: true,
|
||||||
|
sectionType: 'upload',
|
||||||
|
data: {},
|
||||||
|
errors: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: 'submit.progressbar.license',
|
||||||
|
id: 'license',
|
||||||
|
config: '',
|
||||||
|
mandatory: true,
|
||||||
|
sectionType: 'license',
|
||||||
|
data: {},
|
||||||
|
errors: []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result).toBeObservable(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return list of submission disabled sections', () => {
|
||||||
|
spyOn((service as any).store, 'select').and.returnValue(hot('-a|', {
|
||||||
|
a: subState.objects[826]
|
||||||
|
}));
|
||||||
|
|
||||||
|
const result = service.getDisabledSectionsList('826');
|
||||||
|
const expected = cold('bc|', {
|
||||||
|
b: [],
|
||||||
|
c:
|
||||||
|
[
|
||||||
|
{
|
||||||
|
header: 'submit.progressbar.describe.indexing',
|
||||||
|
id: 'indexing',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: 'submit.progressbar.describe.acknowledgement',
|
||||||
|
id: 'acknowledgement',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: 'submit.progressbar.describe.identifiers',
|
||||||
|
id: 'identifiers',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: 'submit.progressbar.describe.references',
|
||||||
|
id: 'references',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result).toBeObservable(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return true/false when section is hidden/visible', () => {
|
||||||
|
let section: any = {
|
||||||
|
config: '',
|
||||||
|
header: '',
|
||||||
|
mandatory: true,
|
||||||
|
sectionType: 'collection' as any,
|
||||||
|
visibility: {
|
||||||
|
main: 'HIDDEN',
|
||||||
|
other: 'HIDDEN'
|
||||||
|
},
|
||||||
|
collapsed: false,
|
||||||
|
enabled: true,
|
||||||
|
data: {},
|
||||||
|
errors: [],
|
||||||
|
isLoading: false,
|
||||||
|
isValid: false
|
||||||
|
};
|
||||||
|
expect(service.isSectionHidden(section)).toBeTruthy();
|
||||||
|
|
||||||
|
section = {
|
||||||
|
header: 'submit.progressbar.describe.keyinformation',
|
||||||
|
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/keyinformation',
|
||||||
|
mandatory: true,
|
||||||
|
sectionType: 'submission-form',
|
||||||
|
collapsed: false,
|
||||||
|
enabled: true,
|
||||||
|
data: {},
|
||||||
|
errors: [],
|
||||||
|
isLoading: false,
|
||||||
|
isValid: false
|
||||||
|
};
|
||||||
|
expect(service.isSectionHidden(section)).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return properly submission link name', () => {
|
||||||
|
let expected = 'workspaceitems';
|
||||||
|
router.setRoute('/workspaceitems/826/edit');
|
||||||
|
expect(service.getSubmissionObjectLinkName()).toBe(expected);
|
||||||
|
|
||||||
|
expected = 'workspaceitems';
|
||||||
|
router.setRoute('/submit');
|
||||||
|
expect(service.getSubmissionObjectLinkName()).toBe(expected);
|
||||||
|
|
||||||
|
expected = 'workflowitems';
|
||||||
|
router.setRoute('/workflowitems/826/edit');
|
||||||
|
expect(service.getSubmissionObjectLinkName()).toBe(expected);
|
||||||
|
|
||||||
|
expected = 'edititems';
|
||||||
|
router.setRoute('/items/9e79b1f2-ae0f-4737-9a4b-990952a8857c/edit');
|
||||||
|
expect(service.getSubmissionObjectLinkName()).toBe(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return properly submission scope', () => {
|
||||||
|
let expected = SubmissionScopeType.WorkspaceItem;
|
||||||
|
;
|
||||||
|
router.setRoute('/workspaceitems/826/edit');
|
||||||
|
expect(service.getSubmissionScope()).toBe(expected);
|
||||||
|
|
||||||
|
router.setRoute('/submit');
|
||||||
|
expect(service.getSubmissionScope()).toBe(expected);
|
||||||
|
|
||||||
|
expected = SubmissionScopeType.WorkflowItem;
|
||||||
|
router.setRoute('/workflowitems/826/edit');
|
||||||
|
expect(service.getSubmissionScope()).toBe(expected);
|
||||||
|
|
||||||
|
expected = SubmissionScopeType.EditItem;
|
||||||
|
router.setRoute('/items/9e79b1f2-ae0f-4737-9a4b-990952a8857c/edit');
|
||||||
|
expect(service.getSubmissionScope()).toBe(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return properly submission status', () => {
|
||||||
|
spyOn((service as any).store, 'select').and.returnValue(hot('-a-b', {
|
||||||
|
a: subState,
|
||||||
|
b: validSubState
|
||||||
|
}));
|
||||||
|
const result = service.getSubmissionStatus('826');
|
||||||
|
const expected = cold('cc-d', {
|
||||||
|
c: false,
|
||||||
|
d: true
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result).toBeObservable(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return submission save processing status', () => {
|
||||||
|
spyOn((service as any).store, 'select').and.returnValue(hot('-a', {
|
||||||
|
a: subState.objects[826]
|
||||||
|
}));
|
||||||
|
|
||||||
|
const result = service.getSubmissionSaveProcessingStatus('826');
|
||||||
|
const expected = cold('bb', {
|
||||||
|
b: false
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result).toBeObservable(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return submission deposit processing status', () => {
|
||||||
|
spyOn((service as any).store, 'select').and.returnValue(hot('-a', {
|
||||||
|
a: subState.objects[826]
|
||||||
|
}));
|
||||||
|
|
||||||
|
const result = service.getSubmissionDepositProcessingStatus('826');
|
||||||
|
const expected = cold('bb', {
|
||||||
|
b: false
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result).toBeObservable(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should redirect to MyDspace page', () => {
|
||||||
|
const spy = spyOn((service as any).routeService, 'getPreviousUrl');
|
||||||
|
|
||||||
|
spy.and.returnValue('/mydspace?configuration=workflow');
|
||||||
|
service.redirectToMyDSpace();
|
||||||
|
|
||||||
|
expect((service as any).router.navigateByUrl).toHaveBeenCalledWith('/mydspace?configuration=workflow');
|
||||||
|
|
||||||
|
spy.and.returnValue('');
|
||||||
|
service.redirectToMyDSpace();
|
||||||
|
|
||||||
|
expect((service as any).router.navigate).toHaveBeenCalledWith(['/mydspace']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should retrieve submission from REST endpoint', () => {
|
||||||
|
(service as any).restService.getDataById.and.returnValue(hot('a|', {
|
||||||
|
a: submissionRestREsponse
|
||||||
|
}));
|
||||||
|
|
||||||
|
const result = service.retrieveSubmission('826');
|
||||||
|
const expected = cold('(b|)', {
|
||||||
|
b: submissionRestREsponse[0]
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result).toBeObservable(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should start Auto Save', () => {
|
||||||
|
spyOn((service as any).store, 'dispatch');
|
||||||
|
|
||||||
|
const duration = config.submission.autosave.timer * (1000 * 60);
|
||||||
|
const expected = Observable.timer(duration, duration);
|
||||||
|
|
||||||
|
service.startAutoSave('826');
|
||||||
|
|
||||||
|
expect((service as any).timerObs).toEqual(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should stop Auto Save', () => {
|
||||||
|
service.startAutoSave('826');
|
||||||
|
service.stopAutoSave();
|
||||||
|
|
||||||
|
expect((service as any).autoSaveSub).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
@@ -152,7 +152,7 @@ export class SubmissionService {
|
|||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSectionsState(submissionId: string): Observable<boolean> {
|
getSubmissionStatus(submissionId: string): Observable<boolean> {
|
||||||
return this.store.select(submissionSelector)
|
return this.store.select(submissionSelector)
|
||||||
.map((submissions: SubmissionState) => submissions.objects[submissionId])
|
.map((submissions: SubmissionState) => submissions.objects[submissionId])
|
||||||
.filter((item) => isNotUndefined(item) && isNotUndefined(item.sections))
|
.filter((item) => isNotUndefined(item) && isNotUndefined(item.sections))
|
||||||
@@ -178,16 +178,14 @@ export class SubmissionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSubmissionSaveProcessingStatus(submissionId: string): Observable<boolean> {
|
getSubmissionSaveProcessingStatus(submissionId: string): Observable<boolean> {
|
||||||
return this.store.select(submissionObjectFromIdSelector(submissionId))
|
return this.getSubmissionObject(submissionId)
|
||||||
.filter((state: SubmissionObjectEntry) => isNotUndefined(state))
|
|
||||||
.map((state: SubmissionObjectEntry) => state.savePending)
|
.map((state: SubmissionObjectEntry) => state.savePending)
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.startWith(false);
|
.startWith(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
getSubmissionDepositProcessingStatus(submissionId: string): Observable<boolean> {
|
getSubmissionDepositProcessingStatus(submissionId: string): Observable<boolean> {
|
||||||
return this.store.select(submissionObjectFromIdSelector(submissionId))
|
return this.getSubmissionObject(submissionId)
|
||||||
.filter((state: SubmissionObjectEntry) => isNotUndefined(state))
|
|
||||||
.map((state: SubmissionObjectEntry) => state.depositPending)
|
.map((state: SubmissionObjectEntry) => state.depositPending)
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.startWith(false);
|
.startWith(false);
|
||||||
|
Reference in New Issue
Block a user