diff --git a/playwright.config.ts b/playwright.config.ts index e1e50d1..87e2034 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -2,7 +2,8 @@ import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ testDir: './e2e', - fullyParallel: true, + fullyParallel: false, + workers: 4, retries: process.env.CI ? 2 : 0, use: { baseURL: 'http://127.0.0.1:4173', diff --git a/src/hooks/__tests__/useBarcodeScanner.test.tsx b/src/hooks/__tests__/useBarcodeScanner.test.tsx index 791ee95..3c50b8b 100644 --- a/src/hooks/__tests__/useBarcodeScanner.test.tsx +++ b/src/hooks/__tests__/useBarcodeScanner.test.tsx @@ -2,12 +2,16 @@ import { renderHook, waitFor } from '@testing-library/react'; import { describe, it, beforeEach, afterEach, expect, vi, type MockInstance } from 'vitest'; import { useBarcodeScanner } from '../useBarcodeScanner'; -const decodeFromVideoDevice = vi.fn(); +const { decodeFromVideoDevice, MockBrowserMultiFormatReader } = vi.hoisted(() => { + const decodeSpy = vi.fn(); + const Reader = vi.fn(function MockBrowserMultiFormatReader(this: { decodeFromVideoDevice: typeof decodeSpy }) { + this.decodeFromVideoDevice = decodeSpy; + }); + return { decodeFromVideoDevice: decodeSpy, MockBrowserMultiFormatReader: Reader }; +}); vi.mock('@zxing/browser', () => ({ - BrowserMultiFormatReader: vi.fn(function MockBrowserMultiFormatReader() { - return { decodeFromVideoDevice }; - }), + BrowserMultiFormatReader: MockBrowserMultiFormatReader, })); declare global { diff --git a/src/screens/ActivePickListScreen.tsx b/src/screens/ActivePickListScreen.tsx index 90d4dfd..67a42a1 100644 --- a/src/screens/ActivePickListScreen.tsx +++ b/src/screens/ActivePickListScreen.tsx @@ -91,25 +91,17 @@ export const ActivePickListScreen = () => { const sortedItems = useMemo(() => { return [...itemsVisibleByStatus].sort((a, b) => { - const productA = productMap.get(a.product_id); - const productB = productMap.get(b.product_id); + const timeA = a.created_at ?? a.updated_at ?? 0; + const timeB = b.created_at ?? b.updated_at ?? 0; - const nameA = productA ? normalizeName(productA.name) : ''; - const nameB = productB ? normalizeName(productB.name) : ''; - - const nameComparison = nameA.localeCompare(nameB, undefined, { sensitivity: 'base' }); - if (nameComparison !== 0) { - return nameComparison; + if (timeA !== timeB) { + return timeA - timeB; } - if (a.is_carton !== b.is_carton) { - return a.is_carton ? 1 : -1; - } + const nameA = normalizeName(productMap.get(a.product_id)?.name ?? ''); + const nameB = normalizeName(productMap.get(b.product_id)?.name ?? ''); - const timeA = a.updated_at ?? a.created_at; - const timeB = b.updated_at ?? b.created_at; - - return timeA - timeB; + return nameA.localeCompare(nameB, undefined, { sensitivity: 'base' }); }); }, [itemsVisibleByStatus, productMap]); diff --git a/src/screens/ManageProductsScreen.tsx b/src/screens/ManageProductsScreen.tsx index 4d99956..92a38c5 100644 --- a/src/screens/ManageProductsScreen.tsx +++ b/src/screens/ManageProductsScreen.tsx @@ -8,6 +8,7 @@ import { DialogTitle, InputAdornment, MenuItem, + Snackbar, Stack, TextField, Typography, @@ -301,7 +302,14 @@ export const ManageProductsScreen = () => { Manage Products - {feedback ? {feedback.text} : null} + setFeedback(null)} + anchorOrigin={{ vertical: 'top', horizontal: 'center' }} + > + {feedback ? {feedback.text} : null} +