const filters = [ { can_id: "123-456", interval: 789 }, { can_id: "1", interval: 1000 }, { can_id: "1000", interval: 1 } ] const data = [ { vin: "3C4PDCBG0ET127145", year: 2021, model: "Ocean", trim: "Basic", ecu_list: "ECUA 2.0.0, ECUB 2.1.1", log_level: "info", canbus: { enabled: true, data_logger_enabled: true, max_mem_buffer_size: 1, max_disk_buffer_size: 2, filters: filters }, idps_enabled: true, iccid: "8988300000000000000", }, { vin: "1G1FP87S3GN100062" }, { vin: "1HGCG325XYA062256", year: 2021 }, { vin: "1J4GZ78YXWC160024", year: 2021, model: "Ocean" }, { vin: "2C3CCAAG8CH222800", model: "Ocean", trim: "Basic" }, { vin: "KNADM4A39C6028108", year: 2021, model: "Ocean", trim: "Basic" }, { vin: "1G11C5SL9FF153507", year: 2021, model: "Ocean", trim: "Basic" }, ]; const ecusData = [ { created: "2021-07-14T20:09:40.98187Z", ecu: "ECUA", hw_version: "HWVERSION", sw_version: "SWVERSION", vendor: "VENDOR", supplier_sw_version: "SUPPLIER_SW_VERSION", serial_number: "SERIAL_NUMBER", boot_loader_version: "BOOT_LOADER", code_data_string: "CONFIG", fingerprint: "FINGERPRINT", updated: "2021-07-14T20:09:40.98187Z", }, { code_data_string: "CONFIG", created: "2021-07-14T20:09:40.98187Z", ecu: "ECUB", hw_version: "HWVERSION", sw_version: "SWVERSION", updated: "2021-07-14T20:09:40.98187Z", }, ]; const signals = { data: [ { timestamp: "2021-07-14T20:09:40.98187Z", name: "signal", value: 123 }, ], }; const trexLogs = { RealOffset: 0, blobSize: 62072819, bytesRead: 29874, data: [ { "level": "info", "timestamp": "2023-Feb-15 23:44:36.934746", "line_number": 948, "filename": "ota_service.cpp", "msg": "ota::cleanup() Deleting directory \"/fisker/ota/1534\"", "received_timestamp": "2023-Feb-15 23:44:37.203102197" }, { "level": "debug", "timestamp": "2023-Feb-15 23:44:36.970715", "line_number": 992, "filename": "ota_service.cpp", "msg": "ota::end() manifest process aborted with error state", "received_timestamp": "2023-Feb-15 23:44:37.203197597" }, { "level": "debug", "timestamp": "2023-Feb-15 23:44:36.971745", "line_number": 91, "filename": "vom_impl.cpp", "msg": "vom::send_ota_result_fb() Sending 0x4F9->tbox_ota_res_fb (==OTA_error)", "received_timestamp": "2023-Feb-15 23:44:37.203249997" } ] } const vehiclesAPI = { addTags: async (vins, tags) => { return { vins, tags, }; }, addVehicle: async (vehicle) => { data.push(vehicle); return vehicle; }, deleteVehicle: async (vin) => { const index = data.findIndex(element => element.vin === vin); if (index >= 0) data.splice(index, 1); return vin; }, getConnections: async (vins) => { const result = {}; vins.VINs.forEach((vin) => { result[vin] = true; result["2:" + vin] = false; }); return result; }, getECUs: async () => { return { data: ecusData, total: ecusData.length }; }, getModels: async () => { return { data: ["Ocean", "Pear"], }; }, getLocations: jest .fn() .mockResolvedValue( { data: [{ altitude: 5, longitude: 10, latitude: 15, vin: "TESTVIN123" }] }, ), getLocationsVehiclePaths: async () => { return { '3FAFP13P31R199430': [[16.891136999999986, 26.832352999999955], [56.891136999999986, 66.832352999999955], [26.891136999999986, 36.832352999999955]], '3FAFP13P71R199060': [[36.891136999999986, 46.832352999999955], [76.891136999999986, 16.832352999999955]], '3FAFP13P61R199390': [], }; }, getVehicle: async (vin) => { const index = data.findIndex(element => element.vin === vin); return data[index]; }, getVehicles: async () => { return { data }; }, getFleets: async (vin) => { return { data: ["fleet1", "fleet2"] } }, getYears: async () => { return { data: [2021, 2022], }; }, sendCommand: async (vin, command) => { return { vin, command, }; }, updateVehicle: async (vin, vehicle) => { const index = data.findIndex(element => element.vin === vin); if (index >= 0) data[index] = vehicle; return vehicle; }, updateConfig: async (vin, vehicle) => { return { message: "Sent" }; }, getCANSignals: async (vin, vehicle) => { return signals; }, getTRexLogs: async (vin, search, date, offset, count, direction, token) => { return trexLogs; }, getVersionLog: async (vin) => ({ "data": [ { "id": 1, "vin": "${vin}", "version_source": "TREX", "version": "0.9.56", "created_at": "2023-01-13T02:11:33.327214Z" }, { "id": 2, "vin": "${vin}", "version_source": "DBC", "version": "386c18977a1be3cda60c953e5902c680dbe82b89523f2527e80cd9db863db991", "created_at": "2023-01-13T02:11:33.330932Z" } ], "total": 2 }), sendDiagnosticCommand: async (search) => ({ Message: `remote diagnostic command sent to ${search.vins.length} vehicles` }), getAllFlashpacks: async (token) => { return { data: ["41.14", "43.19"], }; }, getFlashpackECUMappings: async (model, year, flashpack, token) => { return { "data": [ { "flashpack": "41.14", "car_model": "Ocean", "car_year": 2023, "car_ecu_name": "ADAS", "car_ecu_version": "ADASVersion" }, { "flashpack": "41.14", "car_model": "Ocean", "car_year": 2023, "car_ecu_name": "ACUN", "car_ecu_version": "ACUNVersion" } ], }; }, addFlashpackECUMapping: async (data, token) => { return { message: "Created" }; }, deleteFlashpackECUMapping: async (data, token) => { return { message: "Deleted" }; }, flashpackVersionBulkUpdate: async (data, token) => { return { message: "Updated" } } }; export default vehiclesAPI;