Repository navigation
Conversation
fe251ba to
782f804
Compare
NetworkTheoryAppliedResearchInstitute
left a comment
There was a problem hiding this comment.
Thanks for these, Nirmal. They're real tests: only the DynamoDB client and axios are mocked, and the inventory controller, model and translation code all run for real, with no network or AWS access.
What I checked: commit 782f804, against current main (9373310). I read both files and traced every test against main's code. I did not run them: our review setup doesn't execute PR code locally, and no Agrinet CI job runs unit tests (the hardcoded-URL check did run and pass). From reading, all 36 should pass on main. Both files go to Jest through backend/scripts/test-files.js, so plain npm test picks them up, and they don't overlap any open PR.
I also checked that the assertions catch real breaks. Each of these would fail at least one test:
- dropping
|| []at inventory_controller.js:9 - changing the 201
- loosening the
!== undefinedchecks - removing the Array.isArray guard or the missing-URL guard
- dropping toLowerCase() or dialect merging in translation.js
Nicely done.
Needed before merge:
- Please rebase onto main and push. The branch predates codeql.yml on main, so CodeQL has never run on this PR, and main's ruleset requires a CodeQL result. After the push a maintainer will approve the fork runs. Reviews have to come after that push.
- In the same push, please change backend/tests/translation.test.js:40-45. The test only gets a repeated placeholder by passing
region: '{listingTerm}', which the laterlistingTermvariable then expands. That pins re-expansion of a caller-supplied value, and a safer single-pass replace in translateMessage (translation.js:103-105 on main) would fail it. No real template repeats a placeholder. Suggestion:- use
region: 'Oaxaca'and expect'📈 High listing volume detected in Oaxaca – over 100 active listings.' - test the g flag directly with
expect(translateMessage('{a} and {a}', 'en', { a: 'x' })).toBe('x and x')
- use
Optional:
3. inventory_controller.test.js:96-109 still passes if syncExternal stops calling createInventoryItem (controller:89), because each feed item already has all 12 model fields. Adding an item like { id: 'kale', name: 'Kale', note: 'x' }, expecting defaults applied and note dropped, would cover it. Bump imported to 3 and adjust the put expectation.
4. test:106 uses toHaveBeenCalledWith(url), which requires exactly one argument, so it would fail if someone later adds a timeout to axios.get. Checking axios.get.mock.calls[0][0] would be looser.
5. The description says npm test won't pick these files up. Since cf9299f (your #183) it does. The coverage numbers were also measured on the old base, and translation.js has changed since. Please update the description after rebasing, since it may become the squash commit message.
Note, no change needed: test:58, 72-77 and 87-92 pin the current DynamoDB params: create is an unconditional put, and the stock/price updates have no existence check. That's fine for tests that record current behaviour. We read them as describing it, not endorsing it, and may tighten it later.
Clean single commit with a matching sign-off, and no new dependencies. Thanks again.
Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
782f804 to
ac34b43
Compare
Adds 37 tests for inventory handlers and translation behavior. Inventory coverage exercises model defaults, stock and price updates, external imports, missing configuration, and storage/network failures. Translation coverage exercises locale fallback, dialect inheritance, PING terminology, supplied variables, repeated placeholders, and unresolved-placeholder warnings.
External-import coverage includes a partial record, checks applied defaults and omitted unknown fields, and verifies that supplied fields survive normalization. The fetch assertion checks the destination URL while allowing request options such as timeouts. Separate translation cases cover a normal Oaxaca message and repeated placeholders without requiring caller-supplied values to be expanded again.
Rebased onto upstream main at
9373310. The PR changes only the two test files; production code, dependencies, test runners, and quality checks are unchanged relative to that base. Plaincd backend && npm testdiscovers both suites.Validation rechecked on November 13, 2026, at
ac34b438a8746a1135a7c7271d29bb6b41faa92a:cd backend && node node_modules/jest/bin/jest.js --config jest.config.js --runInBand --runTestsByPath __tests__/inventory_controller.test.js __tests__/translation.test.jsruns all 37 tests. Scoped coverage was remeasured for the inventory controller/model and translation utility../scripts/list-hardcoded-urls.shandgit diff --check 9373310afff24ca3294367e6308702446876bc2a...HEADpass.The earlier review's requested rebase, placeholder-test correction and description refresh are addressed. The import-normalization fixture and timeout-compatible fetch assertion also address its optional suggestions. Deliberate-regression and compatibility controls were rerun only in an isolated temporary copy; production code was not changed.
The PR is non-draft, conflict-free and ready for independent human review. Hosted CodeQL and hardcoded-URL checks await maintainer authorization. Local passing results do not replace those gates.
The contribution follows the fork/PR and per-commit DCO requirements in NTARI's Bug-Build-Test guide. This test-only change alters no conformance binding and makes no live AWS, external inventory-service or deployment verification claim. The author must not merge the PR.