jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.5k stars 4.02k forks source link

Applications should not delete entire User records in tests. #26226

Open mshima opened 4 months ago

mshima commented 4 months ago
Overview of the issue

Tests removes every User and Authorities in tests making more difficult to implement and test more advanced security based on Users. Liquibase and any other bootstrapped data are removed. We should avoid removing Users and Authorities in tests.

https://github.com/jhipster/generator-jhipster/blob/f0cea144428a03c0a37d4d2f19f97f81aa602a25/generators/server/templates/src/test/java/_package_/security/DomainUserDetailsServiceIT.java.ejs#L87 https://github.com/jhipster/generator-jhipster/blob/f0cea144428a03c0a37d4d2f19f97f81aa602a25/generators/server/templates/src/test/java/_package_/web/rest/AccountResourceIT.java.ejs#L150 https://github.com/jhipster/generator-jhipster/blob/f0cea144428a03c0a37d4d2f19f97f81aa602a25/generators/spring-boot/templates/src/test/java/_package_/_entityPackage_/web/rest/UserResourceIT.java.ejs#L269

Related issues
Suggest a Fix
JHipster Version(s)
JHipster configuration
Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System
mshima commented 4 months ago

It’s partially implemented. Missing reactive sql and mongodb.

mraible commented 4 months ago

Since it's related, I recently had to workaround this in my 21-Points Health project. In case others run into this with v8.4.0 and previous, here's a fix: https://github.com/mraible/21-points/pull/258/commits/caa91ba41fc03f1723f68a9ef5b22340a065eb4c.

mshima commented 4 months ago

Cache seems to be influencing in tests. Tests requiring workaround increased: https://github.com/jhipster/generator-jhipster/blob/fb2b56dfb61f5058e58d7ea3173f1d5e12aaf995/generators/spring-boot/generator.ts#L289-L294