Added tests

This commit is contained in:
Giuseppe Digilio
2019-01-10 19:13:40 +01:00
parent 5723a1df84
commit 9edd18f289
10 changed files with 1516 additions and 47 deletions

View File

@@ -55,7 +55,54 @@ export const mockSectionsErrors = [
}
];
export const submissionRestResponse = [
export const mockUploadResponse1Errors = {
errors: [
{
message: 'error.validation.required',
paths: [
'/sections/traditionalpageone/dc.title',
'/sections/traditionalpageone/dc.date.issued'
]
}
]
};
export const mockUploadResponse1ParsedErrors: any = {
traditionalpageone: [
{ path: '/sections/traditionalpageone/dc.title', message: 'error.validation.required' },
{ path: '/sections/traditionalpageone/dc.date.issued', message: 'error.validation.required' }
]
};
export const mockUploadResponse2Errors = {
errors: [
{
message: 'error.validation.required',
paths: [
'/sections/traditionalpageone/dc.title',
'/sections/traditionalpageone/dc.date.issued'
]
},
{
message: 'error.upload',
paths: [
'/sections/upload'
]
}
]
};
export const mockUploadResponse2ParsedErrors = {
traditionalpageone: [
{ path: '/sections/traditionalpageone/dc.title', message: 'error.validation.required' },
{ path: '/sections/traditionalpageone/dc.date.issued', message: 'error.validation.required' }
],
upload: [
{ path: '/sections/upload', message: 'error.upload' }
]
};
export const mockSubmissionRestResponse = [
{
id: 826,
lastModified: '2018-08-03T12:49:45.268+0000',
@@ -257,6 +304,7 @@ export const submissionRestResponse = [
}
}
];
export const mockSubmissionObject = {
collection: {
handle: '10673/2',
@@ -476,9 +524,9 @@ export const mockSubmissionObject = {
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',
self: 'https://rest.api/dspace-spring-rest/api/eperson/epersons/99423c27-b642-5tg6-a9cd-6d910e68dca5',
id: '99423c27-b642-5tg6-a9cd-6d910e68dca5',
uuid: '99423c27-b642-5tg6-a9cd-6d910e68dca5',
type: 'eperson',
name: 'dspacedemo+submit@gmail.com',
metadata: [
@@ -494,7 +542,7 @@ export const mockSubmissionObject = {
}
],
_links: {
self: 'https://rest.api/dspace-spring-rest/api/eperson/epersons/99423c27-b642-4bb9-a9cd-6d910e68dca5'
self: 'https://rest.api/dspace-spring-rest/api/eperson/epersons/99423c27-b642-5tg6-a9cd-6d910e68dca5'
}
},
id: 826,
@@ -518,18 +566,276 @@ export const mockSubmissionObject = {
]
}
],
self: 'https://rest.api/dspace-spring-rest/api/submission/workspaceitems/269',
self: 'https://rest.api/dspace-spring-rest/api/submission/workspaceitems/826',
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'
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'
}
}
};
export const mockSubmissionObjectNew = {
collection: {
handle: '10673/2',
license: 'https://rest.api/dspace-spring-rest/api/core/collections/45f2f3f1-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/45f2f3f1-ba1f-4f36-908a-3f1ea9a557eb',
id: '45f2f3f1-ba1f-4f36-908a-3f1ea9a557eb',
uuid: '45f2f3f1-ba1f-4f36-908a-3f1ea9a557eb',
type: 'collection',
name: 'Another 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/45f2f3f1-ba1f-4f36-908a-3f1ea9a557eb/license',
defaultAccessConditions: 'https://rest.api/dspace-spring-rest/api/core/collections/45f2f3f1-ba1f-4f36-908a-3f1ea9a557eb/defaultAccessConditions',
logo: 'https://rest.api/dspace-spring-rest/api/core/collections/45f2f3f1-ba1f-4f36-908a-3f1ea9a557eb/logo',
self: 'https://rest.api/dspace-spring-rest/api/core/collections/45f2f3f1-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: 'traditionaltwo',
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-45gh23e68dca5',
id: '99423c27-b642-4bb9-a9cd-45gh23e68dca5',
uuid: '99423c27-b642-4bb9-a9cd-45gh23e68dca5',
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-45gh23e68dca5'
}
},
id: 826,
lastModified: '2019-01-09T10:17:33.738+0000',
sections: {},
errors: [],
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'
}
};
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 = {
@@ -801,3 +1107,127 @@ export const mockSubmissionState: SubmissionObjectState = {
depositPending: false
}
};
export const mockSectionsState = {
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
};
export const mockSectionsList = [
{
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpageone',
mandatory: true,
data: {},
errors: [],
header: 'submit.progressbar.describe.stepone',
id: 'traditionalpageone',
sectionType: 'submission-form'
},
{
config: 'https://rest.api/dspace-spring-rest/api/config/submissionforms/traditionalpagetwo',
mandatory: true,
data: {},
errors: [],
header: 'submit.progressbar.describe.steptwo',
id: 'traditionalpagetwo',
sectionType: 'submission-form'
},
{
config: 'https://rest.api/dspace-spring-rest/api/config/submissionuploads/upload',
mandatory: true,
data: {},
errors: [],
header: 'submit.progressbar.upload',
id: 'upload',
sectionType: 'upload'
},
{
config: '',
mandatory: true,
data: {},
errors: [],
header: 'submit.progressbar.license',
id: 'license',
sectionType: 'license'
}
];