-
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.
- Loading branch information
Showing
14 changed files
with
535 additions
and
104 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
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,15 @@ | ||
{ | ||
"userId": 2, | ||
"displayName": "Admin", | ||
"institution": { | ||
"id": 150, | ||
"name": "The Broad Institute of MIT and Harvard" | ||
}, | ||
"roles": [ | ||
{ | ||
"userId": 2, | ||
"roleId": 4, | ||
"name": "Admin" | ||
} | ||
] | ||
} |
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,16 @@ | ||
{ | ||
"userId": 1, | ||
"displayName": "Chairperson", | ||
"institution": { | ||
"id": 150, | ||
"name": "The Broad Institute of MIT and Harvard" | ||
}, | ||
"roles": [ | ||
{ | ||
"userId": 1, | ||
"roleId": 2, | ||
"name": "Chairperson", | ||
"dacId": 1 | ||
} | ||
] | ||
} |
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,21 @@ | ||
[ | ||
{ | ||
"daaId": 1, | ||
"createUserId": 3479, | ||
"createDate": 1722023675199, | ||
"updateUserId": 3479, | ||
"updateDate": 1722023675199, | ||
"initialDacId": 1, | ||
"file": { | ||
"fileStorageObjectId": 1, | ||
"entityId": "1", | ||
"fileName": "DUOS_Uniform_Data_Access_Agreement.pdf", | ||
"category": "dataAccessAgreement", | ||
"mediaType": "application/octet-stream", | ||
"createUserId": 3479, | ||
"createDate": 1722023675199, | ||
"deleted": false | ||
}, | ||
"broadDaa": true | ||
} | ||
] |
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,67 @@ | ||
{ | ||
"dacId": 1, | ||
"name": "Test DAC", | ||
"description": "Test DAC", | ||
"createDate": "Oct 6, 2020", | ||
"updateDate": "Jun 27, 2024", | ||
"chairpersons": [ | ||
{ | ||
"userId": 1, | ||
"email": "test@broadinstitute.org", | ||
"displayName": "Chairperson", | ||
"createDate": 1704827256598, | ||
"roles": [ | ||
{ | ||
"userId": 1, | ||
"roleId": 2, | ||
"name": "Chairperson", | ||
"dacId": 1 | ||
} | ||
], | ||
"emailPreference": true, | ||
"institutionId": 150, | ||
"eraCommonsId": "test" | ||
} | ||
], | ||
"members": [ | ||
{ | ||
"userId": 2, | ||
"email": "test2@broadinstitute.org", | ||
"displayName": "Member", | ||
"createDate": 1704827256598, | ||
"roles": [ | ||
{ | ||
"userId": 2, | ||
"roleId": 1, | ||
"name": "Member", | ||
"dacId": 1 | ||
} | ||
], | ||
"emailPreference": true, | ||
"institutionId": 150, | ||
"eraCommonsId": "test" | ||
} | ||
], | ||
"electionIds": [], | ||
"datasetIds": [], | ||
"email": "grushton@broadinstitute.org", | ||
"associatedDaa": { | ||
"daaId": 1, | ||
"createUserId": 5146, | ||
"createDate": 1713386755554, | ||
"updateUserId": 5146, | ||
"updateDate": 1713386755554, | ||
"initialDacId": 8, | ||
"file": { | ||
"fileStorageObjectId": 216, | ||
"entityId": 1, | ||
"fileName": "test_daa.txt", | ||
"category": "dataAccessAgreement", | ||
"mediaType": "application/octet-stream", | ||
"createUserId": 5146, | ||
"createDate": 1713386755554, | ||
"deleted": false | ||
}, | ||
"broadDaa": true | ||
} | ||
} |
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,36 @@ | ||
/* eslint-disable no-undef,no-console */ | ||
|
||
import React from 'react'; | ||
import {mount} from 'cypress/react'; | ||
import {DacUsers} from '../../../src/pages/manage_dac/DacUsers.jsx'; | ||
import dac from './dac.json'; | ||
|
||
describe('Dac User Tests', () => { | ||
it('Shows a DAC Members', () => { | ||
cy.viewport(600, 800); | ||
const props = { | ||
dac: dac, | ||
removeButton: true, | ||
removeHandler: () => { console.log('Remove Button Clicked'); } | ||
}; | ||
mount(<DacUsers {...props} />); | ||
dac.chairpersons.forEach(u => { | ||
cy.contains(u.displayName); | ||
cy.get('[data-cy="remove_button_' + u.userId + '"]').click().then(() => { | ||
cy.contains('Pending Removal'); | ||
}); | ||
cy.get('[data-cy="remove_button_' + u.userId + '"]').click().then(() => { | ||
cy.get('Pending Removal').should('not.exist'); | ||
}); | ||
}); | ||
dac.members.forEach(u => { | ||
cy.contains(u.displayName); | ||
cy.get('[data-cy="remove_button_' + u.userId + '"]').click().then(() => { | ||
cy.contains('Pending Removal'); | ||
}); | ||
cy.get('[data-cy="remove_button_' + u.userId + '"]').click().then(() => { | ||
cy.get('Pending Removal').should('not.exist'); | ||
}); | ||
}); | ||
}); | ||
}); |
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,119 @@ | ||
/* eslint-disable no-undef */ | ||
|
||
import React from 'react'; | ||
import {mount} from 'cypress/react'; | ||
import {DAA} from '../../../src/libs/ajax/DAA'; | ||
import {DAC} from '../../../src/libs/ajax/DAC'; | ||
import {Storage} from '../../../src/libs/storage'; | ||
import EditDac from '../../../src/pages/manage_dac/EditDac'; | ||
import {BrowserRouter} from 'react-router-dom'; | ||
import admin from './admin.json'; | ||
import chair from './chair.json'; | ||
import daas from './daas.json'; | ||
import dac from './dac.json'; | ||
import {setUserRoleStatuses} from '../../../src/libs/utils'; | ||
|
||
// It's necessary to wrap components that contain `Link` components | ||
const WrappedEditDac = (props) => { | ||
return <BrowserRouter><EditDac {...props}/></BrowserRouter>; | ||
}; | ||
|
||
describe('EditDAC Tests', () => { | ||
|
||
Cypress._.each([admin, chair], (user) => { | ||
it('Edit DAC page should load for ' + user.displayName, () => { | ||
cy.viewport(600, 800); | ||
cy.stub(Storage, 'getCurrentUser').returns(user); | ||
cy.stub(DAC, 'get').returns(dac); | ||
cy.stub(DAA, 'getDaas').returns([]); | ||
const props = {match: {params: {dacId: dac.dacId}}}; | ||
mount(WrappedEditDac(props)); | ||
cy.contains(dac.name).should('exist'); | ||
cy.get('[data-cy="dac_name"]').should('not.be.disabled'); | ||
cy.get('[data-cy="dac_description"]').should('not.be.disabled'); | ||
cy.get('[data-cy="dac_email"]').should('not.be.disabled'); | ||
cy.get('[data-cy="btn_save"]').should('not.be.disabled'); | ||
cy.get('[data-cy="btn_cancel"]').should('not.be.disabled'); | ||
cy.get('[data-cy="daa_radio"]').should('not.be.disabled'); | ||
cy.get('[data-cy="daa_upload_button"]').should('not.be.disabled'); | ||
}); | ||
}); | ||
|
||
it('Admins can create a DAC', () => { | ||
cy.viewport(600, 600); | ||
Storage.clearStorage(); | ||
setUserRoleStatuses(admin, Storage); | ||
cy.stub(DAA, 'getDaas').returns(daas); | ||
cy.stub(DAC, 'removeDacMember').returns(Promise.resolve(200)); | ||
cy.stub(DAC, 'addDacChair').returns(Promise.resolve(200)); | ||
cy.stub(DAC, 'removeDacChair').returns(Promise.resolve(200)); | ||
cy.stub(DAC, 'addDacMember').returns(Promise.resolve(200)); | ||
cy.stub(DAA, 'addDaaToDac').returns(Promise.resolve(200)); | ||
const props = { | ||
match: { | ||
params: { | ||
dacId: undefined | ||
} | ||
}, | ||
history: { | ||
push() { | ||
} | ||
} | ||
}; | ||
mount(WrappedEditDac(props)); | ||
cy.get('[data-cy="dac_name"]').should('not.be.disabled'); | ||
cy.get('[data-cy="dac_name"]').should('be.empty'); | ||
cy.get('[data-cy="dac_description"]').should('not.be.disabled'); | ||
cy.get('[data-cy="dac_description"]').should('be.empty'); | ||
cy.get('[data-cy="dac_email"]').should('not.be.disabled'); | ||
cy.get('[data-cy="dac_email"]').should('be.empty'); | ||
cy.get('[data-cy="btn_save"]').should('not.be.disabled'); | ||
cy.get('[data-cy="btn_cancel"]').should('not.be.disabled'); | ||
|
||
// Create a DAC | ||
const dacCreate = cy.stub(DAC, 'create').returns(dac); | ||
|
||
cy.get('[data-cy="dac_name"]').type('New DAC Name'); | ||
cy.get('[data-cy="dac_description"]').type('New DAC Description'); | ||
cy.get('[data-cy="dac_email"]').type('New DAC Email'); | ||
cy.get('[data-cy="daa_radio"]').first().check(); | ||
cy.get('[data-cy="btn_save"]').click().then(() => { | ||
expect(dacCreate).to.be.called; | ||
}); | ||
}); | ||
|
||
it('Chairs cannot create a DAC', () => { | ||
cy.viewport(600, 600); | ||
Storage.clearStorage(); | ||
setUserRoleStatuses(chair, Storage); | ||
cy.stub(DAA, 'getDaas').returns(daas); | ||
cy.stub(DAC, 'removeDacMember').returns(Promise.resolve(200)); | ||
cy.stub(DAC, 'addDacChair').returns(Promise.resolve(200)); | ||
cy.stub(DAC, 'removeDacChair').returns(Promise.resolve(200)); | ||
cy.stub(DAC, 'addDacMember').returns(Promise.resolve(200)); | ||
cy.stub(DAA, 'addDaaToDac').returns(Promise.resolve(200)); | ||
const props = { | ||
match: { | ||
params: { | ||
dacId: undefined | ||
} | ||
}, | ||
history: { | ||
push() { | ||
} | ||
} | ||
}; | ||
mount(WrappedEditDac(props)); | ||
|
||
// Try to create a DAC | ||
const dacCreate = cy.stub(DAC, 'create'); | ||
cy.get('[data-cy="dac_name"]').type('New DAC Name'); | ||
cy.get('[data-cy="dac_description"]').type('New DAC Description'); | ||
cy.get('[data-cy="dac_email"]').type('New DAC Email'); | ||
cy.get('[data-cy="daa_radio"]').first().check(); | ||
cy.get('[data-cy="btn_save"]').click().then(() => { | ||
expect(dacCreate).to.not.be.called; | ||
}); | ||
}); | ||
|
||
}); |
Oops, something went wrong.