diff --git a/cypress/component/DAC/editDac.spec.js b/cypress/component/DAC/editDac.spec.js index 4923a5364..bc6b1d570 100644 --- a/cypress/component/DAC/editDac.spec.js +++ b/cypress/component/DAC/editDac.spec.js @@ -2,6 +2,7 @@ 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'; @@ -18,11 +19,12 @@ const WrappedEditDac = (props) => { describe('EditDAC Tests', () => { Cypress._.each([admin, chair], (user) => { - it('Should Load for ' + user.displayName, () => { - cy.viewport(600, 600); + 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); - const props = {match: {params: {dacId: 1}}}; + 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'); @@ -30,6 +32,8 @@ describe('EditDAC Tests', () => { 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'); }); }); diff --git a/cypress/component/DAC/manageEditDac.spec.js b/cypress/component/DAC/manageEditDac.spec.js index 3731b9159..d650b5849 100644 --- a/cypress/component/DAC/manageEditDac.spec.js +++ b/cypress/component/DAC/manageEditDac.spec.js @@ -15,14 +15,17 @@ const WrappedManageEditDac = (props) => { return ; }; +/** + * This manage page is the pre-Data Access Agreement way to edit a DAC and will be removed when DAA work is complete. + */ describe('ManageEditDAC Tests', () => { Cypress._.each([admin, chair], (user) => { - it('Should Load for ' + user.displayName, () => { + it('Manage Edit DAC page should load for ' + user.displayName, () => { cy.viewport(600, 600); cy.stub(Storage, 'getCurrentUser').returns(user); cy.stub(DAC, 'get').returns(dac); - const props = {match: {params: {dacId: 1}}}; + const props = {match: {params: {dacId: dac.dacId}}}; mount(WrappedManageEditDac(props)); cy.contains(dac.name).should('exist'); cy.get('[data-cy="dac_name"]').should('not.be.disabled'); diff --git a/src/pages/manage_dac/EditDac.jsx b/src/pages/manage_dac/EditDac.jsx index 2735b13d3..03a98f113 100644 --- a/src/pages/manage_dac/EditDac.jsx +++ b/src/pages/manage_dac/EditDac.jsx @@ -1,21 +1,21 @@ import * as ld from 'lodash'; -import React, { useEffect, useState } from 'react'; +import React, {useEffect, useState} from 'react'; import AsyncSelect from 'react-select/async'; -import { DAC } from '../../libs/ajax/DAC'; -import { DAA } from '../../libs/ajax/DAA'; -import { Models } from '../../libs/models'; -import { PromiseSerial } from '../../libs/utils'; -import { Alert } from '../../components/Alert'; -import { Link } from 'react-router-dom'; -import { DacUsers } from './DacUsers'; -import { Notifications } from '../../libs/utils'; +import {DAC} from '../../libs/ajax/DAC'; +import {DAA} from '../../libs/ajax/DAA'; +import {Models} from '../../libs/models'; +import {PromiseSerial} from '../../libs/utils'; +import {Alert} from '../../components/Alert'; +import {Link} from 'react-router-dom'; +import {DacUsers} from './DacUsers'; +import {Notifications} from '../../libs/utils'; import editDACIcon from '../../images/dac_icon.svg'; import backArrowIcon from '../../images/back_arrow.svg'; -import { Spinner } from '../../components/Spinner'; -import { Styles } from '../../libs/theme'; +import {Spinner} from '../../components/Spinner'; +import {Styles} from '../../libs/theme'; import DUOSUniformDataAccessAgreement from '../../assets/DUOS_Uniform_Data_Access_Agreement.pdf'; import PublishIcon from '@mui/icons-material/Publish'; -import { UploadDaaModal } from '../../components/modals/UploadDaaModal'; +import {UploadDaaModal} from '../../components/modals/UploadDaaModal'; import {Storage} from '../../libs/storage'; export const CHAIR = 'chair'; @@ -56,13 +56,12 @@ export default function EditDac(props) { const daas = await DAA.getDaas(); const broadDaa = daas.find(daa => daa.broadDaa === true); setBroadDaa(broadDaa); - setState(prev => ({ ...prev, dac: fetchedDac })); + setState(prev => ({...prev, dac: fetchedDac})); const matchingDaas = daas.filter(daa => daa.initialDacId === fetchedDac.dacId); setMatchingDaas(matchingDaas); const daa = fetchedDac?.associatedDaa ? fetchedDac.associatedDaa : null; setSelectedDaa(daa?.daaId ? daa : null); - } - catch(e) { + } catch (e) { Notifications.showError({text: 'Error: Unable to retrieve current DAC from server'}); } } else { @@ -70,8 +69,7 @@ export default function EditDac(props) { const daas = await DAA.getDaas(); const broadDaa = daas.find(daa => daa.broadDaa === true); setBroadDaa(broadDaa); - } - catch(e) { + } catch (e) { Notifications.showError({text: 'Error: Unable to retrieve current DAC from server'}); } } @@ -171,7 +169,9 @@ export default function EditDac(props) { const userSearch = (invalidUserIds, query, callback) => { DAC.autocompleteUsers(query).then( items => { - const filteredUsers = ld.filter(items, item => { return !invalidUserIds.includes(item.userId); }); + const filteredUsers = ld.filter(items, item => { + return !invalidUserIds.includes(item.userId); + }); const options = filteredUsers.map(function (item) { return { key: item.userId, @@ -272,7 +272,7 @@ export default function EditDac(props) { } }; - const handleAttachment = async(attachment) => { + const handleAttachment = async (attachment) => { if (dacId !== undefined) { setUploadedDaaFile(attachment); setDaaFileData(attachment[0]); @@ -301,7 +301,7 @@ export default function EditDac(props) { dirtyFlag: true })); } else { - setSelectedDaa({ ...selectedDaa, daaId: daaId }); + setSelectedDaa({...selectedDaa, daaId: daaId}); setNewDaaId(daaId); setState(prev => ({ ...prev, @@ -310,22 +310,25 @@ export default function EditDac(props) { } }; - const DaaItem = ({ specificDaa }) => ( -
- handleDaaChange(specificDaa.daaId)} style={{accentColor:'#00609f'}}/> -
-
-
+ const DaaItem = ({specificDaa}) => ( +
+ handleDaaChange(specificDaa.daaId)} style={{accentColor: '#00609f'}}/> +
+
+
{specificDaa.file.fileName}
-
+
Uploaded on {specificDaa?.updateDate ? new Date(specificDaa.updateDate).toLocaleDateString() : ''}
-
-
- {DAA.getDaaFileById(specificDaa.daaId, specificDaa.file.fileName);}} className='button button-white' style={{ padding: '10px 12px' }}> - + @@ -336,80 +339,91 @@ export default function EditDac(props) { return ( isLoading ? : -
-
-
+
+
+
- {'Back'}/ + {'Back'}/
- {'Edit'}/ + {'Edit'}/
-
{dacText}
-
{dacId === undefined ? 'Create DAC' : fetchedDac?.name}
+
{dacText}
+
{dacId === undefined ? 'Create DAC' : fetchedDac?.name}

-
-
-
-
+
+
+
+
- -
+ +
- -
+ +