-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into gr-DUOS-2479
- Loading branch information
Showing
28 changed files
with
318 additions
and
3,943 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Data Submission Schema Validation Tests | ||
|
||
Validation tests here rely on the fixture: `cypress/fixtures/dataset-registration-schema_v1.json` which is a copy of | ||
what is stored in Consent: https://consent.dsde-dev.broadinstitute.org/schemas/dataset-registration/v1 | ||
If there are changes there, they need to be copied to this file for tests to reflect back end validation. | ||
|
||
From project root, run: | ||
```shell | ||
curl -s -S -X 'GET' "https://consent.dsde-dev.broadinstitute.org/schemas/dataset-registration/v1" -H 'accept: application/json' -o ./cypress/fixtures/dataset-registration-schema_v1.json | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
cypress/component/DataSubmission/registration_validation.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* eslint-disable no-undef */ | ||
import {compileSchema, validateForm} from '../../../src/pages/data_submission/RegistrationValidation.js'; | ||
|
||
const formData = { | ||
'studyType': 'Observational', | ||
'studyName': 'name', | ||
'studyDescription': 'description', | ||
'dataTypes': ['types'], | ||
'phenotypeIndication': 'phenotype', | ||
'species': 'species', | ||
'piName': 'PI Name', | ||
'dataCustodianEmail': ['[email protected]'], | ||
'publicVisibility': true, | ||
'dataSubmitterUserId': 1, | ||
'nihAnvilUse': 'I am not NHGRI funded and do not plan to store data in AnVIL', | ||
'consentGroups': [{ | ||
'numberOfParticipants': 2, | ||
'consentGroupName': 'name', | ||
'generalResearchUse': true, | ||
'dataAccessCommitteeId': 1, | ||
'url': 'https://asdf.com' | ||
}] | ||
}; | ||
|
||
let schema = undefined; | ||
|
||
beforeEach(function () { | ||
cy.fixture('dataset-registration-schema_v1').then(function (data) { | ||
schema = data; | ||
}); | ||
}); | ||
|
||
describe('Dataset Registration Schema Validator', () => { | ||
|
||
it('Compiles schema and generates a validate function', () => { | ||
const validateFunction = compileSchema(schema); | ||
expect(validateFunction).to.not.be.null; | ||
}); | ||
|
||
it('Validates a valid instance of a schema', () => { | ||
const [valid, validation] = validateForm(schema, formData); | ||
expect(valid).to.be.true; | ||
expect(validation).to.be.empty; | ||
}); | ||
|
||
it('Invalidates an invalid instance of a schema', () => { | ||
const [valid, validation] = validateForm(schema, {}); | ||
expect(valid).to.be.false; | ||
expect(validation).to.not.be.empty; | ||
}); | ||
|
||
it('Validates a valid date field', () => { | ||
const form = Object.assign({}, formData, {targetDeliveryDate: '2021-01-01', targetPublicReleaseDate: '2021-01-01'}); | ||
const [valid, validation] = validateForm(schema, form); | ||
expect(valid).to.be.true; | ||
expect(validation).to.be.empty; | ||
}); | ||
|
||
it('Invalidates an invalid date field', () => { | ||
const form = Object.assign({}, formData, {targetDeliveryDate: '20210101', targetPublicReleaseDate: '20210101'}); | ||
const [valid, validation] = validateForm(schema, form); | ||
expect(valid).to.be.false; | ||
expect(validation).to.not.be.empty; | ||
}); | ||
|
||
it('Validates a valid email field', () => { | ||
const form = Object.assign({}, formData, {dataCustodianEmail: ['[email protected]']}); | ||
const [valid, validation] = validateForm(schema, form); | ||
expect(valid).to.be.true; | ||
expect(validation).to.be.empty; | ||
}); | ||
|
||
it('Invalidates an invalid email field', () => { | ||
const form = Object.assign({}, formData, {dataCustodianEmail: ['user']}); | ||
const [valid, validation] = validateForm(schema, form); | ||
expect(valid).to.be.false; | ||
expect(validation).to.not.be.empty; | ||
}); | ||
|
||
it('Validates a valid uri field', () => { | ||
const consentGroup = { | ||
'numberOfParticipants': 2, | ||
'consentGroupName': 'name', | ||
'generalResearchUse': true, | ||
'dataAccessCommitteeId': 1, | ||
'url': 'https://some.site.org' | ||
}; | ||
const form = Object.assign({}, formData, {consentGroups: [consentGroup]}); | ||
const [valid, validation] = validateForm(schema, form); | ||
expect(valid).to.be.true; | ||
expect(validation).to.be.empty; | ||
}); | ||
|
||
it('Invalidates an invalid uri field', () => { | ||
const consentGroup = { | ||
'numberOfParticipants': 2, | ||
'consentGroupName': 'name', | ||
'generalResearchUse': true, | ||
'dataAccessCommitteeId': 1, | ||
'url': 'some place . org' | ||
}; | ||
const form = Object.assign({}, formData, {consentGroups: [consentGroup]}); | ||
const [valid, validation] = validateForm(schema, form); | ||
expect(valid).to.be.false; | ||
expect(validation).to.not.be.empty; | ||
}); | ||
|
||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.