Skip to content

refactor: move duplicate-name enforcement from UI layer to saveTemplate#197

Open
JuliaKalder wants to merge 1 commit into
mainfrom
fix/issue-85
Open

refactor: move duplicate-name enforcement from UI layer to saveTemplate#197
JuliaKalder wants to merge 1 commit into
mainfrom
fix/issue-85

Conversation

@JuliaKalder
Copy link
Copy Markdown
Owner

Summary

  • Adds a case-insensitive duplicate-name check to saveTemplate in modules/template-store.js; throws an error with err.code = "DUPLICATE_NAME" when a conflict is detected, so no direct caller can bypass the uniqueness rule
  • Removes the pre-save duplicate check from handleSave in options/options.js and replaces it with a catch on DUPLICATE_NAME, showing the same inline validation error as before
  • Adds 4 new tests in tests/template-store.test.js covering: new template with duplicate name, update to another template's name, keeping own name on update, and case-insensitivity

Verification

All new tests pass. The 7 pre-existing migrateV0toV1 failures are unrelated to this change (they test the input array instead of the returned templates property from .map()).

Fixes #85

Move the duplicate-name check from the UI layer (options.js) to the
data layer (template-store.js) so no direct caller of saveTemplate can
bypass it. The check is case-insensitive and throws with err.code =
"DUPLICATE_NAME". The options.js handleSave now catches that error to
show the same inline validation message as before.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

[MEDIUM] Duplicate-name uniqueness rule enforced in UI layer (options.js) instead of data layer (template-store.js)

1 participant