From b4a9c5aa3b0140216359dc0f8a80556eb9c60297 Mon Sep 17 00:00:00 2001 From: Quentin France Date: Sat, 30 Apr 2022 16:19:15 +0200 Subject: [PATCH] Frontend: Add GeneratorButton styled with HistoryStore --- src/main/webapp/app/common/domain/Service.ts | 1 + .../webapp/app/common/primary/HistoryStore.ts | 5 + .../app/common/secondary/RestServiceId.ts | 2 + .../springboot/primary/Generator.component.ts | 12 +- .../primary/generator/ServiceProjection.ts | 148 ++++++++++++++++++ .../AngularGenerator.component.ts | 4 +- .../angular-generator/AngularGenerator.vue | 7 +- .../angular-generator/index.ts | 0 .../GeneratorButton.component.ts | 37 +++++ .../generator-button/GeneratorButton.vue | 11 ++ .../generator/generator-button/index.ts | 4 + .../ProjectGenerator.component.ts | 4 +- .../project-generator/ProjectGenerator.vue | 58 +++++++ .../project-generator/index.ts | 0 .../ReactGenerator.component.ts | 4 +- .../react-generator/ReactGenerator.vue | 6 +- .../{ => generator}/react-generator/index.ts | 0 .../SpringBootGenerator.component.ts | 4 +- .../SpringBootGenerator.vue | 81 ++++++++++ .../spring-boot-generator/index.ts | 2 +- .../SvelteGenerator.component.ts | 0 .../svelte-generator/SvelteGenerator.vue | 0 .../{ => generator}/svelte-generator/index.ts | 0 .../vue-generator/VueGenerator.component.ts | 4 +- .../vue-generator/VueGenerator.vue | 7 +- .../{ => generator}/vue-generator/index.ts | 0 .../project-generator/ProjectGenerator.vue | 58 ------- .../SpringbootGenerator.vue | 96 ------------ .../cypress/integration/Generator.spec.ts | 33 ++-- .../spec/common/primary/HistoryStore.spec.ts | 21 +++ .../common/secondary/RestServiceId.spec.ts | 1 + .../generator/ServiceProjection.spec.ts | 68 ++++++++ .../AngularGenerator.spec.ts | 19 ++- .../generator-button/GeneratorButton.spec.ts | 80 ++++++++++ .../ProjectGenerator.spec.ts | 84 ++++------ .../react-generator/ReactGenerator.spec.ts | 25 ++- .../SpringBootGenerator.spec.ts | 127 ++++++--------- .../svelte-generator/SvelteGenerator.spec.ts | 4 +- .../vue-generator/VueGenerator.spec.ts | 25 ++- 39 files changed, 670 insertions(+), 372 deletions(-) create mode 100644 src/main/webapp/app/springboot/primary/generator/ServiceProjection.ts rename src/main/webapp/app/springboot/primary/{ => generator}/angular-generator/AngularGenerator.component.ts (89%) rename src/main/webapp/app/springboot/primary/{ => generator}/angular-generator/AngularGenerator.vue (53%) rename src/main/webapp/app/springboot/primary/{ => generator}/angular-generator/index.ts (100%) create mode 100644 src/main/webapp/app/springboot/primary/generator/generator-button/GeneratorButton.component.ts create mode 100644 src/main/webapp/app/springboot/primary/generator/generator-button/GeneratorButton.vue create mode 100644 src/main/webapp/app/springboot/primary/generator/generator-button/index.ts rename src/main/webapp/app/springboot/primary/{ => generator}/project-generator/ProjectGenerator.component.ts (96%) create mode 100644 src/main/webapp/app/springboot/primary/generator/project-generator/ProjectGenerator.vue rename src/main/webapp/app/springboot/primary/{ => generator}/project-generator/index.ts (100%) rename src/main/webapp/app/springboot/primary/{ => generator}/react-generator/ReactGenerator.component.ts (92%) rename src/main/webapp/app/springboot/primary/{ => generator}/react-generator/ReactGenerator.vue (85%) rename src/main/webapp/app/springboot/primary/{ => generator}/react-generator/index.ts (100%) rename src/main/webapp/app/springboot/primary/{ => generator}/spring-boot-generator/SpringBootGenerator.component.ts (97%) create mode 100644 src/main/webapp/app/springboot/primary/generator/spring-boot-generator/SpringBootGenerator.vue rename src/main/webapp/app/springboot/primary/{ => generator}/spring-boot-generator/index.ts (68%) rename src/main/webapp/app/springboot/primary/{ => generator}/svelte-generator/SvelteGenerator.component.ts (100%) rename src/main/webapp/app/springboot/primary/{ => generator}/svelte-generator/SvelteGenerator.vue (100%) rename src/main/webapp/app/springboot/primary/{ => generator}/svelte-generator/index.ts (100%) rename src/main/webapp/app/springboot/primary/{ => generator}/vue-generator/VueGenerator.component.ts (92%) rename src/main/webapp/app/springboot/primary/{ => generator}/vue-generator/VueGenerator.vue (77%) rename src/main/webapp/app/springboot/primary/{ => generator}/vue-generator/index.ts (100%) delete mode 100644 src/main/webapp/app/springboot/primary/project-generator/ProjectGenerator.vue create mode 100644 src/test/javascript/spec/springboot/primary/generator/ServiceProjection.spec.ts rename src/test/javascript/spec/springboot/primary/{ => generator}/angular-generator/AngularGenerator.spec.ts (80%) create mode 100644 src/test/javascript/spec/springboot/primary/generator/generator-button/GeneratorButton.spec.ts rename src/test/javascript/spec/springboot/primary/{ => generator}/project-generator/ProjectGenerator.spec.ts (84%) rename src/test/javascript/spec/springboot/primary/{ => generator}/react-generator/ReactGenerator.spec.ts (82%) rename src/test/javascript/spec/springboot/primary/{ => generator}/spring-boot-generator/SpringBootGenerator.spec.ts (82%) rename src/test/javascript/spec/springboot/primary/{ => generator}/svelte-generator/SvelteGenerator.spec.ts (79%) rename src/test/javascript/spec/springboot/primary/{ => generator}/vue-generator/VueGenerator.spec.ts (82%) diff --git a/src/main/webapp/app/common/domain/Service.ts b/src/main/webapp/app/common/domain/Service.ts index 9a2407843b5..1f0521b8abe 100644 --- a/src/main/webapp/app/common/domain/Service.ts +++ b/src/main/webapp/app/common/domain/Service.ts @@ -11,6 +11,7 @@ export enum Service { MARIADB = 'MARIADB', MYSQL = 'MYSQL', MONGODB = 'MONGODB', + MONGOCK = 'MONGOCK', POSTGRESQL = 'POSTGRESQL', SONAR_JAVA_BACKEND = 'SONAR_JAVA_BACKEND', SONAR_JAVA_BACKEND_AND_FRONTEND = 'SONAR_JAVA_BACKEND_AND_FRONTEND', diff --git a/src/main/webapp/app/common/primary/HistoryStore.ts b/src/main/webapp/app/common/primary/HistoryStore.ts index 8d8780bc737..08e3ba248bd 100644 --- a/src/main/webapp/app/common/primary/HistoryStore.ts +++ b/src/main/webapp/app/common/primary/HistoryStore.ts @@ -1,5 +1,6 @@ import { defineStore } from 'pinia'; import { History } from '@/common/domain/History'; +import { Service } from '@/common/domain/Service'; const emptyHistory = (): History => ({ services: [], @@ -14,6 +15,10 @@ export const useHistoryStore = defineStore('HistoryStore', { getters: { getHistory: state => state.history, + hasCalledService: + state => + (service: Service): boolean => + state.history.services.includes(service), }, actions: { diff --git a/src/main/webapp/app/common/secondary/RestServiceId.ts b/src/main/webapp/app/common/secondary/RestServiceId.ts index 3b982f4c518..c7dbbb19847 100644 --- a/src/main/webapp/app/common/secondary/RestServiceId.ts +++ b/src/main/webapp/app/common/secondary/RestServiceId.ts @@ -26,6 +26,8 @@ export const toService = (restServiceId: RestServiceId): Service => { return Service.MAVEN_JAVA; case 'mongodb': return Service.MONGODB; + case 'mongock': + return Service.MONGOCK; case 'mysql': return Service.MYSQL; case 'postgresql': diff --git a/src/main/webapp/app/springboot/primary/Generator.component.ts b/src/main/webapp/app/springboot/primary/Generator.component.ts index 5620b22d803..630ecc5734d 100644 --- a/src/main/webapp/app/springboot/primary/Generator.component.ts +++ b/src/main/webapp/app/springboot/primary/Generator.component.ts @@ -1,14 +1,14 @@ import { defineComponent, ref } from 'vue'; import { ProjectToUpdate } from '@/springboot/primary/ProjectToUpdate'; -import { AngularGeneratorVue } from '@/springboot/primary/angular-generator'; -import { ReactGeneratorVue } from '@/springboot/primary/react-generator'; -import { VueGeneratorVue } from '@/springboot/primary/vue-generator'; -import { SvelteGeneratorVue } from '@/springboot/primary/svelte-generator'; -import { SpringBootGeneratorVue } from '@/springboot/primary/spring-boot-generator'; +import { AngularGeneratorVue } from '@/springboot/primary/generator/angular-generator'; +import { ReactGeneratorVue } from '@/springboot/primary/generator/react-generator'; +import { VueGeneratorVue } from '@/springboot/primary/generator/vue-generator'; +import { SvelteGeneratorVue } from '@/springboot/primary/generator/svelte-generator'; +import { SpringBootGeneratorVue } from '@/springboot/primary/generator/spring-boot-generator'; import { DefaultButtonVue } from '@/common/primary/default-button'; import { HeaderVue } from '@/springboot/primary/header'; import { IconVue } from '@/common/primary/icon'; -import { ProjectGeneratorVue } from '@/springboot/primary/project-generator'; +import { ProjectGeneratorVue } from '@/springboot/primary/generator/project-generator'; export default defineComponent({ name: 'GeneratorComponent', diff --git a/src/main/webapp/app/springboot/primary/generator/ServiceProjection.ts b/src/main/webapp/app/springboot/primary/generator/ServiceProjection.ts new file mode 100644 index 00000000000..f25f38e81b3 --- /dev/null +++ b/src/main/webapp/app/springboot/primary/generator/ServiceProjection.ts @@ -0,0 +1,148 @@ +import { Service } from '@/common/domain/Service'; + +export type ServiceProjection = + | 'aop-logging' + | 'angular' + | 'download' + | 'initialization' + | 'frontend-maven-plugin' + | 'jacoco-check-minimal-coverage' + | 'java-base' + | 'logstash' + | 'maven-java' + | 'mariadb' + | 'mysql' + | 'mongodb' + | 'mongock' + | 'postgresql' + | 'sonar-java-backend' + | 'sonar-java-backend-and-frontend' + | 'spring-boot' + | 'spring-boot-actuator' + | 'spring-boot-jwt' + | 'spring-boot-jwt-with-basic-authentication' + | 'spring-boot-mvc-with-tomcat' + | 'spring-boot-webflux-netty' + | 'react' + | 'react-styled' + | 'vue' + | 'vue-styled' + | 'unknown'; + +export const toServiceProjection = (service: Service): ServiceProjection => { + switch (service) { + case Service.AOP_LOGGING: + return 'aop-logging'; + case Service.ANGULAR: + return 'angular'; + case Service.DOWNLOAD: + return 'download'; + case Service.INITIALIZATION: + return 'initialization'; + case Service.FRONTEND_MAVEN_PLUGIN: + return 'frontend-maven-plugin'; + case Service.JACOCO_CHECK_MINIMAL_COVERAGE: + return 'jacoco-check-minimal-coverage'; + case Service.JAVA_BASE: + return 'java-base'; + case Service.LOGSTASH: + return 'logstash'; + case Service.MAVEN_JAVA: + return 'maven-java'; + case Service.MARIADB: + return 'mariadb'; + case Service.MYSQL: + return 'mysql'; + case Service.MONGODB: + return 'mongodb'; + case Service.MONGOCK: + return 'mongock'; + case Service.POSTGRESQL: + return 'postgresql'; + case Service.SONAR_JAVA_BACKEND: + return 'sonar-java-backend'; + case Service.SONAR_JAVA_BACKEND_AND_FRONTEND: + return 'sonar-java-backend-and-frontend'; + case Service.SPRINGBOOT: + return 'spring-boot'; + case Service.SPRINGBOOT_ACTUATOR: + return 'spring-boot-actuator'; + case Service.SPRINGBOOT_JWT: + return 'spring-boot-jwt'; + case Service.SPRINGBOOT_JWT_WITH_BASIC_AUTHENTICATION: + return 'spring-boot-jwt-with-basic-authentication'; + case Service.SPRINGBOOT_MVC_WITH_TOMCAT: + return 'spring-boot-mvc-with-tomcat'; + case Service.SPRINGBOOT_WEBFLUX_NETTY: + return 'spring-boot-webflux-netty'; + case Service.REACT: + return 'react'; + case Service.REACT_STYLED: + return 'react-styled'; + case Service.VUE: + return 'vue'; + case Service.VUE_STYLED: + return 'vue-styled'; + case Service.UNKNOWN: + return 'unknown'; + } +}; + +export const fromServiceProjection = (serviceProjection: ServiceProjection): Service => { + switch (serviceProjection) { + case 'aop-logging': + return Service.AOP_LOGGING; + case 'angular': + return Service.ANGULAR; + case 'download': + return Service.DOWNLOAD; + case 'initialization': + return Service.INITIALIZATION; + case 'frontend-maven-plugin': + return Service.FRONTEND_MAVEN_PLUGIN; + case 'jacoco-check-minimal-coverage': + return Service.JACOCO_CHECK_MINIMAL_COVERAGE; + case 'java-base': + return Service.JAVA_BASE; + case 'logstash': + return Service.LOGSTASH; + case 'maven-java': + return Service.MAVEN_JAVA; + case 'mariadb': + return Service.MARIADB; + case 'mysql': + return Service.MYSQL; + case 'mongodb': + return Service.MONGODB; + case 'mongock': + return Service.MONGOCK; + case 'postgresql': + return Service.POSTGRESQL; + case 'sonar-java-backend': + return Service.SONAR_JAVA_BACKEND; + case 'sonar-java-backend-and-frontend': + return Service.SONAR_JAVA_BACKEND_AND_FRONTEND; + case 'spring-boot': + return Service.SPRINGBOOT; + case 'spring-boot-actuator': + return Service.SPRINGBOOT_ACTUATOR; + case 'spring-boot-jwt': + return Service.SPRINGBOOT_JWT; + case 'spring-boot-jwt-with-basic-authentication': + return Service.SPRINGBOOT_JWT_WITH_BASIC_AUTHENTICATION; + case 'spring-boot-mvc-with-tomcat': + return Service.SPRINGBOOT_MVC_WITH_TOMCAT; + case 'spring-boot-webflux-netty': + return Service.SPRINGBOOT_WEBFLUX_NETTY; + case 'react': + return Service.REACT; + case 'react-styled': + return Service.REACT_STYLED; + case 'vue': + return Service.VUE; + case 'vue-styled': + return Service.VUE_STYLED; + case 'unknown': + return Service.UNKNOWN; + } +}; diff --git a/src/main/webapp/app/springboot/primary/angular-generator/AngularGenerator.component.ts b/src/main/webapp/app/springboot/primary/generator/angular-generator/AngularGenerator.component.ts similarity index 89% rename from src/main/webapp/app/springboot/primary/angular-generator/AngularGenerator.component.ts rename to src/main/webapp/app/springboot/primary/generator/angular-generator/AngularGenerator.component.ts index e81f8da3244..853bd52f79b 100644 --- a/src/main/webapp/app/springboot/primary/angular-generator/AngularGenerator.component.ts +++ b/src/main/webapp/app/springboot/primary/generator/angular-generator/AngularGenerator.component.ts @@ -2,13 +2,13 @@ import { defineComponent, inject } from 'vue'; import { AngularService } from '@/springboot/domain/client/AngularService'; import { ProjectToUpdate, toProject } from '@/springboot/primary/ProjectToUpdate'; import { Logger } from '@/common/domain/Logger'; -import { DefaultButtonVue } from '@/common/primary/default-button'; +import { GeneratorButtonVue } from '@/springboot/primary/generator/generator-button'; export default defineComponent({ name: 'AngularGeneratorComponent', components: { - DefaultButtonVue, + GeneratorButtonVue, }, props: { diff --git a/src/main/webapp/app/springboot/primary/angular-generator/AngularGenerator.vue b/src/main/webapp/app/springboot/primary/generator/angular-generator/AngularGenerator.vue similarity index 53% rename from src/main/webapp/app/springboot/primary/angular-generator/AngularGenerator.vue rename to src/main/webapp/app/springboot/primary/generator/angular-generator/AngularGenerator.vue index 7e1300d49b7..16f24d7ccb8 100644 --- a/src/main/webapp/app/springboot/primary/angular-generator/AngularGenerator.vue +++ b/src/main/webapp/app/springboot/primary/generator/angular-generator/AngularGenerator.vue @@ -1,11 +1,6 @@ diff --git a/src/main/webapp/app/springboot/primary/angular-generator/index.ts b/src/main/webapp/app/springboot/primary/generator/angular-generator/index.ts similarity index 100% rename from src/main/webapp/app/springboot/primary/angular-generator/index.ts rename to src/main/webapp/app/springboot/primary/generator/angular-generator/index.ts diff --git a/src/main/webapp/app/springboot/primary/generator/generator-button/GeneratorButton.component.ts b/src/main/webapp/app/springboot/primary/generator/generator-button/GeneratorButton.component.ts new file mode 100644 index 00000000000..4b5b910ca43 --- /dev/null +++ b/src/main/webapp/app/springboot/primary/generator/generator-button/GeneratorButton.component.ts @@ -0,0 +1,37 @@ +import { computed, defineComponent, inject } from 'vue'; +import { DefaultButtonVue } from '@/common/primary/default-button'; +import { StoreGeneric } from 'pinia'; +import { fromServiceProjection, ServiceProjection } from '@/springboot/primary/generator/ServiceProjection'; + +export default defineComponent({ + name: 'GeneratorButtonComponent', + + components: { + DefaultButtonVue, + }, + + props: { + label: { + type: String, + required: true, + }, + service: { + type: String, + required: true, + }, + selectorPrefix: { + type: String, + required: true, + }, + }, + + setup(props) { + const historyStore = inject('historyStore') as StoreGeneric; + + const hasCalledService = computed(() => historyStore.hasCalledService(fromServiceProjection(props.service as ServiceProjection))); + + return { + hasCalledService, + }; + }, +}); diff --git a/src/main/webapp/app/springboot/primary/generator/generator-button/GeneratorButton.vue b/src/main/webapp/app/springboot/primary/generator/generator-button/GeneratorButton.vue new file mode 100644 index 00000000000..f8489581cdd --- /dev/null +++ b/src/main/webapp/app/springboot/primary/generator/generator-button/GeneratorButton.vue @@ -0,0 +1,11 @@ + + + diff --git a/src/main/webapp/app/springboot/primary/generator/generator-button/index.ts b/src/main/webapp/app/springboot/primary/generator/generator-button/index.ts new file mode 100644 index 00000000000..d3ea36752d5 --- /dev/null +++ b/src/main/webapp/app/springboot/primary/generator/generator-button/index.ts @@ -0,0 +1,4 @@ +import GeneratorButtonComponent from './GeneratorButton.component'; +import GeneratorButtonVue from './GeneratorButton.vue'; + +export { GeneratorButtonComponent, GeneratorButtonVue }; diff --git a/src/main/webapp/app/springboot/primary/project-generator/ProjectGenerator.component.ts b/src/main/webapp/app/springboot/primary/generator/project-generator/ProjectGenerator.component.ts similarity index 96% rename from src/main/webapp/app/springboot/primary/project-generator/ProjectGenerator.component.ts rename to src/main/webapp/app/springboot/primary/generator/project-generator/ProjectGenerator.component.ts index bdaee339627..0b19f9a670b 100644 --- a/src/main/webapp/app/springboot/primary/project-generator/ProjectGenerator.component.ts +++ b/src/main/webapp/app/springboot/primary/generator/project-generator/ProjectGenerator.component.ts @@ -1,15 +1,15 @@ import { defineComponent, inject } from 'vue'; import { ProjectToUpdate, toProject } from '@/springboot/primary/ProjectToUpdate'; import { Logger } from '@/common/domain/Logger'; -import { DefaultButtonVue } from '@/common/primary/default-button'; import { ProjectService } from '@/springboot/domain/ProjectService'; import { FileDownloader } from '@/common/primary/FileDownloader'; +import { GeneratorButtonVue } from '@/springboot/primary/generator/generator-button'; export default defineComponent({ name: 'ProjectGeneratorComponent', components: { - DefaultButtonVue, + GeneratorButtonVue, }, props: { diff --git a/src/main/webapp/app/springboot/primary/generator/project-generator/ProjectGenerator.vue b/src/main/webapp/app/springboot/primary/generator/project-generator/ProjectGenerator.vue new file mode 100644 index 00000000000..3589763cf59 --- /dev/null +++ b/src/main/webapp/app/springboot/primary/generator/project-generator/ProjectGenerator.vue @@ -0,0 +1,58 @@ + + + diff --git a/src/main/webapp/app/springboot/primary/project-generator/index.ts b/src/main/webapp/app/springboot/primary/generator/project-generator/index.ts similarity index 100% rename from src/main/webapp/app/springboot/primary/project-generator/index.ts rename to src/main/webapp/app/springboot/primary/generator/project-generator/index.ts diff --git a/src/main/webapp/app/springboot/primary/react-generator/ReactGenerator.component.ts b/src/main/webapp/app/springboot/primary/generator/react-generator/ReactGenerator.component.ts similarity index 92% rename from src/main/webapp/app/springboot/primary/react-generator/ReactGenerator.component.ts rename to src/main/webapp/app/springboot/primary/generator/react-generator/ReactGenerator.component.ts index 0f96f372e8b..797fac79d99 100644 --- a/src/main/webapp/app/springboot/primary/react-generator/ReactGenerator.component.ts +++ b/src/main/webapp/app/springboot/primary/generator/react-generator/ReactGenerator.component.ts @@ -2,13 +2,13 @@ import { defineComponent, inject, ref } from 'vue'; import { ProjectToUpdate, toProject } from '@/springboot/primary/ProjectToUpdate'; import { Logger } from '@/common/domain/Logger'; import { ReactService } from '@/springboot/domain/client/ReactService'; -import { DefaultButtonVue } from '@/common/primary/default-button'; +import { GeneratorButtonVue } from '@/springboot/primary/generator/generator-button'; export default defineComponent({ name: 'ReactGeneratorComponent', components: { - DefaultButtonVue, + GeneratorButtonVue, }, props: { diff --git a/src/main/webapp/app/springboot/primary/react-generator/ReactGenerator.vue b/src/main/webapp/app/springboot/primary/generator/react-generator/ReactGenerator.vue similarity index 85% rename from src/main/webapp/app/springboot/primary/react-generator/ReactGenerator.vue rename to src/main/webapp/app/springboot/primary/generator/react-generator/ReactGenerator.vue index e017f1936d6..f33162ce734 100644 --- a/src/main/webapp/app/springboot/primary/react-generator/ReactGenerator.vue +++ b/src/main/webapp/app/springboot/primary/generator/react-generator/ReactGenerator.vue @@ -15,10 +15,10 @@ - diff --git a/src/main/webapp/app/springboot/primary/react-generator/index.ts b/src/main/webapp/app/springboot/primary/generator/react-generator/index.ts similarity index 100% rename from src/main/webapp/app/springboot/primary/react-generator/index.ts rename to src/main/webapp/app/springboot/primary/generator/react-generator/index.ts diff --git a/src/main/webapp/app/springboot/primary/spring-boot-generator/SpringBootGenerator.component.ts b/src/main/webapp/app/springboot/primary/generator/spring-boot-generator/SpringBootGenerator.component.ts similarity index 97% rename from src/main/webapp/app/springboot/primary/spring-boot-generator/SpringBootGenerator.component.ts rename to src/main/webapp/app/springboot/primary/generator/spring-boot-generator/SpringBootGenerator.component.ts index 1a6e1d14823..baf408a06b8 100644 --- a/src/main/webapp/app/springboot/primary/spring-boot-generator/SpringBootGenerator.component.ts +++ b/src/main/webapp/app/springboot/primary/generator/spring-boot-generator/SpringBootGenerator.component.ts @@ -2,13 +2,13 @@ import { defineComponent, inject } from 'vue'; import { ProjectToUpdate, toProject } from '@/springboot/primary/ProjectToUpdate'; import { Logger } from '@/common/domain/Logger'; import { SpringBootService } from '@/springboot/domain/SpringBootService'; -import { DefaultButtonVue } from '@/common/primary/default-button'; +import { GeneratorButtonVue } from '@/springboot/primary/generator/generator-button'; export default defineComponent({ name: 'SpringBootGeneratorComponent', components: { - DefaultButtonVue, + GeneratorButtonVue, }, props: { diff --git a/src/main/webapp/app/springboot/primary/generator/spring-boot-generator/SpringBootGenerator.vue b/src/main/webapp/app/springboot/primary/generator/spring-boot-generator/SpringBootGenerator.vue new file mode 100644 index 00000000000..829bb4fd4e5 --- /dev/null +++ b/src/main/webapp/app/springboot/primary/generator/spring-boot-generator/SpringBootGenerator.vue @@ -0,0 +1,81 @@ + + + diff --git a/src/main/webapp/app/springboot/primary/spring-boot-generator/index.ts b/src/main/webapp/app/springboot/primary/generator/spring-boot-generator/index.ts similarity index 68% rename from src/main/webapp/app/springboot/primary/spring-boot-generator/index.ts rename to src/main/webapp/app/springboot/primary/generator/spring-boot-generator/index.ts index eb3b45d487f..6cf5ebb0e90 100644 --- a/src/main/webapp/app/springboot/primary/spring-boot-generator/index.ts +++ b/src/main/webapp/app/springboot/primary/generator/spring-boot-generator/index.ts @@ -1,4 +1,4 @@ import SpringBootGeneratorComponent from './SpringBootGenerator.component'; -import SpringBootGeneratorVue from './SpringbootGenerator.vue'; +import SpringBootGeneratorVue from './SpringBootGenerator.vue'; export { SpringBootGeneratorComponent, SpringBootGeneratorVue }; diff --git a/src/main/webapp/app/springboot/primary/svelte-generator/SvelteGenerator.component.ts b/src/main/webapp/app/springboot/primary/generator/svelte-generator/SvelteGenerator.component.ts similarity index 100% rename from src/main/webapp/app/springboot/primary/svelte-generator/SvelteGenerator.component.ts rename to src/main/webapp/app/springboot/primary/generator/svelte-generator/SvelteGenerator.component.ts diff --git a/src/main/webapp/app/springboot/primary/svelte-generator/SvelteGenerator.vue b/src/main/webapp/app/springboot/primary/generator/svelte-generator/SvelteGenerator.vue similarity index 100% rename from src/main/webapp/app/springboot/primary/svelte-generator/SvelteGenerator.vue rename to src/main/webapp/app/springboot/primary/generator/svelte-generator/SvelteGenerator.vue diff --git a/src/main/webapp/app/springboot/primary/svelte-generator/index.ts b/src/main/webapp/app/springboot/primary/generator/svelte-generator/index.ts similarity index 100% rename from src/main/webapp/app/springboot/primary/svelte-generator/index.ts rename to src/main/webapp/app/springboot/primary/generator/svelte-generator/index.ts diff --git a/src/main/webapp/app/springboot/primary/vue-generator/VueGenerator.component.ts b/src/main/webapp/app/springboot/primary/generator/vue-generator/VueGenerator.component.ts similarity index 92% rename from src/main/webapp/app/springboot/primary/vue-generator/VueGenerator.component.ts rename to src/main/webapp/app/springboot/primary/generator/vue-generator/VueGenerator.component.ts index a9a0d65a546..8a84f2e8a87 100644 --- a/src/main/webapp/app/springboot/primary/vue-generator/VueGenerator.component.ts +++ b/src/main/webapp/app/springboot/primary/generator/vue-generator/VueGenerator.component.ts @@ -2,13 +2,13 @@ import { defineComponent, inject, ref } from 'vue'; import { ProjectToUpdate, toProject } from '@/springboot/primary/ProjectToUpdate'; import { Logger } from '@/common/domain/Logger'; import { VueService } from '@/springboot/domain/client/VueService'; -import { DefaultButtonVue } from '@/common/primary/default-button'; +import { GeneratorButtonVue } from '@/springboot/primary/generator/generator-button'; export default defineComponent({ name: 'VueGeneratorComponent', components: { - DefaultButtonVue, + GeneratorButtonVue, }, props: { diff --git a/src/main/webapp/app/springboot/primary/vue-generator/VueGenerator.vue b/src/main/webapp/app/springboot/primary/generator/vue-generator/VueGenerator.vue similarity index 77% rename from src/main/webapp/app/springboot/primary/vue-generator/VueGenerator.vue rename to src/main/webapp/app/springboot/primary/generator/vue-generator/VueGenerator.vue index d676c8b6d92..d7392e28b6c 100644 --- a/src/main/webapp/app/springboot/primary/vue-generator/VueGenerator.vue +++ b/src/main/webapp/app/springboot/primary/generator/vue-generator/VueGenerator.vue @@ -15,7 +15,12 @@ - + diff --git a/src/main/webapp/app/springboot/primary/vue-generator/index.ts b/src/main/webapp/app/springboot/primary/generator/vue-generator/index.ts similarity index 100% rename from src/main/webapp/app/springboot/primary/vue-generator/index.ts rename to src/main/webapp/app/springboot/primary/generator/vue-generator/index.ts diff --git a/src/main/webapp/app/springboot/primary/project-generator/ProjectGenerator.vue b/src/main/webapp/app/springboot/primary/project-generator/ProjectGenerator.vue deleted file mode 100644 index a66827ad460..00000000000 --- a/src/main/webapp/app/springboot/primary/project-generator/ProjectGenerator.vue +++ /dev/null @@ -1,58 +0,0 @@ - - - diff --git a/src/main/webapp/app/springboot/primary/spring-boot-generator/SpringbootGenerator.vue b/src/main/webapp/app/springboot/primary/spring-boot-generator/SpringbootGenerator.vue index b46dc31df66..e69de29bb2d 100644 --- a/src/main/webapp/app/springboot/primary/spring-boot-generator/SpringbootGenerator.vue +++ b/src/main/webapp/app/springboot/primary/spring-boot-generator/SpringbootGenerator.vue @@ -1,96 +0,0 @@ - - - diff --git a/src/test/javascript/cypress/integration/Generator.spec.ts b/src/test/javascript/cypress/integration/Generator.spec.ts index 44b0d85e4cd..f1063934f06 100644 --- a/src/test/javascript/cypress/integration/Generator.spec.ts +++ b/src/test/javascript/cypress/integration/Generator.spec.ts @@ -21,34 +21,35 @@ describe('Generator', () => { it('should display generator page', () => { cy.get(headerSelector('title')).contains('JHipster lite'); - cy.get(projectGeneratorSelector('init-button')).contains('Init'); - cy.get(projectGeneratorSelector('add-maven-button')).contains('Maven'); - cy.get(projectGeneratorSelector('add-jacoco-button')).contains('JaCoCo'); - cy.get(projectGeneratorSelector('add-sonar-backend-button')).contains('Sonar Backend'); - cy.get(projectGeneratorSelector('add-sonar-backend-frontend-button')).contains('Sonar Backend+Frontend'); + cy.get(projectGeneratorSelector('add-initialization-button')).contains('Init'); + cy.get(projectGeneratorSelector('add-maven-java-button')).contains('Maven'); + cy.get(projectGeneratorSelector('add-jacoco-check-minimal-coverage-button')).contains('JaCoCo'); + cy.get(projectGeneratorSelector('add-sonar-java-backend-button')).contains('Sonar Backend'); + cy.get(projectGeneratorSelector('add-sonar-java-backend-and-frontend-button')).contains('Sonar Backend+Frontend'); cy.get(projectGeneratorSelector('add-java-base-button')).contains('Java Base'); cy.get(projectGeneratorSelector('add-frontend-maven-plugin-button')).contains('Frontend Maven Plugin'); - cy.get(projectGeneratorSelector('download-button')).should('not.exist'); + cy.get(projectGeneratorSelector('add-download-button')).should('not.exist'); }); it('should display spring boot', () => { cy.get(generatorSelector('option-springboot')).check(); + cy.get(springBootGeneratorSelector('add-spring-boot-button')).contains('Spring Boot'); - cy.get(springBootGeneratorSelector('add-spring-boot-mvc-tomcat-button')).contains('Spring MVC Tomcat'); + cy.get(springBootGeneratorSelector('add-spring-boot-mvc-with-tomcat-button')).contains('Spring MVC Tomcat'); cy.get(springBootGeneratorSelector('add-spring-boot-webflux-netty-button')).contains('Spring Webflux Netty'); cy.get(springBootGeneratorSelector('add-spring-boot-actuator-button')).contains('Spring Boot Actuator'); - cy.get(springBootGeneratorSelector('add-spring-boot-aop-button')).contains('AOP Logging'); - cy.get(springBootGeneratorSelector('add-spring-boot-logstash-button')).contains('Logstash'); + cy.get(springBootGeneratorSelector('add-aop-logging-button')).contains('AOP Logging'); + cy.get(springBootGeneratorSelector('add-logstash-button')).contains('Logstash'); cy.get(springBootGeneratorSelector('add-spring-boot-jwt-button')).contains('Security JWT'); - cy.get(springBootGeneratorSelector('add-spring-boot-jwt-basic-auth-button')).contains('Security JWT Basic Auth'); + cy.get(springBootGeneratorSelector('add-spring-boot-jwt-with-basic-authentication-button')).contains('Security JWT Basic Auth'); - cy.get(springBootGeneratorSelector('add-spring-boot-database-postgresql-button')).contains('PostgreSQL'); - cy.get(springBootGeneratorSelector('add-spring-boot-database-mysql-button')).contains('MySQL'); - cy.get(springBootGeneratorSelector('add-spring-boot-database-mariadb-button')).contains('MariaDB'); - cy.get(springBootGeneratorSelector('add-spring-boot-database-mongodb-button')).contains('MongoDB'); - cy.get(springBootGeneratorSelector('add-spring-boot-database-migration-mongock-button')).contains('Mongock'); + cy.get(springBootGeneratorSelector('add-postgresql-button')).contains('PostgreSQL'); + cy.get(springBootGeneratorSelector('add-mysql-button')).contains('MySQL'); + cy.get(springBootGeneratorSelector('add-mariadb-button')).contains('MariaDB'); + cy.get(springBootGeneratorSelector('add-mongodb-button')).contains('MongoDB'); + cy.get(springBootGeneratorSelector('add-mongock-button')).contains('Mongock'); }); it('should display angular', () => { @@ -73,6 +74,6 @@ describe('Generator', () => { it('should display download button when project path is filled', () => { cy.get('#path').type('/tmp/jhlite'); - cy.get(projectGeneratorSelector('download-button')).contains('Download'); + cy.get(projectGeneratorSelector('add-download-button')).contains('Download'); }); }); diff --git a/src/test/javascript/spec/common/primary/HistoryStore.spec.ts b/src/test/javascript/spec/common/primary/HistoryStore.spec.ts index b76ee54cbef..d36e0c1b6dc 100644 --- a/src/test/javascript/spec/common/primary/HistoryStore.spec.ts +++ b/src/test/javascript/spec/common/primary/HistoryStore.spec.ts @@ -2,6 +2,7 @@ import { createPinia, setActivePinia } from 'pinia'; import { useHistoryStore } from '@/common/primary/HistoryStore'; import { History } from '@/common/domain/History'; import { createHistory } from '../domain/History.fixture'; +import { Service } from '../../../../../main/webapp/app/common/domain/Service'; describe('HistoryStore', () => { beforeEach(() => { @@ -32,4 +33,24 @@ describe('HistoryStore', () => { expect(historyStore.getHistory).toEqual(history); }); + + it('should have called service', () => { + const historyStore = useHistoryStore(); + const history = createHistory({ + services: [Service.INITIALIZATION], + }); + historyStore.setHistory(history); + + expect(historyStore.hasCalledService(Service.INITIALIZATION)).toBe(true); + }); + + it('should not have called service', () => { + const historyStore = useHistoryStore(); + const history = createHistory({ + services: [Service.INITIALIZATION], + }); + historyStore.setHistory(history); + + expect(historyStore.hasCalledService(Service.JAVA_BASE)).toBe(false); + }); }); diff --git a/src/test/javascript/spec/common/secondary/RestServiceId.spec.ts b/src/test/javascript/spec/common/secondary/RestServiceId.spec.ts index c05bfa6c6a1..060dd4185fa 100644 --- a/src/test/javascript/spec/common/secondary/RestServiceId.spec.ts +++ b/src/test/javascript/spec/common/secondary/RestServiceId.spec.ts @@ -14,6 +14,7 @@ describe('RestServiceId', () => { expect(toService('mariadb')).toEqual(Service.MARIADB); expect(toService('maven-java')).toEqual(Service.MAVEN_JAVA); expect(toService('mongodb')).toEqual(Service.MONGODB); + expect(toService('mongock')).toEqual(Service.MONGOCK); expect(toService('mysql')).toEqual(Service.MYSQL); expect(toService('postgresql')).toEqual(Service.POSTGRESQL); expect(toService('sonar-java-backend')).toEqual(Service.SONAR_JAVA_BACKEND); diff --git a/src/test/javascript/spec/springboot/primary/generator/ServiceProjection.spec.ts b/src/test/javascript/spec/springboot/primary/generator/ServiceProjection.spec.ts new file mode 100644 index 00000000000..b78e376d0a6 --- /dev/null +++ b/src/test/javascript/spec/springboot/primary/generator/ServiceProjection.spec.ts @@ -0,0 +1,68 @@ +import { Service } from '@/common/domain/Service'; +import { fromServiceProjection, ServiceProjection, toServiceProjection } from '@/springboot/primary/generator/ServiceProjection'; + +describe('ServiceProjection', () => { + it('should convert from Service to ServiceProjection', () => { + expect(toServiceProjection(Service.AOP_LOGGING)).toEqual('aop-logging'); + expect(toServiceProjection(Service.ANGULAR)).toEqual('angular'); + expect(toServiceProjection(Service.DOWNLOAD)).toEqual('download'); + expect(toServiceProjection(Service.INITIALIZATION)).toEqual('initialization'); + expect(toServiceProjection(Service.FRONTEND_MAVEN_PLUGIN)).toEqual('frontend-maven-plugin'); + expect(toServiceProjection(Service.JACOCO_CHECK_MINIMAL_COVERAGE)).toEqual('jacoco-check-minimal-coverage'); + expect(toServiceProjection(Service.JAVA_BASE)).toEqual('java-base'); + expect(toServiceProjection(Service.LOGSTASH)).toEqual('logstash'); + expect(toServiceProjection(Service.MAVEN_JAVA)).toEqual('maven-java'); + expect(toServiceProjection(Service.MARIADB)).toEqual('mariadb'); + expect(toServiceProjection(Service.MYSQL)).toEqual('mysql'); + expect(toServiceProjection(Service.MONGODB)).toEqual('mongodb'); + expect(toServiceProjection(Service.MONGOCK)).toEqual('mongock'); + expect(toServiceProjection(Service.POSTGRESQL)).toEqual('postgresql'); + expect(toServiceProjection(Service.SONAR_JAVA_BACKEND)).toEqual('sonar-java-backend'); + expect(toServiceProjection(Service.SONAR_JAVA_BACKEND_AND_FRONTEND)).toEqual('sonar-java-backend-and-frontend'); + expect(toServiceProjection(Service.SPRINGBOOT)).toEqual('spring-boot'); + expect(toServiceProjection(Service.SPRINGBOOT_ACTUATOR)).toEqual('spring-boot-actuator'); + expect(toServiceProjection(Service.SPRINGBOOT_JWT)).toEqual('spring-boot-jwt'); + expect(toServiceProjection(Service.SPRINGBOOT_JWT_WITH_BASIC_AUTHENTICATION)).toEqual( + 'spring-boot-jwt-with-basic-authentication' + ); + expect(toServiceProjection(Service.SPRINGBOOT_MVC_WITH_TOMCAT)).toEqual('spring-boot-mvc-with-tomcat'); + expect(toServiceProjection(Service.SPRINGBOOT_WEBFLUX_NETTY)).toEqual('spring-boot-webflux-netty'); + expect(toServiceProjection(Service.REACT)).toEqual('react'); + expect(toServiceProjection(Service.REACT_STYLED)).toEqual('react-styled'); + expect(toServiceProjection(Service.VUE)).toEqual('vue'); + expect(toServiceProjection(Service.VUE_STYLED)).toEqual('vue-styled'); + expect(toServiceProjection(Service.UNKNOWN)).toEqual('unknown'); + }); + + it('should convert from ServiceProjection to Service', () => { + expect(fromServiceProjection('aop-logging')).toEqual(Service.AOP_LOGGING); + expect(fromServiceProjection('angular')).toEqual(Service.ANGULAR); + expect(fromServiceProjection('download')).toEqual(Service.DOWNLOAD); + expect(fromServiceProjection('initialization')).toEqual(Service.INITIALIZATION); + expect(fromServiceProjection('frontend-maven-plugin')).toEqual(Service.FRONTEND_MAVEN_PLUGIN); + expect(fromServiceProjection('jacoco-check-minimal-coverage')).toEqual(Service.JACOCO_CHECK_MINIMAL_COVERAGE); + expect(fromServiceProjection('java-base')).toEqual(Service.JAVA_BASE); + expect(fromServiceProjection('logstash')).toEqual(Service.LOGSTASH); + expect(fromServiceProjection('maven-java')).toEqual(Service.MAVEN_JAVA); + expect(fromServiceProjection('mariadb')).toEqual(Service.MARIADB); + expect(fromServiceProjection('mysql')).toEqual(Service.MYSQL); + expect(fromServiceProjection('mongodb')).toEqual(Service.MONGODB); + expect(fromServiceProjection('mongock')).toEqual(Service.MONGOCK); + expect(fromServiceProjection('postgresql')).toEqual(Service.POSTGRESQL); + expect(fromServiceProjection('sonar-java-backend')).toEqual(Service.SONAR_JAVA_BACKEND); + expect(fromServiceProjection('sonar-java-backend-and-frontend')).toEqual(Service.SONAR_JAVA_BACKEND_AND_FRONTEND); + expect(fromServiceProjection('spring-boot')).toEqual(Service.SPRINGBOOT); + expect(fromServiceProjection('spring-boot-actuator')).toEqual(Service.SPRINGBOOT_ACTUATOR); + expect(fromServiceProjection('spring-boot-jwt')).toEqual(Service.SPRINGBOOT_JWT); + expect(fromServiceProjection('spring-boot-jwt-with-basic-authentication')).toEqual( + Service.SPRINGBOOT_JWT_WITH_BASIC_AUTHENTICATION + ); + expect(fromServiceProjection('spring-boot-mvc-with-tomcat')).toEqual(Service.SPRINGBOOT_MVC_WITH_TOMCAT); + expect(fromServiceProjection('spring-boot-webflux-netty')).toEqual(Service.SPRINGBOOT_WEBFLUX_NETTY); + expect(fromServiceProjection('react')).toEqual(Service.REACT); + expect(fromServiceProjection('react-styled')).toEqual(Service.REACT_STYLED); + expect(fromServiceProjection('vue')).toEqual(Service.VUE); + expect(fromServiceProjection('vue-styled')).toEqual(Service.VUE_STYLED); + expect(fromServiceProjection('unknown')).toEqual(Service.UNKNOWN); + }); +}); diff --git a/src/test/javascript/spec/springboot/primary/angular-generator/AngularGenerator.spec.ts b/src/test/javascript/spec/springboot/primary/generator/angular-generator/AngularGenerator.spec.ts similarity index 80% rename from src/test/javascript/spec/springboot/primary/angular-generator/AngularGenerator.spec.ts rename to src/test/javascript/spec/springboot/primary/generator/angular-generator/AngularGenerator.spec.ts index d3e805c7c5a..6f29a3d7ea3 100644 --- a/src/test/javascript/spec/springboot/primary/angular-generator/AngularGenerator.spec.ts +++ b/src/test/javascript/spec/springboot/primary/generator/angular-generator/AngularGenerator.spec.ts @@ -1,13 +1,14 @@ import { shallowMount, VueWrapper } from '@vue/test-utils'; -import { stubAngularService } from '../../domain/client/AngularService.fixture'; +import { stubAngularService } from '../../../domain/client/AngularService.fixture'; import { ProjectToUpdate } from '@/springboot/primary/ProjectToUpdate'; -import { createProjectToUpdate } from '../ProjectToUpdate.fixture'; -import { stubLogger } from '../../../common/domain/Logger.fixture'; +import { createProjectToUpdate } from '../../ProjectToUpdate.fixture'; +import { stubLogger } from '../../../../common/domain/Logger.fixture'; import { AngularService } from '@/springboot/domain/client/AngularService'; import { Logger } from '@/common/domain/Logger'; -import { AngularGeneratorVue } from '@/springboot/primary/angular-generator'; +import { AngularGeneratorVue } from '@/springboot/primary/generator/angular-generator'; let wrapper: VueWrapper; +let component: any; interface WrapperOptions { angularService: AngularService; @@ -33,6 +34,7 @@ const wrap = (wrapperOptions?: Partial) => { }, }, }); + component = wrapper.vm; }; describe('AngularGenerator', () => { @@ -47,8 +49,7 @@ describe('AngularGenerator', () => { angularService.add.resolves({}); await wrap({ angularService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#angular'); - await button.trigger('click'); + await component.addAngular(); expect(angularService.add.called).toBe(false); }); @@ -58,8 +59,7 @@ describe('AngularGenerator', () => { angularService.add.resolves({}); await wrap({ angularService, project: createProjectToUpdate({ folder: 'project/path' }) }); - const button = wrapper.find('#angular'); - await button.trigger('click'); + await component.addAngular(); const args = angularService.add.getCall(0).args[0]; expect(args).toEqual({ @@ -77,8 +77,7 @@ describe('AngularGenerator', () => { angularService.add.rejects({}); await wrap({ angularService, logger, project: createProjectToUpdate({ folder: 'path' }) }); - const initButton = wrapper.find('#angular'); - await initButton.trigger('click'); + await component.addAngular(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding Angular to project failed'); diff --git a/src/test/javascript/spec/springboot/primary/generator/generator-button/GeneratorButton.spec.ts b/src/test/javascript/spec/springboot/primary/generator/generator-button/GeneratorButton.spec.ts new file mode 100644 index 00000000000..fb0a9710f7c --- /dev/null +++ b/src/test/javascript/spec/springboot/primary/generator/generator-button/GeneratorButton.spec.ts @@ -0,0 +1,80 @@ +import { shallowMount, VueWrapper } from '@vue/test-utils'; +import { GeneratorButtonVue } from '@/springboot/primary/generator/generator-button'; +import { setActivePinia, StoreGeneric } from 'pinia'; +import { useHistoryStore } from '@/common/primary/HistoryStore'; +import { createTestingPinia } from '@pinia/testing'; +import { createHistory } from '../../../../common/domain/History.fixture'; +import { Service } from '@/common/domain/Service'; +import { ServiceProjection } from '@/springboot/primary/generator/ServiceProjection'; + +let wrapper: VueWrapper; +let component: any; + +interface WrapperOptions { + historyStore: StoreGeneric; + service: ServiceProjection; +} + +const wrap = (wrapperOptions?: Partial) => { + const { historyStore, service }: WrapperOptions = { + historyStore: useHistoryStore(), + service: 'initialization', + ...wrapperOptions, + }; + wrapper = shallowMount(GeneratorButtonVue, { + props: { + label: 'Init', + service: service, + selectorPrefix: 'prefix', + }, + global: { + provide: { + historyStore, + }, + }, + }); + component = wrapper.vm; +}; + +describe('GeneratorButton', () => { + beforeEach(() => { + const pinia = createTestingPinia(); + setActivePinia(pinia); + }); + + it('should exist', () => { + wrap(); + + expect(wrapper.exists()).toBe(true); + }); + + it('should have called service', () => { + const historyStore = useHistoryStore(); + historyStore.setHistory( + createHistory({ + services: [Service.INITIALIZATION], + }) + ); + wrap({ + historyStore, + service: 'initialization', + }); + + expect(component.hasCalledService).toBe(true); + }); + + it('should not have called service', () => { + const historyStore = useHistoryStore(); + historyStore.setHistory( + createHistory({ + services: [Service.INITIALIZATION], + }) + ); + wrap({ + historyStore, + service: 'java-base', + }); + + expect(component.hasCalledService).toBe(false); + }); +}); diff --git a/src/test/javascript/spec/springboot/primary/project-generator/ProjectGenerator.spec.ts b/src/test/javascript/spec/springboot/primary/generator/project-generator/ProjectGenerator.spec.ts similarity index 84% rename from src/test/javascript/spec/springboot/primary/project-generator/ProjectGenerator.spec.ts rename to src/test/javascript/spec/springboot/primary/generator/project-generator/ProjectGenerator.spec.ts index 7e898fd5093..062e02b343c 100644 --- a/src/test/javascript/spec/springboot/primary/project-generator/ProjectGenerator.spec.ts +++ b/src/test/javascript/spec/springboot/primary/generator/project-generator/ProjectGenerator.spec.ts @@ -1,15 +1,16 @@ import { shallowMount, VueWrapper } from '@vue/test-utils'; import { ProjectToUpdate } from '@/springboot/primary/ProjectToUpdate'; -import { createProjectToUpdate } from '../ProjectToUpdate.fixture'; -import { stubLogger } from '../../../common/domain/Logger.fixture'; +import { createProjectToUpdate } from '../../ProjectToUpdate.fixture'; +import { stubLogger } from '../../../../common/domain/Logger.fixture'; import { Logger } from '@/common/domain/Logger'; import { ProjectService } from '@/springboot/domain/ProjectService'; -import { stubProjectService } from '../../domain/ProjectService.fixture'; -import { ProjectGeneratorVue } from '@/springboot/primary/project-generator'; +import { stubProjectService } from '../../../domain/ProjectService.fixture'; +import { ProjectGeneratorVue } from '@/springboot/primary/generator/project-generator'; import { FileDownloader } from '@/common/primary/FileDownloader'; -import { stubFileDownloader } from '../../../common/primary/FileDownloader.fixture'; +import { stubFileDownloader } from '../../../../common/primary/FileDownloader.fixture'; let wrapper: VueWrapper; +let component: any; interface WrapperOptions { projectService: ProjectService; @@ -39,6 +40,7 @@ const wrap = (wrapperOptions?: Partial) => { }, }, }); + component = wrapper.vm; }; describe('ProjectGenerator', () => { @@ -53,8 +55,7 @@ describe('ProjectGenerator', () => { projectService.init.resolves({}); await wrap({ projectService, project: createProjectToUpdate({ folder: '' }) }); - const initButton = wrapper.find('#init'); - await initButton.trigger('click'); + await component.initProject(); expect(projectService.init.called).toBe(false); }); @@ -71,8 +72,7 @@ describe('ProjectGenerator', () => { }); await wrap({ projectService, project: projectToUpdate }); - const initButton = wrapper.find('#init'); - await initButton.trigger('click'); + await component.initProject(); const args = projectService.init.getCall(0).args[0]; expect(args).toEqual({ @@ -90,8 +90,7 @@ describe('ProjectGenerator', () => { projectService.init.rejects({}); await wrap({ projectService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#init'); - await initButton.trigger('click'); + await component.initProject(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Project initialization failed'); @@ -102,8 +101,7 @@ describe('ProjectGenerator', () => { projectService.addMaven.resolves({}); await wrap({ projectService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#maven'); - await button.trigger('click'); + await component.addMaven(); expect(projectService.addMaven.called).toBe(false); }); @@ -120,8 +118,7 @@ describe('ProjectGenerator', () => { }); await wrap({ projectService, project: projectToUpdate }); - const button = wrapper.find('#maven'); - await button.trigger('click'); + await component.addMaven(); const args = projectService.addMaven.getCall(0).args[0]; expect(args).toEqual({ @@ -139,8 +136,7 @@ describe('ProjectGenerator', () => { projectService.addMaven.rejects({}); await wrap({ projectService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#maven'); - await initButton.trigger('click'); + await component.addMaven(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding Maven to project failed'); @@ -151,8 +147,7 @@ describe('ProjectGenerator', () => { projectService.addJaCoCo.resolves({}); await wrap({ projectService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#jacoco'); - await button.trigger('click'); + await component.addJaCoCo(); expect(projectService.addJaCoCo.called).toBe(false); }); @@ -169,8 +164,7 @@ describe('ProjectGenerator', () => { }); await wrap({ projectService, project: projectToUpdate }); - const button = wrapper.find('#jacoco'); - await button.trigger('click'); + await component.addJaCoCo(); const args = projectService.addJaCoCo.getCall(0).args[0]; expect(args).toEqual({ @@ -188,8 +182,7 @@ describe('ProjectGenerator', () => { projectService.addJaCoCo.rejects({}); await wrap({ projectService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#jacoco'); - await initButton.trigger('click'); + await component.addJaCoCo(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding JaCoCo to project failed'); @@ -200,8 +193,7 @@ describe('ProjectGenerator', () => { projectService.addSonarBackend.resolves({}); await wrap({ projectService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#sonar-backend'); - await button.trigger('click'); + await component.addSonarBackend(); expect(projectService.addSonarBackend.called).toBe(false); }); @@ -218,8 +210,7 @@ describe('ProjectGenerator', () => { }); await wrap({ projectService, project: projectToUpdate }); - const button = wrapper.find('#sonar-backend'); - await button.trigger('click'); + await component.addSonarBackend(); const args = projectService.addSonarBackend.getCall(0).args[0]; expect(args).toEqual({ @@ -237,8 +228,7 @@ describe('ProjectGenerator', () => { projectService.addSonarBackend.rejects({}); await wrap({ projectService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#sonar-backend'); - await initButton.trigger('click'); + await component.addSonarBackend(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding Sonar Backend to project failed'); @@ -249,8 +239,7 @@ describe('ProjectGenerator', () => { projectService.addSonarBackendFrontend.resolves({}); await wrap({ projectService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#sonar-backend-frontend'); - await button.trigger('click'); + await component.addSonarBackendFrontend(); expect(projectService.addSonarBackendFrontend.called).toBe(false); }); @@ -267,8 +256,7 @@ describe('ProjectGenerator', () => { }); await wrap({ projectService, project: projectToUpdate }); - const button = wrapper.find('#sonar-backend-frontend'); - await button.trigger('click'); + await component.addSonarBackendFrontend(); const args = projectService.addSonarBackendFrontend.getCall(0).args[0]; expect(args).toEqual({ @@ -286,8 +274,7 @@ describe('ProjectGenerator', () => { projectService.addSonarBackendFrontend.rejects({}); await wrap({ projectService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#sonar-backend-frontend'); - await initButton.trigger('click'); + await component.addSonarBackendFrontend(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding Sonar Backend+Frontend to project failed'); @@ -298,8 +285,7 @@ describe('ProjectGenerator', () => { projectService.addJavaBase.resolves({}); await wrap({ projectService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#javabase'); - await button.trigger('click'); + await component.addJavaBase(); expect(projectService.addJavaBase.called).toBe(false); }); @@ -316,8 +302,7 @@ describe('ProjectGenerator', () => { }); await wrap({ projectService, project: projectToUpdate }); - const button = wrapper.find('#javabase'); - await button.trigger('click'); + await component.addJavaBase(); const args = projectService.addJavaBase.getCall(0).args[0]; expect(args).toEqual({ @@ -335,8 +320,7 @@ describe('ProjectGenerator', () => { projectService.addJavaBase.rejects({}); await wrap({ projectService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#javabase'); - await initButton.trigger('click'); + await component.addJavaBase(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding Java Base to project failed'); @@ -347,8 +331,7 @@ describe('ProjectGenerator', () => { projectService.addFrontendMavenPlugin.resolves({}); await wrap({ projectService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#frontend-maven-plugin'); - await button.trigger('click'); + await component.addFrontendMavenPlugin(); expect(projectService.addFrontendMavenPlugin.called).toBe(false); }); @@ -365,8 +348,7 @@ describe('ProjectGenerator', () => { }); await wrap({ projectService, project: projectToUpdate }); - const button = wrapper.find('#frontend-maven-plugin'); - await button.trigger('click'); + await component.addFrontendMavenPlugin(); const args = projectService.addFrontendMavenPlugin.getCall(0).args[0]; expect(args).toEqual({ @@ -384,8 +366,7 @@ describe('ProjectGenerator', () => { projectService.addFrontendMavenPlugin.rejects({}); await wrap({ projectService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#frontend-maven-plugin'); - await initButton.trigger('click'); + await component.addFrontendMavenPlugin(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding Frontend Maven Plugin to project failed'); @@ -403,8 +384,7 @@ describe('ProjectGenerator', () => { }); await wrap({ projectService, project: projectToUpdate }); - const button = wrapper.find('#download'); - await button.trigger('click'); + await component.download(); const args = projectService.download.getCall(0).args[0]; expect(args).toEqual({ @@ -428,8 +408,7 @@ describe('ProjectGenerator', () => { }); await wrap({ projectService, project: projectToUpdate }); - const button = wrapper.find('#download'); - await button.trigger('click'); + await component.download(); const args = projectService.download.getCall(0).args[0]; expect(args).toEqual({ @@ -447,8 +426,7 @@ describe('ProjectGenerator', () => { projectService.download.rejects(new Error('foo')); await wrap({ projectService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const downloadButton = wrapper.find('#download'); - await downloadButton.trigger('click'); + await component.download(); const [message, error] = logger.error.getCall(0).args; expect(message).toBe('Downloading project failed'); diff --git a/src/test/javascript/spec/springboot/primary/react-generator/ReactGenerator.spec.ts b/src/test/javascript/spec/springboot/primary/generator/react-generator/ReactGenerator.spec.ts similarity index 82% rename from src/test/javascript/spec/springboot/primary/react-generator/ReactGenerator.spec.ts rename to src/test/javascript/spec/springboot/primary/generator/react-generator/ReactGenerator.spec.ts index 60095c8c663..f0a5fbdf242 100644 --- a/src/test/javascript/spec/springboot/primary/react-generator/ReactGenerator.spec.ts +++ b/src/test/javascript/spec/springboot/primary/generator/react-generator/ReactGenerator.spec.ts @@ -1,13 +1,14 @@ import { shallowMount, VueWrapper } from '@vue/test-utils'; import { ProjectToUpdate } from '@/springboot/primary/ProjectToUpdate'; -import { createProjectToUpdate } from '../ProjectToUpdate.fixture'; -import { stubLogger } from '../../../common/domain/Logger.fixture'; +import { createProjectToUpdate } from '../../ProjectToUpdate.fixture'; +import { stubLogger } from '../../../../common/domain/Logger.fixture'; import { Logger } from '@/common/domain/Logger'; import { ReactService } from '@/springboot/domain/client/ReactService'; -import { stubReactService } from '../../domain/client/ReactService.fixture'; -import { ReactGeneratorVue } from '@/springboot/primary/react-generator'; +import { stubReactService } from '../../../domain/client/ReactService.fixture'; +import { ReactGeneratorVue } from '@/springboot/primary/generator/react-generator'; let wrapper: VueWrapper; +let component: any; interface WrapperOptions { reactService: ReactService; @@ -33,6 +34,7 @@ const wrap = (wrapperOptions?: Partial) => { }, }, }); + component = wrapper.vm; }; describe('ReactGenerator', () => { @@ -47,8 +49,7 @@ describe('ReactGenerator', () => { reactService.add.resolves({}); await wrap({ reactService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#react'); - await button.trigger('click'); + await component.addReact(); expect(reactService.add.called).toBe(false); }); @@ -58,8 +59,7 @@ describe('ReactGenerator', () => { reactService.add.resolves({}); await wrap({ reactService, project: createProjectToUpdate({ folder: 'project/path' }) }); - const button = wrapper.find('#react'); - await button.trigger('click'); + await component.addReact(); const args = reactService.add.getCall(0).args[0]; expect(args).toEqual({ @@ -78,8 +78,7 @@ describe('ReactGenerator', () => { const checkbox = wrapper.find('#react-with-style'); await checkbox.setValue(true); - const button = wrapper.find('#react'); - await button.trigger('click'); + await component.addReact(); const args = reactService.addWithStyle.getCall(0).args[0]; expect(args).toEqual({ @@ -97,8 +96,7 @@ describe('ReactGenerator', () => { reactService.add.rejects({}); await wrap({ reactService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#react'); - await initButton.trigger('click'); + await component.addReact(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding React to project failed'); @@ -112,8 +110,7 @@ describe('ReactGenerator', () => { const checkbox = wrapper.find('#react-with-style'); await checkbox.setValue(true); - const initButton = wrapper.find('#react'); - await initButton.trigger('click'); + await component.addReact(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding React with style to project failed'); diff --git a/src/test/javascript/spec/springboot/primary/spring-boot-generator/SpringBootGenerator.spec.ts b/src/test/javascript/spec/springboot/primary/generator/spring-boot-generator/SpringBootGenerator.spec.ts similarity index 82% rename from src/test/javascript/spec/springboot/primary/spring-boot-generator/SpringBootGenerator.spec.ts rename to src/test/javascript/spec/springboot/primary/generator/spring-boot-generator/SpringBootGenerator.spec.ts index 6de7f1b286d..473ac9ca613 100644 --- a/src/test/javascript/spec/springboot/primary/spring-boot-generator/SpringBootGenerator.spec.ts +++ b/src/test/javascript/spec/springboot/primary/generator/spring-boot-generator/SpringBootGenerator.spec.ts @@ -1,13 +1,14 @@ import { shallowMount, VueWrapper } from '@vue/test-utils'; import { ProjectToUpdate } from '@/springboot/primary/ProjectToUpdate'; -import { createProjectToUpdate } from '../ProjectToUpdate.fixture'; -import { stubLogger } from '../../../common/domain/Logger.fixture'; +import { createProjectToUpdate } from '../../ProjectToUpdate.fixture'; +import { stubLogger } from '../../../../common/domain/Logger.fixture'; import { Logger } from '@/common/domain/Logger'; import { SpringBootService } from '@/springboot/domain/SpringBootService'; -import { stubSpringBootService } from '../../domain/SpringBootService.fixture'; -import { SpringBootGeneratorVue } from '@/springboot/primary/spring-boot-generator'; +import { stubSpringBootService } from '../../../domain/SpringBootService.fixture'; +import { SpringBootGeneratorVue } from '@/springboot/primary/generator/spring-boot-generator'; let wrapper: VueWrapper; +let component: any; interface WrapperOptions { springBootService: SpringBootService; @@ -33,6 +34,7 @@ const wrap = (wrapperOptions?: Partial) => { }, }, }); + component = wrapper.vm; }; describe('SpringBootGenerator', () => { @@ -47,8 +49,7 @@ describe('SpringBootGenerator', () => { springBootService.addSpringBoot.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#springboot'); - await button.trigger('click'); + await component.addSpringBoot(); expect(springBootService.addSpringBoot.called).toBe(false); }); @@ -58,8 +59,7 @@ describe('SpringBootGenerator', () => { springBootService.addSpringBoot.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: 'project/path' }) }); - const button = wrapper.find('#springboot'); - await button.trigger('click'); + await component.addSpringBoot(); const args = springBootService.addSpringBoot.getCall(0).args[0]; expect(args).toEqual({ @@ -77,8 +77,7 @@ describe('SpringBootGenerator', () => { springBootService.addSpringBoot.rejects({}); await wrap({ springBootService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#springboot'); - await initButton.trigger('click'); + await component.addSpringBoot(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding SpringBoot to project failed'); @@ -89,8 +88,7 @@ describe('SpringBootGenerator', () => { springBootService.addSpringBootMvcTomcat.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#springbootmvctomcat'); - await button.trigger('click'); + await component.addSpringBootMvcTomcat(); expect(springBootService.addSpringBootMvcTomcat.called).toBe(false); }); @@ -100,8 +98,7 @@ describe('SpringBootGenerator', () => { springBootService.addSpringBootMvcTomcat.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: 'project/path' }) }); - const button = wrapper.find('#springbootmvctomcat'); - await button.trigger('click'); + await component.addSpringBootMvcTomcat(); const args = springBootService.addSpringBootMvcTomcat.getCall(0).args[0]; expect(args).toEqual({ @@ -119,8 +116,7 @@ describe('SpringBootGenerator', () => { springBootService.addSpringBootMvcTomcat.rejects({}); await wrap({ springBootService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#springbootmvctomcat'); - await initButton.trigger('click'); + await component.addSpringBootMvcTomcat(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding SpringBoot MVC with Tomcat to project failed'); @@ -131,8 +127,7 @@ describe('SpringBootGenerator', () => { springBootService.addSpringBootWebfluxNetty.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#springbootwebfluxnetty'); - await button.trigger('click'); + await component.addSpringBootWebfluxNetty(); expect(springBootService.addSpringBootWebfluxNetty.called).toBe(false); }); @@ -142,8 +137,7 @@ describe('SpringBootGenerator', () => { springBootService.addSpringBootWebfluxNetty.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: 'project/path' }) }); - const button = wrapper.find('#springbootwebfluxnetty'); - await button.trigger('click'); + await component.addSpringBootWebfluxNetty(); const args = springBootService.addSpringBootWebfluxNetty.getCall(0).args[0]; expect(args).toEqual({ @@ -161,8 +155,7 @@ describe('SpringBootGenerator', () => { springBootService.addSpringBootWebfluxNetty.rejects({}); await wrap({ springBootService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#springbootwebfluxnetty'); - await initButton.trigger('click'); + await component.addSpringBootWebfluxNetty(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding SpringBoot Webflux with Netty to project failed'); @@ -173,8 +166,7 @@ describe('SpringBootGenerator', () => { springBootService.addSpringBootActuator.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#springboot-actuator'); - await button.trigger('click'); + await component.addSpringBootActuator(); expect(springBootService.addSpringBootActuator.called).toBe(false); }); @@ -184,8 +176,7 @@ describe('SpringBootGenerator', () => { springBootService.addSpringBootActuator.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: 'project/path' }) }); - const button = wrapper.find('#springboot-actuator'); - await button.trigger('click'); + await component.addSpringBootActuator(); const args = springBootService.addSpringBootActuator.getCall(0).args[0]; expect(args).toEqual({ @@ -203,8 +194,7 @@ describe('SpringBootGenerator', () => { springBootService.addSpringBootActuator.rejects({}); await wrap({ springBootService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#springboot-actuator'); - await initButton.trigger('click'); + await component.addSpringBootActuator(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding SpringBoot Actuator to project failed'); @@ -217,8 +207,7 @@ describe('SpringBootGenerator', () => { springBootService.addSpringBootAopLogging.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#springboot-aop'); - await button.trigger('click'); + await component.addSpringBootAopLogging(); expect(springBootService.addSpringBootAopLogging.called).toBe(false); }); @@ -228,8 +217,7 @@ describe('SpringBootGenerator', () => { springBootService.addSpringBootAopLogging.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: 'project/path' }) }); - const button = wrapper.find('#springboot-aop'); - await button.trigger('click'); + await component.addSpringBootAopLogging(); const args = springBootService.addSpringBootAopLogging.getCall(0).args[0]; expect(args).toEqual({ @@ -247,8 +235,7 @@ describe('SpringBootGenerator', () => { springBootService.addSpringBootAopLogging.rejects({}); await wrap({ springBootService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#springboot-aop'); - await initButton.trigger('click'); + await component.addSpringBootAopLogging(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding SpringBoot AOP Logging to project failed'); @@ -261,8 +248,7 @@ describe('SpringBootGenerator', () => { springBootService.addSpringBootLogstash.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#springboot-logstash'); - await button.trigger('click'); + await component.addSpringBootLogstash(); expect(springBootService.addSpringBootLogstash.called).toBe(false); }); @@ -272,8 +258,7 @@ describe('SpringBootGenerator', () => { springBootService.addSpringBootLogstash.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: 'project/path' }) }); - const button = wrapper.find('#springboot-logstash'); - await button.trigger('click'); + await component.addSpringBootLogstash(); const args = springBootService.addSpringBootLogstash.getCall(0).args[0]; expect(args).toEqual({ @@ -291,8 +276,7 @@ describe('SpringBootGenerator', () => { springBootService.addSpringBootLogstash.rejects({}); await wrap({ springBootService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#springboot-logstash'); - await initButton.trigger('click'); + await component.addSpringBootLogstash(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding SpringBoot Logstash to project failed'); @@ -305,8 +289,7 @@ describe('SpringBootGenerator', () => { springBootService.addJWT.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#springboot-jwt'); - await button.trigger('click'); + await component.addSpringBootSecurityJWT(); expect(springBootService.addJWT.called).toBe(false); }); @@ -316,8 +299,7 @@ describe('SpringBootGenerator', () => { springBootService.addJWT.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: 'project/path' }) }); - const button = wrapper.find('#springboot-jwt'); - await button.trigger('click'); + await component.addSpringBootSecurityJWT(); const args = springBootService.addJWT.getCall(0).args[0]; expect(args).toEqual({ @@ -335,8 +317,7 @@ describe('SpringBootGenerator', () => { springBootService.addJWT.rejects({}); await wrap({ springBootService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#springboot-jwt'); - await initButton.trigger('click'); + await component.addSpringBootSecurityJWT(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding SpringBoot Security JWT to project failed'); @@ -347,8 +328,7 @@ describe('SpringBootGenerator', () => { springBootService.addBasicAuthJWT.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#springboot-jwt-basic-auth'); - await button.trigger('click'); + await component.addSpringBootSecurityJWTBasicAuth(); expect(springBootService.addBasicAuthJWT.called).toBe(false); }); @@ -358,8 +338,7 @@ describe('SpringBootGenerator', () => { springBootService.addBasicAuthJWT.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: 'project/path' }) }); - const button = wrapper.find('#springboot-jwt-basic-auth'); - await button.trigger('click'); + await component.addSpringBootSecurityJWTBasicAuth(); const args = springBootService.addBasicAuthJWT.getCall(0).args[0]; expect(args).toEqual({ @@ -377,8 +356,7 @@ describe('SpringBootGenerator', () => { springBootService.addBasicAuthJWT.rejects({}); await wrap({ springBootService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#springboot-jwt-basic-auth'); - await initButton.trigger('click'); + await component.addSpringBootSecurityJWTBasicAuth(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding SpringBoot Security JWT Basic Auth to project failed'); @@ -390,8 +368,7 @@ describe('SpringBootGenerator', () => { springBootService.addPostgres.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#springboot-database-postgresql'); - await button.trigger('click'); + await component.addPostgreSQL(); expect(springBootService.addPostgres.called).toBe(false); }); @@ -401,8 +378,7 @@ describe('SpringBootGenerator', () => { springBootService.addPostgres.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: 'project/path' }) }); - const button = wrapper.find('#springboot-database-postgresql'); - await button.trigger('click'); + await component.addPostgreSQL(); const args = springBootService.addPostgres.getCall(0).args[0]; expect(args).toEqual({ @@ -420,8 +396,7 @@ describe('SpringBootGenerator', () => { springBootService.addPostgres.rejects({}); await wrap({ springBootService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#springboot-database-postgresql'); - await initButton.trigger('click'); + await component.addPostgreSQL(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding SpringBoot Database PostgreSQL to project failed'); @@ -432,8 +407,7 @@ describe('SpringBootGenerator', () => { springBootService.addMySQL.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#springboot-database-mysql'); - await button.trigger('click'); + await component.addMySQL(); expect(springBootService.addMySQL.called).toBe(false); }); @@ -443,8 +417,7 @@ describe('SpringBootGenerator', () => { springBootService.addMySQL.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: 'project/path' }) }); - const button = wrapper.find('#springboot-database-mysql'); - await button.trigger('click'); + await component.addMySQL(); const args = springBootService.addMySQL.getCall(0).args[0]; expect(args).toEqual({ @@ -462,8 +435,7 @@ describe('SpringBootGenerator', () => { springBootService.addMySQL.rejects({}); await wrap({ springBootService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#springboot-database-mysql'); - await initButton.trigger('click'); + await component.addMySQL(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding SpringBoot Database MySQL to project failed'); @@ -474,8 +446,7 @@ describe('SpringBootGenerator', () => { springBootService.addMariaDB.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#springboot-database-mariadb'); - await button.trigger('click'); + await component.addMariaDB(); expect(springBootService.addMariaDB.called).toBe(false); }); @@ -485,8 +456,7 @@ describe('SpringBootGenerator', () => { springBootService.addMariaDB.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: 'project/path' }) }); - const button = wrapper.find('#springboot-database-mariadb'); - await button.trigger('click'); + await component.addMariaDB(); const args = springBootService.addMariaDB.getCall(0).args[0]; expect(args).toEqual({ @@ -504,8 +474,7 @@ describe('SpringBootGenerator', () => { springBootService.addMariaDB.rejects({}); await wrap({ springBootService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#springboot-database-mariadb'); - await initButton.trigger('click'); + await component.addMariaDB(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding SpringBoot Database MariaDB to project failed'); @@ -516,8 +485,7 @@ describe('SpringBootGenerator', () => { springBootService.addMongoDB.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#springboot-database-mongodb'); - await button.trigger('click'); + await component.addMongoDB(); expect(springBootService.addMongoDB.called).toBe(false); }); @@ -527,8 +495,7 @@ describe('SpringBootGenerator', () => { springBootService.addMongoDB.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: 'project/path' }) }); - const button = wrapper.find('#springboot-database-mongodb'); - await button.trigger('click'); + await component.addMongoDB(); const args = springBootService.addMongoDB.getCall(0).args[0]; expect(args).toEqual({ @@ -546,8 +513,7 @@ describe('SpringBootGenerator', () => { springBootService.addMongoDB.rejects({}); await wrap({ springBootService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#springboot-database-mongodb'); - await initButton.trigger('click'); + await component.addMongoDB(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding SpringBoot Database MongoDB to project failed'); @@ -560,8 +526,7 @@ describe('SpringBootGenerator', () => { springBootService.addSpringBootMongockInit.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#springboot-database-migration-mongock'); - await button.trigger('click'); + await component.addMongock(); expect(springBootService.addSpringBootMongockInit.called).toBe(false); }); @@ -571,8 +536,7 @@ describe('SpringBootGenerator', () => { springBootService.addSpringBootMongockInit.resolves({}); await wrap({ springBootService, project: createProjectToUpdate({ folder: 'project/path' }) }); - const button = wrapper.find('#springboot-database-migration-mongock'); - await button.trigger('click'); + await component.addMongock(); const args = springBootService.addSpringBootMongockInit.getCall(0).args[0]; expect(args).toEqual({ @@ -590,8 +554,7 @@ describe('SpringBootGenerator', () => { springBootService.addSpringBootMongockInit.rejects({}); await wrap({ springBootService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#springboot-database-migration-mongock'); - await initButton.trigger('click'); + await component.addMongock(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding SpringBoot Database Migration Mongock to project failed'); diff --git a/src/test/javascript/spec/springboot/primary/svelte-generator/SvelteGenerator.spec.ts b/src/test/javascript/spec/springboot/primary/generator/svelte-generator/SvelteGenerator.spec.ts similarity index 79% rename from src/test/javascript/spec/springboot/primary/svelte-generator/SvelteGenerator.spec.ts rename to src/test/javascript/spec/springboot/primary/generator/svelte-generator/SvelteGenerator.spec.ts index 76ed9099a1d..f4795eb2221 100644 --- a/src/test/javascript/spec/springboot/primary/svelte-generator/SvelteGenerator.spec.ts +++ b/src/test/javascript/spec/springboot/primary/generator/svelte-generator/SvelteGenerator.spec.ts @@ -1,7 +1,7 @@ import { shallowMount, VueWrapper } from '@vue/test-utils'; import { ProjectToUpdate } from '@/springboot/primary/ProjectToUpdate'; -import { createProjectToUpdate } from '../ProjectToUpdate.fixture'; -import { SvelteGeneratorVue } from '@/springboot/primary/svelte-generator'; +import { createProjectToUpdate } from '../../ProjectToUpdate.fixture'; +import { SvelteGeneratorVue } from '@/springboot/primary/generator/svelte-generator'; let wrapper: VueWrapper; diff --git a/src/test/javascript/spec/springboot/primary/vue-generator/VueGenerator.spec.ts b/src/test/javascript/spec/springboot/primary/generator/vue-generator/VueGenerator.spec.ts similarity index 82% rename from src/test/javascript/spec/springboot/primary/vue-generator/VueGenerator.spec.ts rename to src/test/javascript/spec/springboot/primary/generator/vue-generator/VueGenerator.spec.ts index 30737ef0966..c155fd2ca02 100644 --- a/src/test/javascript/spec/springboot/primary/vue-generator/VueGenerator.spec.ts +++ b/src/test/javascript/spec/springboot/primary/generator/vue-generator/VueGenerator.spec.ts @@ -1,13 +1,14 @@ import { shallowMount, VueWrapper } from '@vue/test-utils'; import { ProjectToUpdate } from '@/springboot/primary/ProjectToUpdate'; -import { createProjectToUpdate } from '../ProjectToUpdate.fixture'; -import { stubLogger } from '../../../common/domain/Logger.fixture'; +import { createProjectToUpdate } from '../../ProjectToUpdate.fixture'; +import { stubLogger } from '../../../../common/domain/Logger.fixture'; import { Logger } from '@/common/domain/Logger'; import { VueService } from '@/springboot/domain/client/VueService'; -import { stubVueService } from '../../domain/client/VueService.fixture'; -import { VueGeneratorVue } from '@/springboot/primary/vue-generator'; +import { stubVueService } from '../../../domain/client/VueService.fixture'; +import { VueGeneratorVue } from '@/springboot/primary/generator/vue-generator'; let wrapper: VueWrapper; +let component: any; interface WrapperOptions { vueService: VueService; @@ -33,6 +34,7 @@ const wrap = (wrapperOptions?: Partial) => { }, }, }); + component = wrapper.vm; }; describe('VueGenerator', () => { @@ -47,8 +49,7 @@ describe('VueGenerator', () => { vueService.add.resolves({}); await wrap({ vueService, project: createProjectToUpdate({ folder: '' }) }); - const button = wrapper.find('#vue'); - await button.trigger('click'); + await component.addVue(); expect(vueService.add.called).toBe(false); }); @@ -58,8 +59,7 @@ describe('VueGenerator', () => { vueService.add.resolves({}); await wrap({ vueService, project: createProjectToUpdate({ folder: 'project/path' }) }); - const button = wrapper.find('#vue'); - await button.trigger('click'); + await component.addVue(); const args = vueService.add.getCall(0).args[0]; expect(args).toEqual({ @@ -78,8 +78,7 @@ describe('VueGenerator', () => { const checkbox = wrapper.find('#vue-with-style'); await checkbox.setValue(true); - const button = wrapper.find('#vue'); - await button.trigger('click'); + await component.addVue(); const args = vueService.addWithStyle.getCall(0).args[0]; expect(args).toEqual({ @@ -97,8 +96,7 @@ describe('VueGenerator', () => { vueService.add.rejects({}); await wrap({ vueService, logger, project: createProjectToUpdate({ folder: 'project/path' }) }); - const initButton = wrapper.find('#vue'); - await initButton.trigger('click'); + await component.addVue(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding Vue to project failed'); @@ -112,8 +110,7 @@ describe('VueGenerator', () => { const checkbox = wrapper.find('#vue-with-style'); await checkbox.setValue(true); - const initButton = wrapper.find('#vue'); - await initButton.trigger('click'); + await component.addVue(); const [message] = logger.error.getCall(0).args; expect(message).toBe('Adding Vue with style to project failed');