Files
ota-admin-portal/src/components/Contexts/__mocks__/CarUpdatesContext.jsx
Paul Adamsen aa43431d12 CEC-4157 - Add new statuses to car_update_progress (#334)
* CEC-4157 - Add new statuses to car_update_progress

* small fix
2023-05-18 12:41:30 -04:00

144 lines
3.6 KiB
JavaScript

import React from "react";
const CarUpdatesContext = React.createContext();
let busy = false;
let carUpdates = [
{
id: 1,
vin: "1G1FP87S3GN100062",
manifest_id: 283,
status: "downloaded",
msg: "downloaded",
created: "2021-07-01T22:40:07.778509Z",
updated: "2021-07-12T18:22:13.736755Z",
updatemanifest: {
id: 283,
name: "TEST UPDATE",
version: "1000",
description: "UPDATE DESCRIPTION",
release_notes: "https://releasenotes.com",
ecu_list: "AGS 1.0.0,AMP 1.0.0",
created: "2021-08-20T18:37:41.960397Z",
updated: "2021-08-20T18:37:50.007853Z",
},
},
{
id: 2,
vin: "1G1FP87S3GN100062",
manifest_id: 285,
status: "downloaded",
msg: "downloaded",
created: "2021-07-01T22:40:07.778509Z",
updated: "2021-07-12T18:22:13.736755Z",
updatemanifest: {
id: 285,
name: "TEST UPDATE",
version: "1000",
description: "UPDATE DESCRIPTION",
release_notes: "https://releasenotes.com",
ecu_list: "AGS 1.0.0,AMP 1.0.0",
created: "2021-08-20T18:37:41.960397Z",
updated: "2021-08-20T18:37:50.007853Z",
},
},
{
id: 3,
vin: "1G1FP87S3GN100062",
manifest_id: 286,
status: "downloaded",
msg: "downloaded",
created: "2021-07-01T22:40:07.778509Z",
updated: "2021-07-12T18:22:13.736755Z",
updatemanifest: {
id: 286,
name: "TEST UPDATE",
version: "1000",
description: "UPDATE DESCRIPTION",
release_notes: "https://releasenotes.com",
ecu_list: "AGS 1.0.0,AMP 1.0.0",
created: "2021-08-20T18:37:41.960397Z",
updated: "2021-08-20T18:37:50.007853Z",
},
},
];
let totalCarUpdates = 2;
let carUpdateLog = {
data: [
{
id: 90,
carupdate_id: 283,
username: "test username 1",
status: "package_install_complete",
error_code: 0,
created: "2021-08-23T17:06:38.410115Z",
updated: "2021-08-23T17:06:38.410115Z",
},
{
id: 89,
carupdate_id: 283,
username: "test username 2",
status: "package_install_start",
error_code: 0,
info: "TEST",
created: "2021-08-23T17:06:38.030052Z",
updated: "2021-08-23T17:06:38.030052Z",
},
{
id: 88,
carupdate_id: 284,
username: "test username 3",
status: "install_approval_await",
error_code: 0,
info: "TEST",
created: "2021-08-23T17:06:38.030052Z",
updated: "2021-08-23T17:06:38.030052Z",
},
{
id: 87,
carupdate_id: 285,
username: "test username 2",
status: "install_scheduled",
error_code: 0,
info: "TEST",
created: "2021-08-23T17:06:38.030052Z",
updated: "2021-08-23T17:06:38.030052Z",
},
{
id: 86,
carupdate_id: 286,
username: "test username 2",
status: "requirements_failed",
error_code: 0,
info: "TEST",
created: "2021-08-23T17:06:38.030052Z",
updated: "2021-08-23T17:06:38.030052Z",
},
],
total: 3,
};
let sumsVersions = {
"data": ["2023.02.01.0.0.A", "2023.02.01.0.0.B"]
}
export const CarUpdatesProvider = ({ children }) => {
return <div data-testid="mocked-carupdatesprovider">{children}</div>;
};
export const useCarUpdatesContext = () => ({
busy,
carUpdates,
totalCarUpdates,
deployCarUpdates: jest.fn((data) => data),
getCarUpdates: jest.fn(() => ({
data: carUpdates,
})),
getLog: jest.fn(() => carUpdateLog),
getVINUpdates: jest.fn(() => carUpdates),
startMonitor: jest.fn(),
stopMonitor: jest.fn(),
approveUpdate: jest.fn(),
getSUMSVersions: jest.fn(() => sumsVersions),
updateSUMSVersion: jest.fn(),
});