Repository navigation
fix(addons): honor is_active on group create - #1111
Conversation
Persist normalizeBoolean(is_active, true) ? 1 : 0 when inserting into addon_groups in POST /api/addon-groups so groups created with is_active: false are stored as inactive. Fixes #1064
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@greptile review |
|
Intent
Verify and implement the surgical fix for FreeOpenSourcePOS/FloCafe issue #1064 ("persist is_active flag when creating addon groups"): in
main/routes/addon-groups.ts,POST /api/addon-groupsomitsis_activefrom theINSERT INTO addon_groupsstatement, causing groups created withis_active: falseto always be stored as active (1). PersistnormalizeBoolean(is_active, true) ? 1 : 0on group creation. Deliver via theno-mistakespipeline as its own PR withFixes #1064in the PR summary so the issue and PR are linked.What Changed
POST /api/addon-groupsinmain/routes/addon-groups.tsto readis_activefrom the request body and persistnormalizeBoolean(is_active, true) ? 1 : 0in theINSERT INTO addon_groupsstatement.is_activerequest body field forPOST /api/addon-groupsindocs/reference/api.md.tests/issue-245-246-addon-groups.test.tsto verify thatPOST /api/addon-groupsdefaultsis_activetotrue(1) when omitted and persistsfalse(0) whenis_active: falseis supplied.Fixes #1064
Risk Assessment
✅ Low: Surgical fix that persists the normalized is_active flag on add-on group creation and adds direct API and database assertions.
Testing
Built the backend (
npm run build), executed the targeted add-on group and inventory API test suites (test:issue-245-246-addon-groups,test:category-addon-groups,test:issue-244-product-addon-links,test:issue-125-addon-reads,test:addon-inventory-api), and stood up the compiled Express server against an isolated SQLite database to drive three live scenarios coveringis_active: falsecreation, omittedis_activedefaulting totrue, and non-boolean falsyis_activeinputs (0,"false") plus child-creation rejection on newly created inactive groups; all checks and scenarios passed. This is a backend API and SQLite persistence change with no UI surface change, so API/database evidence was captured in the evidence directory.Evidence: Live API and SQLite verification transcript for POST /api/addon-groups is_active persistence
{ "serverPort": 3001, "scenario1_createInactiveBooleanFalse": { "postStatus": 201, "responseIsActive": false, "sqliteRow": { "id": "014a8e9b-d2bb-4662-8d5a-ccdf87156df6", "name": "Seasonal Toppings (Inactive)", "is_active": 0 }, "visibleInDefaultActiveList": false, "visibleInIncludeInactiveList": true }, "scenario2_createOmittedDefaultsToActive": { "postStatus": 201, "responseIsActive": true, "sqliteRow": { "id": "d267e70c-ac98-43b9-8398-0e050c3bebe4", "name": "Standard Milk Options", "is_active": 1 }, "visibleInDefaultActiveList": true }, "scenario3_adversarialFalsyAndInactiveGuard": { "numericZeroStatus": 201, "numericZeroResponseIsActive": false, "numericZeroSqliteRow": { "id": "2dc39d74-989a-4dfc-b8e7-5cc5d9895c84", "name": "Numeric Zero Inactive Group", "is_active": 0 }, "stringFalseStatus": 201, "stringFalseResponseIsActive": false, "stringFalseSqliteRow": { "id": "523ade03-a817-4272-8a7c-643149be4d0d", "name": "String False Inactive Group", "is_active": 0 }, "appendChildToNewlyCreatedInactiveGroup": { "status": 400, "data": { "error": "Cannot add add-ons to an inactive group" } } } }Evidence: Integration test suite output (tests/issue-245-246-addon-groups.test.ts)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
npm run buildnpm run test:issue-245-246-addon-groupsnpm run test:category-addon-groupsnpm run test:issue-244-product-addon-linksnpm run test:issue-125-addon-readsnpm run test:addon-inventory-apiLive HTTP and SQLite verification againstdist/main/server.js(POST /api/addon-groups,GET /api/addon-groups,GET /api/addon-groups?include_inactive=true,POST /api/addon-groups/:id/addons)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.