Skip to content

Commit addbd42

Browse files
committed
[FIX] point_of_sale: fix offline mode in tours
1 parent 0246d70 commit addbd42

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

addons/point_of_sale/static/tests/generic_helpers/offline_util.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ConnectionLostError } from "@web/core/network/rpc";
44
const originalFetch = window.fetch;
55
const originalSend = XMLHttpRequest.prototype.send;
66
const originalConsoleError = console.error;
7+
const originalNavigatorOnLine = navigator.onLine;
78

89
export function setOfflineMode() {
910
return run(() => {
@@ -20,6 +21,11 @@ export function setOfflineMode() {
2021
} else {
2122
originalConsoleError.apply(console, args);
2223
}
24+
25+
Object.defineProperty(navigator, "onLine", {
26+
get: () => false,
27+
configurable: true,
28+
});
2329
};
2430
}, "Offline mode is now enabled");
2531
}
@@ -29,5 +35,9 @@ export function setOnlineMode() {
2935
window.fetch = originalFetch;
3036
XMLHttpRequest.prototype.send = originalSend;
3137
console.error = originalConsoleError;
38+
Object.defineProperty(navigator, "onLine", {
39+
get: () => originalNavigatorOnLine,
40+
configurable: true,
41+
});
3242
}, "Offline mode is now disabled");
3343
}

0 commit comments

Comments
 (0)