Fix barcode lookup test reliability

This commit is contained in:
beatz174-bit committed 2025-12-01 21:48:17 +10:00
1 parent 5bb16d155f
commit 5edc2057be
10 files changed
+122 -82

No files matched your search

+7 -1
View File
@@ -76,6 +76,12 @@ export const AddProductDialog = ({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [open, categoryOptions, initialBarcode]);
useEffect(() => {
if (!open || !barcode) return;
void lookupBarcode(barcode);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [open, barcode]);
useEffect(() => {
if (!barcode) {
setLookupStatus('idle');
@@ -181,7 +187,7 @@ export const AddProductDialog = ({
async function lookupBarcode(code: string) {
if (!code) return;
if (typeof navigator !== 'undefined' && 'onLine' in navigator && !navigator.onLine) {
if (typeof navigator !== 'undefined' && 'onLine' in navigator && navigator.onLine === false) {
setLookupStatus('offline');
setExternalProduct(null);
return;