`;
-exports[`App Route /home authenticated 1`] = `
+exports[`App Route /carupdate-deploy authenticated 1`] = `
@@ -337,7 +337,7 @@ exports[`App Route /home authenticated 1`] = `
Fisker OTA Portal
@@ -353,13 +353,13 @@ exports[`App Route /home authenticated 1`] = `
+
+
+
+ [1]
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /carupdate-deploy unauthenticated 1`] = `
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /carupdate-status authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+ Sign Out
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ Home
+
+
+
+
+
+ -
+
+
+
+ View Updates
+
+
+
+
+
+ -
+
+
+
+ Create Updates
+
+
+
+
+
+ -
+
+
+
+ View Vehicles
+
+
+
+
+
+ -
+
+
+
+ Add Vehicles
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ID
+
+
+ Vehicle
+
+
+ Status
+
+
+ Created
+
+
+ Updated
+
+
+
+
+
+
+
+
+
+
+ Rows per page:
+
+
+
+
+
+
+ 0-0 of 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /carupdate-status unauthenticated 1`] = `
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /home authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+ Sign Out
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ Home
+
+
+
+
+
+ -
+
+
+
+ View Updates
+
+
+
+
+
+ -
+
+
+
+ Create Updates
+
+
+
+
+
+ -
+
+
+
+ View Vehicles
+
+
+
+
+
+ -
+
+
+
+ Add Vehicles
+
+
+
+
+
+
+
+
+
+
+
+
@@ -630,7 +1559,7 @@ exports[`App Route /package-upload authenticated 1`] = `
Fisker OTA Portal
@@ -646,13 +1575,13 @@ exports[`App Route /package-upload authenticated 1`] = `
@@ -1053,7 +1982,7 @@ exports[`App Route /package-upload unauthenticated 1`] = `
class="makeStyles-root-58"
>
@@ -1145,7 +2074,7 @@ exports[`App Route /page-not-found authenticated 1`] = `
Fisker OTA Portal
@@ -1161,13 +2090,13 @@ exports[`App Route /page-not-found authenticated 1`] = `
`;
-exports[`App Route /vehicle-add authenticated 1`] = `
+exports[`App Route /update authenticated 1`] = `
@@ -1427,7 +2356,7 @@ exports[`App Route /vehicle-add authenticated 1`] = `
Fisker OTA Portal
@@ -1443,13 +2372,13 @@ exports[`App Route /vehicle-add authenticated 1`] = `
+
+
+
+
+ Update Package
+ 1
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /update unauthenticated 1`] = `
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /updates authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+ Sign Out
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ Home
+
+
+
+
+
+ -
+
+
+
+ View Updates
+
+
+
+
+
+ -
+
+
+
+ Create Updates
+
+
+
+
+
+ -
+
+
+
+ View Vehicles
+
+
+
+
+
+ -
+
+
+
+ Add Vehicles
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Updates
+
+
+
+
+
+
+ ID
+
+
+ Name
+
+
+ Version
+
+
+ Created
+
+
+ Actions
+
+
+
+
+
+
+
+
+
+
+ Rows per page:
+
+
+
+
+
+
+ 0-0 of 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /updates unauthenticated 1`] = `
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /vehicle-add authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+ Sign Out
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ Home
+
+
+
+
+
+ -
+
+
+
+ View Updates
+
+
+
+
+
+ -
+
+
+
+ Create Updates
+
+
+
+
+
+ -
+
+
+
+ View Vehicles
+
+
+
+
+
+ -
+
+
+
+ Add Vehicles
+
+
+
+
+
+
+
+
+
+
@@ -1791,7 +3739,7 @@ exports[`App Route /vehicle-add unauthenticated 1`] = `
class="makeStyles-root-81"
>
`;
+
+exports[`App Route /vehicle-status authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+ Sign Out
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ Home
+
+
+
+
+
+ -
+
+
+
+ View Updates
+
+
+
+
+
+ -
+
+
+
+ Create Updates
+
+
+
+
+
+ -
+
+
+
+ View Vehicles
+
+
+
+
+
+ -
+
+
+
+ Add Vehicles
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ FISKER123
+ Updates
+
+
+
+
+
+
+ ID
+
+
+ Update
+
+
+ Status
+
+
+ Created
+
+
+ Updated
+
+
+
+
+
+
+
+
+
+
+ Rows per page:
+
+
+
+
+
+
+ 0-0 of 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /vehicle-status unauthenticated 1`] = `
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /vehicles authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+ Sign Out
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ Home
+
+
+
+
+
+ -
+
+
+
+ View Updates
+
+
+
+
+
+ -
+
+
+
+ Create Updates
+
+
+
+
+
+ -
+
+
+
+ View Vehicles
+
+
+
+
+
+ -
+
+
+
+ Add Vehicles
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Vehicles
+
+
+
+
+
+
+ VIN
+
+
+ Model
+
+
+ Year
+
+
+ Created
+
+
+ Updated
+
+
+
+
+
+
+
+
+
+
+ Rows per page:
+
+
+
+
+
+
+ 0-0 of 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /vehicles unauthenticated 1`] = `
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+
+
+
+
+
+
+
+
+
+`;
diff --git a/src/components/Cars/StatusModal/index.jsx b/src/components/Cars/StatusModal/index.jsx
index 5d34bd6..fc12d97 100644
--- a/src/components/Cars/StatusModal/index.jsx
+++ b/src/components/Cars/StatusModal/index.jsx
@@ -49,7 +49,7 @@ export default function CarStatusModal(props) {
aria-labelledby="transition-modal-title"
aria-describedby="transition-modal-description"
className={classes.modal}
- open={props.vin}
+ open={props.vin !== null && props.vin !== undefined}
onClose={props.handleClose}
BackdropComponent={Backdrop}
BackdropProps={{
diff --git a/src/components/Contexts/UpdateContext.test.jsx b/src/components/Contexts/UpdatesContext.test.jsx
similarity index 98%
rename from src/components/Contexts/UpdateContext.test.jsx
rename to src/components/Contexts/UpdatesContext.test.jsx
index c184b3f..8baa89d 100644
--- a/src/components/Contexts/UpdateContext.test.jsx
+++ b/src/components/Contexts/UpdatesContext.test.jsx
@@ -7,8 +7,8 @@ import {
fireEvent,
waitFor,
} from "@testing-library/react";
-import { UpdatesProvider, useUpdatesContext } from "../Contexts/UpdatesContext";
-import { StatusProvider, useStatusContext } from "../Contexts/StatusContext";
+import { UpdatesProvider, useUpdatesContext } from "./UpdatesContext";
+import { StatusProvider, useStatusContext } from "./StatusContext";
import { TEST_AUTH_OBJECT } from "../../utils/testing";
describe("UpdatesContext", () => {
diff --git a/src/components/Contexts/__mocks__/UpdatesContext.jsx b/src/components/Contexts/__mocks__/UpdatesContext.jsx
new file mode 100644
index 0000000..0521357
--- /dev/null
+++ b/src/components/Contexts/__mocks__/UpdatesContext.jsx
@@ -0,0 +1,26 @@
+import React from "react";
+
+const UpdatesContext = React.createContext();
+
+let busy = false;
+let packages = [];
+let totalPackages = 0;
+let carUpdates = [];
+let totalCarUpdates = 0;
+
+export const UpdatesProvider = ({ children }) => {
+ return {children};
+};
+
+export const useUpdatesContext = () => ({
+ busy,
+ packages,
+ totalPackages,
+ carUpdates,
+ totalCarUpdates,
+ getPackages: jest.fn(() => packages),
+ updatePackage: jest.fn((data) => data),
+ createCarUpdates: jest.fn((data) => data),
+ getCarUpdates: jest.fn(() => carUpdates),
+ getVINUpdates: jest.fn(() => carUpdates),
+});
diff --git a/src/components/Contexts/__mocks__/VehicleContext.jsx b/src/components/Contexts/__mocks__/VehicleContext.jsx
index 4813960..566826c 100644
--- a/src/components/Contexts/__mocks__/VehicleContext.jsx
+++ b/src/components/Contexts/__mocks__/VehicleContext.jsx
@@ -2,6 +2,7 @@ import React from "react";
let busy = false;
let vehicles = [];
+let totalVehicles = 0;
let error = null;
export const VehicleProvider = ({ children }) => {
@@ -11,6 +12,7 @@ export const VehicleProvider = ({ children }) => {
export const useVehicleContext = () => ({
busy,
vehicles,
+ totalVehicles,
getVehicles: jest.fn(() => vehicles),
addVehicle: jest.fn(),
});
diff --git a/src/components/ErrorBoundary.jsx b/src/components/ErrorBoundary.jsx
index b377051..ad4a168 100644
--- a/src/components/ErrorBoundary.jsx
+++ b/src/components/ErrorBoundary.jsx
@@ -2,25 +2,60 @@ import React, { Component } from "react";
import PropTypes from "prop-types";
import { Typography } from "@material-ui/core";
+const reload = () => {
+ window.location.reload();
+};
export default class ErrorBoundary extends Component {
state = {
error: "",
errorInfo: "",
hasError: false,
};
+
static getDerivedStateFromError(error) {
return { hasError: true, error };
}
+
componentDidCatch(error, errorInfo) {
this.setState({ errorInfo });
}
+
render() {
- if (this.state.hasError)
+ if (this.state.hasError) {
+ if (this.state.error && this.state.error.name === "ChunkLoadError") {
+ reload();
+ return;
+ }
+
return (
-
- Client-side Error Occured and Logged
-
+
+
+ Sorry, an error has occured and been logged
+
+
+ Click to reload
+
+
);
+ }
return this.props.children;
}
}
`;
-exports[`App Route /home authenticated 1`] = `
+exports[`App Route /carupdate-deploy authenticated 1`] = `
@@ -337,7 +337,7 @@ exports[`App Route /home authenticated 1`] = `
Fisker OTA Portal
@@ -353,13 +353,13 @@ exports[`App Route /home authenticated 1`] = `
+
+
+
+
+`;
+
+exports[`App Route /carupdate-deploy unauthenticated 1`] = `
+
+
+
+
+
+
+ + [1] +
+ +
+
+`;
+
+exports[`App Route /carupdate-status authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + Fisker OTA Portal +
+
+
+`;
+
+exports[`App Route /carupdate-status unauthenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Sign Out
+
+
+
+
+ + Fisker OTA Portal +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
-
+
-
+
+ + + Home + ++ + +
+
-
+
+ + + View Updates + ++ + +
+
-
+
+ + + Create Updates + ++ + +
+
-
+
+ + + View Vehicles + ++ + +
+
-
+
+ + + Add Vehicles + ++ + +
+
+
+
+
+
+
+
+
+
+
+
+ | + ID + | ++ Vehicle + | ++ Status + | ++ Created + | ++ Updated + | +
|---|---|---|---|---|
|
+
+
+
+ + Rows per page: + +
+
+
+
+ + 0-0 of 0 + +
+
+ |
+ ||||
+
+`;
+
+exports[`App Route /home authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + Fisker OTA Portal +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Sign Out
+
+
+
+
+ + Fisker OTA Portal +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
-
+
-
+
+ + + Home + ++ + +
+
-
+
+ + + View Updates + ++ + +
+
-
+
+ + + Create Updates + ++ + +
+
-
+
+ + + View Vehicles + ++ + +
+
-
+
+ + + Add Vehicles + ++ + +
+
@@ -630,7 +1559,7 @@ exports[`App Route /package-upload authenticated 1`] = `
Fisker OTA Portal
@@ -646,13 +1575,13 @@ exports[`App Route /package-upload authenticated 1`] = `
@@ -1053,7 +1982,7 @@ exports[`App Route /package-upload unauthenticated 1`] = `
class="makeStyles-root-58"
>
@@ -1145,7 +2074,7 @@ exports[`App Route /page-not-found authenticated 1`] = `
Fisker OTA Portal
@@ -1161,13 +2090,13 @@ exports[`App Route /page-not-found authenticated 1`] = `
`;
-exports[`App Route /vehicle-add authenticated 1`] = `
+exports[`App Route /update authenticated 1`] = `
@@ -1427,7 +2356,7 @@ exports[`App Route /vehicle-add authenticated 1`] = `
Fisker OTA Portal
@@ -1443,13 +2372,13 @@ exports[`App Route /vehicle-add authenticated 1`] = `
+
+
+
+
+ Update Package
+ 1
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /update unauthenticated 1`] = `
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /updates authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+ Sign Out
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ Home
+
+
+
+
+
+ -
+
+
+
+ View Updates
+
+
+
+
+
+ -
+
+
+
+ Create Updates
+
+
+
+
+
+ -
+
+
+
+ View Vehicles
+
+
+
+
+
+ -
+
+
+
+ Add Vehicles
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Updates
+
+
+
+
+
+
+ ID
+
+
+ Name
+
+
+ Version
+
+
+ Created
+
+
+ Actions
+
+
+
+
+
+
+
+
+
+
+ Rows per page:
+
+
+
+
+
+
+ 0-0 of 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /updates unauthenticated 1`] = `
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /vehicle-add authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+ Sign Out
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ Home
+
+
+
+
+
+ -
+
+
+
+ View Updates
+
+
+
+
+
+ -
+
+
+
+ Create Updates
+
+
+
+
+
+ -
+
+
+
+ View Vehicles
+
+
+
+
+
+ -
+
+
+
+ Add Vehicles
+
+
+
+
+
+
+
+
+
+
@@ -1791,7 +3739,7 @@ exports[`App Route /vehicle-add unauthenticated 1`] = `
class="makeStyles-root-81"
>
`;
+
+exports[`App Route /vehicle-status authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+ Sign Out
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ Home
+
+
+
+
+
+ -
+
+
+
+ View Updates
+
+
+
+
+
+ -
+
+
+
+ Create Updates
+
+
+
+
+
+ -
+
+
+
+ View Vehicles
+
+
+
+
+
+ -
+
+
+
+ Add Vehicles
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ FISKER123
+ Updates
+
+
+
+
+
+
+ ID
+
+
+ Update
+
+
+ Status
+
+
+ Created
+
+
+ Updated
+
+
+
+
+
+
+
+
+
+
+ Rows per page:
+
+
+
+
+
+
+ 0-0 of 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /vehicle-status unauthenticated 1`] = `
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /vehicles authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+ Sign Out
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ Home
+
+
+
+
+
+ -
+
+
+
+ View Updates
+
+
+
+
+
+ -
+
+
+
+ Create Updates
+
+
+
+
+
+ -
+
+
+
+ View Vehicles
+
+
+
+
+
+ -
+
+
+
+ Add Vehicles
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Vehicles
+
+
+
+
+
+
+ VIN
+
+
+ Model
+
+
+ Year
+
+
+ Created
+
+
+ Updated
+
+
+
+
+
+
+
+
+
+
+ Rows per page:
+
+
+
+
+
+
+ 0-0 of 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /vehicles unauthenticated 1`] = `
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+
+
+
+
+
+
+
+
+
+`;
diff --git a/src/components/Cars/StatusModal/index.jsx b/src/components/Cars/StatusModal/index.jsx
index 5d34bd6..fc12d97 100644
--- a/src/components/Cars/StatusModal/index.jsx
+++ b/src/components/Cars/StatusModal/index.jsx
@@ -49,7 +49,7 @@ export default function CarStatusModal(props) {
aria-labelledby="transition-modal-title"
aria-describedby="transition-modal-description"
className={classes.modal}
- open={props.vin}
+ open={props.vin !== null && props.vin !== undefined}
onClose={props.handleClose}
BackdropComponent={Backdrop}
BackdropProps={{
diff --git a/src/components/Contexts/UpdateContext.test.jsx b/src/components/Contexts/UpdatesContext.test.jsx
similarity index 98%
rename from src/components/Contexts/UpdateContext.test.jsx
rename to src/components/Contexts/UpdatesContext.test.jsx
index c184b3f..8baa89d 100644
--- a/src/components/Contexts/UpdateContext.test.jsx
+++ b/src/components/Contexts/UpdatesContext.test.jsx
@@ -7,8 +7,8 @@ import {
fireEvent,
waitFor,
} from "@testing-library/react";
-import { UpdatesProvider, useUpdatesContext } from "../Contexts/UpdatesContext";
-import { StatusProvider, useStatusContext } from "../Contexts/StatusContext";
+import { UpdatesProvider, useUpdatesContext } from "./UpdatesContext";
+import { StatusProvider, useStatusContext } from "./StatusContext";
import { TEST_AUTH_OBJECT } from "../../utils/testing";
describe("UpdatesContext", () => {
diff --git a/src/components/Contexts/__mocks__/UpdatesContext.jsx b/src/components/Contexts/__mocks__/UpdatesContext.jsx
new file mode 100644
index 0000000..0521357
--- /dev/null
+++ b/src/components/Contexts/__mocks__/UpdatesContext.jsx
@@ -0,0 +1,26 @@
+import React from "react";
+
+const UpdatesContext = React.createContext();
+
+let busy = false;
+let packages = [];
+let totalPackages = 0;
+let carUpdates = [];
+let totalCarUpdates = 0;
+
+export const UpdatesProvider = ({ children }) => {
+ return {children};
+};
+
+export const useUpdatesContext = () => ({
+ busy,
+ packages,
+ totalPackages,
+ carUpdates,
+ totalCarUpdates,
+ getPackages: jest.fn(() => packages),
+ updatePackage: jest.fn((data) => data),
+ createCarUpdates: jest.fn((data) => data),
+ getCarUpdates: jest.fn(() => carUpdates),
+ getVINUpdates: jest.fn(() => carUpdates),
+});
diff --git a/src/components/Contexts/__mocks__/VehicleContext.jsx b/src/components/Contexts/__mocks__/VehicleContext.jsx
index 4813960..566826c 100644
--- a/src/components/Contexts/__mocks__/VehicleContext.jsx
+++ b/src/components/Contexts/__mocks__/VehicleContext.jsx
@@ -2,6 +2,7 @@ import React from "react";
let busy = false;
let vehicles = [];
+let totalVehicles = 0;
let error = null;
export const VehicleProvider = ({ children }) => {
@@ -11,6 +12,7 @@ export const VehicleProvider = ({ children }) => {
export const useVehicleContext = () => ({
busy,
vehicles,
+ totalVehicles,
getVehicles: jest.fn(() => vehicles),
addVehicle: jest.fn(),
});
diff --git a/src/components/ErrorBoundary.jsx b/src/components/ErrorBoundary.jsx
index b377051..ad4a168 100644
--- a/src/components/ErrorBoundary.jsx
+++ b/src/components/ErrorBoundary.jsx
@@ -2,25 +2,60 @@ import React, { Component } from "react";
import PropTypes from "prop-types";
import { Typography } from "@material-ui/core";
+const reload = () => {
+ window.location.reload();
+};
export default class ErrorBoundary extends Component {
state = {
error: "",
errorInfo: "",
hasError: false,
};
+
static getDerivedStateFromError(error) {
return { hasError: true, error };
}
+
componentDidCatch(error, errorInfo) {
this.setState({ errorInfo });
}
+
render() {
- if (this.state.hasError)
+ if (this.state.hasError) {
+ if (this.state.error && this.state.error.name === "ChunkLoadError") {
+ reload();
+ return;
+ }
+
return (
-
- Client-side Error Occured and Logged
-
+
+
+ Sorry, an error has occured and been logged
+
+
+ Click to reload
+
+
);
+ }
return this.props.children;
}
}
`;
-exports[`App Route /vehicle-add authenticated 1`] = `
+exports[`App Route /update authenticated 1`] = `
@@ -1427,7 +2356,7 @@ exports[`App Route /vehicle-add authenticated 1`] = `
Fisker OTA Portal
@@ -1443,13 +2372,13 @@ exports[`App Route /vehicle-add authenticated 1`] = `
+
+
+
+
+ Update Package
+ 1
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /update unauthenticated 1`] = `
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /updates authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+ Sign Out
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ Home
+
+
+
+
+
+ -
+
+
+
+ View Updates
+
+
+
+
+
+ -
+
+
+
+ Create Updates
+
+
+
+
+
+ -
+
+
+
+ View Vehicles
+
+
+
+
+
+ -
+
+
+
+ Add Vehicles
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Updates
+
+
+
+
+
+
+ ID
+
+
+ Name
+
+
+ Version
+
+
+ Created
+
+
+ Actions
+
+
+
+
+
+
+
+
+
+
+ Rows per page:
+
+
+
+
+
+
+ 0-0 of 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /updates unauthenticated 1`] = `
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /vehicle-add authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+ Sign Out
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ Home
+
+
+
+
+
+ -
+
+
+
+ View Updates
+
+
+
+
+
+ -
+
+
+
+ Create Updates
+
+
+
+
+
+ -
+
+
+
+ View Vehicles
+
+
+
+
+
+ -
+
+
+
+ Add Vehicles
+
+
+
+
+
+
+
+
+
+
@@ -1791,7 +3739,7 @@ exports[`App Route /vehicle-add unauthenticated 1`] = `
class="makeStyles-root-81"
>
`;
+
+exports[`App Route /vehicle-status authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+ Sign Out
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ Home
+
+
+
+
+
+ -
+
+
+
+ View Updates
+
+
+
+
+
+ -
+
+
+
+ Create Updates
+
+
+
+
+
+ -
+
+
+
+ View Vehicles
+
+
+
+
+
+ -
+
+
+
+ Add Vehicles
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ FISKER123
+ Updates
+
+
+
+
+
+
+ ID
+
+
+ Update
+
+
+ Status
+
+
+ Created
+
+
+ Updated
+
+
+
+
+
+
+
+
+
+
+ Rows per page:
+
+
+
+
+
+
+ 0-0 of 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /vehicle-status unauthenticated 1`] = `
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /vehicles authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+ Sign Out
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ Home
+
+
+
+
+
+ -
+
+
+
+ View Updates
+
+
+
+
+
+ -
+
+
+
+ Create Updates
+
+
+
+
+
+ -
+
+
+
+ View Vehicles
+
+
+
+
+
+ -
+
+
+
+ Add Vehicles
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Vehicles
+
+
+
+
+
+
+ VIN
+
+
+ Model
+
+
+ Year
+
+
+ Created
+
+
+ Updated
+
+
+
+
+
+
+
+
+
+
+ Rows per page:
+
+
+
+
+
+
+ 0-0 of 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /vehicles unauthenticated 1`] = `
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+
+
+
+
+
+
+
+
+
+`;
diff --git a/src/components/Cars/StatusModal/index.jsx b/src/components/Cars/StatusModal/index.jsx
index 5d34bd6..fc12d97 100644
--- a/src/components/Cars/StatusModal/index.jsx
+++ b/src/components/Cars/StatusModal/index.jsx
@@ -49,7 +49,7 @@ export default function CarStatusModal(props) {
aria-labelledby="transition-modal-title"
aria-describedby="transition-modal-description"
className={classes.modal}
- open={props.vin}
+ open={props.vin !== null && props.vin !== undefined}
onClose={props.handleClose}
BackdropComponent={Backdrop}
BackdropProps={{
diff --git a/src/components/Contexts/UpdateContext.test.jsx b/src/components/Contexts/UpdatesContext.test.jsx
similarity index 98%
rename from src/components/Contexts/UpdateContext.test.jsx
rename to src/components/Contexts/UpdatesContext.test.jsx
index c184b3f..8baa89d 100644
--- a/src/components/Contexts/UpdateContext.test.jsx
+++ b/src/components/Contexts/UpdatesContext.test.jsx
@@ -7,8 +7,8 @@ import {
fireEvent,
waitFor,
} from "@testing-library/react";
-import { UpdatesProvider, useUpdatesContext } from "../Contexts/UpdatesContext";
-import { StatusProvider, useStatusContext } from "../Contexts/StatusContext";
+import { UpdatesProvider, useUpdatesContext } from "./UpdatesContext";
+import { StatusProvider, useStatusContext } from "./StatusContext";
import { TEST_AUTH_OBJECT } from "../../utils/testing";
describe("UpdatesContext", () => {
diff --git a/src/components/Contexts/__mocks__/UpdatesContext.jsx b/src/components/Contexts/__mocks__/UpdatesContext.jsx
new file mode 100644
index 0000000..0521357
--- /dev/null
+++ b/src/components/Contexts/__mocks__/UpdatesContext.jsx
@@ -0,0 +1,26 @@
+import React from "react";
+
+const UpdatesContext = React.createContext();
+
+let busy = false;
+let packages = [];
+let totalPackages = 0;
+let carUpdates = [];
+let totalCarUpdates = 0;
+
+export const UpdatesProvider = ({ children }) => {
+ return {children};
+};
+
+export const useUpdatesContext = () => ({
+ busy,
+ packages,
+ totalPackages,
+ carUpdates,
+ totalCarUpdates,
+ getPackages: jest.fn(() => packages),
+ updatePackage: jest.fn((data) => data),
+ createCarUpdates: jest.fn((data) => data),
+ getCarUpdates: jest.fn(() => carUpdates),
+ getVINUpdates: jest.fn(() => carUpdates),
+});
diff --git a/src/components/Contexts/__mocks__/VehicleContext.jsx b/src/components/Contexts/__mocks__/VehicleContext.jsx
index 4813960..566826c 100644
--- a/src/components/Contexts/__mocks__/VehicleContext.jsx
+++ b/src/components/Contexts/__mocks__/VehicleContext.jsx
@@ -2,6 +2,7 @@ import React from "react";
let busy = false;
let vehicles = [];
+let totalVehicles = 0;
let error = null;
export const VehicleProvider = ({ children }) => {
@@ -11,6 +12,7 @@ export const VehicleProvider = ({ children }) => {
export const useVehicleContext = () => ({
busy,
vehicles,
+ totalVehicles,
getVehicles: jest.fn(() => vehicles),
addVehicle: jest.fn(),
});
diff --git a/src/components/ErrorBoundary.jsx b/src/components/ErrorBoundary.jsx
index b377051..ad4a168 100644
--- a/src/components/ErrorBoundary.jsx
+++ b/src/components/ErrorBoundary.jsx
@@ -2,25 +2,60 @@ import React, { Component } from "react";
import PropTypes from "prop-types";
import { Typography } from "@material-ui/core";
+const reload = () => {
+ window.location.reload();
+};
export default class ErrorBoundary extends Component {
state = {
error: "",
errorInfo: "",
hasError: false,
};
+
static getDerivedStateFromError(error) {
return { hasError: true, error };
}
+
componentDidCatch(error, errorInfo) {
this.setState({ errorInfo });
}
+
render() {
- if (this.state.hasError)
+ if (this.state.hasError) {
+ if (this.state.error && this.state.error.name === "ChunkLoadError") {
+ reload();
+ return;
+ }
+
return (
-
- Client-side Error Occured and Logged
-
+
+
+ Sorry, an error has occured and been logged
+
+
+ Click to reload
+
+
);
+ }
return this.props.children;
}
}
`;
-exports[`App Route /vehicle-add authenticated 1`] = `
+exports[`App Route /update authenticated 1`] = `
@@ -1427,7 +2356,7 @@ exports[`App Route /vehicle-add authenticated 1`] = `
Fisker OTA Portal
@@ -1443,13 +2372,13 @@ exports[`App Route /vehicle-add authenticated 1`] = `
+
+
+
+
+ Update Package
+ 1
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /update unauthenticated 1`] = `
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /updates authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+ Sign Out
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ Home
+
+
+
+
+
+ -
+
+
+
+ View Updates
+
+
+
+
+
+ -
+
+
+
+ Create Updates
+
+
+
+
+
+ -
+
+
+
+ View Vehicles
+
+
+
+
+
+ -
+
+
+
+ Add Vehicles
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Updates
+
+
+
+
+
+
+ ID
+
+
+ Name
+
+
+ Version
+
+
+ Created
+
+
+ Actions
+
+
+
+
+
+
+
+
+
+
+ Rows per page:
+
+
+
+
+
+
+ 0-0 of 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /updates unauthenticated 1`] = `
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /vehicle-add authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+ Sign Out
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ Home
+
+
+
+
+
+ -
+
+
+
+ View Updates
+
+
+
+
+
+ -
+
+
+
+ Create Updates
+
+
+
+
+
+ -
+
+
+
+ View Vehicles
+
+
+
+
+
+ -
+
+
+
+ Add Vehicles
+
+
+
+
+
+
+
+
+
+
@@ -1791,7 +3739,7 @@ exports[`App Route /vehicle-add unauthenticated 1`] = `
class="makeStyles-root-81"
>
`;
+
+exports[`App Route /vehicle-status authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+ Sign Out
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ Home
+
+
+
+
+
+ -
+
+
+
+ View Updates
+
+
+
+
+
+ -
+
+
+
+ Create Updates
+
+
+
+
+
+ -
+
+
+
+ View Vehicles
+
+
+
+
+
+ -
+
+
+
+ Add Vehicles
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ FISKER123
+ Updates
+
+
+
+
+
+
+ ID
+
+
+ Update
+
+
+ Status
+
+
+ Created
+
+
+ Updated
+
+
+
+
+
+
+
+
+
+
+ Rows per page:
+
+
+
+
+
+
+ 0-0 of 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /vehicle-status unauthenticated 1`] = `
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /vehicles authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+ Sign Out
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ Home
+
+
+
+
+
+ -
+
+
+
+ View Updates
+
+
+
+
+
+ -
+
+
+
+ Create Updates
+
+
+
+
+
+ -
+
+
+
+ View Vehicles
+
+
+
+
+
+ -
+
+
+
+ Add Vehicles
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Vehicles
+
+
+
+
+
+
+ VIN
+
+
+ Model
+
+
+ Year
+
+
+ Created
+
+
+ Updated
+
+
+
+
+
+
+
+
+
+
+ Rows per page:
+
+
+
+
+
+
+ 0-0 of 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`App Route /vehicles unauthenticated 1`] = `
+
+
+
+
+
+
+ Fisker OTA Portal
+
+
+
+
+
+
+
+
+
+
+
+
+`;
diff --git a/src/components/Cars/StatusModal/index.jsx b/src/components/Cars/StatusModal/index.jsx
index 5d34bd6..fc12d97 100644
--- a/src/components/Cars/StatusModal/index.jsx
+++ b/src/components/Cars/StatusModal/index.jsx
@@ -49,7 +49,7 @@ export default function CarStatusModal(props) {
aria-labelledby="transition-modal-title"
aria-describedby="transition-modal-description"
className={classes.modal}
- open={props.vin}
+ open={props.vin !== null && props.vin !== undefined}
onClose={props.handleClose}
BackdropComponent={Backdrop}
BackdropProps={{
diff --git a/src/components/Contexts/UpdateContext.test.jsx b/src/components/Contexts/UpdatesContext.test.jsx
similarity index 98%
rename from src/components/Contexts/UpdateContext.test.jsx
rename to src/components/Contexts/UpdatesContext.test.jsx
index c184b3f..8baa89d 100644
--- a/src/components/Contexts/UpdateContext.test.jsx
+++ b/src/components/Contexts/UpdatesContext.test.jsx
@@ -7,8 +7,8 @@ import {
fireEvent,
waitFor,
} from "@testing-library/react";
-import { UpdatesProvider, useUpdatesContext } from "../Contexts/UpdatesContext";
-import { StatusProvider, useStatusContext } from "../Contexts/StatusContext";
+import { UpdatesProvider, useUpdatesContext } from "./UpdatesContext";
+import { StatusProvider, useStatusContext } from "./StatusContext";
import { TEST_AUTH_OBJECT } from "../../utils/testing";
describe("UpdatesContext", () => {
diff --git a/src/components/Contexts/__mocks__/UpdatesContext.jsx b/src/components/Contexts/__mocks__/UpdatesContext.jsx
new file mode 100644
index 0000000..0521357
--- /dev/null
+++ b/src/components/Contexts/__mocks__/UpdatesContext.jsx
@@ -0,0 +1,26 @@
+import React from "react";
+
+const UpdatesContext = React.createContext();
+
+let busy = false;
+let packages = [];
+let totalPackages = 0;
+let carUpdates = [];
+let totalCarUpdates = 0;
+
+export const UpdatesProvider = ({ children }) => {
+ return {children};
+};
+
+export const useUpdatesContext = () => ({
+ busy,
+ packages,
+ totalPackages,
+ carUpdates,
+ totalCarUpdates,
+ getPackages: jest.fn(() => packages),
+ updatePackage: jest.fn((data) => data),
+ createCarUpdates: jest.fn((data) => data),
+ getCarUpdates: jest.fn(() => carUpdates),
+ getVINUpdates: jest.fn(() => carUpdates),
+});
diff --git a/src/components/Contexts/__mocks__/VehicleContext.jsx b/src/components/Contexts/__mocks__/VehicleContext.jsx
index 4813960..566826c 100644
--- a/src/components/Contexts/__mocks__/VehicleContext.jsx
+++ b/src/components/Contexts/__mocks__/VehicleContext.jsx
@@ -2,6 +2,7 @@ import React from "react";
let busy = false;
let vehicles = [];
+let totalVehicles = 0;
let error = null;
export const VehicleProvider = ({ children }) => {
@@ -11,6 +12,7 @@ export const VehicleProvider = ({ children }) => {
export const useVehicleContext = () => ({
busy,
vehicles,
+ totalVehicles,
getVehicles: jest.fn(() => vehicles),
addVehicle: jest.fn(),
});
diff --git a/src/components/ErrorBoundary.jsx b/src/components/ErrorBoundary.jsx
index b377051..ad4a168 100644
--- a/src/components/ErrorBoundary.jsx
+++ b/src/components/ErrorBoundary.jsx
@@ -2,25 +2,60 @@ import React, { Component } from "react";
import PropTypes from "prop-types";
import { Typography } from "@material-ui/core";
+const reload = () => {
+ window.location.reload();
+};
export default class ErrorBoundary extends Component {
state = {
error: "",
errorInfo: "",
hasError: false,
};
+
static getDerivedStateFromError(error) {
return { hasError: true, error };
}
+
componentDidCatch(error, errorInfo) {
this.setState({ errorInfo });
}
+
render() {
- if (this.state.hasError)
+ if (this.state.hasError) {
+ if (this.state.error && this.state.error.name === "ChunkLoadError") {
+ reload();
+ return;
+ }
+
return (
-
- Client-side Error Occured and Logged
-
+
+
+ Sorry, an error has occured and been logged
+
+
+ Click to reload
+
+
);
+ }
return this.props.children;
}
}
+
+
+
+ + Update Package + 1 +
+ +
+
+`;
+
+exports[`App Route /updates authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + Fisker OTA Portal +
+
+
+`;
+
+exports[`App Route /updates unauthenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Sign Out
+
+
+
+
+ + Fisker OTA Portal +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
-
+
-
+
+ + + Home + ++ + +
+
-
+
+ + + View Updates + ++ + +
+
-
+
+ + + Create Updates + ++ + +
+
-
+
+ + + View Vehicles + ++ + +
+
-
+
+ + + Add Vehicles + ++ + +
+
+
+
+
+ + Updates +
+
+
+
+
+
+ | + ID + | ++ Name + | ++ Version + | ++ Created + | ++ Actions + | +
|---|---|---|---|---|
|
+
+
+
+ + Rows per page: + +
+
+
+
+ + 0-0 of 0 + +
+
+ |
+ ||||
+
+`;
+
+exports[`App Route /vehicle-add authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + Fisker OTA Portal +
+
+
+
@@ -1791,7 +3739,7 @@ exports[`App Route /vehicle-add unauthenticated 1`] = `
class="makeStyles-root-81"
>
`;
+
+exports[`App Route /vehicle-status authenticated 1`] = `
+
- Client-side Error Occured and Logged
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Sign Out
+
+
+
+
+ + Fisker OTA Portal +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
-
+
-
+
+ + + Home + ++ + +
+
-
+
+ + + View Updates + ++ + +
+
-
+
+ + + Create Updates + ++ + +
+
-
+
+ + + View Vehicles + ++ + +
+
-
+
+ + + Add Vehicles + ++ + +
+
+
+`;
+
+exports[`App Route /vehicle-status unauthenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Sign Out
+
+
+
+
+ + Fisker OTA Portal +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
-
+
-
+
+ + + Home + ++ + +
+
-
+
+ + + View Updates + ++ + +
+
-
+
+ + + Create Updates + ++ + +
+
-
+
+ + + View Vehicles + ++ + +
+
-
+
+ + + Add Vehicles + ++ + +
+
+
+
+
+ + FISKER123 + Updates +
+
+
+
+
+
+ | + ID + | ++ Update + | ++ Status + | ++ Created + | ++ Updated + | +
|---|---|---|---|---|
|
+
+
+
+ + Rows per page: + +
+
+
+
+ + 0-0 of 0 + +
+
+ |
+ ||||
+
+`;
+
+exports[`App Route /vehicles authenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + Fisker OTA Portal +
+
+
+`;
+
+exports[`App Route /vehicles unauthenticated 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Sign Out
+
+
+
+
+ + Fisker OTA Portal +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
-
+
-
+
+ + + Home + ++ + +
+
-
+
+ + + View Updates + ++ + +
+
-
+
+ + + Create Updates + ++ + +
+
-
+
+ + + View Vehicles + ++ + +
+
-
+
+ + + Add Vehicles + ++ + +
+
+
+
+
+ + Vehicles +
+
+
+
+
+
+ | + VIN + | ++ Model + | ++ Year + | ++ Created + | ++ Updated + | +|
|---|---|---|---|---|---|
|
+
+
+
+ + Rows per page: + +
+
+
+
+ + 0-0 of 0 + +
+
+ |
+ |||||
+
+`;
diff --git a/src/components/Cars/StatusModal/index.jsx b/src/components/Cars/StatusModal/index.jsx
index 5d34bd6..fc12d97 100644
--- a/src/components/Cars/StatusModal/index.jsx
+++ b/src/components/Cars/StatusModal/index.jsx
@@ -49,7 +49,7 @@ export default function CarStatusModal(props) {
aria-labelledby="transition-modal-title"
aria-describedby="transition-modal-description"
className={classes.modal}
- open={props.vin}
+ open={props.vin !== null && props.vin !== undefined}
onClose={props.handleClose}
BackdropComponent={Backdrop}
BackdropProps={{
diff --git a/src/components/Contexts/UpdateContext.test.jsx b/src/components/Contexts/UpdatesContext.test.jsx
similarity index 98%
rename from src/components/Contexts/UpdateContext.test.jsx
rename to src/components/Contexts/UpdatesContext.test.jsx
index c184b3f..8baa89d 100644
--- a/src/components/Contexts/UpdateContext.test.jsx
+++ b/src/components/Contexts/UpdatesContext.test.jsx
@@ -7,8 +7,8 @@ import {
fireEvent,
waitFor,
} from "@testing-library/react";
-import { UpdatesProvider, useUpdatesContext } from "../Contexts/UpdatesContext";
-import { StatusProvider, useStatusContext } from "../Contexts/StatusContext";
+import { UpdatesProvider, useUpdatesContext } from "./UpdatesContext";
+import { StatusProvider, useStatusContext } from "./StatusContext";
import { TEST_AUTH_OBJECT } from "../../utils/testing";
describe("UpdatesContext", () => {
diff --git a/src/components/Contexts/__mocks__/UpdatesContext.jsx b/src/components/Contexts/__mocks__/UpdatesContext.jsx
new file mode 100644
index 0000000..0521357
--- /dev/null
+++ b/src/components/Contexts/__mocks__/UpdatesContext.jsx
@@ -0,0 +1,26 @@
+import React from "react";
+
+const UpdatesContext = React.createContext();
+
+let busy = false;
+let packages = [];
+let totalPackages = 0;
+let carUpdates = [];
+let totalCarUpdates = 0;
+
+export const UpdatesProvider = ({ children }) => {
+ return
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + Fisker OTA Portal +
+{children}
;
+};
+
+export const useUpdatesContext = () => ({
+ busy,
+ packages,
+ totalPackages,
+ carUpdates,
+ totalCarUpdates,
+ getPackages: jest.fn(() => packages),
+ updatePackage: jest.fn((data) => data),
+ createCarUpdates: jest.fn((data) => data),
+ getCarUpdates: jest.fn(() => carUpdates),
+ getVINUpdates: jest.fn(() => carUpdates),
+});
diff --git a/src/components/Contexts/__mocks__/VehicleContext.jsx b/src/components/Contexts/__mocks__/VehicleContext.jsx
index 4813960..566826c 100644
--- a/src/components/Contexts/__mocks__/VehicleContext.jsx
+++ b/src/components/Contexts/__mocks__/VehicleContext.jsx
@@ -2,6 +2,7 @@ import React from "react";
let busy = false;
let vehicles = [];
+let totalVehicles = 0;
let error = null;
export const VehicleProvider = ({ children }) => {
@@ -11,6 +12,7 @@ export const VehicleProvider = ({ children }) => {
export const useVehicleContext = () => ({
busy,
vehicles,
+ totalVehicles,
getVehicles: jest.fn(() => vehicles),
addVehicle: jest.fn(),
});
diff --git a/src/components/ErrorBoundary.jsx b/src/components/ErrorBoundary.jsx
index b377051..ad4a168 100644
--- a/src/components/ErrorBoundary.jsx
+++ b/src/components/ErrorBoundary.jsx
@@ -2,25 +2,60 @@ import React, { Component } from "react";
import PropTypes from "prop-types";
import { Typography } from "@material-ui/core";
+const reload = () => {
+ window.location.reload();
+};
export default class ErrorBoundary extends Component {
state = {
error: "",
errorInfo: "",
hasError: false,
};
+
static getDerivedStateFromError(error) {
return { hasError: true, error };
}
+
componentDidCatch(error, errorInfo) {
this.setState({ errorInfo });
}
+
render() {
- if (this.state.hasError)
+ if (this.state.hasError) {
+ if (this.state.error && this.state.error.name === "ChunkLoadError") {
+ reload();
+ return;
+ }
+
return (
-
+
+ Sorry, an error has occured and been logged
+
+
+ Click to reload
+
+
);
+ }
return this.props.children;
}
}