* Fix template function (#105) * CEC-638 Add EK test ECU (#106) * CEC-638 Add EK ECU * Update test * CEC-638 Should be EKS (#107) * Should be EKS * Update snapshot * CEC-624 Display update status info and ECU (#108) * Diplay ECU name in update status (#110) Optimize car update status progress control Remove car update status page test Replace with individual component tests * Handle case ECU is not in message (#111) * Refresh button label (#112) * Update ECU refresh button label * Update snapshot * remove * CEC-660 Fix release notes field (#113) * CEC-775 Manifest details component (#114) * CEC-775 Manifest details component * Code smells * Fix build warning * CEC-1050 New manifest format (#117) * CEC-1050 Manifest changes * Fix delete bug * Add approve update button * Code smell * Remove update approval * CEC-464 can filters forms (#118) * can filters forms and lists * unit tests * updating warnings and tests * merge develop * fixed snapshots * update jest mocks * updating tests * CEC-1050 Self download indicator (#119) * CEC-1160 Fix package warnings (#121) * CEC-1160 Last dependabot fix (#122) * CEC-1058 fleet forms (#123) * working fleets page * unit tests * snapshots * updating messages and snapshots * updating extraneous snaps * Update codeowners (#125) * CEC-1167 ota admin portal (#127) * Add test coverage script * Remove unnecessary check * CEC-1167 unit test and code coverage * included sonar job * updated the workflow * updated sonar properties * updated sonar properties * updated sonar properties * updated sonar properties * updated sonar properties * updated sonar properties * updated sonar properties * updated sonar properties Co-authored-by: jwu-fisker <jwu@fiskerinc.com> * CEC-1167 implementing ths coverage thresold (#128) * CEC-1216 Remove unused components (#129) * CEC-1216 Remove unused components * Remove import * CEC-1183/CEC-1201 fleet vehicles forms (#130) * working fleet vehicles forms * snapshots and api tests * CEC-1182 fleet filter forms (#131) * forms for fleet can filters * unit tests for fleet filters * removing warnings * updating regex * CEC-532 Display manifest file properties (#133) * CEC-532 Display update file properties * npm audit fix * CEC-1317 npm update (#134) * CEC-1320 Update for memory regions (#135) * CEC-1320 Update for memory regions * Clean up * CEC-1256/CEC-1330 data logger for vehicles/fleets and details tabs for vehicles/fleets (#136) * forms for fleet can filters * unit tests for fleet filters * removing warnings * updating regex * added fleet details page * fleet pages * smoothed out bugs * fleets done * working update, delete vehicles * finished mocks, still need snapshots and context tests * contexts done * snapshot tests * updating code smells * smells * CEC-1256/CEC-1330 fixing filters length function (#137) * fixing filters length function * adding filters testing * code smell * code smells * bug * CEC-1387 superset integration and removal of grafana (#138) * replace grafana with superset * updating snapshots * CEC-1316 azure migration (#140) * test portal azure * :doh: * runner * WIP * values * letsencrypt + docker cache * stg/prd * portal things * cleanup * split build/deploy + temp stage deploy * :doh: * try this * and prod * this works for now, can improve later * no need to specify azure anymore Co-authored-by: Drew Taylor <69828061+drew-fisker@users.noreply.github.com> * CEC-1369 Fix display of update error (#139) * CEC-1369 Fix display of update error * Update snapshot * CEC-749 Generate cert UI (#141) * Add Create Certificate page * Tests * Update permission check * Use Azure * CEC-1387 updating superset dns names (#142) * updating superset dns names * updating snapshots * Fix (#143) * CEC-749 Fix types (#144) * Merge branch 'develop' Co-authored-by: Drew Taylor <69828061+drew-fisker@users.noreply.github.com> Co-authored-by: venkats09 <97122017+venkats09@users.noreply.github.com> Co-authored-by: Rafi Greenberg <72412693+rafi-fisker@users.noreply.github.com>
185 lines
5.4 KiB
JavaScript
185 lines
5.4 KiB
JavaScript
jest.mock("../Contexts/CarUpdatesContext");
|
|
jest.mock("../Contexts/FileUploadContext");
|
|
jest.mock("../Contexts/VehicleContext");
|
|
jest.mock("../Contexts/ManifestCreateContext");
|
|
jest.mock("../Contexts/ManifestsContext");
|
|
jest.mock("../Contexts/UserContext");
|
|
jest.mock("../../services/monitoring");
|
|
jest.mock("../../services/vehiclesAPI");
|
|
|
|
import {
|
|
render,
|
|
screen,
|
|
cleanup,
|
|
waitFor,
|
|
waitForElementToBeRemoved,
|
|
} from "@testing-library/react";
|
|
import { setToken } from "../Contexts/UserContext";
|
|
import { TEST_AUTH_OBJECT } from "../../utils/testing";
|
|
import App from ".";
|
|
|
|
const LOADING_STATUS = "Loading...";
|
|
|
|
const renderRoute = async (route) => {
|
|
window.history.pushState({}, "", route);
|
|
const { container } = render(<App />);
|
|
if (screen.queryByText(LOADING_STATUS)) {
|
|
await waitForElementToBeRemoved(() => screen.getByText(LOADING_STATUS));
|
|
}
|
|
return container;
|
|
};
|
|
|
|
const check = async (path, selector, compare) => {
|
|
const container = await renderRoute(path);
|
|
expect(container.querySelector(selector).innerHTML).toEqual(compare);
|
|
expect(container).toMatchSnapshot();
|
|
};
|
|
|
|
const sleepAndCheck = async (path, selector, compare) => {
|
|
const container = await renderRoute(path);
|
|
await waitFor(() => {});
|
|
expect(container.querySelector(selector).innerHTML).toEqual(compare);
|
|
expect(container).toMatchSnapshot();
|
|
};
|
|
|
|
describe("App", () => {
|
|
const rxMakeStyles = /makeStyles-(\w+)-(\d+)/gi;
|
|
|
|
beforeAll(() => {
|
|
// Stablize Table Pagination control ids
|
|
expect.addSnapshotSerializer({
|
|
test: function (val) {
|
|
return val && typeof val === "string" && val.indexOf("mui-") > -1;
|
|
},
|
|
print: function (val) {
|
|
let str = val;
|
|
str = str.replace(/mui-\d*/g, "mui-00000");
|
|
|
|
return `"${str}"`;
|
|
},
|
|
});
|
|
expect.addSnapshotSerializer({
|
|
test: (val) => {
|
|
return val && typeof val === "string" && val.search(rxMakeStyles) > -1;
|
|
},
|
|
print: function (val) {
|
|
let str = val;
|
|
str = str.replace(rxMakeStyles, "makeStyles-$1-0000");
|
|
|
|
return `"${str}"`;
|
|
},
|
|
});
|
|
}, 60000);
|
|
|
|
afterEach(() => {
|
|
setToken(null);
|
|
cleanup();
|
|
});
|
|
|
|
it("Route / unauthenticated", async () => {
|
|
await sleepAndCheck("/", "span.MuiButton-label", "Sign In");
|
|
});
|
|
|
|
it("Route /home unauthenticated", async () => {
|
|
await sleepAndCheck("/home", "span.MuiButton-label", "Sign In");
|
|
});
|
|
|
|
it("Route /packages unauthenticated", async () => {
|
|
await check("/packages", "span.MuiButton-label", "Sign In");
|
|
});
|
|
|
|
it("Route /package-status unauthenticated", async () => {
|
|
await check("/package-status/1", "span.MuiButton-label", "Sign In");
|
|
});
|
|
|
|
it("Route /package-deploy unauthenticated", async () => {
|
|
await check("/package-deploy/1", "span.MuiButton-label", "Sign In");
|
|
});
|
|
|
|
it("Route /package-create unauthenticated", async () => {
|
|
await check("/package-create", "span.MuiButton-label", "Sign In");
|
|
});
|
|
|
|
it("Route /vehicle-add unauthenticated", async () => {
|
|
await check("/vehicle-add", "span.MuiButton-label", "Sign In");
|
|
});
|
|
|
|
it("Route /vehicles unauthenticated", async () => {
|
|
await check("/vehicles", "span.MuiButton-label", "Sign In");
|
|
});
|
|
|
|
it("Route /vehicle-status unauthenticated", async () => {
|
|
await check("/vehicle-status/FISKER123", "span.MuiButton-label", "Sign In");
|
|
});
|
|
|
|
it("Route /vehicle-status/vin/carupdateid unauthenticated", async () => {
|
|
await check(
|
|
"/vehicle-status/1G1FP87S3GN100062/283",
|
|
"span.MuiButton-label",
|
|
"Sign In"
|
|
);
|
|
});
|
|
|
|
it("Route /tools/certificates/add unauthenticated", async () => {
|
|
await check("/tools/certificates/add", "span.MuiButton-label", "Sign In");
|
|
});
|
|
|
|
it("Route /page-not-found unauthenticated", async () => {
|
|
await check("/page-not-found", "h1", "Page Not Found");
|
|
});
|
|
it("Route / authenticated", async () => {
|
|
setToken(TEST_AUTH_OBJECT);
|
|
await sleepAndCheck("/", "h6", "Home");
|
|
});
|
|
|
|
it("Route /home authenticated", async () => {
|
|
setToken(TEST_AUTH_OBJECT);
|
|
await sleepAndCheck("/home", "h6", "Home");
|
|
});
|
|
|
|
it("Route /page-not-found authenticated", async () => {
|
|
setToken(TEST_AUTH_OBJECT);
|
|
await check("/page-not-found", "h1", "Page Not Found");
|
|
});
|
|
|
|
it("Route /packages authenticated", async () => {
|
|
setToken(TEST_AUTH_OBJECT);
|
|
await check("/packages", "h6", "Deployments");
|
|
});
|
|
|
|
it("Route /package-status authenticated", async () => {
|
|
setToken(TEST_AUTH_OBJECT);
|
|
await check("/package-status/1", "h6", "Manifest Test Manifest 1.0");
|
|
});
|
|
|
|
it("Route /package-deploy authenticated", async () => {
|
|
setToken(TEST_AUTH_OBJECT);
|
|
await check("/package-deploy/1", "h6", "Deploy Test Manifest 1.0");
|
|
});
|
|
|
|
it("Route /package-create authenticated", async () => {
|
|
setToken(TEST_AUTH_OBJECT);
|
|
await check("/package-create", "h6", "Create Deployments");
|
|
});
|
|
|
|
it("Route /vehicle-add authenticated", async () => {
|
|
setToken(TEST_AUTH_OBJECT);
|
|
await check("/vehicle-add", "h6", "Add Vehicle");
|
|
});
|
|
|
|
it("Route /vehicles authenticated", async () => {
|
|
setToken(TEST_AUTH_OBJECT);
|
|
await check("/vehicles", "h6", "Vehicles");
|
|
});
|
|
|
|
it("Route /vehicle-status authenticated", async () => {
|
|
setToken(TEST_AUTH_OBJECT);
|
|
await check("/vehicle-status/FISKER123", "h6", "Vehicle FISKER123 Details");
|
|
});
|
|
|
|
it("Route /tools/certificates/add authenticated", async () => {
|
|
setToken(TEST_AUTH_OBJECT);
|
|
await check("/tools/certificates/add", "h6", "Create Certificate");
|
|
});
|
|
});
|