Skip to content

Conversation

@rosskukulinski
Copy link

Summary

  • Fix Item constructor to read quantity from quantityPb.amount or deprecatedQuantity fields (protobuf format from API)
  • Fix Item._encode() to properly encode quantity as quantityPb.amount per the ListItem protobuf schema
  • Add Mocha/Chai test framework with comprehensive integration tests

Problem

The quantity field was broken in two ways:

  1. Reading: Items returned from API have quantity in quantityPb.amount or deprecatedQuantity, but the constructor only looked at quantity
  2. Writing: _encode() tried to set a quantity field that doesn't exist in the protobuf schema, causing the error: .pcov.proto.ListItem#quantity is not a field

Solution

  • Constructor now reads: quantityPb?.amount ?? deprecatedQuantity ?? quantity
  • _encode() now writes: quantityPb: { amount: String(quantity) }

Test Coverage

Added 22 integration tests covering:

  • Adding items with/without quantity
  • Numeric and string quantities
  • Updating quantity on existing items
  • Item details, checked status, name updates
  • Multiple property updates at once
  • Item retrieval (by id/name)
  • JSON serialization
  • Input validation

Run tests with:

[email protected] ANYLIST_PASSWORD=yourpassword npm test

Test plan

  • All 22 integration tests pass
  • Adding items with quantity works
  • Updating quantity on existing items works
  • Removing items with quantity works (no more protobuf error)

🤖 Generated with Claude Code

- Fix Item constructor to read quantity from quantityPb.amount or
  deprecatedQuantity fields (protobuf format from API)
- Fix Item._encode() to properly encode quantity as quantityPb.amount
  per the ListItem protobuf schema
- Add Mocha/Chai test framework
- Add comprehensive integration tests for Item class covering:
  - Adding items with/without quantity
  - Updating quantity on existing items
  - Item details, checked status, name updates
  - Multiple property updates
  - Item retrieval and serialization
  - Input validation

Fixes the ".pcov.proto.ListItem#quantity is not a field" error when
adding or removing items with quantity set.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
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.

1 participant