Repository: jhipster/jhipster-lite
Pull request #10833 (2024-09-14 09:16:26)

Update vue-core vitest configuration and sonar properties for front
- fix https://github.com/jhipster/jhipster-lite/issues/10822

qmonmert: @pascalgrimaud I added tests for HomeRouter #10835 but if it is unused qou can close the PR 

Patch:
diff --git a/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java b/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java
index 4183a93bc..58f02bb34 100644
--- a/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java
+++ b/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java
@@ -113,7 +113,7 @@ public class VueModulesFactory {
         .add(SOURCE.template("Dummy.spec.ts"), to("src/test/webapp/unit/Dummy.spec.ts"))
         .add(APP_SOURCE.template("test/webapp/unit/shared/http/infrastructure/secondary/AxiosHttp.spec.ts.mustache"), TEST_DESTINATION.append("unit/shared/http/infrastructure/secondary/AxiosHttp.spec.ts"))
         .add(APP_SOURCE.template("test/webapp/unit/shared/http/infrastructure/secondary/AxiosStub.ts.mustache"), TEST_DESTINATION.append("unit/shared/http/infrastructure/secondary/AxiosStub.ts"))
-        .add(APP_SOURCE.template("test/webapp/unit/router/HomeRouter.spec.ts.mustache"), TEST_DESTINATION.append("unit/router/HomeRouter.spec.ts"))
+        .add(APP_SOURCE.template("test/webapp/unit/router/infrastructure/primary/HomeRouter.spec.ts.mustache"), TEST_DESTINATION.append("unit/router/infrastructure/primary/HomeRouter.spec.ts"))
         .and()
       .build();
     //@formatter:on
diff --git a/src/main/resources/generator/client/vue/webapp/app/test/webapp/unit/router/HomeRouter.spec.ts.mustache b/src/main/resources/generator/client/vue/webapp/app/test/webapp/unit/router/infrastructure/primary/HomeRouter.spec.ts.mustache
similarity index 100%
rename from src/main/resources/generator/client/vue/webapp/app/test/webapp/unit/router/HomeRouter.spec.ts.mustache
rename to src/main/resources/generator/client/vue/webapp/app/test/webapp/unit/router/infrastructure/primary/HomeRouter.spec.ts.mustache
diff --git a/src/main/resources/generator/server/sonar/sonar-fullstack-project.properties.mustache b/src/main/resources/generator/server/sonar/sonar-fullstack-project.properties.mustache
index 19fefbb56..803641c2d 100644
--- a/src/main/resources/generator/server/sonar/sonar-fullstack-project.properties.mustache
+++ b/src/main/resources/generator/server/sonar/sonar-fullstack-project.properties.mustache
@@ -17,7 +17,13 @@ sonar.testExecutionReportPaths={{projectBuildDirectory}}/test-results/TESTS-resu
 sonar.javascript.lcov.reportPaths={{projectBuildDirectory}}/test-results/lcov.info
 
 sonar.sourceEncoding=UTF-8
-sonar.exclusions=src/main/webapp/main.ts, src/main/webapp/app/main.ts, src/main/webapp/content/**/*.*, {{projectBuildDirectory}}/classes/static/**/*.*, src/main/webapp/app/index.tsx
+sonar.exclusions=\
+  src/main/webapp/app/home/infrastructure/primary/*.*,\
+  src/main/webapp/app/*.ts,\
+  src/main/webapp/content/**/*.*,\
+  {{projectBuildDirectory}}/classes/static/**/*.*,\
+  src/main/webapp/app/index.tsx,\
+  src/main/webapp/main.ts
 
 sonar.issue.ignore.multicriteria=S117,S119,S125,S3437,S4502,S4684,S4032,S5778,S1133,S6206,S6437,S6564,UndocumentedApi
 
diff --git a/src/main/resources/generator/server/sonar/sonar-project.properties.mustache b/src/main/resources/generator/server/sonar/sonar-project.properties.mustache
index 2e78d59b9..9dcdc64e6 100644
--- a/src/main/resources/generator/server/sonar/sonar-project.properties.mustache
+++ b/src/main/resources/generator/server/sonar/sonar-project.properties.mustache
@@ -14,7 +14,12 @@ sonar.java.codeCoveragePlugin=jacoco
 sonar.junit.reportPaths={{projectBuildDirectory}}/surefire-reports,{{projectBuildDirectory}}/failsafe-reports
 
 sonar.sourceEncoding=UTF-8
-sonar.exclusions=src/main/webapp/main.ts, src/main/webapp/app/main.ts, src/main/webapp/content/**/*.*, {{projectBuildDirectory}}/classes/static/**/*.*, src/main/webapp/app/index.tsx
+sonar.exclusions=\
+  src/main/webapp/app/*.ts,\
+  src/main/webapp/content/**/*.*,\
+  {{projectBuildDirectory}}/classes/static/**/*.*,\
+  src/main/webapp/app/index.tsx,\
+  src/main/webapp/main.ts
 
 sonar.issue.ignore.multicriteria=S117,S119,S125,S3437,S4502,S4684,S4032,S5778,S1133,S6206,S6548,S6437,S6471,UndocumentedApi
 


Test patch:
diff --git a/src/main/resources/generator/client/vue/vitest.config.ts.mustache b/src/main/resources/generator/client/vue/vitest.config.ts.mustache
index 6062abddd..4f9241071 100644
--- a/src/main/resources/generator/client/vue/vitest.config.ts.mustache
+++ b/src/main/resources/generator/client/vue/vitest.config.ts.mustache
@@ -27,11 +27,24 @@ export default defineConfig({
       exclude: [
         ...configDefaults.coverage.exclude as string[],
         'src/main/webapp/app/main.ts',
+        'src/main/webapp/app/injections.ts',
+        'src/main/webapp/app/router.ts',
         'src/main/webapp/**/*.component.ts',
       ],
       provider: 'istanbul',
       reportsDirectory: '{{projectBuildDirectory}}/test-results/',
-      reporter: ['html', 'json-summary', 'text', 'text-summary', 'lcov', 'clover']
+      reporter: ['html', 'json-summary', 'text', 'text-summary', 'lcov', 'clover'],
+      thresholds: {
+        perFile: true,
+        autoUpdate: true,
+        100: true,
+      },
+      watermarks: {
+        statements: [100, 100],
+        branches: [100, 100],
+        functions: [100, 100],
+        lines: [100, 100],
+      },
     },
   },
 });
diff --git a/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java
index 30b4a5a07..9b45fda3e 100644
--- a/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java
+++ b/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java
@@ -84,7 +84,7 @@ class VueModulesFactoryTest {
       .hasFiles("src/test/webapp/unit/Dummy.spec.ts")
       .hasFiles("src/test/webapp/unit/shared/http/infrastructure/secondary/AxiosHttp.spec.ts")
       .hasFiles("src/test/webapp/unit/shared/http/infrastructure/secondary/AxiosStub.ts")
-      .hasFiles("src/test/webapp/unit/router/HomeRouter.spec.ts");
+      .hasFiles("src/test/webapp/unit/router/infrastructure/primary/HomeRouter.spec.ts");
     //@formatter:on
   }
 
diff --git a/src/test/java/tech/jhipster/lite/generator/server/sonarqube/domain/SonarQubeModulesFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/server/sonarqube/domain/SonarQubeModulesFactoryTest.java
index 409bcbba3..b7967b2ae 100644
--- a/src/test/java/tech/jhipster/lite/generator/server/sonarqube/domain/SonarQubeModulesFactoryTest.java
+++ b/src/test/java/tech/jhipster/lite/generator/server/sonarqube/domain/SonarQubeModulesFactoryTest.java
@@ -40,9 +40,7 @@ class SonarQubeModulesFactoryTest {
         .hasFile("sonar-project.properties")
         .containing("sonar.coverage.jacoco.xmlReportPaths=target/jacoco/jacoco.xml")
         .containing("sonar.junit.reportPaths=target/surefire-reports,target/failsafe-reports")
-        .containing(
-          "sonar.exclusions=src/main/webapp/main.ts, src/main/webapp/app/main.ts, src/main/webapp/content/**/*.*, target/classes/static/**/*.*, src/main/webapp/app/index.tsx"
-        )
+        .containing("sonar.exclusions=\\")
         .notContaining("sonar.testExecutionReportPaths=target/test-results/TESTS-results-sonar.xml");
     }
 
@@ -54,9 +52,7 @@ class SonarQubeModulesFactoryTest {
 
       assertCommonModule(module)
         .hasFile("sonar-project.properties")
-        .containing(
-          "sonar.exclusions=src/main/webapp/main.ts, src/main/webapp/app/main.ts, src/main/webapp/content/**/*.*, target/classes/static/**/*.*, src/main/webapp/app/index.tsx"
-        )
+        .containing("sonar.exclusions=\\")
         .containing("sonar.testExecutionReportPaths=target/test-results/TESTS-results-sonar.xml")
         .containing("sonar.javascript.lcov.reportPaths=target/test-results/lcov.info");
     }
@@ -134,9 +130,7 @@ class SonarQubeModulesFactoryTest {
 
       assertCommonModule(module)
         .hasFile("sonar-project.properties")
-        .containing(
-          "sonar.exclusions=src/main/webapp/main.ts, src/main/webapp/app/main.ts, src/main/webapp/content/**/*.*, build/classes/static/**/*.*, src/main/webapp/app/index.tsx"
-        )
+        .containing("sonar.exclusions=\\")
         .notContaining("sonar.testExecutionReportPaths=build/test-results/TESTS-results-sonar.xml");
     }
 
@@ -148,9 +142,7 @@ class SonarQubeModulesFactoryTest {
 
       assertCommonModule(module)
         .hasFile("sonar-project.properties")
-        .containing(
-          "sonar.exclusions=src/main/webapp/main.ts, src/main/webapp/app/main.ts, src/main/webapp/content/**/*.*, build/classes/static/**/*.*, src/main/webapp/app/index.tsx"
-        )
+        .containing("sonar.exclusions=\\")
         .containing("sonar.testExecutionReportPaths=build/test-results/TESTS-results-sonar.xml")
         .containing("sonar.javascript.lcov.reportPaths=build/test-results/lcov.info");
     }