diff --git a/package-lock.json b/package-lock.json index 55c27be..5c1f620 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,6 +33,7 @@ "react-router-dom": "^5.3.0", "react-router-hash-link": "^2.4.3", "react-scripts": "5.0.0", + "usehooks-ts": "^2.7.1", "web-vitals": "^2.1.4" }, "devDependencies": { @@ -16432,6 +16433,19 @@ "punycode": "^2.1.0" } }, + "node_modules/usehooks-ts": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/usehooks-ts/-/usehooks-ts-2.7.2.tgz", + "integrity": "sha512-DeLqSnGg9VvpwPZA+6lKVURJKM9EBu7bbIXuYclQ9COO3w4lacnJa0uP0iJbC/lAmY7GlmPinjZfGNNmDTlUpg==", + "engines": { + "node": ">=16.15.0", + "npm": ">=8" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -29270,6 +29284,12 @@ "punycode": "^2.1.0" } }, + "usehooks-ts": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/usehooks-ts/-/usehooks-ts-2.7.2.tgz", + "integrity": "sha512-DeLqSnGg9VvpwPZA+6lKVURJKM9EBu7bbIXuYclQ9COO3w4lacnJa0uP0iJbC/lAmY7GlmPinjZfGNNmDTlUpg==", + "requires": {} + }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", diff --git a/package.json b/package.json index 11daec5..5a7d5ed 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "react-router-dom": "^5.3.0", "react-router-hash-link": "^2.4.3", "react-scripts": "5.0.0", + "usehooks-ts": "^2.7.1", "web-vitals": "^2.1.4" }, "scripts": { @@ -67,9 +68,9 @@ "coverageThreshold": { "global": { "branches": 39, - "functions": 45.5, - "lines": 50, - "statements": 49 + "functions": 47, + "lines": 55, + "statements": 55 } }, "coverageReporters": [ diff --git a/src/components/App/__snapshots__/App.test.js.snap b/src/components/App/__snapshots__/App.test.js.snap index ad4b43a..527bc6c 100644 --- a/src/components/App/__snapshots__/App.test.js.snap +++ b/src/components/App/__snapshots__/App.test.js.snap @@ -3311,7 +3311,7 @@ exports[`App Route /packages authenticated 1`] = ` /> -
+ -
-
+
@@ -3460,6 +3459,7 @@ exports[`App Route /packages authenticated 1`] = ` +
@@ -6015,7 +6015,7 @@ exports[`App Route /vehicle-add authenticated 1`] = ` class="PrivateSwitchBase-input-0" name="log-level-group" type="radio" - value="warn" + value="warning" />
- Warn + Warning
+ diff --git a/src/components/CANFilter/Table/index.jsx b/src/components/CANFilter/Table/index.jsx index 61b2a7a..55d985d 100644 --- a/src/components/CANFilter/Table/index.jsx +++ b/src/components/CANFilter/Table/index.jsx @@ -53,6 +53,7 @@ const PAGE_SIZE = "CAN_FILTER_TABLE_PAGE_SIZE"; const MainForm = ({ vin }) => { const classes = useStyles(); + const [search, onSearch] = useState(""); const [pageSize, setPageSize] = useLocalStorage(PAGE_SIZE, 10); const [pageIndex, setPageIndex] = useState(0); const [orderBy, setOrderBy] = useState("id"); @@ -68,6 +69,7 @@ const MainForm = ({ vin }) => { await getFilters( vin, { + search, limit: pageSize, offset: pageSize * pageIndex, order: `${orderBy} ${order}`, @@ -80,7 +82,7 @@ const MainForm = ({ vin }) => { } })(); // eslint-disable-next-line react-hooks/exhaustive-deps - }, [vin, token, pageIndex, pageSize, orderBy, order]); + }, [vin, token, pageIndex, pageSize, orderBy, order, search]); const handleChangePageIndex = (event, newIndex) => { setPageIndex(newIndex); @@ -166,7 +168,7 @@ const MainForm = ({ vin }) => { - + diff --git a/src/components/Cars/Add/__snapshots__/index.test.jsx.snap b/src/components/Cars/Add/__snapshots__/index.test.jsx.snap index 95c6340..2d706b6 100644 --- a/src/components/Cars/Add/__snapshots__/index.test.jsx.snap +++ b/src/components/Cars/Add/__snapshots__/index.test.jsx.snap @@ -388,7 +388,7 @@ exports[`VehicleAddForm Render 1`] = ` class="PrivateSwitchBase-input-0" name="log-level-group" type="radio" - value="warn" + value="warning" />
- Warn + Warning
+ + + {fleets.map((row) => ( + + + {row} + + + ))} + + + + + + +
+ + ) +} + +const FleetsTab = (props) => { + return ( + + + + ) +} + + +export default FleetsTab; \ No newline at end of file diff --git a/src/components/Cars/Status/FleetsTab.test.jsx b/src/components/Cars/Status/FleetsTab.test.jsx new file mode 100644 index 0000000..58fad88 --- /dev/null +++ b/src/components/Cars/Status/FleetsTab.test.jsx @@ -0,0 +1,47 @@ +jest.mock("../../Contexts/VehicleContext"); +jest.mock("../../Contexts/StatusContext"); +jest.mock("../../Contexts/UserContext"); +jest.mock("@material-ui/core/utils/unstable_useId", () => + jest.fn().mockReturnValue("mui-test-id") +); + +import React from "react"; +import {render, waitFor} from "@testing-library/react"; +import { BrowserRouter } from "react-router-dom"; + +import {StatusProvider} from "../../Contexts/StatusContext"; +import {VehicleProvider} from "../../Contexts/VehicleContext"; +import {setToken, UserProvider} from "../../Contexts/UserContext"; +import {TEST_AUTH_OBJECT} from "../../../utils/testing"; +import addSnapshotSerializer from "../../../utils/snapshot"; +import FleetsTab from "./FleetsTab"; + +const renderFleetsTab = async () => { + const {container} = render( + + + + + + + + + + ); + await waitFor(() => { + /* render */ + }); + return container; +}; + +describe("FleetsTab", () => { + beforeAll(() => { + addSnapshotSerializer(expect); + }); + + it("Render", async () => { + setToken(TEST_AUTH_OBJECT); + const container = await renderFleetsTab(); + expect(container).toMatchSnapshot(); + }); +}); diff --git a/src/components/Cars/Status/__snapshots__/CANSignalsTab.test.jsx.snap b/src/components/Cars/Status/__snapshots__/CANSignalsTab.test.jsx.snap new file mode 100644 index 0000000..a45ea88 --- /dev/null +++ b/src/components/Cars/Status/__snapshots__/CANSignalsTab.test.jsx.snap @@ -0,0 +1,23 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`CANSignalsTab Render 1`] = ` +
+
+
+
+ CAN Signals +
+

+ Loading... +

+
+
+
+`; diff --git a/src/components/Cars/Status/__snapshots__/DigitalTwinTab.test.jsx.snap b/src/components/Cars/Status/__snapshots__/DigitalTwinTab.test.jsx.snap index a376e8e..607b45f 100644 --- a/src/components/Cars/Status/__snapshots__/DigitalTwinTab.test.jsx.snap +++ b/src/components/Cars/Status/__snapshots__/DigitalTwinTab.test.jsx.snap @@ -27,6 +27,13 @@ exports[`DigitalTwinTab Render 1`] = ` : false +
+ + ICC Connected + + : + true +

diff --git a/src/components/Cars/Status/__snapshots__/FleetsTab.test.jsx.snap b/src/components/Cars/Status/__snapshots__/FleetsTab.test.jsx.snap new file mode 100644 index 0000000..4353af6 --- /dev/null +++ b/src/components/Cars/Status/__snapshots__/FleetsTab.test.jsx.snap @@ -0,0 +1,280 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`FleetsTab Render 1`] = ` +

+
+
+
+
+
+
+ Fleets +
+
+
+
+ +
+ +
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + +
+ + CAN ID + + +
+ + fleet1 + +
+ + fleet2 + +
+
+
+
+
+
+
+`; diff --git a/src/components/Cars/Status/__snapshots__/index.test.jsx.snap b/src/components/Cars/Status/__snapshots__/index.test.jsx.snap index 02f5063..87bafee 100644 --- a/src/components/Cars/Status/__snapshots__/index.test.jsx.snap +++ b/src/components/Cars/Status/__snapshots__/index.test.jsx.snap @@ -137,6 +137,24 @@ exports[`CarStatus Render 1`] = ` class="MuiTouchRipple-root" /> +
+ diff --git a/src/components/Cars/Status/index.jsx b/src/components/Cars/Status/index.jsx index 0943eb7..4d45e26 100644 --- a/src/components/Cars/Status/index.jsx +++ b/src/components/Cars/Status/index.jsx @@ -13,6 +13,7 @@ import { useStatusContext } from "../../Contexts/StatusContext"; import useStyles from "../../useStyles"; import CANSignalsTab from "./CANSignalsTab"; import RemoteCommandsTab from "./RemoteCommandsTab"; +import FleetsTab from "./FleetsTab"; const tabHashes = ["details", "updates", "filters"]; @@ -66,6 +67,7 @@ const CarStatus = () => { + @@ -92,6 +94,10 @@ const CarStatus = () => { + + + + ); }; diff --git a/src/components/Cars/Update/__snapshots__/index.test.jsx.snap b/src/components/Cars/Update/__snapshots__/index.test.jsx.snap index 0a175dd..403c08a 100644 --- a/src/components/Cars/Update/__snapshots__/index.test.jsx.snap +++ b/src/components/Cars/Update/__snapshots__/index.test.jsx.snap @@ -390,7 +390,7 @@ exports[`VehicleUpdate Render 1`] = ` class="PrivateSwitchBase-input-0" name="log-level-group" type="radio" - value="warn" + value="warning" />
- Warn + Warning