Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from protractor to cypress #653

Merged
merged 75 commits into from
Apr 29, 2022
Merged

Migrate from protractor to cypress #653

merged 75 commits into from
Apr 29, 2022

Conversation

mshima
Copy link
Member

@mshima mshima commented Apr 28, 2022

Closes #639

configuration,
qs: {
redirect_uri,
client_id: clientId,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has to be hard-coded to the client ID for the native app on Auth0 and Okta. This is a different between these providers and Keycloak. You also have to hard-code the client ID in auth-config.service.ts. https://www.jhipster.tech/security/#update-your-ionic-app

password,
},
});
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get a 404 on this call with Auth0.

Screen Shot 2022-04-28 at 19 50 16

@mraible
Copy link
Collaborator

mraible commented Apr 29, 2022

Try to start the ionic server and run cypress using npx cypress.

I ran ionic serve in one terminal and npx cypress open in the other. This runs everything on 8100, but the error is the same.

@mshima
Copy link
Member Author

mshima commented Apr 29, 2022

@mraible the missing feature is auth0 support.
I think we can merge it and continue at main.

@mraible
Copy link
Collaborator

mraible commented Apr 29, 2022

I just started testing this again using npm link in the Cypress branch.

Screen Shot 2022-04-29 at 09 35 30

Two things that seem strange:

  1. The warnings about relationships when everything works just fine.
  2. Why is it creating files in node_modules?

It's taking forever to create the app. Maybe because I'm using my M1? Most of the testing I did yesterday on my Intel.

@mshima
Copy link
Member Author

mshima commented Apr 29, 2022

  1. The warnings about relationships when everything works just fine.

It's a bug at jdl, that generates otherEntityRelationshipName without the otherEntityRelationship.
In other words, jdl creates the back reference name, without the back reference.

It's in my jhipster todo, but the jhipster todo is quite big right now.

  1. Why is it creating files in node_modules?

That's odd, I think you used npm to update generators/ionic/resources/base/package.json and they are leftovers.

@mraible
Copy link
Collaborator

mraible commented Apr 29, 2022

I'll try on my Intel and see if it happens there. I did notice that if I do the following in the cypress branch, it updates package-lock.json.

rm -rf package-lock.json node_modules
npm i

@mshima
Copy link
Member Author

mshima commented Apr 29, 2022

It's taking forever to create the app. Maybe because I'm using my M1? Most of the testing I did yesterday on my Intel.

I use M1, I don't see a big slowdown, sometimes just a small delay.

time jhipster-ionic jdl bug-tracker.jh --skip-install --skip-jhipster-dependencies
24,45s user 3,43s system 108% cpu 25,685 total

The npm install part installs maven too. Is slow, but I don't think we can do anything.

time jhipster-ionic jdl bug-tracker.jh --skip-jhipster-dependencies
50,43s user 19,20s system 55% cpu 2:06,05 total

@mshima
Copy link
Member Author

mshima commented Apr 29, 2022

I'll try on my Intel and see if it happens there. I did notice that if I do the following in the cypress branch, it updates package-lock.json.

It happens almost every time, if any transitional dependency is updated, the package-lock changes.
That's the reason we regenerate the generator-jhipster package lock weekly.

@mraible
Copy link
Collaborator

mraible commented Apr 29, 2022

I don't know if this is something we should fix, but husky causes issues if I create an Ionic app in an existing JHipster project that's been checked into Git.

git clone https://github.com/oktadev/okta-jhipster-ionic-example.git
cd okta-jhipster-ionic-example
rm -rf ionic-app
take ionic-app
jhipster-ionic

The creation of the app fails towards the end:

Running npm install for you to install the required dependencies.
npm WARN deprecated source-map-resolve@0.6.0: See https://github.com/lydell/source-map-resolve#deprecated

> ionic4j@0.0.1 prepare
> husky install

.git can't be found (see https://git.io/Jc3F9)
npm ERR! code 1
npm ERR! path /Users/mraible/Downloads/okta-jhipster-ionic-example/ionic-app
npm ERR! command failed
npm ERR! command sh -c husky install

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mraible/.npm/_logs/2022-04-29T16_13_44_975Z-debug-0.log
ERROR! Command failed with exit code 1: npm install
Error: Command failed with exit code 1: npm install
    at makeError (/Users/mraible/dev/generator-jhipster-ionic/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/Users/mraible/dev/generator-jhipster-ionic/node_modules/execa/index.js:118:26)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  shortMessage: 'Command failed with exit code 1: npm install',
  command: 'npm install',
  escapedCommand: 'npm install',
  exitCode: 1,
  signal: undefined,
  signalDescription: undefined,
  stdout: undefined,
  stderr: undefined,
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}

If I remove the following from package.json, I can npm install just fine.

"prepare": "husky install",

@zhyd1997
Copy link
Contributor

@mshima

I confirmed your bounty request and paid $500 by PayPal.

@mraible
Copy link
Collaborator

mraible commented Apr 29, 2022

I just re-created my Ionic app with this branch. npm run e2e works in that all the tests pass against Keycloak. I was a little surprised I needed to click Stop at the end, but I think that's because Cypress is listening for changes and will re-run tests if there are any. npm run e2e:ci also works.

    ✔  All specs passed!                        00:40       23       23        -        -        -

Execution time: 1 min. 8 s.

I still think we should change it so npm run e2e runs npm run e2e:ci since that's how the main generator (and Svelte blueprint) works.

@mraible
Copy link
Collaborator

mraible commented Apr 29, 2022

I tested with Auth0 and there's still an issue fetching /callback. Setting the credentials as environment variables does work.

export CYPRESS_E2E_USERNAME=foo
export CYPRESS_E2E_PASSWORD=bar

I'm OK with merging this and continuing Okta/Auth0 support in a different branch.

@mshima mshima merged commit 4e1e0ed into main Apr 29, 2022
@mshima mshima deleted the cypress branch April 29, 2022 17:19
@mraible
Copy link
Collaborator

mraible commented Apr 29, 2022

e2e opens cypress ui at main generator:

If you look at this repo, you'll see the difference: https://github.com/oktadev/okta-jhipster-ionic-example

  • For the backend: ./mvnw in one terminal and run npm run e2e in another. You won't need to do anything for all the Cypress tests to run. It might prompt you to Quick Chrome b/c a download isn't finished, but that's unrelated.
  • For Ionic: Start the backend with ./mvnw -Pprod and run npm run e2e in the Ionic app. You have to click in the Cypress app in order for tests to run.

This was referenced Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Convert Protractor tests to Cypress
3 participants