Fix RxDB COL20 when barcode scanning fields are undefined#134
Conversation
📝 WalkthroughWalkthroughThis pull request modifies the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/core/src/screens/main/hooks/mutations/use-local-mutation.test.ts (1)
60-68: Expand this regression to includebarcode_scanning_suffixundefined as well.The issue scope calls out both fields; asserting both in one test better protects against partial regressions.
Suggested test update
const patchResult = await act(async () => { return result.current.localPatch({ document: document as never, data: { barcode_scanning_prefix: undefined, + barcode_scanning_suffix: undefined, } as never, }); }); expect(persistedDoc.barcode_scanning_prefix).toBe(''); + expect(persistedDoc.barcode_scanning_suffix).toBe(''); expect(patchResult?.changes).not.toHaveProperty('barcode_scanning_prefix'); + expect(patchResult?.changes).not.toHaveProperty('barcode_scanning_suffix'); expect(mockConvertLocalDateToUTCString).toHaveBeenCalledTimes(1);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/core/src/screens/main/hooks/mutations/use-local-mutation.test.ts` around lines 60 - 68, Update the test in use-local-mutation.test.ts to also simulate and assert the handling of barcode_scanning_suffix being undefined: when applying the mutation that currently sets data: { barcode_scanning_prefix: undefined } also include barcode_scanning_suffix: undefined (or add a separate mutation call for it), then assert persistedDoc.barcode_scanning_suffix.toBe('') and expect(patchResult?.changes).not.toHaveProperty('barcode_scanning_suffix'); keep the existing assertion for barcode_scanning_prefix and the mockConvertLocalDateToUTCString call count unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/core/src/screens/main/hooks/mutations/use-local-mutation.test.ts`:
- Around line 60-68: Update the test in use-local-mutation.test.ts to also
simulate and assert the handling of barcode_scanning_suffix being undefined:
when applying the mutation that currently sets data: { barcode_scanning_prefix:
undefined } also include barcode_scanning_suffix: undefined (or add a separate
mutation call for it), then assert persistedDoc.barcode_scanning_suffix.toBe('')
and expect(patchResult?.changes).not.toHaveProperty('barcode_scanning_suffix');
keep the existing assertion for barcode_scanning_prefix and the
mockConvertLocalDateToUTCString call count unchanged.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/core/src/screens/main/hooks/mutations/use-local-mutation.test.tspackages/core/src/screens/main/hooks/mutations/use-local-mutation.ts
📊 Test Coverage Report
Coverage Legend
|
🚀 Deployment Summary
🔗 Quick Links🤖 Updated by GitHub Actions |
Summary
useLocalMutationfrom writingundefinedvalues into RxDB documentsincrementalModify, while still updatingdate_modified_gmtundefinedTest plan
pnpm --filter @wcpos/core lintand confirm there are no lint errors.pnpm --filter @wcpos/core testand confirm the core suite passes.COL20validation errors forbarcode_scanning_prefix/barcode_scanning_suffix.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests