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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
4b194f0
test: added official cypress angular schematic.
zhyd1997 Apr 7, 2022
960e044
build: removed protractor package.
zhyd1997 Apr 7, 2022
8593cf1
chore: added .angular folder into .gitignore.
zhyd1997 Apr 7, 2022
ea23153
chore: fix tsconfig types.
zhyd1997 Apr 7, 2022
d20abed
test: base cypress.
zhyd1997 Apr 7, 2022
8970ebc
test: oauth2 cypress.
zhyd1997 Apr 7, 2022
4ef5ca5
test: jwt cypress.
zhyd1997 Apr 7, 2022
c9bfd5a
chore: renamed e2e/spec to cypress/integration.
zhyd1997 Apr 7, 2022
430c1d8
test: template cypress [1/2].
zhyd1997 Apr 7, 2022
04ec06e
test: templates cypress [2/2].
zhyd1997 Apr 7, 2022
8a8d28f
fix: updated e2e test dir.
zhyd1997 Apr 7, 2022
5d7cfd6
fix: updated login page path in e2e file.
zhyd1997 Apr 7, 2022
5f1fc90
fix: updated login page path in e2e file (oauth2).
zhyd1997 Apr 7, 2022
ad50f3b
fix: removed await keyword.
zhyd1997 Apr 7, 2022
42b4982
build: added missing '@cypress/schematic'.
zhyd1997 Apr 7, 2022
e784ff4
test: updated snapshots.
zhyd1997 Apr 8, 2022
ac2f328
fix: typo.
zhyd1997 Apr 8, 2022
929a23e
test: fixed CORS issue.
zhyd1997 Apr 12, 2022
128104a
test: oAuth 2.0
zhyd1997 Apr 12, 2022
0bd07e2
test: fix login failed with OAuth 2.0
zhyd1997 Apr 12, 2022
7703e1d
refactor: consisted OAuth test style with JWT.
zhyd1997 Apr 13, 2022
3f5b2b7
test: updated entity e2e.
zhyd1997 Apr 13, 2022
a4e5783
test: fix grammar error.
zhyd1997 Apr 13, 2022
56a97e4
chore: removed unnecessary .angular from .gitignore.
zhyd1997 Apr 14, 2022
8ee3237
fix: added cypress-localstore-commands library for perserve local sto…
zhyd1997 Apr 14, 2022
0b0f905
test: fixed kc login.
zhyd1997 Apr 14, 2022
9d9aca3
ci: enabled e2e github actions.
zhyd1997 Apr 14, 2022
c138424
chore: removed unexisted package-lock.json in main branch codebase.
zhyd1997 Apr 14, 2022
c6bc50b
fix: typo.
zhyd1997 Apr 14, 2022
a54f4f2
fix: removed redundant signIn click.
zhyd1997 Apr 14, 2022
0c412dc
[WIP] ci: used cypress official gh actions.
zhyd1997 Apr 14, 2022
efb3da2
ci: added cypress e2e running command.
zhyd1997 Apr 14, 2022
a99947b
ci: updated e2e script.
zhyd1997 Apr 15, 2022
f2d2da1
fix: missing cy.visit() at the first time.
zhyd1997 Apr 15, 2022
78acec2
fix: conditional render login button.
zhyd1997 Apr 16, 2022
e4be791
refactor: moved page objects into support folder.
zhyd1997 Apr 16, 2022
60742a3
fix: replaced kc-login with signIn button.
zhyd1997 Apr 16, 2022
40d60f3
ci: added keycloak host.
zhyd1997 Apr 16, 2022
6af21da
fix: used Chrome for e2e test and enabled Cookies.
zhyd1997 Apr 17, 2022
b542177
Merge pull request #644 from zhyd1997/test/migrated_e2e_from_protract…
mshima Apr 25, 2022
5d49f31
Continue cypress migration.
mshima Apr 26, 2022
ee1878d
Update snapshots
mshima Apr 26, 2022
7b506f0
Fixes to jwt.
mshima Apr 27, 2022
a72b918
Upload cypress results.
mshima Apr 27, 2022
46fd845
Stop using ng cli for cypress
mshima Apr 27, 2022
8fa340a
Customize docker app.yml for ionic cors.
mshima Apr 27, 2022
bc37477
Revert "Stop using ng cli for cypress"
mshima Apr 27, 2022
4bc5680
Adjust replacement
mshima Apr 27, 2022
d8a616a
Reduce to 2 retries
mshima Apr 27, 2022
ebae346
Start supporting others fieldTypes.
mshima Apr 27, 2022
1b34a29
Fix enum fields.
mshima Apr 27, 2022
057e275
Update snapshot
mshima Apr 27, 2022
b112637
Implement oauth2 login by api.
mshima Apr 28, 2022
a8c3aa9
Drop cypress-localstorage-commands dependency
mshima Apr 28, 2022
e8a594a
Use entityClassHumanized at menus.
mshima Apr 28, 2022
94264ac
Customize .prettierignore
mshima Apr 28, 2022
c765a87
Update snapshot
mshima Apr 28, 2022
ad74e94
Move app.component.(html/scss) to base
mshima Apr 28, 2022
0f6e134
Redirect to tabs when logged in with jwt.
mshima Apr 28, 2022
8644a66
Fix jwt welcome test.
mshima Apr 28, 2022
b1dcb6e
Fix cypress with blobs.
mshima Apr 28, 2022
60b31ad
Customize gitignore
mshima Apr 28, 2022
2facd14
Fix typo
mshima Apr 29, 2022
eebd45b
Replace docker env with a spring profile.
mshima Apr 29, 2022
ba0624e
Update snapshot
mshima Apr 29, 2022
aff1e34
Fix .gitignore
mshima Apr 29, 2022
8a49bb1
Disable video by default
mshima Apr 29, 2022
e8f1a4f
Change constants from camel case to upper case.
mshima Apr 29, 2022
d7a0e4f
Remove bad password test and enable admin login test.
mshima Apr 29, 2022
e479eff
Remove issuer trailing / if exists.
mshima Apr 29, 2022
af3a6e9
Update login.e2e-spec.ts
mshima Apr 29, 2022
909628c
Cleanup server generator
mshima Apr 29, 2022
9b2cd45
Environment variables required Cypress.env().
mshima Apr 29, 2022
04d0d97
Configure ng serve to run at port 8100
mshima Apr 29, 2022
9dc0fc1
Capitalize Ionic [skip-ci]
Apr 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions .github/workflows/ionic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ jobs:
- 21-points
include:
- jdl: monolith-jwt
e2e: 0
e2e: 1
- jdl: monolith-oauth2
e2e: 0
e2e: 1
- jdl: gateway-oauth2
e2e: 0
e2e: 1
- jdl: reactive-oauth2
e2e: 0
e2e: 1
- jdl: 21-points
e2e: 0
e2e: 1

steps:
#----------------------------------------------------------------------
Expand Down Expand Up @@ -104,10 +104,30 @@ jobs:
run: npm run docker:app:up
- name: Wait for backend to start
run: npm run ci:server:await
- name: Modify /etc/hosts
run: |
echo '127.0.0.1 keycloak' | sudo tee -a /etc/hosts
cat /etc/hosts
- name: Launch ionic e2e test
id: e2e
if: ${{ matrix.e2e == 1 }}
run: xvfb-run --server-args="-screen 0 1024x768x24" --auto-servernum npm run e2e
working-directory: ${{ github.workspace }}/ionic4j
uses: cypress-io/github-action@v2
with:
browser: chrome
command: npm run e2e:ci
working-directory: ${{ github.workspace }}/ionic4j
- name: 'E2E: Store failure screenshots'
uses: actions/upload-artifact@v3
if: always() && steps.e2e.outcome == 'failure'
with:
name: screenshots-${{ matrix.jdl }}
path: ${{ github.workspace }}/ionic4j/cypress/screenshots
- name: 'E2E: Store failure videos'
uses: actions/upload-artifact@v3
if: always() && steps.e2e.outcome == 'failure'
with:
name: videos-${{ matrix.jdl }}
path: ${{ github.workspace }}/ionic4j/cypress/videos
- name: Dump docker logs on failure
if: failure()
uses: jwalton/gh-docker-logs@v2
8 changes: 7 additions & 1 deletion .yo-rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,18 @@
],
"sbs": false,
"written": true
},
"server": {
"command": false,
"priorities": ["postWriting"],
"sbs": true,
"written": true
}
},
"jhipsterVersion": "7.7.0",
"prettierDefaultIndent": 2,
"projectName": "JHipster Ionic Blueprint v2",
"skipCommitHook": true,
"subGenerators": ["app", "ionic", "project-name"]
"subGenerators": ["app", "ionic", "project-name", "server"]
}
}
2 changes: 1 addition & 1 deletion cli/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const packageFolderName = basename(packagePath);
[packageFolderName]: version,
},
printBlueprintLogo: () => {
console.log('===================== JHipster ionic =====================');
console.log('===================== JHipster Ionic =====================');
console.log('');
},
lookups: [{ packagePaths: [packagePath], lookups: ['generators'] }],
Expand Down
60 changes: 48 additions & 12 deletions generators/app/__snapshots__/generator.spec.mjs.snap
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,40 @@ Object {
"../ionic4j/capacitor.config.ts": Object {
"stateCleared": "modified",
},
"../ionic4j/e2e/pages/app.po.ts": Object {
"../ionic4j/cypress.json": Object {
"stateCleared": "modified",
},
"../ionic4j/e2e/pages/login.po.ts": Object {
"../ionic4j/cypress/fixtures/integration-test.png": Object {
"stateCleared": "modified",
},
"../ionic4j/e2e/protractor.conf.js": Object {
"../ionic4j/cypress/integration/app.e2e-spec.ts": Object {
"stateCleared": "modified",
},
"../ionic4j/e2e/spec/app.e2e-spec.ts": Object {
"../ionic4j/cypress/integration/login.e2e-spec.ts": Object {
"stateCleared": "modified",
},
"../ionic4j/e2e/spec/login.e2e-spec.ts": Object {
"../ionic4j/cypress/plugins/index.ts": Object {
"stateCleared": "modified",
},
"../ionic4j/e2e/tsconfig.json": Object {
"../ionic4j/cypress/support/commands.ts": Object {
"stateCleared": "modified",
},
"../ionic4j/cypress/support/config.ts": Object {
"stateCleared": "modified",
},
"../ionic4j/cypress/support/index.ts": Object {
"stateCleared": "modified",
},
"../ionic4j/cypress/support/pages/app.po.ts": Object {
"stateCleared": "modified",
},
"../ionic4j/cypress/support/pages/entity.po.ts": Object {
"stateCleared": "modified",
},
"../ionic4j/cypress/support/pages/login.po.ts": Object {
"stateCleared": "modified",
},
"../ionic4j/cypress/tsconfig.json": Object {
"stateCleared": "modified",
},
"../ionic4j/ionic.config.json": Object {
Expand Down Expand Up @@ -550,22 +568,40 @@ Object {
"../ionic-app/capacitor.config.ts": Object {
"stateCleared": "modified",
},
"../ionic-app/e2e/pages/app.po.ts": Object {
"../ionic-app/cypress.json": Object {
"stateCleared": "modified",
},
"../ionic-app/cypress/fixtures/integration-test.png": Object {
"stateCleared": "modified",
},
"../ionic-app/cypress/integration/app.e2e-spec.ts": Object {
"stateCleared": "modified",
},
"../ionic-app/cypress/integration/login.e2e-spec.ts": Object {
"stateCleared": "modified",
},
"../ionic-app/cypress/plugins/index.ts": Object {
"stateCleared": "modified",
},
"../ionic-app/cypress/support/commands.ts": Object {
"stateCleared": "modified",
},
"../ionic-app/cypress/support/config.ts": Object {
"stateCleared": "modified",
},
"../ionic-app/e2e/pages/login.po.ts": Object {
"../ionic-app/cypress/support/index.ts": Object {
"stateCleared": "modified",
},
"../ionic-app/e2e/protractor.conf.js": Object {
"../ionic-app/cypress/support/pages/app.po.ts": Object {
"stateCleared": "modified",
},
"../ionic-app/e2e/spec/app.e2e-spec.ts": Object {
"../ionic-app/cypress/support/pages/entity.po.ts": Object {
"stateCleared": "modified",
},
"../ionic-app/e2e/spec/login.e2e-spec.ts": Object {
"../ionic-app/cypress/support/pages/login.po.ts": Object {
"stateCleared": "modified",
},
"../ionic-app/e2e/tsconfig.json": Object {
"../ionic-app/cypress/tsconfig.json": Object {
"stateCleared": "modified",
},
"../ionic-app/ionic.config.json": Object {
Expand Down
63 changes: 51 additions & 12 deletions generators/ionic/__snapshots__/generator.spec.mjs.snap
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,40 @@ Object {
"capacitor.config.ts": Object {
"stateCleared": "modified",
},
"e2e/pages/app.po.ts": Object {
"cypress.json": Object {
"stateCleared": "modified",
},
"e2e/pages/login.po.ts": Object {
"cypress/fixtures/integration-test.png": Object {
"stateCleared": "modified",
},
"e2e/protractor.conf.js": Object {
"cypress/integration/app.e2e-spec.ts": Object {
"stateCleared": "modified",
},
"e2e/spec/app.e2e-spec.ts": Object {
"cypress/integration/login.e2e-spec.ts": Object {
"stateCleared": "modified",
},
"e2e/spec/login.e2e-spec.ts": Object {
"cypress/plugins/index.ts": Object {
"stateCleared": "modified",
},
"e2e/tsconfig.json": Object {
"cypress/support/commands.ts": Object {
"stateCleared": "modified",
},
"cypress/support/config.ts": Object {
"stateCleared": "modified",
},
"cypress/support/index.ts": Object {
"stateCleared": "modified",
},
"cypress/support/pages/app.po.ts": Object {
"stateCleared": "modified",
},
"cypress/support/pages/entity.po.ts": Object {
"stateCleared": "modified",
},
"cypress/support/pages/login.po.ts": Object {
"stateCleared": "modified",
},
"cypress/tsconfig.json": Object {
"stateCleared": "modified",
},
"ionic.config.json": Object {
Expand Down Expand Up @@ -517,22 +535,43 @@ Object {
"capacitor.config.ts": Object {
"stateCleared": "modified",
},
"e2e/pages/app.po.ts": Object {
"cypress.json": Object {
"stateCleared": "modified",
},
"cypress/fixtures/integration-test.png": Object {
"stateCleared": "modified",
},
"cypress/integration/app.e2e-spec.ts": Object {
"stateCleared": "modified",
},
"cypress/integration/login.e2e-spec.ts": Object {
"stateCleared": "modified",
},
"cypress/plugins/index.ts": Object {
"stateCleared": "modified",
},
"cypress/support/commands.ts": Object {
"stateCleared": "modified",
},
"cypress/support/config.ts": Object {
"stateCleared": "modified",
},
"cypress/support/index.ts": Object {
"stateCleared": "modified",
},
"e2e/pages/login.po.ts": Object {
"cypress/support/oauth2.ts": Object {
"stateCleared": "modified",
},
"e2e/protractor.conf.js": Object {
"cypress/support/pages/app.po.ts": Object {
"stateCleared": "modified",
},
"e2e/spec/app.e2e-spec.ts": Object {
"cypress/support/pages/entity.po.ts": Object {
"stateCleared": "modified",
},
"e2e/spec/login.e2e-spec.ts": Object {
"cypress/support/pages/login.po.ts": Object {
"stateCleared": "modified",
},
"e2e/tsconfig.json": Object {
"cypress/tsconfig.json": Object {
"stateCleared": "modified",
},
"ionic.config.json": Object {
Expand Down
15 changes: 12 additions & 3 deletions generators/ionic/files.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
* limitations under the License.
*/
const PAGES_DIR = 'src/app/pages/';
const E2E_TEST_DIR = 'e2e/';
const E2E_ENTITY_DIR = 'cypress/support/pages/';
const E2E_TEST_DIR = 'cypress/integration/';

export const files = {
client: [
{
templates: [
'capacitor.config.ts',
'ionic.config.json',
'e2e/pages/login.po.ts',
'src/app/interceptors/auth.interceptor.ts',
'src/app/pages/home/home.page.scss',
'src/app/pages/welcome/welcome.page.scss',
Expand Down Expand Up @@ -104,16 +104,25 @@ export const entityFiles = {
],
e2e: [
{
path: E2E_TEST_DIR,
path: E2E_ENTITY_DIR,
templates: [
{
file: 'entities/_entity.po.ts',
renameTo: ctx => `entities/${ctx.entityFolderName}/${ctx.entityFileName}.po.ts`,
},
],
},
{
path: E2E_TEST_DIR,
templates: [
{
file: 'entities/_entity.e2e-spec.ts',
renameTo: ctx => `entities/${ctx.entityFolderName}/${ctx.entityFileName}.e2e-spec.ts`,
},
{
file: 'entities/_entity.json',
renameTo: ctx => `entities/${ctx.entityFolderName}/${ctx.entityFileName}.json`,
},
],
},
],
Expand Down
35 changes: 10 additions & 25 deletions generators/ionic/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -194,22 +194,9 @@ export default class extends GeneratorBaseEntities {
},
});
// write client side files for angular
this.addEntityToModule(
entity.entityentityInstance,
entity.entityClass,
entity.entityAngularName,
entity.entityFolderName,
entity.entityFileName,
entity.enableTranslation
);
this.addEntityRouteToModule(
entity.entityInstance,
entity.entityClass,
entity.entityAngularName,
entity.entityFolderName,
entity.entityFileName,
entity.enableTranslation
);
const { entityClassHumanized, entityAngularName, entityFileName, entityFolderName } = entity;
this.addEntityToModule({ entityClassHumanized, entityAngularName, entityFileName });
this.addEntityRouteToModule({ entityAngularName, entityFolderName, entityFileName });
})
);
},
Expand Down Expand Up @@ -312,14 +299,12 @@ ${chalk.green(` ionic serve`)}
* @private
* Add a new entity in the TS modules file.
*
* @param {string} entityInstance - Entity Instance
* @param {string} entityClass - Entity Class
* @param {string} entityAngularName - Entity Angular Name
* @param {string} entityFolderName - Entity Folder Name
* @param {string} entityFileName - Entity File Name
* @param {boolean} enableTranslation - If translations are enabled or not
* @param {string} options - Entity Instance
* @param {string} options.entityClassHumanized - Entity Class
* @param {string} options.entityAngularName - Entity Angular Name
* @param {string} options.entityFileName - Entity File Name
*/
addEntityToModule(entityInstance, entityClass, entityAngularName, entityFolderName, entityFileName, enableTranslation) {
addEntityToModule({ entityClassHumanized, entityAngularName, entityFileName }) {
// workaround method being called on initialization
if (!entityAngularName) {
return;
Expand All @@ -329,7 +314,7 @@ ${chalk.green(` ionic serve`)}
const isSpecificEntityAlreadyGenerated = utils.checkStringInFile(entityPagePath, `route: '${entityFileName}'`, this);

if (!isSpecificEntityAlreadyGenerated) {
const pageEntry = `{ name: '${entityAngularName}', component: '${entityAngularName}Page', route: '${entityFileName}' },`;
const pageEntry = `{ name: '${entityClassHumanized}', component: '${entityAngularName}Page', route: '${entityFileName}' },`;
utils.rewriteFile(
{
file: entityPagePath,
Expand Down Expand Up @@ -363,7 +348,7 @@ ${chalk.green(` ionic serve`)}
* @param {string} entityFileName - Entity File Name
* @param {boolean} enableTranslation - If translations are enabled or not
*/
addEntityRouteToModule(entityInstance, entityClass, entityAngularName, entityFolderName, entityFileName, enableTranslation) {
addEntityRouteToModule({ entityAngularName, entityFolderName, entityFileName }) {
// workaround method being called on initialization
if (!entityAngularName) {
return;
Expand Down
5 changes: 5 additions & 0 deletions generators/ionic/resources/base/.gitignore.jhi.ionic
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<&_ if (!fragment.section) { -&>
# ionic rules:
cypress/screenshots
cypress/videos
<&_ } -&>
6 changes: 6 additions & 0 deletions generators/ionic/resources/base/.prettierignore.jhi.ionic
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<&_ if (!fragment.section) { -&>
# ionic rules:
.angular
cypress/screenshots
cypress/videos
<&_ } -&>
Loading