CEC-1369 Fix display of update error (#139)

* CEC-1369 Fix display of update error

* Update snapshot
This commit is contained in:
John Wu
2022-04-18 16:22:22 -07:00
committed by GitHub
parent b4d06cf52f
commit 81aeedc521
4 changed files with 84 additions and 267 deletions

View File

@@ -3,6 +3,7 @@ import { render, waitFor } from "@testing-library/react";
import CarUpdateStatusProgress from "../CarUpdateStatusProgress";
import useStyles from "../../useStyles";
import s from "./Statuses";
const TestWrapper = ({ status }) => {
const classes = useStyles();
@@ -21,7 +22,7 @@ describe("CarUpdateStatusProgress", () => {
name: "manifest_received",
status: {
car_update_id: 297,
msg: "manifest_received",
msg: s.ManifestReceived,
err: -6,
extra_info: "",
},
@@ -30,7 +31,7 @@ describe("CarUpdateStatusProgress", () => {
name: "manifest_accepted",
status: {
car_update_id: 297,
msg: "manifest_accepted",
msg: s.ManifestAccepted,
err: -7,
extra_info: "",
},
@@ -39,7 +40,7 @@ describe("CarUpdateStatusProgress", () => {
name: "download_started",
status: {
car_update_id: 297,
msg: "download_started",
msg: s.DownloadStarted,
err: -14,
extra_info: "",
},
@@ -53,7 +54,7 @@ describe("CarUpdateStatusProgress", () => {
file_total: 1264672,
package_current: 0,
package_total: 2529856,
msg: "download_start",
msg: s.DownloadStarted,
err: 0,
},
},
@@ -66,7 +67,7 @@ describe("CarUpdateStatusProgress", () => {
file_total: 1264672,
package_current: 1048576,
package_total: 2529856,
msg: "downloading",
msg: s.Downloading,
err: 0,
},
},
@@ -79,7 +80,7 @@ describe("CarUpdateStatusProgress", () => {
file_total: 1264672,
package_current: 1264672,
package_total: 2529856,
msg: "download_complete",
msg: s.DownloadCompleted,
err: 0,
},
},
@@ -87,7 +88,7 @@ describe("CarUpdateStatusProgress", () => {
name: "package_download_complete",
status: {
car_update_id: 297,
msg: "package_download_complete",
msg: s.PackageDownloadCompleted,
err: -15,
extra_info: "",
},
@@ -101,7 +102,7 @@ describe("CarUpdateStatusProgress", () => {
file_total: 100,
package_current: 0,
package_total: 1000,
msg: "download_error",
msg: s.DownloadFailed,
err: 0,
},
},
@@ -112,7 +113,7 @@ describe("CarUpdateStatusProgress", () => {
ecu: "TEST",
installed: 5,
total_files: 10,
msg: "installing",
msg: s.Installing,
err: 0,
},
},
@@ -123,7 +124,7 @@ describe("CarUpdateStatusProgress", () => {
ecu: "TEST",
installed: 10,
total_files: 10,
msg: "install_complete",
msg: s.InstallSucceeded,
err: 0,
},
},
@@ -134,7 +135,7 @@ describe("CarUpdateStatusProgress", () => {
ecu: "TEST",
installed: 5,
total_files: 10,
msg: "install_error",
msg: s.InstallFailed,
err: 0,
},
},

View File

@@ -0,0 +1,38 @@
const Statuses = {
Pending: "pending",
ManifestReceived: "manifest_received",
ManifestAccepted: "manifest_accepted",
ManifestRejected: "manifest_rejected",
PreconditionAwait: "requirements_await",
PreconditionSuceeded: "requirements_succeeded",
ManifestCancelReceived: "manifest_cancel_received",
ManifestCancelAccepted: "manifest_cancel_accepted",
ManifestCancelRejected: "manifest_cancel_rejected",
ManifestValidationSucceeded: "manifest_validation_succeeded",
ManifestValidationFailed: "manifest_validation_failed",
DownloadStarted: "download_started",
Downloading: "downloading",
DownloadCompleted: "download_completed",
DownloadFailed: "download_failed",
InstallApprovalAwait: "install_approval_await",
InstallApprovalReceived: "install_approval_received",
InstallStarted: "install_started",
Installing: "installing",
InstallSucceeded: "install_succeeded",
InstallFailed: "install_failed",
RollbackStarted: "rollback_started",
RollbackSucceeded: "rollback_succeeded",
RollbackFailed: "rollback_failed",
CleanupSucceeded: "cleanup_succeeded",
CleanupFailed: "cleanup_failed",
ManifestError: "manifest_error",
ManifestRollback: "manifest_rollback",
ManifestSucceeded: "manifest_succeeded",
ManifesCanceled: "manifest_canceled",
PackageDownloadStarted: "package_download_start",
PackageDownloadCompleted: "package_download_complete",
PackageInstallStarted: "package_install_start",
PackageInstallCompleted: "package_install_complete",
};
export default Statuses;

View File

@@ -119,25 +119,6 @@ exports[`CarUpdateStatusProgress Render download_complete 1`] = `
Install
</p>
</div>
<div
class="makeStyles-textCenterAlign-353"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root makeStyles-progressIcon-360"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
/>
</svg>
<p
class="MuiTypography-root MuiTypography-body1"
>
Clean up
</p>
</div>
<div
class="makeStyles-textCenterAlign-353"
>
@@ -280,25 +261,6 @@ exports[`CarUpdateStatusProgress Render download_error 1`] = `
Install
</p>
</div>
<div
class="makeStyles-textCenterAlign-475"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root makeStyles-progressIcon-482"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
/>
</svg>
<p
class="MuiTypography-root MuiTypography-body1"
>
Clean up
</p>
</div>
<div
class="makeStyles-textCenterAlign-475"
>
@@ -441,25 +403,6 @@ exports[`CarUpdateStatusProgress Render download_start ECU 1`] = `
Install
</p>
</div>
<div
class="makeStyles-textCenterAlign-231"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root makeStyles-progressIcon-238"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
/>
</svg>
<p
class="MuiTypography-root MuiTypography-body1"
>
Clean up
</p>
</div>
<div
class="makeStyles-textCenterAlign-231"
>
@@ -493,12 +436,12 @@ exports[`CarUpdateStatusProgress Render download_started 1`] = `
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root makeStyles-progressIcon-177"
class="MuiSvgIcon-root makeStyles-progressIcon-177 makeStyles-progressSuccess-178"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"
/>
</svg>
<p
@@ -512,12 +455,12 @@ exports[`CarUpdateStatusProgress Render download_started 1`] = `
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root makeStyles-progressIcon-177"
class="MuiSvgIcon-root makeStyles-progressIcon-177 makeStyles-progressSuccess-178"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"
/>
</svg>
<p
@@ -531,12 +474,12 @@ exports[`CarUpdateStatusProgress Render download_started 1`] = `
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root makeStyles-progressIcon-177"
class="MuiSvgIcon-root makeStyles-progressIcon-177 makeStyles-progressSuccess-178"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"
/>
</svg>
<p
@@ -602,25 +545,6 @@ exports[`CarUpdateStatusProgress Render download_started 1`] = `
Install
</p>
</div>
<div
class="makeStyles-textCenterAlign-170"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root makeStyles-progressIcon-177"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
/>
</svg>
<p
class="MuiTypography-root MuiTypography-body1"
>
Clean up
</p>
</div>
<div
class="makeStyles-textCenterAlign-170"
>
@@ -763,25 +687,6 @@ exports[`CarUpdateStatusProgress Render downloading 1`] = `
Install
</p>
</div>
<div
class="makeStyles-textCenterAlign-292"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root makeStyles-progressIcon-299"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
/>
</svg>
<p
class="MuiTypography-root MuiTypography-body1"
>
Clean up
</p>
</div>
<div
class="makeStyles-textCenterAlign-292"
>
@@ -924,25 +829,6 @@ exports[`CarUpdateStatusProgress Render install_complete ECU 1`] = `
Install
</p>
</div>
<div
class="makeStyles-textCenterAlign-597"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root makeStyles-progressIcon-604"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
/>
</svg>
<p
class="MuiTypography-root MuiTypography-body1"
>
Clean up
</p>
</div>
<div
class="makeStyles-textCenterAlign-597"
>
@@ -1085,25 +971,6 @@ exports[`CarUpdateStatusProgress Render install_error 1`] = `
Install
</p>
</div>
<div
class="makeStyles-textCenterAlign-658"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root makeStyles-progressIcon-665"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
/>
</svg>
<p
class="MuiTypography-root MuiTypography-body1"
>
Clean up
</p>
</div>
<div
class="makeStyles-textCenterAlign-658"
>
@@ -1246,25 +1113,6 @@ exports[`CarUpdateStatusProgress Render installing 1`] = `
Install
</p>
</div>
<div
class="makeStyles-textCenterAlign-536"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root makeStyles-progressIcon-543"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
/>
</svg>
<p
class="MuiTypography-root MuiTypography-body1"
>
Clean up
</p>
</div>
<div
class="makeStyles-textCenterAlign-536"
>
@@ -1407,25 +1255,6 @@ exports[`CarUpdateStatusProgress Render manifest_accepted 1`] = `
Install
</p>
</div>
<div
class="makeStyles-textCenterAlign-109"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root makeStyles-progressIcon-116"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
/>
</svg>
<p
class="MuiTypography-root MuiTypography-body1"
>
Clean up
</p>
</div>
<div
class="makeStyles-textCenterAlign-109"
>
@@ -1568,25 +1397,6 @@ exports[`CarUpdateStatusProgress Render manifest_received 1`] = `
Install
</p>
</div>
<div
class="makeStyles-textCenterAlign-48"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root makeStyles-progressIcon-55"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
/>
</svg>
<p
class="MuiTypography-root MuiTypography-body1"
>
Clean up
</p>
</div>
<div
class="makeStyles-textCenterAlign-48"
>
@@ -1729,25 +1539,6 @@ exports[`CarUpdateStatusProgress Render package_download_complete 1`] = `
Install
</p>
</div>
<div
class="makeStyles-textCenterAlign-414"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root makeStyles-progressIcon-421"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
/>
</svg>
<p
class="MuiTypography-root MuiTypography-body1"
>
Clean up
</p>
</div>
<div
class="makeStyles-textCenterAlign-414"
>

View File

@@ -4,78 +4,65 @@ import Typography from "@material-ui/core/Typography";
import clsx from "clsx";
import CircularProgress from "../CircularProgress";
import s from "./Statuses";
const AwaitStatus = -1;
const ErrorStatus = -100;
const PHASES = [
{
label: "Pending",
events: ["pending"],
events: [s.Pending],
progress: () => 100,
},
{
label: "Received",
events: ["manifest_accepted", "manifest_received"],
events: [s.ManifestAccepted, s.ManifestReceived, s.ManifestRejected],
progress: () => 100,
},
{
label: "Precondition",
events: ["requirements_succeeded"],
events: [s.PreconditionAwait, s.PreconditionSuceeded],
progress: () => 100,
},
{
label: "Download",
events: [
"downloading",
"download_start",
"download_complete",
"download_error",
"package_download_start",
s.Downloading,
s.DownloadStarted,
s.DownloadCompleted,
s.DownloadFailed,
s.PackageDownloadStarted,
],
progress: (msg, progress) =>
[
"package_download_start",
"downloading",
"download_start",
"download_complete",
].indexOf(msg) > -1
? progress
: -100,
progress: (msg, progress) => {
if (msg === s.DownloadFailed) return ErrorStatus;
return progress;
},
},
{
label: "Approved",
events: ["package_download_complete", "install_approval_await"],
progress: () => -1,
events: [s.PackageDownloadCompleted, s.InstallApprovalAwait],
progress: () => AwaitStatus,
},
{
label: "Install",
events: [
"install_approval_received",
"install_start",
"installing",
"install_complete",
"install_error",
s.InstallApprovalReceived,
s.InstallStarted,
s.Installing,
s.InstallSucceeded,
s.InstallFailed,
],
progress: (msg, progress) =>
[
"install_approval_received",
"install_start",
"installing",
"install_complete",
].indexOf(msg) > -1
? progress
: -100,
},
{
label: "Clean up",
events: ["package_install_complete", "cleanup_failed"],
progress: (msg, progress) => {
if (msg === "package_install_complete") return -1;
return -100;
if (msg === s.InstallFailed) return ErrorStatus;
if (msg === s.PackageInstallCompleted) return 100;
return progress;
},
},
{
label: "Updated",
events: ["cleanup_success", "manifest_succeeded"],
progress: (msg, progress) => 100,
events: [s.ManifestSucceeded],
progress: (_msg, _progress) => 100,
},
];