diff --git a/src/components/direct/hisp/TestCard.tsx b/src/components/direct/hisp/TestCard.tsx index aceb90eb..846a98ac 100644 --- a/src/components/direct/hisp/TestCard.tsx +++ b/src/components/direct/hisp/TestCard.tsx @@ -313,7 +313,7 @@ const TestCard = ({ } const renderCriteriaMetIcon = () => { - if (criteriaMet === 'TRUE') { + if (criteriaMet === 'TRUE' || criteriaMet === 'PASSED') { return } else if (criteriaMet === 'FALSE') { return @@ -556,15 +556,16 @@ const TestCard = ({ - {test.criteria && + {((test.criteria && criteriaMet && - Array.from(clearButtonVisibleOnCriteriaSet).some((status) => criteriaMet.includes(status)) && ( - - - - )} + Array.from(clearButtonVisibleOnCriteriaSet).some((status) => criteriaMet.includes(status))) || + isFinished) && ( + + + + )} {test.criteria && manualValidationCriteria.includes(test.criteria) && !apiError && isFinished && ( Waiting Validation )} diff --git a/src/components/direct/hisp/XDRTestCard.tsx b/src/components/direct/hisp/XDRTestCard.tsx index d33c8aa5..8bb5d1e8 100644 --- a/src/components/direct/hisp/XDRTestCard.tsx +++ b/src/components/direct/hisp/XDRTestCard.tsx @@ -9,11 +9,10 @@ import { Tooltip, Typography, FormControl, - Popover, } from '@mui/material' import ContentPasteGoIcon from '@mui/icons-material/ContentPasteGo' import _ from 'lodash' -import React, { useState, useEffect, useRef } from 'react' +import React, { useState, useRef } from 'react' import DynamicTable from './DynamicTable' import { handleXDRAPICall, GetStatus } from '../test-by-criteria/ServerActions' import CheckCircleIcon from '@mui/icons-material/CheckCircle' @@ -85,6 +84,7 @@ interface StepTextProps { inputs: InputFields[] role?: string endpointsGenerated: boolean + criteriaMet: string } interface ValidationResults { @@ -104,30 +104,6 @@ interface CCDAValidationResult { const senderText = 'Hit Run to generate your endpoint.' const receiverText = 'Hit Run to send a XDR message.' -const StepText = ({ inputs, role, endpointsGenerated }: StepTextProps) => { - if (endpointsGenerated) { - return ( - - Step 2: Send XDR message to endpoint and refresh to check status. - - ) - } - - return ( - <> - - Step 1: Provide your{' '} - {inputs.map((input, i) => ( - - {input.name} - {inputs.length - 1 === i ? '. ' : ', '} - - ))} - {role === 'sender' ? senderText : receiverText} - - - ) -} export type FieldValue = boolean | string | number export type ExtraFields = { label: string @@ -190,7 +166,7 @@ const TestCard = ({ test }: TestCardProps) => { const [alertSeverity, setAlertSeverity] = useState<'success' | 'error' | 'warning' | 'info'>('info') const [logType, setLogType] = useState<'request' | 'response' | 'ccdaValidation'>('request') - const manualValidationCriteria = ["['b1-3']", "['b1-3','su1-3']"] + const manualValidationIDs = ['4a', '4b', '20amu2', '20bmu2'] const { data: session } = useSession() const subHeader = 'Description' const subDesc = test['Purpose/Description'] @@ -213,7 +189,6 @@ const TestCard = ({ test }: TestCardProps) => { const handleAlertClose = () => { setAlertOpen(false) } - const toggleLogType = (type: 'request' | 'response' | 'ccdaValidation') => { setLogType(type) } @@ -234,7 +209,45 @@ const TestCard = ({ test }: TestCardProps) => { '44mu2', ] const ccdaRequiredTestIds = ['1', '2', '3add'] + const sendEdgeTestsCriteria = ['b1-1'] const isCCDADocumentRequired = ccdaRequiredTestIds.includes(test.id.toString()) + const StepText = ({ inputs, role, endpointsGenerated, criteriaMet }: StepTextProps) => { + if (manualValidationIDs.includes(test.id.toString()) && isFinished) { + if (test.id == '20amu2' || test.id == '20bmu2') { + console.log('abc') + testRequest == 'Check your SUT logs and accept or reject' + testResponse == 'Check your SUT logs and accept or reject' + } + return ( + + Step 3: Check the logs to accept/reject the response + + ) + } + + if (endpointsGenerated) { + return ( + + Step 2: Send XDR message to endpoint and refresh to check status. + + ) + } + + return ( + <> + + Step 1: Provide your{' '} + {inputs.map((input, i) => ( + + {input.name} + {inputs.length - 1 === i ? '. ' : ', '} + + ))} + {role === 'sender' ? senderText : receiverText} + + + ) + } const [formData] = useState<{ [key: string]: FieldValue }>(() => { const initialData: { [key: string]: FieldValue } = {} test.moreInfo?.fields?.forEach((field) => { @@ -250,6 +263,14 @@ const TestCard = ({ test }: TestCardProps) => { })) } } + + const fixEndpoint = (url: string): string => { + if (url && !url.startsWith('http://') && !url.startsWith('https://')) { + return 'https://' + url + } + return url + } + //Event trigger twice const handleRunTest = async () => { eventTrack(` Run test for ${test.name}`, 'Test By Criteria - XDR Test', `${test.criteria}`) @@ -287,6 +308,7 @@ const TestCard = ({ test }: TestCardProps) => { setIsFinished(true) if (status.results) { setValidationResults(status.results) + setEndpointsGenerated(false) } } else { const response = await handleXDRAPICall({ @@ -309,20 +331,34 @@ const TestCard = ({ test }: TestCardProps) => { }) setTimeout(() => { setIsFinished(true) - if (test.criteria && !manualValidationCriteria.includes(test.criteria)) { + if (test.criteria && !manualValidationIDs.includes(test.id.toString())) { setCriteriaMet(response.criteriaMet) } - if ( - !endpointTestIds.includes(test.id.toString()) && - (response.endpoint.length > 10 || response.endpointTLS.length > 10) - ) { - setEndpointsGenerated(true) - setEndpoint(response.endpoint || defaultEndpoint) - setEndpointTLS(response.endpointTLS || defaultEndpointTLS) + if (!endpointTestIds.includes(test.id.toString())) { + let endpointSet = false + if (response.endpoint && response.endpoint.length > 10) { + setEndpoint(fixEndpoint(response.endpoint)) + endpointSet = true + } + if (response.endpointTLS && response.endpointTLS.length > 10) { + setEndpointTLS(fixEndpoint(response.endpointTLS)) + endpointSet = true + } + if (endpointSet) { + console.log('setting endpoints generated') + setEndpointsGenerated(true) + } } setTestRequestRequest(response.testRequest) setTestRequestResponse(response.testResponse) - if (!testRequest && !testResponse && test.criteria && !manualValidationCriteria.includes(test.criteria)) { + if ( + !testRequest && + !testResponse && + test.criteria && + !manualValidationIDs.includes(test.id.toString()) && + criteriaMet + ) { + console.log('Response null, setting criteria met false') setCriteriaMet('FALSE') } console.log('Criteria met: ', response.criteriaMet) @@ -332,12 +368,12 @@ const TestCard = ({ test }: TestCardProps) => { } catch (error) { console.error('Failed to run test:', error) setApiError(true) - if (test.criteria && !manualValidationCriteria.includes(test.criteria)) { + if (test.criteria && !manualValidationIDs.includes(test.id.toString())) { setCriteriaMet('FALSE') } } finally { setIsLoading(false) - if (test.criteria && !manualValidationCriteria.includes(test.criteria)) { + if (test.criteria && !manualValidationIDs.includes(test.id.toString())) { setTimeout(() => { setIsFinished(false) }, 100) @@ -370,10 +406,9 @@ const TestCard = ({ test }: TestCardProps) => { } const renderCriteriaMetIcon = () => { - if (endpointsGenerated && criteriaMet != 'PASSED') { + if (endpointsGenerated) { return Pending - } - if (criteriaMet === 'TRUE' || criteriaMet === 'PASSED') { + } else if (criteriaMet === 'TRUE' || criteriaMet === 'PASSED' || criteriaMet === 'SUCCESS') { return } else if (criteriaMet === 'FALSE' || criteriaMet === 'ERROR') { return @@ -429,7 +464,12 @@ const TestCard = ({ test }: TestCardProps) => { return No C-CDA Validation results available. } } else { - const content = logType === 'request' ? testRequest : testResponse + let content = logType === 'request' ? testRequest : testResponse + + if ((test.id === '20amu2' || test.id === '20bmu2') && isFinished && (!testRequest || !testResponse)) { + content = 'Check your SUT logs and accept or reject' + } + return } } @@ -529,19 +569,16 @@ const TestCard = ({ test }: TestCardProps) => { {renderLogs()} - {test.criteria && - manualValidationCriteria.includes(test.criteria) && - testRequest && - testRequest.length > 0 && ( - - - - - )} + {test.criteria && manualValidationIDs.includes(test.id.toString()) && isFinished && ( + + + + + )} @@ -554,14 +591,25 @@ const TestCard = ({ test }: TestCardProps) => { {test.desc} {_.isEqual(test.sutRole, 'receiver') && _.has(test, 'inputs') && test.inputs !== undefined && ( - + )} {_.isEqual(test.sutRole, 'sender') && _.has(test, 'inputs') && test.inputs !== undefined && ( - + )} {_.has(test, 'inputs') && test.inputs && !endpointsGenerated && + !isFinished && test.inputs.filter(shouldDisplayInput).map((input) => ( @@ -601,16 +649,22 @@ const TestCard = ({ test }: TestCardProps) => { Endpoint - - - + + + )} )} {requiresCCDADocument() && !endpointsGenerated && ( @@ -658,25 +712,16 @@ const TestCard = ({ test }: TestCardProps) => { - {test.criteria && - criteriaMet && - (criteriaMet.includes('TRUE') || - criteriaMet.includes('FALSE') || - criteriaMet.includes('ERROR') || - criteriaMet.includes('PASSED') || - criteriaMet.includes('PENDING') || - criteriaMet.includes('SUCCESS')) && ( - - - - )} - {test.criteria && - manualValidationCriteria.includes(test.criteria) && - (testRequest || testResponse) && - isFinished && - !apiError && Waiting Validation} + {((test.criteria && criteriaMet) || isFinished) && ( + + + + )} + {test.criteria && manualValidationIDs.includes(test.id.toString()) && isFinished && !apiError && ( + Waiting Validation + )} diff --git a/src/components/direct/test-by-criteria/ServerActions.ts b/src/components/direct/test-by-criteria/ServerActions.ts index 0b441a74..c809156b 100644 --- a/src/components/direct/test-by-criteria/ServerActions.ts +++ b/src/components/direct/test-by-criteria/ServerActions.ts @@ -205,10 +205,10 @@ export async function handleXDRAPICall(data: XDRAPICallData): Promise