fix(email-template): do not insert a duplicate template when the update fails
Problem
EmailTemplateService.saveTemplate runs the lookup and the update (super.create({ id, ...entity })) in one try, and its catch creates a new template. When the update failed (a constraint or DB error), the catch inserted a second template with the same name, language, organization and tenant.
Fix
The template is looked up on its own; only a NotFoundException (a miss) leads to creating one. An existing template is updated and any update error reaches the caller.
Tests
email-template.service.save-template.spec.ts: existing template + failing update → the error propagates, no second create; no template → created once with the expected fields; a lookup failure other than not-found propagates without creating anything.
Notes
Not built or run locally.
Summary by cubic
Fixes EmailTemplateService.saveTemplate so a failed update no longer inserts a duplicate template with the same name, language, organization, and tenant.
- The template lookup now runs on its own; only a miss (
NotFoundException) triggers a create, and update errors propagate to the caller. - Adds tests covering a failing update, a successful create when no template exists, and lookup failures that are not not-found.