Skip to content

Commit

Permalink
XDR Test Cases Fix (#210)
Browse files Browse the repository at this point in the history
* Add H2 tab

* Refine sub-criteria

* Resolve merge conflict

* Fix manual validation on tests that did not require it

* Fix pending displayed when successful response already generated

* Fix H2 subgroups

* Fix receive tab

* Minor fixes to fixed endpoints and H2 subgroups

* Fix incorrect endpoint display

* Fix sub-criteria selection and MT test accept/reject buttons

* Add tests to sendEdgeTests

* Fix pending status after refresh

* Add criteriaMet type manual

* Remove duplicate

* Fix issues for HISP tabs

* Fix XDR Test 16 and 17

* Fix XDR receiver test cases

---------

Co-authored-by: ebrockainq <ebrock@ainq.com>
Co-authored-by: ebrockainq <112428189+ebrockainq@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 4, 2024
1 parent ba50806 commit bc4b5f9
Showing 1 changed file with 78 additions and 23 deletions.
101 changes: 78 additions & 23 deletions src/components/direct/hisp/XDRTestCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ const TestCard = ({ test }: TestCardProps) => {
const [endpoint, setEndpoint] = useState(defaultEndpoint)
const [endpointTLS, setEndpointTLS] = useState(defaultEndpointTLS)
const [validationResults, setValidationResults] = useState<ValidationResults | null>(null)
const [acceptValidationLogs, setAcceptValidationLogs] = useState<boolean>(false)
const [displayValidationMessage, setDisplayValidationMessage] = useState<boolean>(false)

const scrollRef = useRef<HTMLDivElement>(null)
const summaryRef = useRef<HTMLDivElement>(null)
Expand All @@ -173,7 +175,7 @@ const TestCard = ({ test }: TestCardProps) => {
const [alertSeverity, setAlertSeverity] = useState<'success' | 'error' | 'warning' | 'info'>('info')

const [logType, setLogType] = useState<'request' | 'response' | 'ccdaValidation'>('request')
const manualValidationIDs = ['4a', '4b', '20amu2', '20bmu2']
const manualValidationIDs = ['4a', '4b', '20amu2', '20bmu2', '13', '14', '15a', '15b', '18', '19', '30mu2', '31mu2']
const { data: session } = useSession()
const subHeader = 'Description'
const subDesc = test['Purpose/Description']
Expand Down Expand Up @@ -217,6 +219,18 @@ const TestCard = ({ test }: TestCardProps) => {
]
const ccdaRequiredTestIds = ['1', '2', '3add']
const sendXDRTestsIds = ['16', '17']
const xdrTestIdsWithThreeSteps = [
'16',
'32mu2',
'33mu2',
'34mu2',
'35mu2',
'36mu2',
'37mu2',
'38mu2',
'43mu2',
'44mu2',
]
const sendEdgeTestsIds = ['1', '2', '6', '7', '10', '11', '12', '20amu2', '20bmu2', '49mu2']
const isCCDADocumentRequired = ccdaRequiredTestIds.includes(test.id.toString())
const StepText = ({ inputs, role, endpointsGenerated, criteriaMet }: StepTextProps) => {
Expand All @@ -232,7 +246,7 @@ const TestCard = ({ test }: TestCardProps) => {
)
}

if (endpointsGenerated) {
if (endpointsGenerated || xdrTestIdsWithThreeSteps.includes(test.id.toString())) {
return (
<Typography variant="body2">
<strong>Step 2:</strong> Send XDR message to endpoint and refresh to check status.
Expand Down Expand Up @@ -308,7 +322,11 @@ const TestCard = ({ test }: TestCardProps) => {
setIsLoading(true)
setIsFinished(false)
setCriteriaMet('')
if (endpointsGenerated) {

if (
endpointsGenerated ||
(xdrTestIdsWithThreeSteps.includes(test.id.toString()) && !isFinished && criteriaMet === 'PENDING')
) {
const status = await GetStatus(test.id.toString())
console.log('Test status:', status)
setTestRequestRequest(status.testRequest)
Expand Down Expand Up @@ -395,12 +413,16 @@ const TestCard = ({ test }: TestCardProps) => {
}

const handleAcceptTest = () => {
setDisplayValidationMessage(true)
setAcceptValidationLogs(true)
setCriteriaMet('TRUE')
setShowLogs(false)
//setShowLogs(false)
}
const handleRejectTest = () => {
setDisplayValidationMessage(true)
setAcceptValidationLogs(false)
setCriteriaMet('FALSE')
setShowLogs(false)
// setShowLogs(false)
}
const handleClearTest = () => {
setCriteriaMet('')
Expand All @@ -414,18 +436,22 @@ const TestCard = ({ test }: TestCardProps) => {
setEndpointTLS(defaultEndpointTLS)
setApiError(false)
setValidationResults(null)
setDisplayValidationMessage(false)
eventTrack('Clear Test', 'Test By Criteria - XDR Test', `${test.criteria}`)
}

const renderCriteriaMetIcon = () => {
if (endpointsGenerated && criteriaMet === 'PENDING') {
return <Chip variant="outlined" color="warning" label="Pending"></Chip>
}
if (criteriaMet === 'PENDING' && xdrTestIdsWithThreeSteps.includes(test.id.toString())) {
return <Chip variant="outlined" color="warning" label="Pending"></Chip>
}
if (
criteriaMet === 'TRUE' ||
criteriaMet === 'PASSED' ||
criteriaMet === 'SUCCESS' ||
(criteriaMet === 'MANUAL' && isFinished)
(criteriaMet === 'MANUAL' && isFinished && !xdrTestIdsWithThreeSteps.includes(test.id.toString()))
) {
return <Chip color="success" label="Success"></Chip>
} else if (criteriaMet === 'FALSE' || criteriaMet === 'ERROR' || criteriaMet === 'FAILED') {
Expand Down Expand Up @@ -595,19 +621,33 @@ const TestCard = ({ test }: TestCardProps) => {
<Button variant="outlined" onClick={() => handleToggleLogs('RETURN TO TEST')}>
RETURN TO TEST
</Button>
{test.criteria &&

{((test.criteria &&
manualValidationIDs.includes(test.id.toString()) &&
testRequest &&
testRequest.length > 0 && (
<Box sx={{ display: 'flex', gap: 1 }}>
<Button variant="outlined" color="success" onClick={handleAcceptTest}>
Accept
</Button>
<Button variant="text" sx={{ color: palette.warningDark }} onClick={handleRejectTest}>
Reject
</Button>
</Box>
)}
testRequest.length > 0 &&
!displayValidationMessage) ||
(test.criteria &&
xdrTestIdsWithThreeSteps.includes(test.id.toString()) &&
criteriaMet === 'MANUAL' &&
testRequest &&
testRequest.length > 0 &&
!displayValidationMessage)) && (
<Box sx={{ display: 'flex', gap: 1 }}>
<Button variant="outlined" color="success" onClick={handleAcceptTest}>
Accept
</Button>
<Button variant="text" sx={{ color: palette.warningDark }} onClick={handleRejectTest}>
Reject
</Button>
</Box>
)}
{displayValidationMessage &&
(acceptValidationLogs ? (
<Chip color="success" label="Validation Accepted"></Chip>
) : (
<Chip color="error" label="Validation Rejected"></Chip>
))}
</Box>
</Box>
) : (
Expand Down Expand Up @@ -708,13 +748,23 @@ const TestCard = ({ test }: TestCardProps) => {
>
<Box>
{' '}
{test.criteria &&
{((test.criteria &&
manualValidationIDs.includes(test.id.toString()) &&
(testRequest || testResponse) &&
isFinished &&
!apiError && (
<Typography sx={{ ml: 1, color: 'primary' }}>Waiting Validation...(Check Logs)</Typography>
)}
!apiError &&
criteriaMet !== 'TRUE' &&
criteriaMet !== 'FALSE') ||
(test.criteria &&
xdrTestIdsWithThreeSteps.includes(test.id.toString()) &&
(testRequest || testResponse) &&
isFinished &&
!apiError &&
criteriaMet !== 'TRUE' &&
criteriaMet !== 'FALSE' &&
criteriaMet === 'MANUAL')) && (
<Typography sx={{ ml: 1, color: 'primary' }}>Waiting Validation...(Check Logs)</Typography>
)}
</Box>
<Box
sx={{
Expand All @@ -730,15 +780,20 @@ const TestCard = ({ test }: TestCardProps) => {
loading={isLoading}
done={isFinished}
progressive={
(sendEdgeTestsIds.includes(test.id.toString()) || sendXDRTestsIds.includes(test.id.toString())) &&
(sendEdgeTestsIds.includes(test.id.toString()) ||
sendXDRTestsIds.includes(test.id.toString()) ||
xdrTestIdsWithThreeSteps.includes(test.id.toString())) &&
!endpointsGenerated
}
progressDuration={loadingTime}
onClick={handleRunTest}
variant="contained"
color="primary"
>
{endpointsGenerated ? 'REFRESH' : 'RUN'}
{endpointsGenerated ||
(xdrTestIdsWithThreeSteps.includes(test.id.toString()) && criteriaMet === 'PENDING')
? 'REFRESH'
: 'RUN'}
</LoadingButton>

{/* <div ref={hiddenAnchorRef} style={{ visibility: 'hidden', top: '50px' }}></div> */}
Expand Down

0 comments on commit bc4b5f9

Please sign in to comment.