Skip to content

fix(settings): track order numbering in isDirty - #1490

Merged
khaira777 merged 2 commits into
mainfrom
fm/flocafe-fix-settings-order-numbering-dirty
Nov 7, 2026
Merged

khaira777 merged 2 commits into
mainfrom
fm/flocafe-fix-settings-order-numbering-dirty

Conversation

@khaira777

@khaira777 khaira777 commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Fix F-05 (https://github.com/FreeOpenSourcePOS/FloCafe/issues/1484): In frontend/src/app/(dashboard)/settings/page.tsx:3893-3903, isDirty omits JSON.stringify(orderNumberForm) !== JSON.stringify(savedOrderNumberForm). When an admin changes only an Order & Invoice Numbering field in Settings > Store (GeneralSettingsTab), no Save/Discard bar appears and the edit is lost on navigation. Include orderNumberForm vs savedOrderNumberForm in isDirty and verify with a regression test.

Fixes #1484

What Changed

  • Included JSON.stringify(orderNumberForm) !== JSON.stringify(savedOrderNumberForm) in the SettingsPage isDirty calculation in frontend/src/app/(dashboard)/settings/page.tsx so modifying only Order & Invoice Numbering fields surfaces the Save/Discard bar and tracks unsaved state.
  • Added an E2E regression test in frontend/e2e/settings-request-budget.spec.ts verifying that editing only order or invoice numbering fields shows the Save Changes and Discard buttons and cleanly saves or discards the edits.

Risk Assessment

✅ Low: Minimal, well-bounded fix that includes orderNumberForm vs savedOrderNumberForm in SettingsPage isDirty calculation with an end-to-end regression test covering edit, discard, and save flows.

Testing

Built the backend and static frontend, ran the new Playwright regression test (Editing only order numbering marks Settings dirty and saves or discards cleanly), the order-numbering hydration test, npm run test:order-numbering-settings, and qa-settings-store-locale.spec.ts, and drove four live scenarios in Chromium against the running FloCafe E2E server with visual screenshot and API state evidence captured for dirty-bar appearance, blocked navigation on unsaved edits, Discard recovery, and Save Changes persistence across page reloads; all checks passed.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Editing only an Order & Invoice Numbering field in Settings > Store surfaces the floating Save/Discard bar ✅ pass live ~/.no-mistakes/evidence/01M6T0Z2T8FNKYN8B784NETK0Z/01-order-numbering-dirty-save-bar.png
Adversarial navigation guard blocks client-side navigation away from Settings when only Order & Invoice Numbering has unsaved edits ✅ pass live ~/.no-mistakes/evidence/01M6T0Z2T8FNKYN8B784NETK0Z/02-navigation-blocked-unsaved-order-numbering.png
Clicking Discard when only Order & Invoice Numbering was edited reloads saved values from the database and hides the Save/Discard bar ✅ pass live ~/.no-mistakes/evidence/01M6T0Z2T8FNKYN8B784NETK0Z/03-order-numbering-discarded-clean.png
Clicking Save Changes when only Order & Invoice Numbering was edited persists the values to SQLite and rehydrates them after a full page reload ✅ pass live ~/.no-mistakes/evidence/01M6T0Z2T8FNKYN8B784NETK0Z/04-order-numbering-saved-and-reloaded.png

Dirty Save/Discard bar shown when only Order Number Prefix is edited
Navigation guard blocks leaving Settings while Order Numbering edit is unsaved
Discard restores Order and Invoice Numbering fields from database and hides Save/Discard bar
Save Changes persists Order and Invoice Numbering edits and rehydrates them after full page reload

Evidence: Live verification summary JSON (API and UI state across all scenarios)
{
  "verifiedAt": "2026-11-07T03:48:35.254Z",
  "initialApi": {
    "order_number_prefix": "ORD",
    "order_number_include_date": true,
    "order_number_reset_daily": true,
    "invoice_number_prefix": "INV",
    "invoice_number_include_period": true,
    "invoice_number_reset_period": "daily",
    "invoice_financial_year_start_month": 4,
    "invoice_financial_year_start_day": 1
  },
  "scenario1_dirtyOnOrderNumberingOnlyEdit": {
    "editedOrderPrefix": "CAFE",
    "saveChangesVisible": true,
    "discardVisible": true,
    "unsavedBannerVisible": true
  },
  "scenario2_navigationGuardBlocksUnsavedExit": {
    "clickedHref": "/pos",
    "urlAfterClick": "http://127.0.0.1:3001/settings/?tab=store",
    "preservedUnsavedOrderPrefix": "CAFE"
  },
  "scenario3_discardRevertsAndClearsDirty": {
    "orderPrefixAfterDiscard": "ORD",
    "invoicePrefixAfterDiscard": "INV",
    "saveBarCountAfterDiscard": 0
  },
  "scenario4_savePersistsAndRehydratesOnReload": {
    "persistedApiResponse": {
      "order_number_prefix": "CAFE",
      "order_number_include_date": true,
      "order_number_reset_daily": true,
      "invoice_number_prefix": "BILL",
      "invoice_number_include_period": true,
      "invoice_number_reset_period": "daily",
      "invoice_financial_year_start_month": 4,
      "invoice_financial_year_start_day": 1
    },
    "reloadedOrderPrefix": "CAFE",
    "reloadedInvoicePrefix": "BILL",
    "saveBarCountAfterReload": 0
  }
}

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.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Editing only an Order & Invoice Numbering field in Settings > Store surfaces the floating Save/Discard bar ✅ pass live ~/.no-mistakes/evidence/01M6T0Z2T8FNKYN8B784NETK0Z/01-order-numbering-dirty-save-bar.png
Adversarial navigation guard blocks client-side navigation away from Settings when only Order & Invoice Numbering has unsaved edits ✅ pass live ~/.no-mistakes/evidence/01M6T0Z2T8FNKYN8B784NETK0Z/02-navigation-blocked-unsaved-order-numbering.png
Clicking Discard when only Order & Invoice Numbering was edited reloads saved values from the database and hides the Save/Discard bar ✅ pass live ~/.no-mistakes/evidence/01M6T0Z2T8FNKYN8B784NETK0Z/03-order-numbering-discarded-clean.png
Clicking Save Changes when only Order & Invoice Numbering was edited persists the values to SQLite and rehydrates them after a full page reload ✅ pass live ~/.no-mistakes/evidence/01M6T0Z2T8FNKYN8B784NETK0Z/04-order-numbering-saved-and-reloaded.png
  • cd frontend && npx playwright test e2e/settings-request-budget.spec.ts -g "Editing only order numbering marks Settings dirty and saves or discards cleanly" --config=playwright.config.ts --project=chromium
  • cd frontend && npx playwright test e2e/settings-request-budget.spec.ts -g "Save All preserves order numbering edits during hydration" --config=playwright.config.ts --project=chromium
  • npm run test:order-numbering-settings
  • cd frontend && npx playwright test e2e/qa-settings-store-locale.spec.ts --config=playwright.config.ts --project=chromium
  • Live Playwright browser verification against tests/e2e-server.cjs driving Order & Invoice Numbering dirty state, navigation guard, Discard, Save Changes, and reload persistence with screenshot capture
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Include JSON.stringify(orderNumberForm) !== JSON.stringify(savedOrderNumberForm) in the Settings page isDirty check so editing only an Order & Invoice Numbering field displays the floating Save/Discard bar.

Fixes #1484
@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Track order and invoice numbering edits as unsaved settings

🐞 Bug fix 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Include order and invoice numbering edits in Settings’ unsaved-changes detection so Save/Discard
 appears.
• Add Playwright coverage for numbering-only edits, discard recovery, and saving.
Diagram

graph TD
  Form["Numbering form"] --> Dirty{"Unsaved changes?"} -->|Yes| Bar["Save/Discard bar"] --> Save["Save all"] --> API["Settings API"]
  Snapshot["Saved values"] --> Dirty
  Bar --> Discard["Discard edits"] --> API
Loading
High-Level Assessment

Extend the existing dirty-state calculation rather than introduce separate numbering-specific controls. The existing Save/Discard and navigation-guard flows already depend on that calculation.

Files changed (2) +87 / -1

Bug fix (1) +2 / -1
page.tsxInclude numbering form in dirty-state detection +2/-1

Include numbering form in dirty-state detection

• Compares current and saved order-numbering forms in SettingsPage’s isDirty calculation. Numbering-only edits now trigger the existing unsaved-changes bar and navigation protection.

frontend/src/app/(dashboard)/settings/page.tsx

Tests (1) +85 / -0
settings-request-budget.spec.tsCover numbering-only Save/Discard behavior +85/-0

Cover numbering-only Save/Discard behavior

• Adds a mocked Playwright test that checks the action bar appears when only an order or invoice prefix changes and disappears after discard. It also verifies that saving an order-prefix edit sends the updated value and clears the dirty state.

frontend/e2e/settings-request-budget.spec.ts

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can hide the parts of a finding you never read, like the evidence or the agent prompt

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@khaira777 khaira777 changed the title fix(frontend): mark settings dirty when order numbering changes fix(settings): track order numbering in isDirty Nov 7, 2026
@khaira777
khaira777 enabled auto-merge (squash) November 7, 2026 04:08
@khaira777
khaira777 merged commit cc1379b into main Nov 7, 2026
23 checks passed
@khaira777
khaira777 deleted the fm/flocafe-fix-settings-order-numbering-dirty branch November 7, 2026 04:19
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.

fix(settings): include orderNumberForm in Settings isDirty state

1 participant