Repository: jhipster/jhipster-lite
Pull request #11635 (2024-12-26 08:05:06)

Set homepage as optional for vue-18next

DamnClin: I don't understand the failing test... Are there any known issue with build cache?

Patch:
diff --git a/src/main/java/tech/jhipster/lite/generator/client/vue/i18n/domain/VueI18nModuleFactory.java b/src/main/java/tech/jhipster/lite/generator/client/vue/i18n/domain/VueI18nModuleFactory.java
index 6f9ce3933..0a8f0673d 100644
--- a/src/main/java/tech/jhipster/lite/generator/client/vue/i18n/domain/VueI18nModuleFactory.java
+++ b/src/main/java/tech/jhipster/lite/generator/client/vue/i18n/domain/VueI18nModuleFactory.java
@@ -1,8 +1,7 @@
 package tech.jhipster.lite.generator.client.vue.i18n.domain;
 
 import static tech.jhipster.lite.module.domain.JHipsterModule.*;
-import static tech.jhipster.lite.module.domain.npm.JHLiteNpmVersionSource.COMMON;
-import static tech.jhipster.lite.module.domain.npm.JHLiteNpmVersionSource.VUE;
+import static tech.jhipster.lite.module.domain.npm.JHLiteNpmVersionSource.*;
 
 import tech.jhipster.lite.module.domain.JHipsterModule;
 import tech.jhipster.lite.module.domain.file.JHipsterSource;
@@ -46,9 +45,6 @@ public class VueI18nModuleFactory {
       .batch(TEST_SOURCE, to(INDEX_TEST))
         .addFile("setupTests.ts")
         .and()
-      .batch(TEST_SOURCE, to(INDEX_TEST + "webapp/unit/home/infrastructure/primary/"))
-        .addFile("HomePageVue.spec.ts")
-        .and()
       .batch(APP_SOURCE, to(INDEX_TEST + "webapp/unit"))
         .addFile("i18n.spec.ts")
         .and()
@@ -60,13 +56,15 @@ public class VueI18nModuleFactory {
           .add(lineBeforeText(PROVIDER_NEEDLE
           ), "app.use(I18NextVue, { i18next });")
         .and()
-        .in(path(INDEX + "/home/infrastructure/primary/HomepageVue.vue"))
-          .add(lineAfterRegex("Vue 3 \\+ TypeScript \\+ Vite"), properties.indentation().times(2) + "<h2 v-html=\"$t('home.translationEnabled')\"></h2>")
-        .and()
         .in(path("./vitest.config.ts"))
           .add(lineAfterRegex("test:"), properties.indentation().times(2) + "setupFiles: ['./src/test/setupTests.ts'],")
           .and()
         .and()
+      .optionalReplacements()
+        .in(path(INDEX + "/home/infrastructure/primary/HomepageVue.vue"))
+          .add(lineAfterRegex("Vue 3 \\+ TypeScript \\+ Vite"), properties.indentation().times(2) + "<h2 v-html=\"$t('home.translationEnabled')\"></h2>")
+          .and()
+        .and()
       .build();
     //@formatter:off
   }


Test patch:
diff --git a/src/main/resources/generator/client/vue/i18n/src/test/HomePageVue.spec.ts b/src/main/resources/generator/client/vue/i18n/src/test/HomePageVue.spec.ts
deleted file mode 100644
index 536fa9cff..000000000
--- a/src/main/resources/generator/client/vue/i18n/src/test/HomePageVue.spec.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import HomepageVue from '@/home/infrastructure/primary/HomepageVue.vue';
-import { shallowMount, type VueWrapper } from '@vue/test-utils';
-import { describe, expect, it } from 'vitest';
-
-let wrapper: VueWrapper;
-
-const wrap = () => {
-  wrapper = shallowMount(HomepageVue);
-};
-
-describe('App I18next', () => {
-  it('should renders with translation', () => {
-    wrap();
-
-    expect(wrapper.text()).toContain('translationEnabled');
-  });
-});
diff --git a/src/test/java/tech/jhipster/lite/generator/client/vue/i18n/domain/VueI18nModuleFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/client/vue/i18n/domain/VueI18nModuleFactoryTest.java
index 774a3b4ba..2f216cad9 100644
--- a/src/test/java/tech/jhipster/lite/generator/client/vue/i18n/domain/VueI18nModuleFactoryTest.java
+++ b/src/test/java/tech/jhipster/lite/generator/client/vue/i18n/domain/VueI18nModuleFactoryTest.java
@@ -19,14 +19,7 @@ class VueI18nModuleFactoryTest {
       JHipsterModulesFixture.propertiesBuilder(TestFileUtils.tmpDirForTest()).projectBaseName("jhipster").build()
     );
 
-    JHipsterModuleAsserter asserter = assertThatModuleWithFiles(
-      module,
-      packageJsonFile(),
-      mainFile(),
-      homepage(),
-      homepageTest(),
-      vitest()
-    );
+    JHipsterModuleAsserter asserter = assertThatModuleWithFiles(module, packageJsonFile(), mainFile(), homepage(), vitest());
     asserter
       .hasFile("package.json")
       .containing(nodeDependency("i18next"))
@@ -56,9 +49,7 @@ class VueI18nModuleFactoryTest {
       .and()
       .hasFile("src/main/webapp/app/home/locales/en.ts")
       .and()
-      .hasFile("src/main/webapp/app/home/locales/fr.ts")
-      .and()
-      .hasFile("src/test/webapp/unit/home/infrastructure/primary/HomepageVue.spec.ts");
+      .hasFile("src/main/webapp/app/home/locales/fr.ts");
   }
 
   private ModuleFile mainFile() {
@@ -72,13 +63,6 @@ class VueI18nModuleFactoryTest {
     );
   }
 
-  private ModuleFile homepageTest() {
-    return file(
-      "src/test/resources/projects/vue/HomepageVue.spec.ts.template",
-      "src/test/webapp/unit/home/infrastructure/primary/HomepageVue.spec.ts"
-    );
-  }
-
   private ModuleFile vitest() {
     return file("src/test/resources/projects/vue/vitest.config.ts.template", "./vitest.config.ts");
   }
diff --git a/src/test/resources/projects/vue/HomepageVue.spec.ts.template b/src/test/resources/projects/vue/HomepageVue.spec.ts.template
deleted file mode 100644
index 536fa9cff..000000000
--- a/src/test/resources/projects/vue/HomepageVue.spec.ts.template
+++ /dev/null
@@ -1,17 +0,0 @@
-import HomepageVue from '@/home/infrastructure/primary/HomepageVue.vue';
-import { shallowMount, type VueWrapper } from '@vue/test-utils';
-import { describe, expect, it } from 'vitest';
-
-let wrapper: VueWrapper;
-
-const wrap = () => {
-  wrapper = shallowMount(HomepageVue);
-};
-
-describe('App I18next', () => {
-  it('should renders with translation', () => {
-    wrap();
-
-    expect(wrapper.text()).toContain('translationEnabled');
-  });
-});