Repository navigation
Enable test email buttons on the permissions a test needs - #506
Merged
Merged
Conversation
A test email needs Transactional write and Templates read, since the template is read with the member's own permissions, and no contacts permission. The templates and broadcasts pages asked for Templates read and Contacts write, and the transactional notifications page did not ask for Templates read. Gate all three on the same predicate, show cc and bcc in the test dialog only with Contacts read, and list the transactional endpoints that read a template under Templates read.
Make canReadContacts required on the test dialog so a page cannot drop it, pin that a cc typed before the permission goes is not sent, say in the matrix that creating a transactional notification or changing its template needs Templates read, and tidy the translations.
transactional.update reads the template whenever the body carries channels, which every console edit sends. Also pin that a bcc typed before Contacts read goes is not sent, and refresh catalogue references.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #506 +/- ##
==========================================
- Coverage 88.77% 88.76% -0.01%
==========================================
Files 366 366
Lines 71512 71512
==========================================
- Hits 63483 63480 -3
- Misses 5398 5400 +2
- Partials 2631 2632 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Move the Fix line to the open 43.2 version and refresh catalogue references.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #503 (known, not handled there).
What changes
POST /api/transactional.testTemplatechecks Transactional write. It then reads the template with the member's own permissions, so Templates read is needed too. The contact upsert runs system-scoped, so no contacts permission is needed. Before this PR the console's Send Test Email buttons did not match:canSendTestEmailpredicate inservices/api/permissions.ts, and a sharedSendTestEmailButtonreplacing the two copies of the tooltip and button.canReadContactsprop. CC and BCC are shown, and sent, only with Contacts read, which the server requires for them.transactional.create, andtransactional.updatewhen the body carrieschannels(every console edit does), since both read the template with the member's context. The Transactional write lines say what also needs Templates read.No backend change, no migration, no environment variable.
Plan:
plans/fix-test-email-button-permissions-plan.md. Docs: Notifuse/docs#28.Tests
TestTransactionalHandler/Template Testing Permissions):templates/read.success: true.canSendTestEmailcases.SendTestEmailButton: enabled, disabled, tooltip.npx vitest run(2107 tests at the first commit).npx tsc -b,npx eslint .(warnings unchanged from dev) andnpm run build.Known, not handled
broadcasts.sendToIndividualalso reads the template with the member's context and is not listed under Templates read. No screen calls it.SendTemplateModal'swithCCAndBCCprop is still unused.