Skip to content

Commit

Permalink
DAC-315 Resolved bug in Certifying progress timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
amnambiar committed Oct 27, 2022
1 parent fa0a1c4 commit 774bb89
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 40 deletions.
28 changes: 1 addition & 27 deletions react-web/public/static/data/certifying.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,4 @@
{
"status": "certifying",
"state": "running",
"progress": {
"current-task": { "name": "double-satisfaction", "index": 2 },
"qc-progress": { "successes": 3, "failures": 1, "discarded": 0 },
"finished-tasks": [
{
"task": { "name": "standard-property", "index": 1 },
"qc-result": { "successes": 7, "failures": 2, "discarded": 0 },
"succeeded": false
},
{
"task": { "name": "unit-tests", "index": 0 },
"qc-result": { "successes": 0, "failures": 0, "discarded": 0 },
"succeeded": true
}
],
"progress-index": 18
},
"plan": [
{ "name": "unit-tests", "index": 0 },
{ "name": "standard-property", "index": 1 },
{ "name": "double-satisfaction", "index": 2 },
{ "name": "no-locked-funds", "index": 3 },
{ "name": "crash-tolerance", "index": 5 },
{ "name": "white-list", "index": 6 },
{ "name": "dl-tests", "index": 7 }
]
"state": "running"
}
14 changes: 7 additions & 7 deletions react-web/src/components/TimelineItem/TimelineItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { FC } from "react";
import classNames from "classnames";
// TBD - import PassedImg from 'assets/images/passed.svg' - while moving to assets instead of public

export interface ITimelineItem {
config: {
Expand All @@ -26,10 +25,15 @@ const TimelineItem: FC<ITimelineItem> = ({
} else if (!unitTestSuccess && (status === "finished" || status === 'certifying')) {
state = 'failed'
}
// TBD - return PassedImg
return "images/" + state + ".svg";
};

const renderProgressPercentage = () => {
if (state === "running" && status === "certifying") {
return <span className="progress-percentage">{progress}%</span>
}
};

return (
<li
data-value={status}
Expand All @@ -49,11 +53,7 @@ const TimelineItem: FC<ITimelineItem> = ({
src={getURLFor(state)}
alt={state}
/>
{
(state === 'running' && status === 'certifying') ?
<span className="progress-percentage">{progress}%</span>
: null
}
{renderProgressPercentage()}
<span className="text" data-testid={text}>
{text}
</span>
Expand Down
25 changes: 19 additions & 6 deletions react-web/src/pages/certification/Certification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,17 @@ const Certification = () => {
let returnObj = { ...item, state: currentState };
if (
status === "certifying" &&
currentState === "running" &&
res.data.progress &&
res.data.plan
currentState === "running"
) {
if (res.data.progress && res.data.plan) {
returnObj["progress"] = Math.trunc(
(res.data.progress["finished-tasks"].length /
getPlannedCertificationTaskCount(res.data.plan)) *
100
);
} else {
returnObj["progress"] = 0
}
}
return returnObj;
}
Expand Down Expand Up @@ -152,7 +154,7 @@ const Certification = () => {
.then((response) => response.data)
.then((uuid) => {
// await fetchData.get("/run/" + uid)
fetchData.get("static/data/finished-escrow-UTFail.json").then((res) => {
fetchData.get("static/data/certifying.json").then((res) => {
const status = res.data.status,
state = res.data.hasOwnProperty("state") ? res.data.state : "";
Expand All @@ -161,8 +163,19 @@ const Certification = () => {
if (item.status === status) {
const currentState = status === "finished" ? "passed" : (state || "running")
let returnObj = { ...item, state: currentState };
if (status === 'certifying' && currentState === 'running' && res.data.progress && res.data.plan) {
returnObj['progress'] = Math.trunc((res.data.progress['finished-tasks'].length / getPlannedCertificationTaskCount(res.data.plan)) * 100)
if (
status === "certifying" &&
currentState === "running"
) {
if (res.data.progress && res.data.plan) {
returnObj["progress"] = Math.trunc(
(res.data.progress["finished-tasks"].length /
getPlannedCertificationTaskCount(res.data.plan)) *
100
);
} else {
returnObj["progress"] = 0
}
}
return returnObj;
} else {
Expand Down

0 comments on commit 774bb89

Please sign in to comment.