Fix barcode lookup test reliability
This commit is contained in:
1 parent
5bb16d155f
commit
5edc2057be
10 files changed
+122
-82
No files matched your search
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user