feat: prevent admin users from deleting their own accounts
Description
This PR prevents an admin from deleting their own account while logged in. Previously, the admin could remove themselves from the app (from settings > admin) which resulted in a strange behavior. Now, a error is thrown if an admin tries to. I also updated the tests to correctly test the deletion (with a new mock and a new test case).
Related Issues
How can it be tested?
Try to delete yourself as an admin and an error shoul be thrown.
Check list before submitting
- [x] This PR is wrote in a clear language and correctly labeled
- [x] I created the related changeset for my changes with
npx changeset - [x] I have performed a self-review of my code (no debugs, no commented code, good naming, etc.)
- [x] I wrote the relative tests
- [ ] I created a PR for the documentation if necessary and attached the link to this PR
Bundle Report
Changes will decrease total bundle size by 266.12kB (-13.18%) :arrow_down:. This is within the configured threshold :white_check_mark:
Detailed changes
| Bundle name | Size | Change |
|---|---|---|
| manifest | 1.75MB | -266.12kB (-13.18%) :arrow_down: |
Affected Assets, Files, and Routes:
view changes for bundle: manifest
Assets Changed:
| Asset Name | Size Change | Total Size | Change (%) |
|---|---|---|---|
admin/main.*.js |
-1.18kB | 434.91kB | -0.27% |
admin/styles.*.css |
-185.72kB | 349.47kB | -34.7% |
assets/dummy-image.jpg |
-46.32kB | 118.71kB | -28.07% |
admin/45.*.js |
12 bytes | 14.6kB | 0.08% |
assets/dummy-invoice.pdf |
-32.91kB | 10.72kB | -75.43% |
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 85.27%. Comparing base (
cb0f178) to head (baef673). Report is 25 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #321 +/- ##
=======================================
Coverage 85.27% 85.27%
=======================================
Files 57 57
Lines 1623 1623
Branches 373 364 -9
=======================================
Hits 1384 1384
- Misses 215 233 +18
+ Partials 24 6 -18
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Hello @Trighap52 thanks for your contribution.
There is a conflict that has to be resolved. Can you check it ? Also we would need to add tests for this behavior.
@Trighap52 are you still working on this? If not, I’d be happy to pick it up and help move it forward
@sahithvibudhi there is no news form @Trighap52 so you can take it from here if you want. Beware as the master branch changed quite a lot during that time, I suggest to start again from the last master version