Skip to content

[mobile] Camera to Barcode#294

Open
lauty95 wants to merge 10 commits intomobile_v15from
issue-293_camera-to-barcode
Open

[mobile] Camera to Barcode#294
lauty95 wants to merge 10 commits intomobile_v15from
issue-293_camera-to-barcode

Conversation

@lauty95
Copy link
Copy Markdown
Collaborator

@lauty95 lauty95 commented Nov 14, 2025

Resolves

#293

Dependency

I chose to use the html5-qrcode dependency based on its download count and documentation quality.
I also reviewed vue-barcode-reader and @zxing/browser. The first one has only ~5k downloads compared to html5-qrcode's ~248k, and it does not seem to have the same level of support.
@zxing/browser could also be a good alternative, but I decided to proceed with html5-qrcode.

How to test

To access the device camera, the app must be served over HTTPS. For this reason, I used ngrok (I believe we used it before): https://dashboard.ngrok.com/get-started/setup/windows

Once ngrok is installed, open a new terminal and run: ngrok http 8000 (in my case I used port 8004)

Screenshot 2025-11-14 at 1 38 21 PM

Demo

For now, I only implemented the camera on the Move page.

On my computer, I do not have a camera installed, so the button to open the camera does not appear:

Screenshot 2025-11-14 at 1 38 37 PM

On my phone:

Screenshot 2025-11-14 at 1 38 37 PM

Live Demo

Screen_Recording_20251114_134313_Chrome.mp4

@lauty95 lauty95 self-assigned this Nov 14, 2025
@lauty95 lauty95 requested a review from agritheory November 14, 2025 16:48
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Nov 14, 2025

Coverage

Coverage Report
FileStmtsMissCoverMissing
__init__.py10100% 
beam
   barcodes.py793456%20, 22, 24, 27, 38–39, 41–42, 47–48, 50–51, 53–55, 61, 71, 79, 86, 89–90, 96–97, 103, 109, 115, 121, 128, 131–134, 136–137
   handling_unit.py813754%26, 32, 64–66, 84, 95–96, 102–103, 105–106, 108–109, 111–112, 114, 116–119, 121–123, 125, 127, 129–130, 135, 137, 141, 143–144, 147, 149–150, 158
   printing.py826421%18–19, 32–43, 45–48, 57–61, 65–66, 68–69, 78–82, 85–86, 92–94, 101–102, 104–106, 108–109, 111, 116, 118–119, 134–139, 141–150
beam/demand
   demand.py3384486%51, 66, 123, 209, 243, 463–464, 483–485, 490–491, 493, 495–497, 499, 504, 543, 621, 625, 662, 667, 674, 695–696, 707, 713–729
   receiving.py1251786%79, 131, 173, 214, 244, 249–260
   sqlite.py59198%40
   utils.py59689%56, 67, 73–75, 83
beam/doctype/beam_mobile_route
   beam_mobile_route.py30100% 
beam/doctype/beam_settings
   beam_settings.py281739%35–37, 40–41, 43, 50, 55–58, 66–68, 72–74
beam/doctype/handling_unit
   __init__.py9366%12–14
   handling_unit.py150100% 
beam/doctype/warehouse_types
   warehouse_types.py30100% 
beam/overrides
   sales_order.py10640%11–16
   stock_entry.py801778%80–81, 86–93, 99–100, 116, 131, 148, 151–152
   work_order.py10280%14, 16
beam/report/demand_map
   demand_map.py35350%4–5, 7–8, 11–12, 15–16, 103–111, 127, 129–143, 146–147
beam/report/handling_unit_traceability
   handling_unit_traceability.py44440%4–6, 9–11, 30–32, 34–35, 37–38, 41–42, 45–46, 48–49, 51–52, 54–55, 57, 63–65, 67–69, 71, 74–77, 79–81, 83–86, 89–90
beam/scan
   __init__.py1432681%21, 25, 31, 39, 71, 118–119, 129, 131–132, 136, 140–141, 144, 155–156, 160, 181, 185, 214, 216, 235–236, 242, 245, 248
   config.py28280%4, 6, 9–17, 19–21, 23–26, 28–30, 32–35, 38–39, 41
   user_login.py31310%4–6, 8, 11–13, 17–19, 21–22, 24–25, 27–29, 31–33, 35–38, 40–45, 47
www/beam
   __init__.py14140%4–7, 10–19
   index.py770%4, 6, 9–13
TOTAL128443366% 

@lauty95 lauty95 mentioned this pull request Nov 17, 2025
@agritheory
Copy link
Copy Markdown
Owner

@lauty95 How can we add tests for this? Does Playwright offer a way to mock the camera?

@lauty95
Copy link
Copy Markdown
Collaborator Author

lauty95 commented Dec 10, 2025

@agritheory

Playwright offers a way to mock the browser's navigator.mediaDevices APIs, so:

I added tests for:

  • Camera button visibility based on camera availability (enumerateDevices mock)
  • Camera activation when the button is clicked (getUserMedia called)
  • Permission-denied error handling
  • Component behavior and UI state changes

What I haven’t found a way to test with Playwright:

  • Actual barcode/QR code detection by the html5-qrcode library
  • Video processing and frame analysis
  • Real camera hardware functionality

What I tried but didn't work:

  • Pre-recorded videos with QR codes - Failed to load Blob URLs in headless browser
  • Canvas streams from static images - html5-qrcode didn't detect codes from canvas streams

@agritheory
Copy link
Copy Markdown
Owner

agritheory commented Dec 10, 2025

@lauty Getting an error on when I try to navigate to a PO/PR.

Update: this is a fixturing issue. The employee users that are fixtured don't have the "Purchase User" Role.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants