From 634e960252a84f0a29cc2cfba772fb2bba9ffd31 Mon Sep 17 00:00:00 2001 From: Bankim Date: Thu, 26 Nov 2026 21:51:18 +0530 Subject: [PATCH 1/2] fix(printers): stop blocking ready Windows USB queues Do not refuse a job on the generic printer error flag alone, and report a queue offline only for PrinterStatus 6 or 7 or when WorkOffline is true. Co-Authored-By: Claude Sonnet 5.5 --- docs/architecture/printing.md | 6 ++-- main/printers/thermal.ts | 26 +++++++++------- tests/windows-queue-bypass.test.ts | 50 +++++++++++++++++++++++++++++- 3 files changed, 68 insertions(+), 14 deletions(-) diff --git a/docs/architecture/printing.md b/docs/architecture/printing.md index aa933ed7e..4f6a0f0af 100644 --- a/docs/architecture/printing.md +++ b/docs/architecture/printing.md @@ -217,7 +217,7 @@ the callout banner. | --- | --- | | Network | Raw socket (`printViaNetwork()` in `main/printers/thermal.ts`). Payloads over 4096 bytes (`NETWORK_PRINT_CHUNK_SIZE`) are sent in 4096-byte chunks with a 10 ms delay between chunks (`NETWORK_PRINT_CHUNK_DELAY_MS`), so a large receipt does not overrun the printer's buffer; smaller payloads are written in a single pass. After writing the payload, `printViaNetwork()` sends `DLE_EOT[1]` (`0x10 0x04 0x01`) and waits for a reply, peer close, or `NETWORK_PRINT_DRAIN_TIMEOUT_MS` (600 ms) before closing the socket so slower printer microcontrollers finish draining trailing commands without stalling silent printers. `validateNetworkPrinterTarget()` (enforced on `/api/printers` configuration, `/:id/status` probes, LAN discovery in `main/printers/lan-discovery.ts`, and `printViaNetwork()` dispatch) rejects cloud metadata endpoints, unspecified/broadcast addresses, and FloCafe's own local listening ports across canonical and non-canonical (shorthand, octal, hexadecimal, and integer) IPv4 forms while preserving hostnames, custom ports, LAN/Tailscale/IPv6 addresses, and link-local printers. | | CUPS | `lp -d -o raw `, using an exclusive (`wx`, `0600`) temporary file with a per-job UUID suffix that is unlinked only if created. | -| Windows | `OpenPrinterW` with `pDataType` set to `RAW`, reading an exclusive (`wx`, `0600`) temporary file with a per-job UUID suffix that is unlinked only if created. Before `StartDocPrinter`, the helper refuses a queue that is set to Use Printer Offline, offline, or not available. For those three refusals only, when the queue's port is a Standard TCP/IP port in RAW mode, `main/printers/windows-queue-bypass.ts` sends the same bytes once to that port with `printViaNetwork()`. No job exists in the spool at that point, so the bypass cannot print a ticket twice. When the port has SNMP status enabled, the failure detail says so and the POS shows how to turn it off. | +| Windows | `OpenPrinterW` with `pDataType` set to `RAW`, reading an exclusive (`wx`, `0600`) temporary file with a per-job UUID suffix that is unlinked only if created. Before `StartDocPrinter`, the helper refuses a queue that reports out of paper, paper jam, cover open, Use Printer Offline, offline, not available, or needs attention. The generic error status flag alone does not block the job; `StartDocPrinter`, `StartPagePrinter`, and `WritePrinter` failures still fail it. For the Use Printer Offline, offline, and not-available refusals only, when the queue's port is a Standard TCP/IP port in RAW mode, `main/printers/windows-queue-bypass.ts` sends the same bytes once to that port with `printViaNetwork()`. No job exists in the spool at that point, so the bypass cannot print a ticket twice. When the port has SNMP status enabled, the failure detail says so and the POS shows how to turn it off. | | macOS Mac App Store | IPP over the local CUPS UNIX domain socket `/private/var/run/cupsd` (with loopback HTTP fallback on `127.0.0.1:631`) using `main/printers/ipp-client.ts` and `document-format` `application/vnd.cups-raw`, because the macOS App Sandbox blocks shelling out to `lp` and blocks outbound TCP to `localhost:631` while permitting `/private/var/run/cupsd` under `com.apple.security.print`. | | WebUSB | The browser WebUSB API through the frontend bridge. A browser terminal needs a secure origin, so it opens FloCafe over the [Secure Network](overview.md#secure-network-https-for-lan-devices) HTTPS address; the desktop app uses `localhost`, which is already secure. Permissions are per origin. | @@ -233,7 +233,9 @@ socket and decodes the answer into online, cover open, paper out, paper near end The probe never throws, and it returns when the first query gets no answer, so a printer that does not implement `DLE EOT` costs one timeout. `statusToFailureCause()` maps the result to one cause: `paper_out`, `cover_open`, `printer_error`, `offline`, or `unreachable`. USB queues report -`queue_offline` or `queue_missing` from OS detection. After a test print to a network printer, the +`queue_offline` or `queue_missing` from OS detection. On Windows a queue is offline only when +`Win32_Printer.WorkOffline` is true or `PrinterStatus` is 6 (Stopped Printing) or 7 (Offline); +Other and Unknown count as not offline. After a test print to a network printer, the route probes that printer and treats `paper_out`, `cover_open`, `printer_error`, and `offline` as failures (preserving `failure_class` from dispatch when more specific, such as `timeout`), because a raw socket can accept bytes that an offline or faulted printer drops. The frontend turns the cause, diff --git a/main/printers/thermal.ts b/main/printers/thermal.ts index 9aa146d5e..a67d8960b 100644 --- a/main/printers/thermal.ts +++ b/main/printers/thermal.ts @@ -740,11 +740,11 @@ function windowsPowerShellCommandArgs(script: string): string[] { } // Enumerate printers via Get-CimInstance (Win32_Printer) using -EncodedCommand. -const DETECT_WINDOWS_PRINTERS_SCRIPT = ` +export const DETECT_WINDOWS_PRINTERS_SCRIPT = ` $ErrorActionPreference = 'Stop' try { - Get-CimInstance -ClassName Win32_Printer -Property Name,Default,PrinterStatus,DriverName | - Select-Object Name,Default,PrinterStatus,DriverName | + Get-CimInstance -ClassName Win32_Printer -Property Name,Default,PrinterStatus,WorkOffline,DriverName | + Select-Object Name,Default,PrinterStatus,WorkOffline,DriverName | ConvertTo-Json -Compress } catch { [Console]::Error.WriteLine($_.Exception.Message) @@ -754,10 +754,14 @@ try { `; // Win32_Printer.PrinterStatus: 1=Other, 2=Unknown, 3=Idle, 4=Printing, 5=Warming Up, 6=Stopped Printing, 7=Offline. -function mapWindowsPrinterStatus(printerStatus: unknown): 'idle' | 'printing' | 'offline' { - if (printerStatus === 3 || printerStatus === 5) return 'idle'; - if (printerStatus === 4) return 'printing'; - return 'offline'; +// USB queues often report Other or Unknown while ready, so only explicit offline signals count. +export function mapWindowsPrinterStatus(entry: { + PrinterStatus?: unknown; + WorkOffline?: unknown; +}): 'idle' | 'printing' | 'offline' { + const { PrinterStatus: status, WorkOffline: workOffline } = entry; + if (workOffline === true || status === 6 || status === 7) return 'offline'; + return status === 4 ? 'printing' : 'idle'; } async function detectWindowsPrinters(signal?: AbortSignal): Promise { @@ -796,7 +800,7 @@ async function detectWindowsPrinters(signal?: AbortSignal): Promise { } blockingStateOrder(); + queueStatusMapping(); console.log('windows queue bypass tests passed'); } @@ -230,6 +236,48 @@ function blockingStateOrder(): void { ); assertOrThrow(!refusable(state(status, attributes)), `status ${status} never uses the bypass`); } + + assertEqualOrThrow(state(0x2), null, 'the generic error flag alone does not block'); + for (const [status, attributes, text] of [ + [0x12, 0, 'printer is out of paper'], + [0xa, 0, 'printer has a paper jam'], + [0x400002, 0, 'printer cover is open'], + [0x2, 0x400, "printer is set to 'Use Printer Offline' in Windows"], + [0x82, 0, 'printer is offline'], + [0x1002, 0, 'printer is not available'], + [0x100002, 0, 'printer needs attention'], + ] as const) { + assertEqualOrThrow(state(status, attributes), text, `status ${status} still blocks`); + } +} + +function queueStatusMapping(): void { + for (const [PrinterStatus, expected] of [ + [1, 'idle'], + [2, 'idle'], + [3, 'idle'], + [4, 'printing'], + [5, 'idle'], + [6, 'offline'], + [7, 'offline'], + ] as const) { + assertEqualOrThrow( + mapWindowsPrinterStatus({ PrinterStatus, WorkOffline: false }), + expected, + `PrinterStatus ${PrinterStatus} maps to ${expected}`, + ); + assertEqualOrThrow( + mapWindowsPrinterStatus({ PrinterStatus, WorkOffline: true }), + 'offline', + `PrinterStatus ${PrinterStatus} with WorkOffline is offline`, + ); + } + assertOrThrow( + /-Property [\w,]*\bWorkOffline\b[\s\S]*Select-Object [\w,]*\bWorkOffline\b/.test( + DETECT_WINDOWS_PRINTERS_SCRIPT, + ), + 'the detection script queries and returns WorkOffline', + ); } main().catch((error) => { From 4cc77013b41eb021cbca2db599b620b721ce62bd Mon Sep 17 00:00:00 2001 From: Bankim Date: Thu, 26 Nov 2026 21:51:19 +0530 Subject: [PATCH 2/2] fix(pwa): open installed KDS and Server App on their own pages Both pages inherited the POS manifest, so an installed app opened /dashboard on a server that cannot back it and sign-in failed. Co-Authored-By: Claude Sonnet 5.5 --- docs/architecture/overview.md | 4 +++ frontend/public/kds-manifest.json | 25 +++++++++++++++++++ frontend/public/server-manifest.json | 25 +++++++++++++++++++ frontend/src/app/kds-standalone/layout.tsx | 8 +++--- frontend/src/app/server-standalone/layout.tsx | 8 +++--- package.json | 3 ++- tests/install-manifests.test.ts | 24 ++++++++++++++++++ 7 files changed, 86 insertions(+), 11 deletions(-) create mode 100644 frontend/public/kds-manifest.json create mode 100644 frontend/public/server-manifest.json create mode 100644 tests/install-manifests.test.ts diff --git a/docs/architecture/overview.md b/docs/architecture/overview.md index 65a3590b3..f261ed933 100644 --- a/docs/architecture/overview.md +++ b/docs/architecture/overview.md @@ -21,6 +21,10 @@ The KDS WebSocket is served at path `/kds` on **both** `:3001` and `:3002`. Both same handler, `setupKdsWebSocket` in [`main/services/kds.ts`](../../main/services/kds.ts), so a KDS client behaves identically whichever port it connects to. +The standalone KDS and Server App pages each link their own web app manifest +(`frontend/public/kds-manifest.json` and `frontend/public/server-manifest.json`), so an installed +app opens `/kds-standalone` or `/server-standalone` and not the POS dashboard. + ```mermaid flowchart TB subgraph main["Electron main process"] diff --git a/frontend/public/kds-manifest.json b/frontend/public/kds-manifest.json new file mode 100644 index 000000000..deeb06a0e --- /dev/null +++ b/frontend/public/kds-manifest.json @@ -0,0 +1,25 @@ +{ + "id": "/kds-standalone", + "name": "Flo KDS", + "short_name": "Flo KDS", + "description": "Kitchen Display System", + "start_url": "/kds-standalone", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#3248FF", + "orientation": "any", + "icons": [ + { + "src": "/icon-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "any maskable" + }, + { + "src": "/icon-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "any maskable" + } + ] +} diff --git a/frontend/public/server-manifest.json b/frontend/public/server-manifest.json new file mode 100644 index 000000000..b1ea8f54f --- /dev/null +++ b/frontend/public/server-manifest.json @@ -0,0 +1,25 @@ +{ + "id": "/server-standalone", + "name": "Flo Server App", + "short_name": "Flo Server", + "description": "Tableside ordering for FloCafe", + "start_url": "/server-standalone", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#3248FF", + "orientation": "any", + "icons": [ + { + "src": "/icon-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "any maskable" + }, + { + "src": "/icon-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "any maskable" + } + ] +} diff --git a/frontend/src/app/kds-standalone/layout.tsx b/frontend/src/app/kds-standalone/layout.tsx index b5790535b..d31b0d5c6 100644 --- a/frontend/src/app/kds-standalone/layout.tsx +++ b/frontend/src/app/kds-standalone/layout.tsx @@ -5,13 +5,11 @@ import { KdsHtmlLang } from '@/components/kds/KdsHtmlLang'; export const metadata: Metadata = { title: 'Flo KDS - Kitchen Display', description: 'Kitchen Display System', + // The root manifest starts at /dashboard, which the KDS server cannot back. + manifest: '/kds-manifest.json', }; -export default function KdsStandaloneLayout({ - children, -}: { - children: React.ReactNode; -}) { +export default function KdsStandaloneLayout({ children }: { children: React.ReactNode }) { return (
diff --git a/frontend/src/app/server-standalone/layout.tsx b/frontend/src/app/server-standalone/layout.tsx index 9d208e5a5..5c2901098 100644 --- a/frontend/src/app/server-standalone/layout.tsx +++ b/frontend/src/app/server-standalone/layout.tsx @@ -9,13 +9,11 @@ const inter = Inter({ subsets: ['latin'] }); export const metadata: Metadata = { title: 'Flo Server App', description: 'Tableside ordering for FloCafe', + // The root manifest starts at /dashboard, which the Server App cannot back. + manifest: '/server-manifest.json', }; -export default function ServerStandaloneLayout({ - children, -}: { - children: React.ReactNode; -}) { +export default function ServerStandaloneLayout({ children }: { children: React.ReactNode }) { return ( diff --git a/package.json b/package.json index 491dedeea..08f3ee1d7 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "pretest": "npm run test:script-coverage && node scripts/run-test.cjs npm run test:payment-methods-split && node scripts/run-test.cjs npm run test:unified-split-check-ux && node scripts/run-test.cjs npm run test:release-regressions && node scripts/run-test.cjs npm run test:product-variants-db && node scripts/run-test.cjs npm run test:product-variants-api", "start": "electron .", "rebuild": "HOME=~/.electron-gyp node-gyp rebuild --target=$(node -p \"require('./node_modules/electron/package.json').version\") --arch=$(node -p \"process.arch\") --dist-url=https://electronjs.org/headers --runtime=electron --directory node_modules/better-sqlite3", - "test": "node scripts/run-test.cjs npm run test:smoke && node scripts/run-test.cjs npm run test:server-port-collision && node scripts/run-test.cjs npm run test:kds-integration && node scripts/run-test.cjs npm run test:kds-broadcast-grouping && node scripts/run-test.cjs npm run test:kds-contract && node scripts/run-test.cjs npm run test:kds-frontend-conflict && node scripts/run-test.cjs npm run test:kds-window-hardening && node scripts/run-test.cjs npm run test:electron-api-contract && node scripts/run-test.cjs npm run test:titlebar-window-options && node scripts/run-test.cjs npm run test:update-ipc-sender-validation && node scripts/run-test.cjs npm run test:settings-ipc-rbac && node scripts/run-test.cjs npm run test:menu-surface && node scripts/run-test.cjs npm run test:pos-keyboard-shortcuts && node scripts/run-test.cjs npm run test:window-readiness && node scripts/run-test.cjs npm run test:window-load-retry && node scripts/run-test.cjs npm run test:cors && node scripts/run-test.cjs npm run test:csp-lan && node scripts/run-test.cjs npm run test:secure-network-certificates && node scripts/run-test.cjs npm run test:secure-network-service && node scripts/run-test.cjs npm run test:secure-network-lan-integrity && node scripts/run-test.cjs npm run test:secure-network-windows && node scripts/run-test.cjs npm run test:release-config && node scripts/run-test.cjs npm run test:update-state && node scripts/run-test.cjs npm run test:update-ui && node scripts/run-test.cjs npm run test:update-channel && node scripts/run-test.cjs npm run test:telemetry && node scripts/run-test.cjs npm run test:telemetry-install-provenance && node scripts/run-test.cjs npm run test:country-provenance && node scripts/run-test.cjs npm run test:first-run && node scripts/run-test.cjs npm run test:phase7-setup-i18n && node scripts/run-test.cjs npm run test:security && node scripts/run-test.cjs npm run test:jwt-secret-cache-identity && node scripts/run-test.cjs npm run test:jwt-secret-persist-before-cache && node scripts/run-test.cjs npm run test:jwt-secret-safe-storage && node scripts/run-test.cjs npm run test:staff-authz && node scripts/run-test.cjs npm run test:self-service-credentials && node scripts/run-test.cjs npm run test:orders-authz && node scripts/run-test.cjs npm run test:order-item-cancel-restore && node scripts/run-test.cjs npm run test:order-item-edit && node scripts/run-test.cjs npm run test:item-price-override && node scripts/run-test.cjs npm run test:offline-mode && node scripts/run-test.cjs npm run test:product-variants-orders && node scripts/run-test.cjs npm run test:addon-inventory-pos-surface && node scripts/run-test.cjs npm run test:addon-inventory-orders && node scripts/run-test.cjs npm run test:addon-inventory-lifecycle && node scripts/run-test.cjs npm run test:order-totals-recompute && node scripts/run-test.cjs npm run test:issue-718-whatsapp-order-status && node scripts/run-test.cjs npm run test:order-audit-log && node scripts/run-test.cjs npm run test:authz-phase3 && node scripts/run-test.cjs npm run test:authorization-permissions && node scripts/run-test.cjs npm run test:auth-ui-deterministic && node scripts/run-test.cjs npm run test:desktop-trailing-slash-routing && node scripts/run-test.cjs npm run test:customer-auth && node scripts/run-test.cjs npm run test:customer-soft-reactivate-bindings && node scripts/run-test.cjs npm run test:customer-pagination && node scripts/run-test.cjs npm run test:customer-top-items && node scripts/run-test.cjs npm run test:server-app-server-role && node scripts/run-test.cjs npm run test:backup && node scripts/run-test.cjs npm run test:issue-278-fail-closed-db && node scripts/run-test.cjs npm run test:recovery-cloud && node scripts/run-test.cjs npm run test:cloud-account-status && node scripts/run-test.cjs npm run test:cloud-live-orders-batching && node scripts/run-test.cjs npm run test:cloud-live-reports && node scripts/run-test.cjs npm run test:printer && node scripts/run-test.cjs npm run test:printing-settings && node scripts/run-test.cjs npm run test:printer-width-refresh && node scripts/run-test.cjs npm run test:printer-migrations && node scripts/run-test.cjs npm run test:printer-text-size && node scripts/run-test.cjs npm run test:print-parity && node scripts/run-test.cjs npm run test:delivery-slip && node scripts/run-test.cjs npm run test:delivery-address && node scripts/run-test.cjs npm run test:thermal-capabilities && node scripts/run-test.cjs npm run test:raster && node scripts/run-test.cjs npm run test:merchant-print-templates && node scripts/run-test.cjs npm run test:merchant-template-transfer && node scripts/run-test.cjs npm run test:print-document && node scripts/run-test.cjs npm run test:menu-printing && node scripts/run-test.cjs npm run test:print-kernel && node scripts/run-test.cjs npm run test:translations && node scripts/run-test.cjs npm run test:print-labels && node scripts/run-test.cjs npm run test:locale-chunks && node scripts/run-test.cjs npm run test:rtl-foundation && node scripts/run-test.cjs npm run test:rtl-setup-auth-settings && node scripts/run-test.cjs npm run test:rtl-dashboard-pos-common && node scripts/run-test.cjs npm run test:rtl-kds-server-whatsapp && node scripts/run-test.cjs npm run test:phone && node scripts/run-test.cjs npm run test:country-localization && node scripts/run-test.cjs npm run test:e2e-argentina-flow && node scripts/run-test.cjs npm run test:charges && node scripts/run-test.cjs npm run test:charges-engine && node scripts/run-test.cjs npm run test:currency && node scripts/run-test.cjs npm run test:tax-engine && node scripts/run-test.cjs npm run test:tax-components && node scripts/run-test.cjs npm run test:tax-pack-catalog && node scripts/run-test.cjs npm run test:tax-pack-management && node scripts/run-test.cjs npm run test:manual-tax-config && node scripts/run-test.cjs npm run test:tax-pack-unavailable-manual-setup && node scripts/run-test.cjs npm run test:legacy-tax-pack-digest && node scripts/run-test.cjs npm run test:community-tax-packs && node scripts/run-test.cjs npm run test:support-ticket && node scripts/run-test.cjs npm run test:customer-phone-search && node scripts/run-test.cjs npm run test:phone-search-integration && node scripts/run-test.cjs npm run test:orders-search && node scripts/run-test.cjs npm run test:settings-search && node scripts/run-test.cjs npm run test:settings-subnav-attention && node scripts/run-test.cjs npm run test:orders-layout-settings && node scripts/run-test.cjs npm run test:pos-catalog-sort && node scripts/run-test.cjs npm run test:pos-sort-settings && node scripts/run-test.cjs npm run test:receipt-column-width && node scripts/run-test.cjs npm run test:receipt-column-oracle && node scripts/run-test.cjs npm run test:notes-validation && node scripts/run-test.cjs npm run test:order-create-refusal-facts && node scripts/run-test.cjs npm run test:order-addon-refusal-facts && node scripts/run-test.cjs npm run test:receipt-printing && node scripts/run-test.cjs npm run test:cancel-override && node scripts/run-test.cjs npm run test:refunds && node scripts/run-test.cjs npm run test:async-refund-pin-event-loop && node scripts/run-test.cjs npm run test:refund-completed-orders && node scripts/run-test.cjs npm run test:cash-closures && node scripts/run-test.cjs npm run test:cash-sessions && node scripts/run-test.cjs npm run test:cash-session-failure && node scripts/run-test.cjs npm run test:kitchen-addons && node scripts/run-test.cjs npm run test:kot-order-notes && node scripts/run-test.cjs npm run test:pos-info-network-ranking && node scripts/run-test.cjs npm run test:order-item-addons && node scripts/run-test.cjs npm run test:issue-125-addon-reads && node scripts/run-test.cjs npm run test:windows-country-code-crash && node scripts/run-test.cjs npm run test:reports-insights && node scripts/run-test.cjs npm run test:reports-daily-stats-table-turn && node scripts/run-test.cjs npm run test:timezone-report-boundaries && node scripts/run-test.cjs npm run test:business-date && node scripts/run-test.cjs npm run test:dashboard-business-date && node scripts/run-test.cjs npm run test:sequence && node scripts/run-test.cjs npm run test:order-numbering-settings && node scripts/run-test.cjs npm run test:integration-happy && node scripts/run-test.cjs npm run test:integration-order-hold-payment && node scripts/run-test.cjs npm run test:integration-tax && node scripts/run-test.cjs npm run test:integration-payments && node scripts/run-test.cjs npm run test:kitchen-delivery-enforcement && node scripts/run-test.cjs npm run test:issue-214 && node scripts/run-test.cjs npm run test:issue-214-auth && node scripts/run-test.cjs npm run test:issue-214-migration && node scripts/run-test.cjs npm run test:issue-255 && node scripts/run-test.cjs npm run test:cart-variant-identity && node scripts/run-test.cjs npm run test:cart-price-override && node scripts/run-test.cjs npm run test:product-variants-screen && node scripts/run-test.cjs npm run test:variant-pos-surface && node scripts/run-test.cjs npm run test:issue-788-order-attempt-storage && node scripts/run-test.cjs npm run test:integration-lifecycle && node scripts/run-test.cjs npm run test:integration-reconciliation && node scripts/run-test.cjs npm run test:integration-loyalty && node scripts/run-test.cjs npm run test:integration-discount && node scripts/run-test.cjs npm run test:loyalty-toggle && node scripts/run-test.cjs npm run test:discount-system && node scripts/run-test.cjs npm run test:integration-discount-settings && node scripts/run-test.cjs npm run test:integration-loyalty-global && node scripts/run-test.cjs npm run test:issue-248-csv && node scripts/run-test.cjs npm run test:integration-loyalty-redemption && node scripts/run-test.cjs npm run test:bills-print-api && node scripts/run-test.cjs npm run test:issue-24 && node scripts/run-test.cjs npm run test:issue-134-routing && node scripts/run-test.cjs npm run test:server-app-station-routing && node scripts/run-test.cjs npm run test:issue-1442 && node scripts/run-test.cjs npm run test:issue-134-mgmt && node scripts/run-test.cjs npm run test:issue-137-barcode && node scripts/run-test.cjs npm run test:issue-244-product-addon-links && node scripts/run-test.cjs npm run test:issue-245-246-addon-groups && node scripts/run-test.cjs npm run test:issue-247-catalog-invariants && node scripts/run-test.cjs npm run test:issue-250-catalog-perf && node scripts/run-test.cjs npm run test:issue-252 && node scripts/run-test.cjs npm run test:inventory-ledger && node scripts/run-test.cjs npm run test:issue-printing-and-kds-resilience && node scripts/run-test.cjs npm run test:issue-258-bill-pagination && node scripts/run-test.cjs npm run test:issue-265-morocco-profile && node scripts/run-test.cjs npm run test:issue-266-currency-symbol-print && node scripts/run-test.cjs npm run test:tables-string-ids && node scripts/run-test.cjs npm run test:issue-646-floor-management && node scripts/run-test.cjs npm run test:held-orders && node scripts/run-test.cjs npm run test:product-images && node scripts/run-test.cjs npm run test:schema-health && node scripts/run-test.cjs npm run test:migration-registry && node scripts/run-test.cjs npm run test:upgrade-path && node scripts/run-test.cjs npm run test:upgrade-matrix-harness && node scripts/run-test.cjs npm run test:migration-v56-v57 && node scripts/run-test.cjs npm run test:migration-v71-repair && node scripts/run-test.cjs npm run test:migration-v80-cash-drawer-pulse && node scripts/run-test.cjs npm run test:migration-v81-cash-closures && node scripts/run-test.cjs npm run test:master-pin && node scripts/run-test.cjs npm run test:google-drive && node scripts/run-test.cjs npm run test:google-drive-qr-menu && node scripts/run-test.cjs npm run test:qr-menu-settings-tab-refresh && node scripts/run-test.cjs npm run test:database-tools-api && node scripts/run-test.cjs npm run test:phone-validation && node scripts/run-test.cjs npm run test:phone-migration && node scripts/run-test.cjs npm run test:issue-133-kds-kot-toggles && node scripts/run-test.cjs npm run test:whatsapp-schema && node scripts/run-test.cjs npm run test:whatsapp-service && node scripts/run-test.cjs npm run test:whatsapp-middleware && node scripts/run-test.cjs npm run test:issue-127-password-recovery && node scripts/run-test.cjs npm run test:dev-tooling && node scripts/run-test.cjs npm run test:windows-uninstaller && node scripts/run-test.cjs npm run test:shutdown-lifecycle && node scripts/run-test.cjs npm run test:redos-hardening && node scripts/run-test.cjs npm run test:startup-cache && node scripts/run-test.cjs npm run test:service-worker && node scripts/run-test.cjs npm run test:issue-389-timezone-override && node scripts/run-test.cjs npm run test:issue-390-locale-preference-invariants && node scripts/run-test.cjs npm run test:issue-475-picker-highlight && node scripts/run-test.cjs npm run test:theme-mode-settings && node scripts/run-test.cjs npm run test:theme-fouc-script && node scripts/run-test.cjs npm run test:ui-regressions-621-623-626 && node scripts/run-test.cjs npm run test:themed-date-time-inputs && node scripts/run-test.cjs npm run test:issue-zero-balance-settlement && node scripts/run-test.cjs npm run test:daily-sales-export && node scripts/run-test.cjs npm run test:daily-invoices-export && node scripts/run-test.cjs npm run test:customer-sales-export && node scripts/run-test.cjs npm run test:card-transaction-id && node scripts/run-test.cjs npm run test:checkout-quick-tender-and-guards && node scripts/run-test.cjs npm run test:issue-terminal-state-guards && node scripts/run-test.cjs npm run test:issue-exact-balance-settlement && node scripts/run-test.cjs npm run test:financial-safety-remediation && node scripts/run-test.cjs npm run test:issue-payload-and-discount-bounds && node scripts/run-test.cjs npm run test:customer-display-config && node scripts/run-test.cjs npm run test:customer-display-settings-route && node scripts/run-test.cjs npm run test:customer-display-pairing && node scripts/run-test.cjs npm run test:customer-display-feed && node scripts/run-test.cjs npm run test:units && node scripts/run-test.cjs npm run test:db-timing && node scripts/run-test.cjs npm run test:supplies-service && node scripts/run-test.cjs npm run test:recipe-order-lifecycle && node scripts/run-test.cjs npm run test:ingredient-cost && node scripts/run-test.cjs npm run test:lint-engine && node scripts/run-test.cjs npm run test:oxc-contributor-checks && node scripts/run-test.cjs npm run test:expenses && node scripts/run-test.cjs npm run test:diagnostics && node scripts/run-test.cjs npm run test:reports-export && node scripts/run-test.cjs npm run test:category-addon-groups && node scripts/run-test.cjs npm run test:addon-inventory-db && node scripts/run-test.cjs npm run test:addon-inventory-api && node scripts/run-test.cjs npm run test:discount-kitchen-approver-identity && node scripts/run-test.cjs npm run test:staff-approvers-directory && node scripts/run-test.cjs npm run test:local-backup && node scripts/run-test.cjs npm run test:status-messages && npm run test:password-policy && npm run test:cloud-password-recovery && node scripts/run-test.cjs npm run test:scheduled-orders && node scripts/run-test.cjs npm run test:newer-db-recovery && node scripts/run-test.cjs npm run test:multi-counter-ordering && node scripts/run-test.cjs npm run test:hybrid-service-model && node scripts/run-test.cjs npm run test:impact-printer && node scripts/run-test.cjs npm run test:malformed-order-body && node scripts/run-test.cjs npm run test:transport-failure-class", + "test": "node scripts/run-test.cjs npm run test:smoke && node scripts/run-test.cjs npm run test:server-port-collision && node scripts/run-test.cjs npm run test:kds-integration && node scripts/run-test.cjs npm run test:kds-broadcast-grouping && node scripts/run-test.cjs npm run test:kds-contract && node scripts/run-test.cjs npm run test:kds-frontend-conflict && node scripts/run-test.cjs npm run test:kds-window-hardening && node scripts/run-test.cjs npm run test:install-manifests && node scripts/run-test.cjs npm run test:electron-api-contract && node scripts/run-test.cjs npm run test:titlebar-window-options && node scripts/run-test.cjs npm run test:update-ipc-sender-validation && node scripts/run-test.cjs npm run test:settings-ipc-rbac && node scripts/run-test.cjs npm run test:menu-surface && node scripts/run-test.cjs npm run test:pos-keyboard-shortcuts && node scripts/run-test.cjs npm run test:window-readiness && node scripts/run-test.cjs npm run test:window-load-retry && node scripts/run-test.cjs npm run test:cors && node scripts/run-test.cjs npm run test:csp-lan && node scripts/run-test.cjs npm run test:secure-network-certificates && node scripts/run-test.cjs npm run test:secure-network-service && node scripts/run-test.cjs npm run test:secure-network-lan-integrity && node scripts/run-test.cjs npm run test:secure-network-windows && node scripts/run-test.cjs npm run test:release-config && node scripts/run-test.cjs npm run test:update-state && node scripts/run-test.cjs npm run test:update-ui && node scripts/run-test.cjs npm run test:update-channel && node scripts/run-test.cjs npm run test:telemetry && node scripts/run-test.cjs npm run test:telemetry-install-provenance && node scripts/run-test.cjs npm run test:country-provenance && node scripts/run-test.cjs npm run test:first-run && node scripts/run-test.cjs npm run test:phase7-setup-i18n && node scripts/run-test.cjs npm run test:security && node scripts/run-test.cjs npm run test:jwt-secret-cache-identity && node scripts/run-test.cjs npm run test:jwt-secret-persist-before-cache && node scripts/run-test.cjs npm run test:jwt-secret-safe-storage && node scripts/run-test.cjs npm run test:staff-authz && node scripts/run-test.cjs npm run test:self-service-credentials && node scripts/run-test.cjs npm run test:orders-authz && node scripts/run-test.cjs npm run test:order-item-cancel-restore && node scripts/run-test.cjs npm run test:order-item-edit && node scripts/run-test.cjs npm run test:item-price-override && node scripts/run-test.cjs npm run test:offline-mode && node scripts/run-test.cjs npm run test:product-variants-orders && node scripts/run-test.cjs npm run test:addon-inventory-pos-surface && node scripts/run-test.cjs npm run test:addon-inventory-orders && node scripts/run-test.cjs npm run test:addon-inventory-lifecycle && node scripts/run-test.cjs npm run test:order-totals-recompute && node scripts/run-test.cjs npm run test:issue-718-whatsapp-order-status && node scripts/run-test.cjs npm run test:order-audit-log && node scripts/run-test.cjs npm run test:authz-phase3 && node scripts/run-test.cjs npm run test:authorization-permissions && node scripts/run-test.cjs npm run test:auth-ui-deterministic && node scripts/run-test.cjs npm run test:desktop-trailing-slash-routing && node scripts/run-test.cjs npm run test:customer-auth && node scripts/run-test.cjs npm run test:customer-soft-reactivate-bindings && node scripts/run-test.cjs npm run test:customer-pagination && node scripts/run-test.cjs npm run test:customer-top-items && node scripts/run-test.cjs npm run test:server-app-server-role && node scripts/run-test.cjs npm run test:backup && node scripts/run-test.cjs npm run test:issue-278-fail-closed-db && node scripts/run-test.cjs npm run test:recovery-cloud && node scripts/run-test.cjs npm run test:cloud-account-status && node scripts/run-test.cjs npm run test:cloud-live-orders-batching && node scripts/run-test.cjs npm run test:cloud-live-reports && node scripts/run-test.cjs npm run test:printer && node scripts/run-test.cjs npm run test:printing-settings && node scripts/run-test.cjs npm run test:printer-width-refresh && node scripts/run-test.cjs npm run test:printer-migrations && node scripts/run-test.cjs npm run test:printer-text-size && node scripts/run-test.cjs npm run test:print-parity && node scripts/run-test.cjs npm run test:delivery-slip && node scripts/run-test.cjs npm run test:delivery-address && node scripts/run-test.cjs npm run test:thermal-capabilities && node scripts/run-test.cjs npm run test:raster && node scripts/run-test.cjs npm run test:merchant-print-templates && node scripts/run-test.cjs npm run test:merchant-template-transfer && node scripts/run-test.cjs npm run test:print-document && node scripts/run-test.cjs npm run test:menu-printing && node scripts/run-test.cjs npm run test:print-kernel && node scripts/run-test.cjs npm run test:translations && node scripts/run-test.cjs npm run test:print-labels && node scripts/run-test.cjs npm run test:locale-chunks && node scripts/run-test.cjs npm run test:rtl-foundation && node scripts/run-test.cjs npm run test:rtl-setup-auth-settings && node scripts/run-test.cjs npm run test:rtl-dashboard-pos-common && node scripts/run-test.cjs npm run test:rtl-kds-server-whatsapp && node scripts/run-test.cjs npm run test:phone && node scripts/run-test.cjs npm run test:country-localization && node scripts/run-test.cjs npm run test:e2e-argentina-flow && node scripts/run-test.cjs npm run test:charges && node scripts/run-test.cjs npm run test:charges-engine && node scripts/run-test.cjs npm run test:currency && node scripts/run-test.cjs npm run test:tax-engine && node scripts/run-test.cjs npm run test:tax-components && node scripts/run-test.cjs npm run test:tax-pack-catalog && node scripts/run-test.cjs npm run test:tax-pack-management && node scripts/run-test.cjs npm run test:manual-tax-config && node scripts/run-test.cjs npm run test:tax-pack-unavailable-manual-setup && node scripts/run-test.cjs npm run test:legacy-tax-pack-digest && node scripts/run-test.cjs npm run test:community-tax-packs && node scripts/run-test.cjs npm run test:support-ticket && node scripts/run-test.cjs npm run test:customer-phone-search && node scripts/run-test.cjs npm run test:phone-search-integration && node scripts/run-test.cjs npm run test:orders-search && node scripts/run-test.cjs npm run test:settings-search && node scripts/run-test.cjs npm run test:settings-subnav-attention && node scripts/run-test.cjs npm run test:orders-layout-settings && node scripts/run-test.cjs npm run test:pos-catalog-sort && node scripts/run-test.cjs npm run test:pos-sort-settings && node scripts/run-test.cjs npm run test:receipt-column-width && node scripts/run-test.cjs npm run test:receipt-column-oracle && node scripts/run-test.cjs npm run test:notes-validation && node scripts/run-test.cjs npm run test:order-create-refusal-facts && node scripts/run-test.cjs npm run test:order-addon-refusal-facts && node scripts/run-test.cjs npm run test:receipt-printing && node scripts/run-test.cjs npm run test:cancel-override && node scripts/run-test.cjs npm run test:refunds && node scripts/run-test.cjs npm run test:async-refund-pin-event-loop && node scripts/run-test.cjs npm run test:refund-completed-orders && node scripts/run-test.cjs npm run test:cash-closures && node scripts/run-test.cjs npm run test:cash-sessions && node scripts/run-test.cjs npm run test:cash-session-failure && node scripts/run-test.cjs npm run test:kitchen-addons && node scripts/run-test.cjs npm run test:kot-order-notes && node scripts/run-test.cjs npm run test:pos-info-network-ranking && node scripts/run-test.cjs npm run test:order-item-addons && node scripts/run-test.cjs npm run test:issue-125-addon-reads && node scripts/run-test.cjs npm run test:windows-country-code-crash && node scripts/run-test.cjs npm run test:reports-insights && node scripts/run-test.cjs npm run test:reports-daily-stats-table-turn && node scripts/run-test.cjs npm run test:timezone-report-boundaries && node scripts/run-test.cjs npm run test:business-date && node scripts/run-test.cjs npm run test:dashboard-business-date && node scripts/run-test.cjs npm run test:sequence && node scripts/run-test.cjs npm run test:order-numbering-settings && node scripts/run-test.cjs npm run test:integration-happy && node scripts/run-test.cjs npm run test:integration-order-hold-payment && node scripts/run-test.cjs npm run test:integration-tax && node scripts/run-test.cjs npm run test:integration-payments && node scripts/run-test.cjs npm run test:kitchen-delivery-enforcement && node scripts/run-test.cjs npm run test:issue-214 && node scripts/run-test.cjs npm run test:issue-214-auth && node scripts/run-test.cjs npm run test:issue-214-migration && node scripts/run-test.cjs npm run test:issue-255 && node scripts/run-test.cjs npm run test:cart-variant-identity && node scripts/run-test.cjs npm run test:cart-price-override && node scripts/run-test.cjs npm run test:product-variants-screen && node scripts/run-test.cjs npm run test:variant-pos-surface && node scripts/run-test.cjs npm run test:issue-788-order-attempt-storage && node scripts/run-test.cjs npm run test:integration-lifecycle && node scripts/run-test.cjs npm run test:integration-reconciliation && node scripts/run-test.cjs npm run test:integration-loyalty && node scripts/run-test.cjs npm run test:integration-discount && node scripts/run-test.cjs npm run test:loyalty-toggle && node scripts/run-test.cjs npm run test:discount-system && node scripts/run-test.cjs npm run test:integration-discount-settings && node scripts/run-test.cjs npm run test:integration-loyalty-global && node scripts/run-test.cjs npm run test:issue-248-csv && node scripts/run-test.cjs npm run test:integration-loyalty-redemption && node scripts/run-test.cjs npm run test:bills-print-api && node scripts/run-test.cjs npm run test:issue-24 && node scripts/run-test.cjs npm run test:issue-134-routing && node scripts/run-test.cjs npm run test:server-app-station-routing && node scripts/run-test.cjs npm run test:issue-1442 && node scripts/run-test.cjs npm run test:issue-134-mgmt && node scripts/run-test.cjs npm run test:issue-137-barcode && node scripts/run-test.cjs npm run test:issue-244-product-addon-links && node scripts/run-test.cjs npm run test:issue-245-246-addon-groups && node scripts/run-test.cjs npm run test:issue-247-catalog-invariants && node scripts/run-test.cjs npm run test:issue-250-catalog-perf && node scripts/run-test.cjs npm run test:issue-252 && node scripts/run-test.cjs npm run test:inventory-ledger && node scripts/run-test.cjs npm run test:issue-printing-and-kds-resilience && node scripts/run-test.cjs npm run test:issue-258-bill-pagination && node scripts/run-test.cjs npm run test:issue-265-morocco-profile && node scripts/run-test.cjs npm run test:issue-266-currency-symbol-print && node scripts/run-test.cjs npm run test:tables-string-ids && node scripts/run-test.cjs npm run test:issue-646-floor-management && node scripts/run-test.cjs npm run test:held-orders && node scripts/run-test.cjs npm run test:product-images && node scripts/run-test.cjs npm run test:schema-health && node scripts/run-test.cjs npm run test:migration-registry && node scripts/run-test.cjs npm run test:upgrade-path && node scripts/run-test.cjs npm run test:upgrade-matrix-harness && node scripts/run-test.cjs npm run test:migration-v56-v57 && node scripts/run-test.cjs npm run test:migration-v71-repair && node scripts/run-test.cjs npm run test:migration-v80-cash-drawer-pulse && node scripts/run-test.cjs npm run test:migration-v81-cash-closures && node scripts/run-test.cjs npm run test:master-pin && node scripts/run-test.cjs npm run test:google-drive && node scripts/run-test.cjs npm run test:google-drive-qr-menu && node scripts/run-test.cjs npm run test:qr-menu-settings-tab-refresh && node scripts/run-test.cjs npm run test:database-tools-api && node scripts/run-test.cjs npm run test:phone-validation && node scripts/run-test.cjs npm run test:phone-migration && node scripts/run-test.cjs npm run test:issue-133-kds-kot-toggles && node scripts/run-test.cjs npm run test:whatsapp-schema && node scripts/run-test.cjs npm run test:whatsapp-service && node scripts/run-test.cjs npm run test:whatsapp-middleware && node scripts/run-test.cjs npm run test:issue-127-password-recovery && node scripts/run-test.cjs npm run test:dev-tooling && node scripts/run-test.cjs npm run test:windows-uninstaller && node scripts/run-test.cjs npm run test:shutdown-lifecycle && node scripts/run-test.cjs npm run test:redos-hardening && node scripts/run-test.cjs npm run test:startup-cache && node scripts/run-test.cjs npm run test:service-worker && node scripts/run-test.cjs npm run test:issue-389-timezone-override && node scripts/run-test.cjs npm run test:issue-390-locale-preference-invariants && node scripts/run-test.cjs npm run test:issue-475-picker-highlight && node scripts/run-test.cjs npm run test:theme-mode-settings && node scripts/run-test.cjs npm run test:theme-fouc-script && node scripts/run-test.cjs npm run test:ui-regressions-621-623-626 && node scripts/run-test.cjs npm run test:themed-date-time-inputs && node scripts/run-test.cjs npm run test:issue-zero-balance-settlement && node scripts/run-test.cjs npm run test:daily-sales-export && node scripts/run-test.cjs npm run test:daily-invoices-export && node scripts/run-test.cjs npm run test:customer-sales-export && node scripts/run-test.cjs npm run test:card-transaction-id && node scripts/run-test.cjs npm run test:checkout-quick-tender-and-guards && node scripts/run-test.cjs npm run test:issue-terminal-state-guards && node scripts/run-test.cjs npm run test:issue-exact-balance-settlement && node scripts/run-test.cjs npm run test:financial-safety-remediation && node scripts/run-test.cjs npm run test:issue-payload-and-discount-bounds && node scripts/run-test.cjs npm run test:customer-display-config && node scripts/run-test.cjs npm run test:customer-display-settings-route && node scripts/run-test.cjs npm run test:customer-display-pairing && node scripts/run-test.cjs npm run test:customer-display-feed && node scripts/run-test.cjs npm run test:units && node scripts/run-test.cjs npm run test:db-timing && node scripts/run-test.cjs npm run test:supplies-service && node scripts/run-test.cjs npm run test:recipe-order-lifecycle && node scripts/run-test.cjs npm run test:ingredient-cost && node scripts/run-test.cjs npm run test:lint-engine && node scripts/run-test.cjs npm run test:oxc-contributor-checks && node scripts/run-test.cjs npm run test:expenses && node scripts/run-test.cjs npm run test:diagnostics && node scripts/run-test.cjs npm run test:reports-export && node scripts/run-test.cjs npm run test:category-addon-groups && node scripts/run-test.cjs npm run test:addon-inventory-db && node scripts/run-test.cjs npm run test:addon-inventory-api && node scripts/run-test.cjs npm run test:discount-kitchen-approver-identity && node scripts/run-test.cjs npm run test:staff-approvers-directory && node scripts/run-test.cjs npm run test:local-backup && node scripts/run-test.cjs npm run test:status-messages && npm run test:password-policy && npm run test:cloud-password-recovery && node scripts/run-test.cjs npm run test:scheduled-orders && node scripts/run-test.cjs npm run test:newer-db-recovery && node scripts/run-test.cjs npm run test:multi-counter-ordering && node scripts/run-test.cjs npm run test:hybrid-service-model && node scripts/run-test.cjs npm run test:impact-printer && node scripts/run-test.cjs npm run test:malformed-order-body && node scripts/run-test.cjs npm run test:transport-failure-class", "test:dev-tooling": "tsx --tsconfig tests/tsconfig.json -r ./tests/register-tsx.cjs tests/dev-tooling-scripts.test.ts && npm run test:phase2 && npm run test:runtime-recovery && npm run test:backend-health && npm run test:url-allowlist && npm run test:static-routes", "test:script-coverage": "node scripts/ci/validate-test-script-coverage.cjs && node tests/test-script-coverage.test.cjs && tsx --tsconfig tests/tsconfig.json -r ./tests/register-tsx.cjs tests/test-harness-assertions.test.ts", "test:lint-engine": "tsx --tsconfig tests/tsconfig.json -r ./tests/register-tsx.cjs tests/lint-engine-parity.test.ts", @@ -99,6 +99,7 @@ "test:kds-contract": "node tests/run-electron-node-test.cjs tests/kds-contract.test.ts", "test:kds-frontend-conflict": "tsx --tsconfig tests/tsconfig.json -r ./tests/register-tsx.cjs tests/kds-frontend-conflict.test.ts", "test:kds-window-hardening": "tsx --tsconfig tests/tsconfig.json -r ./tests/register-tsx.cjs tests/kds-window-hardening.test.ts", + "test:install-manifests": "tsx --tsconfig tests/tsconfig.json -r ./tests/register-tsx.cjs tests/install-manifests.test.ts", "test:electron-api-contract": "tsx --tsconfig tests/tsconfig.json -r ./tests/register-tsx.cjs tests/electron-api-contract.test.ts", "test:titlebar-window-options": "tsx --tsconfig tests/tsconfig.json -r ./tests/register-tsx.cjs tests/titlebar-window-options.test.ts", "test:update-ipc-sender-validation": "tsx --tsconfig tests/tsconfig.json -r ./tests/register-tsx.cjs tests/update-ipc-sender-validation.test.ts", diff --git a/tests/install-manifests.test.ts b/tests/install-manifests.test.ts new file mode 100644 index 000000000..ce5230e5c --- /dev/null +++ b/tests/install-manifests.test.ts @@ -0,0 +1,24 @@ +/** An installed KDS or Server App must open its own page, not the POS dashboard. */ +import * as fs from 'fs'; +import * as path from 'path'; +import { assertEqualOrThrow, assertIncludesOrThrow } from './helpers/test-setup'; + +const frontend = path.join(__dirname, '../frontend'); +const read = (file: string) => fs.readFileSync(path.join(frontend, file), 'utf8'); + +for (const [page, file] of [ + ['/kds-standalone', 'kds-manifest.json'], + ['/server-standalone', 'server-manifest.json'], +]) { + assertIncludesOrThrow( + read(`src/app${page}/layout.tsx`), + `manifest: '/${file}'`, + `${page} links its own manifest`, + ); + const manifest = JSON.parse(read(`public/${file}`)); + assertEqualOrThrow(manifest.start_url, page, `the installed app opens ${page}`); + assertEqualOrThrow(manifest.id, page, `${page} installs apart from the POS`); +} + +console.log('install manifest tests passed'); +process.exit(0);