From df65b8ac2a15cffbd20089226dd714f94c423eee Mon Sep 17 00:00:00 2001 From: Job van Achterberg Date: Fri, 10 Dec 2021 12:41:39 +0100 Subject: [PATCH 1/3] Convert assertions table into list of fieldsets. --- client/components/TestRenderer/index.jsx | 366 +++++++++++------------ 1 file changed, 179 insertions(+), 187 deletions(-) diff --git a/client/components/TestRenderer/index.jsx b/client/components/TestRenderer/index.jsx index 50bfce59d..3fbc33781 100644 --- a/client/components/TestRenderer/index.jsx +++ b/client/components/TestRenderer/index.jsx @@ -203,6 +203,50 @@ const ResultsBulletList = styled.ul` } `; +const AssertionFieldsetList = styled.ul` + > li:not(:first-child) { + margin-top: 1em; + } + + > li:last-child { + margin-bottom: 2em; + } + + > li + li { + margin-top: 1em; + } +`; + +const AssertionFieldset = styled.fieldset` + border: 1px solid #000; + + legend { + display: inline-block; + width: auto; + font-size: 1em; + margin-left: 1em; + margin-bottom: 0; + padding: 0.2em; + } + + .assertion-input-group { + margin-left: 0.5em; + display: flex; + } + + .assertion-input-group ul + ul { + margin-top: 2em; + } + + .assertion-input-group > li + li { + margin-left: 1em; + } + + li input { + margin-right: 0.5em; + } +`; + const Button = styled.button``; const ResultsSection = styled.section``; @@ -597,6 +641,118 @@ const TestRenderer = ({ // pageContent to render instructions; submitResult.resultsJSON indicates results have been submitted if (!pageContent) return null; + const Assertion = ({ data, assertionIndex, commandIndex }) => { + const { description, passChoice, failChoices } = data; + + const [missingChoice, failureChoice] = failChoices; + + const legendId = `command-assertion-${assertionIndex}-${commandIndex}-legend`; + + return ( +
  • + + + {description[0]} + {isSubmitted && ( + + {description[1].description} + + )} + + +
      +
    • + + +
    • +
    • + + +
    • +
    • + + +
    • +
    +
    +
  • + ); + }; + + Assertion.propTypes = { + data: PropTypes.object, + assertionIndex: PropTypes.number, + commandIndex: PropTypes.number + }; + return ( {submitResult && @@ -647,7 +803,6 @@ const TestRenderer = ({ const { header, atOutput, - assertionsHeader, assertions, unexpectedBehaviors } = value; @@ -697,196 +852,33 @@ const TestRenderer = ({ } /> - - - - - - - - {assertions.map( - ( - assertion, - assertionIndex - ) => { - const { - description, - passChoice, - failChoices - } = assertion; - - const [ - missingChoice, - failureChoice - ] = failChoices; - - return ( - - {/*Assertion*/} - - {/*Success case*/} - - {/*Failure cases*/} - - - ); - } - )} - -
    - {assertionsHeader.descriptionHeader || - 'Assertion'} - - {assertionsHeader.passHeader || - 'Success case'} - - {assertionsHeader.failHeader || - 'Failure cases'} -
    - { - description[0] - } - {isSubmitted && ( - - { - description[1] - .description - } - - )} - - - - - - - - - -
    +

    + Assertions {header} +

    + + {assertions.map((data, index) => ( + + ))} + {/*Unexpected Behaviors*/}
    - {unexpectedBehaviors.description[0]} + + { + unexpectedBehaviors + .description[0] + } + {isSubmitted && ( Date: Fri, 10 Dec 2021 19:14:32 +0100 Subject: [PATCH 2/3] Remove redundant aria-labelledby; add h5 heading to assertion legends. --- client/components/TestRenderer/index.jsx | 38 +++++++++++++----------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/client/components/TestRenderer/index.jsx b/client/components/TestRenderer/index.jsx index 3fbc33781..eebd1e4cc 100644 --- a/client/components/TestRenderer/index.jsx +++ b/client/components/TestRenderer/index.jsx @@ -229,6 +229,10 @@ const AssertionFieldset = styled.fieldset` padding: 0.2em; } + h5 { + margin: 0; + } + .assertion-input-group { margin-left: 0.5em; display: flex; @@ -646,29 +650,26 @@ const TestRenderer = ({ const [missingChoice, failureChoice] = failChoices; - const legendId = `command-assertion-${assertionIndex}-${commandIndex}-legend`; - return (
  • - - {description[0]} - {isSubmitted && ( - - {description[1].description} - - )} + +
    + {description[0]} + {isSubmitted && ( + + {description[1].description} + + )} +
    -
      +
      • Date: Fri, 10 Dec 2021 19:56:46 +0100 Subject: [PATCH 3/3] Remove superfluous list context. Remove unneeded aria-labelledby and group label around input. --- client/components/TestRenderer/index.jsx | 115 +++++++++++------------ 1 file changed, 54 insertions(+), 61 deletions(-) diff --git a/client/components/TestRenderer/index.jsx b/client/components/TestRenderer/index.jsx index eebd1e4cc..4799096cb 100644 --- a/client/components/TestRenderer/index.jsx +++ b/client/components/TestRenderer/index.jsx @@ -204,7 +204,7 @@ const ResultsBulletList = styled.ul` `; const AssertionFieldsetList = styled.ul` - > li:not(:first-child) { + > li { margin-top: 1em; } @@ -233,20 +233,16 @@ const AssertionFieldset = styled.fieldset` margin: 0; } - .assertion-input-group { + .assertion-input-list { margin-left: 0.5em; display: flex; } - .assertion-input-group ul + ul { - margin-top: 2em; - } - - .assertion-input-group > li + li { + .assertion-input-list > .assertion-input-group + .assertion-input-group { margin-left: 1em; } - li input { + input { margin-right: 0.5em; } `; @@ -669,23 +665,20 @@ const TestRenderer = ({ -
          -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        + +
      • );