From 86eeaab869003c7486fd95b29e21cc8e975376e2 Mon Sep 17 00:00:00 2001 From: John Wu <76966357+jwu-fisker@users.noreply.github.com> Date: Thu, 14 Oct 2021 12:23:16 -0700 Subject: [PATCH] Development (#94) * CEC-371 Car ECU display (#79) * Merge Development (#53) * Use responsive iframe control for charts (#49) * Use responsive iframe control to charts * Move external Grafana link to Dashboard page * Remove unused embedded style class * Add button label * added delete button to deploy packages * Fix unit test warning Remove unused route from test * Fix styling of button * minor fixes per pr review Co-authored-by: jcw-fisker Co-authored-by: John Cotten Watson <83605808+jcw-fisker@users.noreply.github.com> * Development Merge (#57) * CEC-287 Car connection status (#59) (#60) * Car connection status * Formatting * Merge Development (#64) * Add connection status to vehicles page * ConnectedIcon control * Handle Style * Development (#67) * preliminary map for vehicles * weird zoom bug * passing react tests * fixing warnings and updating snapshots * update node environment to 14 * addressing comments by changing variable types and adding styles to home page title * adding CODEOWNERS file * fixing token error * CEC-371 Update car ECUs display (#78) * Clean up className styles Update car status page to show update and ECUs * Add update ecu version button Show all ECUs on car status page Only show car ecus for search Co-authored-by: jcw-fisker Co-authored-by: John Cotten Watson <83605808+jcw-fisker@users.noreply.github.com> Co-authored-by: Drew Taylor <69828061+drew-fisker@users.noreply.github.com> * CEC-394 Car update log (#81) * CEC-394 Car update status control * Remove Datadog RUM Remove package update components Move control components into Controls folder Add Car update status page * Display update status log Clean up unused update package code * Remove console.logs * no vars * adding timestamp to vehicle popup * modifying vehicle data query * removing extraneous code * removing console log * Clean up SonarCloud warnings (#83) * Clean up SonarCloud warnings * Bogus security warning * Fix another warning * Fix unauthorized locations request * Fix update progress control * CEC-563 New manifest format (#88) * Add ManifestCreateContext Update create manifest page * Finish UI changes and API integration * Fixes * Fix test * Remove manifest ECU file version and type * Fixes * Add manifest ecu file type control * Fix Sonar warnings * Fix test * Update codeowners * Formatting * CEC-553 Change file type to string (#90) * CEC-553 File type uses string enum * Fix test timeout * Fix * Merge development * Increase timeout * Clean up (#95) * Clean up Mock missing methods * Smell Co-authored-by: jcw-fisker Co-authored-by: John Cotten Watson <83605808+jcw-fisker@users.noreply.github.com> Co-authored-by: Drew Taylor <69828061+drew-fisker@users.noreply.github.com> Co-authored-by: Drew Taylor --- .github/CODEOWNERS | 10 +- src/components/App/App.test.js | 42 +- .../App/__snapshots__/App.test.js.snap | 1591 +++++++++++++---- .../Contexts/ManifestCreateContext.jsx | 250 +++ src/components/Contexts/ManifestsContext.jsx | 156 -- src/components/Contexts/UserContext.jsx | 10 +- src/components/Contexts/VehicleContext.jsx | 6 +- .../Contexts/VehicleContext.test.jsx | 2 +- .../__mocks__/ManifestCreateContext.jsx | 53 + .../Contexts/__mocks__/UserContext.jsx | 9 +- .../Contexts/__mocks__/VehicleContext.jsx | 13 +- .../Controls/FileDragArea/index.jsx | 87 + src/components/Controls/ListHead/index.jsx | 14 + .../Controls/ManifestECUFileList/index.jsx | 79 + .../Controls/ManifestECUFileTypes/index.jsx | 36 + .../Controls/ManifestECUList/index.jsx | 87 + .../Controls/ManifestECURow/index.jsx | 33 + .../Controls/ManifestUploadProgress/index.jsx | 68 + .../Controls/PageDragPreventDefault/index.jsx | 24 + src/components/Controls/SubList/index.jsx | 45 - src/components/Controls/SubListItem/index.jsx | 6 +- src/components/Manifest/Create/index.jsx | 127 +- .../Manifest/ECUFilesList/index.jsx | 39 - src/components/Table/HeaderSortable/index.jsx | 14 +- src/components/VehicleMap/index.jsx | 6 +- src/components/useStyles.jsx | 9 + src/services/__mocks__/monitoring.js | 7 +- .../__mocks__/{vehicles.js => vehiclesAPI.js} | 0 src/services/manifestsAPI.js | 55 +- src/services/vehicles.js | 74 - src/services/vehiclesAPI.js | 106 ++ src/utils/manifestValidation.js | 101 ++ 32 files changed, 2293 insertions(+), 866 deletions(-) create mode 100644 src/components/Contexts/ManifestCreateContext.jsx create mode 100644 src/components/Contexts/__mocks__/ManifestCreateContext.jsx create mode 100644 src/components/Controls/FileDragArea/index.jsx create mode 100644 src/components/Controls/ListHead/index.jsx create mode 100644 src/components/Controls/ManifestECUFileList/index.jsx create mode 100644 src/components/Controls/ManifestECUFileTypes/index.jsx create mode 100644 src/components/Controls/ManifestECUList/index.jsx create mode 100644 src/components/Controls/ManifestECURow/index.jsx create mode 100644 src/components/Controls/ManifestUploadProgress/index.jsx create mode 100644 src/components/Controls/PageDragPreventDefault/index.jsx delete mode 100644 src/components/Controls/SubList/index.jsx delete mode 100644 src/components/Manifest/ECUFilesList/index.jsx rename src/services/__mocks__/{vehicles.js => vehiclesAPI.js} (100%) delete mode 100644 src/services/vehicles.js create mode 100644 src/services/vehiclesAPI.js create mode 100644 src/utils/manifestValidation.js diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index a5b3a0f..d7ac0fa 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,8 +1,8 @@ # default codeowners -* jwu@fiskerinc.com dtaylor@fiskerinc.com ggetsin@fiskerinc.com +* jwu@fiskerinc.com dtaylor@fiskerinc.com ggetsin@fiskerinc.com bbaker@fiskerinc.com # devops -.github rgreenberg@fiskerinc.com jwu@fiskerinc.com dtaylor@fiskerinc.com ggetsin@fiskerinc.com -Jenkinsfile rgreenberg@fiskerinc.com jwu@fiskerinc.com dtaylor@fiskerinc.com ggetsin@fiskerinc.com -k8s rgreenberg@fiskerinc.com jwu@fiskerinc.com dtaylor@fiskerinc.com ggetsin@fiskerinc.com -Dockerfile rgreenberg@fiskerinc.com jwu@fiskerinc.com dtaylor@fiskerinc.com ggetsin@fiskerinc.com +.github rgreenberg@fiskerinc.com jwu@fiskerinc.com dtaylor@fiskerinc.com ggetsin@fiskerinc.com bbaker@fiskerinc.com +Jenkinsfile rgreenberg@fiskerinc.com jwu@fiskerinc.com dtaylor@fiskerinc.com ggetsin@fiskerinc.com bbaker@fiskerinc.com +k8s rgreenberg@fiskerinc.com jwu@fiskerinc.com dtaylor@fiskerinc.com ggetsin@fiskerinc.com bbaker@fiskerinc.com +Dockerfile rgreenberg@fiskerinc.com jwu@fiskerinc.com dtaylor@fiskerinc.com ggetsin@fiskerinc.com bbaker@fiskerinc.com diff --git a/src/components/App/App.test.js b/src/components/App/App.test.js index cfa8333..2e024cf 100644 --- a/src/components/App/App.test.js +++ b/src/components/App/App.test.js @@ -1,14 +1,22 @@ +jest.mock("../Contexts/CarUpdatesContext"); jest.mock("../Contexts/FileUploadContext"); jest.mock("../Contexts/VehicleContext"); -jest.mock("../Contexts/UserContext"); +jest.mock("../Contexts/ManifestCreateContext"); jest.mock("../Contexts/ManifestsContext"); -jest.mock("../Contexts/CarUpdatesContext"); -jest.mock("../../services/monitoring"); +jest.mock("../Contexts/UserContext"); jest.mock("../../services/grafanaAPI"); +jest.mock("../../services/monitoring"); +jest.mock("../../services/vehiclesAPI"); -import { render, screen, cleanup, waitFor, waitForElementToBeRemoved } from "@testing-library/react"; +import { + render, + screen, + cleanup, + waitFor, + waitForElementToBeRemoved, +} from "@testing-library/react"; import { setToken } from "../Contexts/UserContext"; -import { TEST_AUTH_OBJECT } from "../../utils/testing" +import { TEST_AUTH_OBJECT } from "../../utils/testing"; import App from "."; const LOADING_STATUS = "Loading..."; @@ -30,26 +38,26 @@ const check = async (path, selector, compare) => { const sleepAndCheck = async (path, selector, compare) => { const container = await renderRoute(path); - await waitFor(() => { }); + await waitFor(() => {}); expect(container.querySelector(selector).innerHTML).toEqual(compare); expect(container).toMatchSnapshot(); }; describe("App", () => { beforeAll(() => { - // Stablize Table Pagination control ids + // Stablize Table Pagination control ids expect.addSnapshotSerializer({ test: function (val) { return val && typeof val === "string" && val.indexOf("mui-") >= 0; }, print: function (val) { let str = val; - str = str.replace(/mui-[0-9]*/g, "mui-00000"); + str = str.replace(/mui-\d*/g, "mui-00000"); return `"${str}"`; - } + }, }); - }); + }, 30000); afterEach(() => { setToken(null); @@ -101,9 +109,13 @@ describe("App", () => { }); it("Route /vehicle-status/vin/carupdateid unauthenticated", async () => { - await check("/vehicle-status/1G1FP87S3GN100062/283", "span.MuiButton-label", "Sign In"); + await check( + "/vehicle-status/1G1FP87S3GN100062/283", + "span.MuiButton-label", + "Sign In" + ); }); - + it("Route /page-not-found unauthenticated", async () => { await check("/page-not-found", "h1", "Page Not Found"); }); @@ -169,6 +181,10 @@ describe("App", () => { it("Route /vehicle-status/vin/carupdateid authenticated", async () => { setToken(TEST_AUTH_OBJECT); - await sleepAndCheck("/vehicle-status/1G1FP87S3GN100062/283", "h6", "Vehicle 1G1FP87S3GN100062, Update TEST UPDATE"); + await sleepAndCheck( + "/vehicle-status/1G1FP87S3GN100062/283", + "h6", + "Vehicle 1G1FP87S3GN100062, Update TEST UPDATE" + ); }); }); diff --git a/src/components/App/__snapshots__/App.test.js.snap b/src/components/App/__snapshots__/App.test.js.snap index c76947c..7f14267 100644 --- a/src/components/App/__snapshots__/App.test.js.snap +++ b/src/components/App/__snapshots__/App.test.js.snap @@ -6,10 +6,10 @@ exports[`App Route / authenticated 1`] = ` data-testid="mocked-userprovider" >
Fisker Admin Portal
@@ -239,7 +239,7 @@ exports[`App Route / authenticated 1`] = `
  • 500

    Cars

    @@ -750,16 +750,16 @@ exports[`App Route /datascope authenticated 1`] = ` class="MuiGrid-root MuiGrid-item MuiGrid-grid-md-6" >

    1,234,567,890

    Signals Collected

    @@ -769,10 +769,10 @@ exports[`App Route /datascope authenticated 1`] = ` class="MuiGrid-root MuiGrid-item MuiGrid-grid-md-12" >