confirm mcu reset
parent
42f6897792
commit
c2e95a79a2
|
@ -296,6 +296,10 @@ export namespace Content {
|
|||
not delete data stored in your web app account. Are you sure you wish
|
||||
to continue?`.replace(/\s+/g, " ");
|
||||
|
||||
export const MCU_RESET_ALERT =
|
||||
`Warning: This will reset all hardware settings to the default values.
|
||||
Are you sure you wish to continue?`.replace(/\s+/g, " ");
|
||||
|
||||
export const AUTO_FACTORY_RESET =
|
||||
`Automatically factory reset when the WiFi network cannot be detected.
|
||||
Useful for typos during FarmBot OS configuration or network changes.`
|
||||
|
|
|
@ -61,13 +61,13 @@ describe("factoryReset()", () => {
|
|||
});
|
||||
|
||||
it("doesn't call factoryReset", async () => {
|
||||
window.confirm = () => false;
|
||||
await actions.factoryReset();
|
||||
expect(mockDevice.resetOS).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("calls factoryReset", async () => {
|
||||
// tslint:disable-next-line:no-any
|
||||
(global as any).confirm = () => true;
|
||||
window.confirm = () => true;
|
||||
await actions.factoryReset();
|
||||
expect(mockDevice.resetOS).toHaveBeenCalled();
|
||||
});
|
||||
|
@ -96,7 +96,7 @@ describe("emergencyLock() / emergencyUnlock", function () {
|
|||
});
|
||||
|
||||
it("calls emergencyUnlock", () => {
|
||||
window.confirm = jest.fn(() => true);
|
||||
window.confirm = () => true;
|
||||
actions.emergencyUnlock();
|
||||
expect(mockDevice.emergencyUnlock).toHaveBeenCalled();
|
||||
});
|
||||
|
@ -141,7 +141,14 @@ describe("MCUFactoryReset()", function () {
|
|||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("doesn't call resetMCU", () => {
|
||||
window.confirm = () => false;
|
||||
actions.MCUFactoryReset();
|
||||
expect(mockDevice.resetMCU).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("calls resetMCU", () => {
|
||||
window.confirm = () => true;
|
||||
actions.MCUFactoryReset();
|
||||
expect(mockDevice.resetMCU).toHaveBeenCalled();
|
||||
});
|
||||
|
|
|
@ -180,6 +180,9 @@ export function bulkToggleControlPanel(payload: boolean) {
|
|||
}
|
||||
|
||||
export function MCUFactoryReset() {
|
||||
if (!confirm(t(Content.MCU_RESET_ALERT))) {
|
||||
return;
|
||||
}
|
||||
return getDevice().resetMCU();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue