diff --git a/.github/workflows/angular.yml b/.github/workflows/angular.yml index f23d85fa87ac..c48f44c8c7f6 100644 --- a/.github/workflows/angular.yml +++ b/.github/workflows/angular.yml @@ -77,68 +77,68 @@ jobs: entity: sql profile: prod war: 0 - protractor: 1 + e2e: 1 testcontainers: 1 - app-type: ngx-psql-es-noi18n-mapsid entity: sqlfull profile: prod war: 0 - protractor: 1 + e2e: 1 testcontainers: 0 - app-type: ngx-mariadb-oauth2-infinispan entity: sqlfull profile: prod war: 0 - protractor: 1 + e2e: 1 testcontainers: 0 - app-type: ngx-mongodb-kafka-cucumber entity: mongodb profile: dev,webpack war: 0 - protractor: 1 + e2e: 1 testcontainers: 0 - app-type: ngx-h2mem-ws-nol2 entity: sql profile: dev,webpack war: 0 # TODO: need change to 1, when maven+war is fixed - protractor: 1 + e2e: 1 testcontainers: 0 - app-type: ngx-gradle-fr entity: sql profile: prod war: 0 - protractor: 1 + e2e: 1 testcontainers: 0 - app-type: ngx-gradle-psql-es-noi18n-mapsid entity: sqlfull profile: prod war: 0 - protractor: 1 + e2e: 1 testcontainers: 1 - app-type: ngx-gradle-mariadb-oauth2-infinispan entity: sql profile: dev,webpack war: 0 - protractor: 1 + e2e: 1 testcontainers: 1 - app-type: ngx-gradle-mongodb-kafka-cucumber entity: mongodb profile: prod war: 0 - protractor: 1 + e2e: 1 testcontainers: 0 - app-type: ngx-gradle-h2disk-ws-nocache entity: sql profile: dev,webpack war: 1 - protractor: 1 + e2e: 1 testcontainers: 0 env: JHI_ENTITY: ${{ matrix.entity }} JHI_APP: ${{ matrix.app-type }} JHI_PROFILE: ${{ matrix.profile }} JHI_WAR: ${{ matrix.war }} - JHI_PROTRACTOR: ${{ matrix.protractor }} + JHI_E2E: ${{ matrix.e2e }} JHI_TESTCONTAINERS: ${{ matrix.testcontainers }} steps: #---------------------------------------------------------------------- @@ -190,7 +190,13 @@ jobs: run: npm run e2e:update-webdriver --versions.chrome ${{ steps.chromedriver-version.outputs.version }} working-directory: /home/runner/app - name: 'TESTS: End-to-End' + id: e2e run: $JHI_SCRIPTS/24-tests-e2e.sh + - uses: actions/upload-artifact@v2 + if: ${{ always() && steps.e2e.outcome == 'failure'}} + with: + name: screenshots-${{ matrix.app-type }} + path: /home/runner/app/target/cypress/screenshots - name: 'TESTS: Sonar analysis' run: $JHI_SCRIPTS/25-sonar-analyze.sh env: diff --git a/.github/workflows/react.yml b/.github/workflows/react.yml index 1b1f64e1c70b..0675a99cd688 100644 --- a/.github/workflows/react.yml +++ b/.github/workflows/react.yml @@ -76,62 +76,62 @@ jobs: entity: sql profile: prod war: 0 - protractor: 1 + e2e: 1 testcontainers: 0 - app-type: react-maven-psql-es-noi18n-mapsid entity: sqlfull profile: prod war: 0 - protractor: 1 + e2e: 1 testcontainers: 1 - app-type: react-maven-h2mem-memcached entity: sql profile: dev,webpack war: 0 # TODO: need change to 1, when maven+war is fixed - protractor: 1 + e2e: 1 testcontainers: 0 - app-type: react-maven-cassandra-session-redis entity: cassandra profile: prod war: 0 - protractor: 1 + e2e: 1 testcontainers: 0 - app-type: react-maven-couchbase-caffeine entity: couchbase profile: prod war: 0 - protractor: 0 + e2e: 0 testcontainers: 0 - app-type: react-gradle-psql-es-noi18n-mapsid entity: sqlfull profile: prod war: 0 - protractor: 1 + e2e: 1 testcontainers: 0 - app-type: react-gradle-h2mem-memcached entity: sql profile: dev,webpack war: 1 - protractor: 1 + e2e: 1 testcontainers: 0 - app-type: react-gradle-cassandra-session-redis entity: cassandra profile: prod war: 0 - protractor: 1 + e2e: 1 testcontainers: 0 - app-type: react-gradle-couchbase-caffeine entity: couchbase profile: prod war: 0 - protractor: 1 + e2e: 1 testcontainers: 0 env: JHI_ENTITY: ${{ matrix.entity }} JHI_APP: ${{ matrix.app-type }} JHI_PROFILE: ${{ matrix.profile }} JHI_WAR: ${{ matrix.war }} - JHI_PROTRACTOR: ${{ matrix.protractor }} + JHI_E2E: ${{ matrix.e2e }} JHI_TESTCONTAINERS: ${{ matrix.testcontainers }} steps: #---------------------------------------------------------------------- @@ -183,7 +183,13 @@ jobs: run: npm run e2e:update-webdriver --versions.chrome ${{ steps.chromedriver-version.outputs.version }} working-directory: /home/runner/app - name: 'TESTS: End-to-End' + id: e2e run: $JHI_SCRIPTS/24-tests-e2e.sh + - uses: actions/upload-artifact@v2 + if: ${{ always() && steps.e2e.outcome == 'failure'}} + with: + name: screenshots-${{ matrix.app-type }} + path: /home/runner/app/target/cypress/screenshots - name: 'TESTS: Sonar analysis' run: $JHI_SCRIPTS/25-sonar-analyze.sh env: diff --git a/.github/workflows/vue.yml b/.github/workflows/vue.yml index fca3e9dff3ca..53171f7b9575 100644 --- a/.github/workflows/vue.yml +++ b/.github/workflows/vue.yml @@ -77,58 +77,58 @@ jobs: entity: sqlfull profile: prod war: 0 - protractor: 1 + e2e: 1 - app-type: vue-noi18n entity: sqlfull profile: prod war: 0 - protractor: 1 + e2e: 1 - app-type: vue-fulli18n-es entity: sql profile: prod war: 0 - protractor: 1 + e2e: 1 - app-type: vue-gateway entity: sql profile: dev,webpack war: 0 - protractor: 1 + e2e: 1 - app-type: vue-gradle-session entity: sql profile: dev,webpack war: 0 - protractor: 1 + e2e: 1 - app-type: vue-ws-theme entity: sql profile: dev,webpack war: 0 - protractor: 1 + e2e: 1 - app-type: vue-oauth2 entity: sql profile: prod war: 0 - protractor: 1 + e2e: 1 - app-type: vue-couchbase entity: couchbase profile: dev,webpack war: 0 - protractor: 1 + e2e: 1 - app-type: vue-mongodb-kafka-cucumber entity: mongodb profile: dev,webpack war: 0 - protractor: 1 + e2e: 1 - app-type: vue-session-cassandra-fr entity: cassandra profile: dev,webpack war: 0 - protractor: 1 + e2e: 1 env: JHI_ENTITY: ${{ matrix.entity }} JHI_APP: ${{ matrix.app-type }} JHI_PROFILE: ${{ matrix.profile }} JHI_WAR: ${{ matrix.war }} - JHI_PROTRACTOR: ${{ matrix.protractor }} + JHI_E2E: ${{ matrix.e2e }} steps: #---------------------------------------------------------------------- # Install all tools and check configuration @@ -175,8 +175,14 @@ jobs: - name: 'TESTS: packaging' run: $JHI_SCRIPTS/23-package.sh - name: 'Synchronize chromedriver version' - if: ${{ matrix.protractor == 1 }} + if: ${{ matrix.e2e == 1 }} run: npm run e2e:update-webdriver --versions.chrome ${{ steps.chromedriver-version.outputs.version }} working-directory: /home/runner/app - name: 'TESTS: End-to-End' + id: e2e run: $JHI_SCRIPTS/24-tests-e2e.sh + - uses: actions/upload-artifact@v2 + if: ${{ always() && steps.e2e.outcome == 'failure'}} + with: + name: screenshots-${{ matrix.app-type }} + path: /home/runner/app/target/cypress/screenshots diff --git a/.github/workflows/webflux.yml b/.github/workflows/webflux.yml index ccaee8c4e024..bab9515e9bf9 100644 --- a/.github/workflows/webflux.yml +++ b/.github/workflows/webflux.yml @@ -72,48 +72,48 @@ jobs: entity: mongodb profile: prod war: 0 - protractor: 1 + e2e: 1 - app-type: webflux-mongodb-es-session entity: mongodb profile: prod war: 0 - protractor: 1 + e2e: 1 - app-type: webflux-mongodb-oauth2 entity: mongodb profile: prod war: 0 - protractor: 1 + e2e: 1 - app-type: webflux-gateway-jwt entity: none profile: prod war: 0 - protractor: 1 + e2e: 1 - app-type: webflux-gateway-oauth2 entity: none profile: prod war: 0 - protractor: 1 + e2e: 1 - app-type: webflux-couchbase entity: couchbase profile: prod war: 0 - protractor: 1 + e2e: 1 - app-type: webflux-couchbase-es-oauth2 entity: couchbase profile: prod war: 0 - protractor: 1 + e2e: 1 - app-type: webflux-psql entity: none profile: prod war: 0 - protractor: 1 + e2e: 1 env: JHI_ENTITY: ${{ matrix.entity }} JHI_APP: ${{ matrix.app-type }} JHI_PROFILE: ${{ matrix.profile }} JHI_WAR: ${{ matrix.war }} - JHI_PROTRACTOR: ${{ matrix.protractor }} + JHI_E2E: ${{ matrix.e2e }} steps: #---------------------------------------------------------------------- # Install all tools and check configuration @@ -164,7 +164,7 @@ jobs: run: npm run e2e:update-webdriver --versions.chrome ${{ steps.chromedriver-version.outputs.version }} working-directory: /home/runner/app - name: 'TESTS: End-to-End' - run: $JHI_SCRIPTS/24-tests-e2e.sh + run: $JHI_SCRIPTS/24-tests-cypress.sh - name: 'TESTS: Sonar analysis' run: $JHI_SCRIPTS/25-sonar-analyze.sh env: diff --git a/azure-pipelines.yml b/azure-pipelines.yml index dbe4fd3a553c..9e11eb8e6278 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -28,7 +28,7 @@ jobs: variables: JHI_PROFILE: dev,webpack JHI_RUN_APP: 1 - JHI_PROTRACTOR: 0 + JHI_CYPRESS: 0 JHI_JDK: 11 # if JHI_LIB_BRANCH value is release, use the release from Maven JHI_LIB_REPO: https://github.com/jhipster/jhipster.git @@ -50,12 +50,12 @@ jobs: JHI_APP: ms-ngx-gateway-eureka-jwt JHI_ENTITY: sqllight JHI_PROFILE: prod - JHI_PROTRACTOR: 1 + JHI_CYPRESS: 1 ms-ngx-gateway-eureka-oauth2: JHI_APP: ms-ngx-gateway-eureka-oauth2 JHI_ENTITY: sqllight JHI_PROFILE: prod - JHI_PROTRACTOR: 1 + JHI_CYPRESS: 1 ms-ngx-gateway-eureka-uaa: JHI_APP: ms-ngx-gateway-eureka-uaa JHI_ENTITY: uaa @@ -69,17 +69,17 @@ jobs: JHI_APP: ms-react-gateway-consul-jwt JHI_ENTITY: sqllight JHI_PROFILE: prod - JHI_PROTRACTOR: 1 + JHI_CYPRESS: 1 ms-react-gateway-consul-oauth2: JHI_APP: ms-react-gateway-consul-oauth2 JHI_ENTITY: sqllight JHI_PROFILE: prod - JHI_PROTRACTOR: 1 + JHI_CYPRESS: 1 jdl-default: JHI_APP: jdl-default JHI_ENTITY: jdl JHI_PROFILE: prod - JHI_PROTRACTOR: 1 + JHI_CYPRESS: 1 JHI_TESTCONTAINERS: 1 steps: #---------------------------------------------------------------------- diff --git a/generators/app/prompts.js b/generators/app/prompts.js index c791119f0157..0ce1fdc887fb 100644 --- a/generators/app/prompts.js +++ b/generators/app/prompts.js @@ -99,7 +99,8 @@ async function askForTestOpts() { } if (!this.skipClient) { // all client side test frameworks should be added here - choices.push({ name: 'Protractor', value: 'protractor' }); + choices.push({ name: 'Protractor **Deprecated**', value: 'protractor' }); + choices.push({ name: 'Cypress', value: 'cypress' }); } const PROMPT = { type: 'checkbox', diff --git a/generators/client/files-angular.js b/generators/client/files-angular.js index e1abd4b1adbc..bf611972df4e 100644 --- a/generators/client/files-angular.js +++ b/generators/client/files-angular.js @@ -39,7 +39,6 @@ const files = { 'tsconfig.app.json', 'tslint.json', '.eslintrc.json', - '.eslintignore', 'angular.json', 'webpack/utils.js', 'webpack/webpack.common.js', diff --git a/generators/client/files-common.js b/generators/client/files-common.js new file mode 100644 index 000000000000..be30cb7b9193 --- /dev/null +++ b/generators/client/files-common.js @@ -0,0 +1,39 @@ +/** + * Copyright 2013-2020 the original author or authors from the JHipster project. + * + * This file is part of the JHipster project, see https://www.jhipster.tech/ + * for more information. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +const mkdirp = require('mkdirp'); +const constants = require('../generator-constants'); + +const MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR; + +module.exports = { + writeFiles, +}; + +const commonFiles = { + common: [ + { + templates: ['.eslintignore'], + }, + ], +}; + +function writeFiles() { + mkdirp(MAIN_SRC_DIR); + this.writeFilesToDisk(commonFiles, this, false, this.fetchFromInstalledJHipster('client/templates/common')); +} diff --git a/generators/client/files-react.js b/generators/client/files-react.js index 3b82c173ce90..a777d35d0fa4 100644 --- a/generators/client/files-react.js +++ b/generators/client/files-react.js @@ -34,7 +34,6 @@ const files = { templates: [ 'package.json', '.eslintrc.json', - '.eslintignore', 'tsconfig.json', 'tsconfig.test.json', { file: '.editorconfig', method: 'copy', noEjs: true }, diff --git a/generators/client/index.js b/generators/client/index.js index f158ce1c8365..1ce9e97b6ef3 100644 --- a/generators/client/index.js +++ b/generators/client/index.js @@ -24,6 +24,7 @@ const prompts = require('./prompts'); const writeAngularFiles = require('./files-angular').writeFiles; const writeReactFiles = require('./files-react').writeFiles; const writeVueFiles = require('./files-vue').writeFiles; +const writeCommonFiles = require('./files-common').writeFiles; const packagejs = require('../../package.json'); const constants = require('../generator-constants'); const statistics = require('../statistics'); @@ -144,6 +145,19 @@ module.exports = class extends BaseBlueprintGenerator { // Public API method used by the getter and also by Blueprints _default() { return { + loadSharedConfig() { + this.loadAppConfig(); + this.loadClientConfig(); + this.loadServerConfig(); + this.loadTranslationConfig(); + }, + composeCommon() { + this.composeWithJHipster('common', true); + }, + composeCypress() { + if (!this.cypressTests) return; + this.composeWithJHipster('cypress', true); + }, composeLanguages() { // We don't expose client/server to cli, composing with languages is used for test purposes. if (this.jhipsterConfig.enableTranslation === false) return; @@ -179,12 +193,6 @@ module.exports = class extends BaseBlueprintGenerator { ); } }, - loadSharedConfig() { - this.loadAppConfig(); - this.loadClientConfig(); - this.loadServerConfig(); - this.loadTranslationConfig(); - }, setupSharedOptions() { this.enableI18nRTL = false; if (this.languages !== undefined) { @@ -247,6 +255,10 @@ module.exports = class extends BaseBlueprintGenerator { // do nothing by default } }, + writeCommonFiles() { + if (this.skipClient) return; + return writeCommonFiles.call(this, useBlueprints); + }, }; } diff --git a/generators/client/templates/angular/package.json.ejs b/generators/client/templates/angular/package.json.ejs index 8ffa32474f1a..c724b60eda52 100644 --- a/generators/client/templates/angular/package.json.ejs +++ b/generators/client/templates/angular/package.json.ejs @@ -144,12 +144,15 @@ <%_ if (protractorTests) { _%> "ts-node": "8.10.2", <%_ } _%> + <%_ if (cypressTests) { _%> + "cypress": "4.12.1", + <%_ } _%> "tslint": "6.1.2", "typescript": "3.9.5", <%_ otherModules.forEach(module => { _%> "<%= module.name %>": "<%= module.version %>", <%_ }); _%> - <%_ if (protractorTests) { _%> + <%_ if (protractorTests || cypressTests) { _%> "webdriver-manager": "12.1.7", <%_ } _%> "webpack": "4.43.0", @@ -171,8 +174,19 @@ "ngc": "ngc -p tsconfig.app.json", "cleanup": "rimraf <%= DIST_DIR %>", "clean-www": "rimraf <%= DIST_DIR %>app/{src,<%= BUILD_DIR %>}", + <%_ if (protractorTests && !cypressTests) { _%> + "e2e": "<%= clientPackageManager %> run e2e:protractor", + <%_ } else if ((cypressTests && !protractorTests) || (protractorTests && cypressTests)) { _%> + "e2e": "<%= clientPackageManager %> run e2e:cypress", + <%_ } _%> <%_ if (protractorTests) { _%> - "e2e": "protractor <%= TEST_SRC_DIR %>protractor.conf.js", + "e2e:protractor": "protractor <%= TEST_SRC_DIR %>protractor.conf.js", + <%_ } _%> + <%_ if (cypressTests) { _%> + "e2e:cypress": "cypress run --browser chrome --headless", + "cypress": "cypress open", + <%_ } _%> + <%_ if (protractorTests || cypressTests) { _%> "postinstall": "<%= clientPackageManager %> run e2e:update-webdriver", "e2e:update-webdriver": "webdriver-manager update --gecko false", <%_ } _%> diff --git a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.html.ejs b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.html.ejs index 1e57338b4e7f..6fd6b21fb460 100644 --- a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.html.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.html.ejs @@ -48,7 +48,7 @@ + formControlName="newPassword" data-cy="resetPassword" #newPassword>
New password confirmation + formControlName="confirmPassword" data-cy="confirmResetPassword">
- +
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/init/password-reset-init.component.html.ejs b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/init/password-reset-init.component.html.ejs index 399ecacb7ecc..2f8cab713cba 100644 --- a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/init/password-reset-init.component.html.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/init/password-reset-init.component.html.ejs @@ -35,7 +35,7 @@
+ formControlName="email" data-cy="emailResetPassword" #email>
- +
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/password/password.component.html.ejs b/generators/client/templates/angular/src/main/webapp/app/account/password/password.component.html.ejs index 4b86cf3b4554..6e9a87505a96 100644 --- a/generators/client/templates/angular/src/main/webapp/app/account/password/password.component.html.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/account/password/password.component.html.ejs @@ -38,7 +38,8 @@ + formControlName="currentPassword" + data-cy="currentPassword">
New password + formControlName="newPassword" + data-cy="newPassword">
New password confirmation + formControlName="confirmPassword" + data-cy="confirmPassword">
- +
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/register/register.component.html.ejs b/generators/client/templates/angular/src/main/webapp/app/account/register/register.component.html.ejs index 6c005afddb24..6366bbe7ea15 100644 --- a/generators/client/templates/angular/src/main/webapp/app/account/register/register.component.html.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/account/register/register.component.html.ejs @@ -19,7 +19,7 @@
-

Registration

+

Registration

Registration saved! Please check your email for confirmation. @@ -49,7 +49,7 @@
+ formControlName="login" data-cy="username" #login>
+ formControlName="email" data-cy="email">
+ formControlName="password" data-cy="firstPassword">
+ formControlName="confirmPassword" data-cy="secondPassword">
- +
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/settings/settings.component.html.ejs b/generators/client/templates/angular/src/main/webapp/app/account/settings/settings.component.html.ejs index 69b9cd67836f..eaeb3df75241 100644 --- a/generators/client/templates/angular/src/main/webapp/app/account/settings/settings.component.html.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/account/settings/settings.component.html.ejs @@ -31,7 +31,7 @@
+ formControlName="firstName" data-cy="firstname">
+ formControlName="lastName" data-cy="lastname">
+ formControlName="email" data-cy="email">
-
<%_ } _%> - +
diff --git a/generators/client/templates/angular/src/main/webapp/app/admin/configuration/configuration.component.html.ejs b/generators/client/templates/angular/src/main/webapp/app/admin/configuration/configuration.component.html.ejs index 062d4b47c9c2..6a2d27d20990 100644 --- a/generators/client/templates/angular/src/main/webapp/app/admin/configuration/configuration.component.html.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/admin/configuration/configuration.component.html.ejs @@ -17,7 +17,7 @@ limitations under the License. -%>
-

Configuration

+

Configuration

Filter (by prefix) diff --git a/generators/client/templates/angular/src/main/webapp/app/admin/health/health.component.html.ejs b/generators/client/templates/angular/src/main/webapp/app/admin/health/health.component.html.ejs index 48eadf6c5b5b..b02418094109 100644 --- a/generators/client/templates/angular/src/main/webapp/app/admin/health/health.component.html.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/admin/health/health.component.html.ejs @@ -18,7 +18,7 @@ -%>

- Health Checks + Health Checks + <%_ if (!skipUserManagement) { _%>
diff --git a/generators/client/templates/angular/src/main/webapp/app/layouts/navbar/navbar.component.html.ejs b/generators/client/templates/angular/src/main/webapp/app/layouts/navbar/navbar.component.html.ejs index 17e31c8fc26d..997a9c5c158c 100644 --- a/generators/client/templates/angular/src/main/webapp/app/layouts/navbar/navbar.component.html.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/layouts/navbar/navbar.component.html.ejs @@ -16,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. -%> -