Generator-jhipster: React: protractor failed with existing data (master)

Created on 14 Feb 2019  ยท  10Comments  ยท  Source: jhipster/generator-jhipster

Overview of the issue

Ping @jdubois @DanielFran

Current master builds are broken.
As Julien said, it's not related to Faker.js, but related to Protractor+React.

For React application, Protractor tests for entities failed if there are already data.
We can't detect it with prod profile, only in dev profile.

The CSRF error in console is another problem, but not related to this one.

Motivation for or Use Case
Reproduce the error
Related issues
Suggest a Fix
JHipster Version(s)
[email protected] /home/pgrimaud/tmp/react-noi18n-es-ws-gradle-session
โ””โ”€โ”€ [email protected] 

##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**
.yo-rc.json file
{
  "generator-jhipster": {
    "baseName": "travisReact",
    "packageName": "io.github.jhipster.travis",
    "packageFolder": "io/github/jhipster/travis",
    "serverPort": "8080",
    "authenticationType": "session",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "websocket": "spring-websocket",
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mysql",
    "searchEngine": "elasticsearch",
    "useSass": false,
    "buildTool": "gradle",
    "enableTranslation": false,
    "messageBroker": false,
    "rememberMeKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "applicationType": "monolith",
    "testFrameworks": ["protractor"],
    "jhiPrefix": "myPrefix",
    "travis": true,
    "serviceDiscoveryType": false,
    "clientPackageManager": "npm",
    "clientFramework": "react",
    "jhipsterVersion": "5.8.1",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": []
  }
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory


JDL entity definitions

entity BankAccount {
  name String required,
  bankNumber Integer,
  agencyNumber Long,
  lastOperationDuration Float,
  meanOperationDuration Double,
  balance BigDecimal required,
  openingDay LocalDate,
  lastOperationDate Instant,
  active Boolean,
  accountType BankAccountType,
  attachment AnyBlob,
  description TextBlob
}
entity Label {
  labelName String required minlength(3)
}
entity Operation {
  date Instant required,
  description String,
  amount BigDecimal required
}
entity FieldTestEntity {
  stringTom String,
  stringRequiredTom String required,
  stringMinlengthTom String minlength(0),
  stringMaxlengthTom String maxlength(20),
  stringPatternTom String pattern(/^[a-zA-Z0-9]*$/),
  integerTom Integer,
  integerRequiredTom Integer required,
  integerMinTom Integer min(0),
  integerMaxTom Integer max(100),
  longTom Long,
  longRequiredTom Long required,
  longMinTom Long min(0),
  longMaxTom Long max(100),
  floatTom Float,
  floatRequiredTom Float required,
  floatMinTom Float min(0),
  floatMaxTom Float max(100),
  doubleRequiredTom Double required,
  doubleMinTom Double min(0),
  doubleMaxTom Double max(100),
  bigDecimalRequiredTom BigDecimal required,
  bigDecimalMinTom BigDecimal min(0),
  bigDecimalMaxTom BigDecimal max(100),
  localDateTom LocalDate,
  localDateRequiredTom LocalDate required,
  instantTom Instant,
  instantRequiredTom Instant required,
  zonedDateTimeTom ZonedDateTime,
  zonedDateTimeRequiredTom ZonedDateTime required,
  booleanTom Boolean,
  booleanRequiredTom Boolean required,
  enumTom EnumFieldClass,
  enumRequiredTom EnumRequiredFieldClass required,
  byteImageTom ImageBlob,
  byteImageRequiredTom ImageBlob required,
  byteImageMinbytesTom ImageBlob minbytes(0),
  byteImageMaxbytesTom ImageBlob maxbytes(10000),
  byteAnyTom AnyBlob,
  byteAnyRequiredTom AnyBlob required,
  byteAnyMinbytesTom AnyBlob minbytes(0),
  byteAnyMaxbytesTom AnyBlob maxbytes(10000),
  byteTextTom TextBlob,
  byteTextRequiredTom TextBlob required,
  byteTextMinbytesTom TextBlob minbytes(0),
  byteTextMaxbytesTom TextBlob maxbytes(10000)
}
entity FieldTestPagerEntity {
  stringJade String,
  stringRequiredJade String required,
  stringMinlengthJade String minlength(0),
  stringMaxlengthJade String maxlength(20),
  stringPatternJade String pattern(/^[a-zA-Z0-9]*$/),
  integerJade Integer,
  integerRequiredJade Integer required,
  integerMinJade Integer min(0),
  integerMaxJade Integer max(100),
  longJade Long,
  longRequiredJade Long required,
  longMinJade Long min(0),
  longMaxJade Long max(100),
  floatJade Float,
  floatRequiredJade Float required,
  floatMinJade Float min(0),
  floatMaxJade Float max(100),
  doubleRequiredJade Double required,
  doubleMinJade Double min(0),
  doubleMaxJade Double max(100),
  bigDecimalRequiredJade BigDecimal required,
  bigDecimalMinJade BigDecimal min(0),
  bigDecimalMaxJade BigDecimal max(100),
  localDateJade LocalDate,
  localDateRequiredJade LocalDate required,
  instantJade Instant,
  instanteRequiredJade Instant required,
  zonedDateTimeJade ZonedDateTime,
  zonedDateTimeRequiredJade ZonedDateTime required,
  booleanJade Boolean,
  booleanRequiredJade Boolean required,
  enumJade EnumFieldClass,
  enumRequiredJade EnumRequiredFieldClass required,
  byteImageJade ImageBlob,
  byteImageRequiredJade ImageBlob required,
  byteImageMinbytesJade ImageBlob minbytes(0),
  byteImageMaxbytesJade ImageBlob maxbytes(10000),
  byteAnyJade AnyBlob,
  byteAnyRequiredJade AnyBlob required,
  byteAnyMinbytesJade AnyBlob minbytes(0),
  byteAnyMaxbytesJade AnyBlob maxbytes(10000),
  byteTextJade TextBlob,
  byteTextRequiredJade TextBlob required,
  byteTextMinbytesJade TextBlob minbytes(0),
  byteTextMaxbytesJade TextBlob maxbytes(10000)
}
entity FieldTestMapstructEntity {
  stringEva String,
  stringRequiredEva String required,
  stringMinlengthEva String minlength(0),
  stringMaxlengthEva String maxlength(20),
  stringPatternEva String pattern(/^[a-zA-Z0-9]*$/),
  integerEva Integer,
  integerRequiredEva Integer required,
  integerMinEva Integer min(0),
  integerMaxEva Integer max(100),
  longEva Long,
  longRequiredEva Long required,
  longMinEva Long min(0),
  longMaxEva Long max(100),
  floatEva Float,
  floatRequiredEva Float required,
  floatMinEva Float min(0),
  floatMaxEva Float max(100),
  doubleRequiredEva Double required,
  doubleMinEva Double min(0),
  doubleMaxEva Double max(100),
  bigDecimalRequiredEva BigDecimal required,
  bigDecimalMinEva BigDecimal min(0),
  bigDecimalMaxEva BigDecimal max(100),
  localDateEva LocalDate,
  localDateRequiredEva LocalDate required,
  instantEva Instant,
  instanteRequiredEva Instant required,
  zonedDateTimeEva ZonedDateTime,
  zonedDateTimeRequiredEva ZonedDateTime required,
  booleanEva Boolean,
  booleanRequiredEva Boolean required,
  enumEva EnumFieldClass,
  enumRequiredEva EnumRequiredFieldClass required,
  byteImageEva ImageBlob,
  byteImageRequiredEva ImageBlob required,
  byteImageMinbytesEva ImageBlob minbytes(0),
  byteImageMaxbytesEva ImageBlob maxbytes(10000),
  byteAnyEva AnyBlob,
  byteAnyRequiredEva AnyBlob required,
  byteAnyMinbytesEva AnyBlob minbytes(0),
  byteAnyMaxbytesEva AnyBlob maxbytes(10000),
  byteTextEva TextBlob,
  byteTextRequiredEva TextBlob required,
  byteTextMinbytesEva TextBlob minbytes(0),
  byteTextMaxbytesEva TextBlob maxbytes(10000)
}
entity FieldTestServiceImplEntity {
  stringMika String,
  stringRequiredMika String required,
  stringMinlengthMika String minlength(0),
  stringMaxlengthMika String maxlength(20),
  stringPatternMika String pattern(/^[a-zA-Z0-9]*$/),
  integerMika Integer,
  integerRequiredMika Integer required,
  integerMinMika Integer min(0),
  integerMaxMika Integer max(100),
  longMika Long,
  longRequiredMika Long required,
  longMinMika Long min(0),
  longMaxMika Long max(100),
  floatMika Float,
  floatRequiredMika Float required,
  floatMinMika Float min(0),
  floatMaxMika Float max(100),
  doubleRequiredMika Double required,
  doubleMinMika Double min(0),
  doubleMaxMika Double max(100),
  bigDecimalRequiredMika BigDecimal required,
  bigDecimalMinMika BigDecimal min(0),
  bigDecimalMaxMika BigDecimal max(100),
  localDateMika LocalDate,
  localDateRequiredMika LocalDate required,
  instantMika Instant,
  instanteRequiredMika Instant required,
  zonedDateTimeMika ZonedDateTime,
  zonedDateTimeRequiredMika ZonedDateTime required,
  booleanMika Boolean,
  booleanRequiredMika Boolean required,
  enumMika EnumFieldClass,
  enumRequiredMika EnumRequiredFieldClass required,
  byteImageMika ImageBlob,
  byteImageRequiredMika ImageBlob required,
  byteImageMinbytesMika ImageBlob minbytes(0),
  byteImageMaxbytesMika ImageBlob maxbytes(10000),
  byteAnyMika AnyBlob,
  byteAnyRequiredMika AnyBlob required,
  byteAnyMinbytesMika AnyBlob minbytes(0),
  byteAnyMaxbytesMika AnyBlob maxbytes(10000),
  byteTextMika TextBlob,
  byteTextRequiredMika TextBlob required,
  byteTextMinbytesMika TextBlob minbytes(0),
  byteTextMaxbytesMika TextBlob maxbytes(10000)
}
entity FieldTestInfiniteScrollEntity {
  stringHugo String,
  stringRequiredHugo String required,
  stringMinlengthHugo String minlength(0),
  stringMaxlengthHugo String maxlength(20),
  stringPatternHugo String pattern(/^[a-zA-Z0-9]*$/),
  integerHugo Integer,
  integerRequiredHugo Integer required,
  integerMinHugo Integer min(0),
  integerMaxHugo Integer max(100),
  longHugo Long,
  longRequiredHugo Long required,
  longMinHugo Long min(0),
  longMaxHugo Long max(100),
  floatHugo Float,
  floatRequiredHugo Float required,
  floatMinHugo Float min(0),
  floatMaxHugo Float max(100),
  doubleRequiredHugo Double required,
  doubleMinHugo Double min(0),
  doubleMaxHugo Double max(100),
  bigDecimalRequiredHugo BigDecimal required,
  bigDecimalMinHugo BigDecimal min(0),
  bigDecimalMaxHugo BigDecimal max(100),
  localDateHugo LocalDate,
  localDateRequiredHugo LocalDate required,
  instantHugo Instant,
  instanteRequiredHugo Instant required,
  zonedDateTimeHugo ZonedDateTime,
  zonedDateTimeRequiredHugo ZonedDateTime required,
  booleanHugo Boolean,
  booleanRequiredHugo Boolean required,
  enumHugo EnumFieldClass,
  enumRequiredHugo EnumRequiredFieldClass required,
  byteImageHugo ImageBlob,
  byteImageRequiredHugo ImageBlob required,
  byteImageMinbytesHugo ImageBlob minbytes(0),
  byteImageMaxbytesHugo ImageBlob maxbytes(10000),
  byteAnyHugo AnyBlob,
  byteAnyRequiredHugo AnyBlob required,
  byteAnyMinbytesHugo AnyBlob minbytes(0),
  byteAnyMaxbytesHugo AnyBlob maxbytes(10000),
  byteTextHugo TextBlob,
  byteTextRequiredHugo TextBlob required,
  byteTextMinbytesHugo TextBlob minbytes(0),
  byteTextMaxbytesHugo TextBlob maxbytes(10000)
}
entity FieldTestServiceClassEntity {
  stringBob String,
  stringRequiredBob String required,
  stringMinlengthBob String minlength(0),
  stringMaxlengthBob String maxlength(20),
  stringPatternBob String pattern(/^[a-zA-Z0-9]*$/),
  integerBob Integer,
  integerRequiredBob Integer required,
  integerMinBob Integer min(0),
  integerMaxBob Integer max(100),
  longBob Long,
  longRequiredBob Long required,
  longMinBob Long min(0),
  longMaxBob Long max(100),
  floatBob Float,
  floatRequiredBob Float required,
  floatMinBob Float min(0),
  floatMaxBob Float max(100),
  doubleRequiredBob Double required,
  doubleMinBob Double min(0),
  doubleMaxBob Double max(100),
  bigDecimalRequiredBob BigDecimal required,
  bigDecimalMinBob BigDecimal min(0),
  bigDecimalMaxBob BigDecimal max(100),
  localDateBob LocalDate,
  localDateRequiredBob LocalDate required,
  instantBob Instant,
  instanteRequiredBob Instant required,
  zonedDateTimeBob ZonedDateTime,
  zonedDateTimeRequiredBob ZonedDateTime required,
  booleanBob Boolean,
  booleanRequiredBob Boolean required,
  enumBob EnumFieldClass,
  enumRequiredBob EnumRequiredFieldClass required,
  byteImageBob ImageBlob,
  byteImageRequiredBob ImageBlob required,
  byteImageMinbytesBob ImageBlob minbytes(0),
  byteImageMaxbytesBob ImageBlob maxbytes(10000),
  byteAnyBob AnyBlob,
  byteAnyRequiredBob AnyBlob required,
  byteAnyMinbytesBob AnyBlob minbytes(0),
  byteAnyMaxbytesBob AnyBlob maxbytes(10000),
  byteTextBob TextBlob,
  byteTextRequiredBob TextBlob required,
  byteTextMinbytesBob TextBlob minbytes(0),
  byteTextMaxbytesBob TextBlob maxbytes(10000)
}
entity FieldTestPaginationEntity {
  stringAlice String,
  stringRequiredAlice String required,
  stringMinlengthAlice String minlength(0),
  stringMaxlengthAlice String maxlength(20),
  stringPatternAlice String pattern(/^[a-zA-Z0-9]*$/),
  integerAlice Integer,
  integerRequiredAlice Integer required,
  integerMinAlice Integer min(0),
  integerMaxAlice Integer max(100),
  longAlice Long,
  longRequiredAlice Long required,
  longMinAlice Long min(0),
  longMaxAlice Long max(100),
  floatAlice Float,
  floatRequiredAlice Float required,
  floatMinAlice Float min(0),
  floatMaxAlice Float max(100),
  doubleRequiredAlice Double required,
  doubleMinAlice Double min(0),
  doubleMaxAlice Double max(100),
  bigDecimalRequiredAlice BigDecimal required,
  bigDecimalMinAlice BigDecimal min(0),
  bigDecimalMaxAlice BigDecimal max(100),
  localDateAlice LocalDate,
  localDateRequiredAlice LocalDate required,
  instantAlice Instant,
  instanteRequiredAlice Instant required,
  zonedDateTimeAlice ZonedDateTime,
  zonedDateTimeRequiredAlice ZonedDateTime required,
  booleanAlice Boolean,
  booleanRequiredAlice Boolean required,
  enumAlice EnumFieldClass,
  enumRequiredAlice EnumRequiredFieldClass required,
  byteImageAlice ImageBlob,
  byteImageRequiredAlice ImageBlob required,
  byteImageMinbytesAlice ImageBlob minbytes(0),
  byteImageMaxbytesAlice ImageBlob maxbytes(10000),
  byteAnyAlice AnyBlob,
  byteAnyRequiredAlice AnyBlob required,
  byteAnyMinbytesAlice AnyBlob minbytes(0),
  byteAnyMaxbytesAlice AnyBlob maxbytes(10000),
  byteTextAlice TextBlob,
  byteTextRequiredAlice TextBlob required,
  byteTextMinbytesAlice TextBlob minbytes(0),
  byteTextMaxbytesAlice TextBlob maxbytes(10000)
}
entity EntityWithDTO {
  emma String
}
entity EntityWithServiceClass {
  zoe String
}
entity EntityWithServiceImpl {
  clara String
}
entity EntityWithPagination {
  nathan String
}
entity EntityWithServiceClassAndPagination {
  enzo String
}
entity EntityWithServiceImplAndPagination {
  hugo String
}
entity EntityWithServiceClassAndDTO {
  lucas String
}
entity EntityWithServiceImplAndDTO {
  louis String
}
entity EntityWithPaginationAndDTO {
  lea String
}
entity EntityWithServiceClassPaginationAndDTO {
  lena String
}
entity EntityWithServiceImplPaginationAndDTO {
  theo String
}

enum BankAccountType {
  CHECKING,
  SAVINGS,
  LOAN
}

enum EnumFieldClass {
  ENUM_VALUE_1,
  ENUM_VALUE_2,
  ENUM_VALUE_3
}

enum EnumRequiredFieldClass {
  ENUM_VALUE_1,
  ENUM_VALUE_2,
  ENUM_VALUE_3
}

relationship OneToMany {
  BankAccount{operation} to Operation{bankAccount(name)}
}
relationship ManyToOne {
  BankAccount{user(login)} to User
}
relationship ManyToMany {
  Operation{label(labelName)} to Label{operation}
}

dto BankAccount, FieldTestMapstructEntity, EntityWithDTO, EntityWithServiceClassAndDTO, EntityWithServiceImplAndDTO, EntityWithPaginationAndDTO, EntityWithServiceClassPaginationAndDTO, EntityWithServiceImplPaginationAndDTO with mapstruct
service BankAccount, FieldTestServiceImplEntity, EntityWithServiceImpl, EntityWithServiceImplAndPagination, EntityWithServiceImplAndDTO, EntityWithServiceImplPaginationAndDTO with serviceImpl
service Label, FieldTestMapstructEntity, FieldTestServiceClassEntity, EntityWithServiceClass, EntityWithServiceClassAndPagination, EntityWithServiceClassAndDTO, EntityWithServiceClassPaginationAndDTO with serviceClass
angularSuffix BankAccount with mySuffix
filter BankAccount, FieldTestServiceClassEntity
clientRootFolder BankAccount, Label, Operation with test-root
paginate Label, FieldTestPaginationEntity, EntityWithPagination, EntityWithServiceClassAndPagination, EntityWithServiceImplAndPagination, EntityWithPaginationAndDTO, EntityWithServiceClassPaginationAndDTO, EntityWithServiceImplPaginationAndDTO with pagination
paginate Operation, FieldTestInfiniteScrollEntity with infinite-scroll
paginate FieldTestPagerEntity with pager

Environment and Tools

openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-2ubuntu0.18.04.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

git version 2.20.1

node: v10.15.0

npm: 6.7.0

yeoman: 2.0.5

yarn: 1.13.0

Docker version 18.03.0-ce, build 0520e24

docker-compose version 1.21.2, build a133471

INFO! Congratulations, JHipster execution is complete!

area react

All 10 comments

@pascalgrimaud I validated yesterday and the issue started hapening with https://github.com/jhipster/generator-jhipster/pull/9104

The issue didn't start happening since #9104 -> the issue is detected since #9104 :-)
It exists since weeks / months. That means #9104 is not the culprit

To reproduce:

  • git clone https://github.com/jhipster/jhipster-sample-app-react.git
  • it was generated with v5.8.1, so before #9104
  • launch the application: ./mvnw
  • go into Label, add one entities
  • go into terminal, launch: npm run e2e
  • here the result:
  Account
    โœ“ should fail to login with bad password
    โœ“ should login with admin account (3194ms)
    โœ“ should be able to sign up (2757ms)
    โœ“ should load user management (2921ms)
    โœ“ should activate the new registered user (1726ms)
    โœ“ should not be able to sign up if login already taken (2916ms)
    โœ“ should not be able to sign up if email already taken
    โœ“ should be able to log in with new registered account (2338ms)
    โœ“ should login with admin account (2234ms)
    โœ“ should fail to update password when using incorrect current password (2733ms)
    โœ“ should be able to update password (3174ms)
    โœ“ should be able to log in with new password (3628ms)
    โœ“ should login with user_test account (2033ms)
    โœ“ should be able to change user_test settings (2644ms)
    โœ“ should login with admin account (2121ms)
    โœ“ should not be able to change admin settings if email already exists (1564ms)
    โœ“ should delete previously created fake user (1999ms)

  Administration
    โœ“ should load user management
    โœ“ should load metrics
    โœ“ should load health
    โœ“ should load configuration
    โœ“ should load audits
    โœ“ should load logs (1613ms)

  BankAccount e2e test
    โœ“ should load BankAccounts
    โœ“ should load create BankAccount page
    โœ“ should create and save BankAccounts
    โœ“ should delete last BankAccount (1573ms)

  Label e2e test
    โœ“ should load Labels
    โœ“ should load create Label page
    1) should create and save Labels
    โœ“ should delete last Label (1582ms)

As I said, the Protractor tests will fail only if there is existing data.
It is the case with dev profile since #9104

Ok, just validated that previous this commit in master all tests were green and no changes in jhipster-bom during that period...

Thanks a lot @pascalgrimaud for the analysis, I thought it was linked to the CSRF issue (which is also annoying).
Concerning the data: I did a specific "faker" context in Liquibase so it's easy to remove, then our tests should be more robust, so we should first try to fix this. I have no idea how this works, but I'll have a look.

A very quick fix for our CI, is to use prod profile: https://github.com/pascalgrimaud/generator-jhipster/commit/f7a8d478032ba9612740ce8b18671baad2b29ad1

But it will just hide this issue.

It's not such a bad fix @pascalgrimaud , as for me the e2e tests should be done in prod profile.
Still I'm trying to find the root cause.

Ok, just did a PR with this quick fix

OK I got this, but it's a bit tricky so I'll do the PR in the next few hours.

  • The issue is that when there is a list of data, it is not displayed immediately at page load (there is a REST call getting the data, so it takes some time to load)
  • As we are counting the number of "delete" buttons to know how much lines there are on the page, we always have "0" as the data isn't loaded yet. So it works only when there is no data :-)
  • Please note that this will still fail if you have more than 20 lines of paginated data, as the paginated data will be hidden. But for the moment we can ignore this.

My current solution is in fact to add 2 lines of data, so I am sure there is at least on line (even when there is initially no data), so I can start counting the "delete" buttons correctly, and thus know if I added one line or not.

@jdubois Sometimes react tests are still failing...

with my .yo-rc.json config here

Bildschirmfoto 2020-04-08 um 16 35 51

smells like it does not work properly with the notification toast message on top left, despite of translation not found, 10+ out of 21 e2e-test cases overall are failing

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marcelinobadin picture marcelinobadin  ยท  3Comments

chegola picture chegola  ยท  4Comments

Steven-Garcia picture Steven-Garcia  ยท  3Comments

frantzynicolas picture frantzynicolas  ยท  3Comments

SudharakaP picture SudharakaP  ยท  3Comments