2 * Copyright (c) 2019 Vodafone Group
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 import React from 'react';
17 import PropTypes from 'prop-types';
18 import Accordion from 'sdc-ui/lib/react/Accordion.js';
19 import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js';
20 import GridSection from 'nfvo-components/grid/GridSection.jsx';
21 import GridItem from 'nfvo-components/grid/GridItem.jsx';
22 import i18n from 'nfvo-utils/i18n/i18n.js';
23 import unCamelCasedString from 'nfvo-utils/unCamelCaseString.js';
25 const TestResultComponent = ({ tests }) => {
28 {tests.map((test, index) => {
29 let name = 'errorCircle';
30 let color = 'warning';
33 test.testResult.toLowerCase() === 'pass'
39 test.testResult.toLowerCase() === 'fail'
41 name = 'exclamationTriangleFull';
44 <li type="none" key={index}>
50 <span className="validation-results-test-result-label">
64 class SoftwareProductValidationResultsView extends React.Component {
66 softwareProductValidation: PropTypes.object
72 vspId: this.props.softwareProductId,
73 versionNumber: this.props.version.name
77 buildSubAccordions(result) {
78 if (result.status && result.status.toLowerCase() === 'completed') {
79 if (!result.results.testResults) {
82 title={i18n('Scenario: {scenario} | Status: {status}', {
83 scenario: result.scenario,
91 <span className="validation-results-test-result-label">
92 {i18n('{title} results are not available', {
93 title: result.scenario
101 dataTestId="vsp-validation-test-result-success"
102 title={i18n('Scenario: {scenario} | Status: {status}', {
103 scenario: result.scenario,
104 status: result.status
106 {Object.keys(result.results.testResults).map(
108 let title = unCamelCasedString(key);
109 if (result.results.testResults[key].length > 0) {
117 result.results.testResults[key]
126 '{title} results are not available',
140 result.status.toLowerCase() === 'failed' &&
141 result.results.errors
145 dataTestId="vsp-validation-test-result-success"
146 title={i18n('Scenario: {scenario} | Status: {status}', {
147 scenario: result.scenario,
148 status: result.status
150 {result.results.errors.map((element, index) => {
152 <li type="none" key={index}>
156 labelPosition="right"
158 <span className="validation-results-test-result-label">
159 {element.reason + ' | ' + element.advice}
166 } else if (result.message || result.httpStatus) {
172 labelPosition="right"
174 <span className="validation-results-test-result-label">
175 {result.message + ' | ' + result.httpStatus}
183 let results = this.props.softwareProductValidation.vspTestResults || [];
184 if (results.length > 0) {
186 <GridSection title={i18n('Validation Results')}>
187 <GridItem colSpan={10}>
190 dataTestId="vsp-validation-test-result"
191 title={i18n('Test Results')}>
192 {results.map(row => this.buildSubAccordions(row))}
199 <GridSection title={i18n('Validation Results')}>
200 <h4>{i18n('No Validation Checks Performed')}</h4>
207 export default SoftwareProductValidationResultsView;