Skip to content

Commit

Permalink
feat: add more tests to general data page and refactor existing ones
Browse files Browse the repository at this point in the history
  • Loading branch information
Flaminia Cavallo authored and Flaminia Cavallo committed Jul 25, 2024
1 parent a899bdf commit d9426ea
Show file tree
Hide file tree
Showing 5 changed files with 227 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react'

const RequestsNavigation = ({ requests, selected, onChange }) =>
requests && requests?.length > 0 ? (
<TabBar>
<TabBar scrollable>
{requests.map((request, index) => (
<Tab
key={request.name}
Expand Down
60 changes: 32 additions & 28 deletions src/components/view/submit-modal/submit-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ const SuccessModalContent = ({ onClose, data, dataSubmitted }) => (

<ModalActions>
<ButtonStrip end>
<Button onClick={onClose}>{i18n.t('Close')}</Button>
<Button onClick={onClose} data-test="close-submission-button">
{i18n.t('Close')}
</Button>
</ButtonStrip>
</ModalActions>
</>
Expand Down Expand Up @@ -286,33 +288,35 @@ const SubmitModal = ({ open, onClose, setDataSubmitted }) => {
position="middle"
onClose={loading ? null : onClose}
>
<ModalTitle>{i18n.t('Submitting data')}</ModalTitle>
{!called && !loading && !submitsAttempted && (
<ConfirmModalContent
exchange={exchange}
requests={requests}
onClose={onClose}
onSubmit={() => {
setSubmitsAttempted(true)
submitExchange()
}}
/>
)}
{error && submitsAttempted && (
<ErrorModalContent
error={error}
onRetry={submitExchange}
onClose={onClose}
/>
)}
{data && (
<SuccessModalContent
data={data}
dataSubmitted={dataSubmitted}
onClose={onClose}
/>
)}
{loading && <LoadingStateModalContent />}
<span data-test="submit-modal-content">
<ModalTitle>{i18n.t('Submitting data')}</ModalTitle>
{!called && !loading && !submitsAttempted && (
<ConfirmModalContent
exchange={exchange}
requests={requests}
onClose={onClose}
onSubmit={() => {
setSubmitsAttempted(true)
submitExchange()
}}
/>
)}
{error && submitsAttempted && (
<ErrorModalContent
error={error}
onRetry={submitExchange}
onClose={onClose}
/>
)}
{data && (
<SuccessModalContent
data={data}
dataSubmitted={dataSubmitted}
onClose={onClose}
/>
)}
{loading && <LoadingStateModalContent />}
</span>
</Modal>
)
}
Expand Down
5 changes: 4 additions & 1 deletion src/components/view/top-bar/top-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ const LinKToEditMode = () => {
return null
}
return (
<div className={styles.additionalContentContainer}>
<div
className={styles.additionalContentContainer}
data-test={'configurations-button'}
>
<Link to="/edit">
<Button small>{i18n.t('Configurations')}</Button>
</Link>
Expand Down
Loading

0 comments on commit d9426ea

Please sign in to comment.