From 210112ee4bde98ec380ff70170eba717e580246b Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 22 Aug 2018 16:50:38 +0200 Subject: [PATCH 1/7] Started working on the import passphrase E2E tests --- cypress/integration/import-passphrase-page.ts | 19 +++++++++ .../wallet-import-passphrase.html | 42 ++++++++++--------- 2 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 cypress/integration/import-passphrase-page.ts diff --git a/cypress/integration/import-passphrase-page.ts b/cypress/integration/import-passphrase-page.ts new file mode 100644 index 0000000..db65ceb --- /dev/null +++ b/cypress/integration/import-passphrase-page.ts @@ -0,0 +1,19 @@ +import { cleanIndexedDB } from "../plugins/helpers/clean-indexed-db"; + +describe("ImportPassphrasePage", () => { + beforeEach(() => { + cleanIndexedDB(); + + cy.visit("http://localhost:8100"); + }); + + it("should not show the import button initially", () => { + + }); + + function goToPage() { + cy.get("[data-cy=restore-backup-button]").click(); + + cy.get("[data-cy=import-passphrase-button]").click(); + } +}); \ No newline at end of file diff --git a/src/pages/wallet-import-passphrase/wallet-import-passphrase.html b/src/pages/wallet-import-passphrase/wallet-import-passphrase.html index a8400a3..98ea5d7 100644 --- a/src/pages/wallet-import-passphrase/wallet-import-passphrase.html +++ b/src/pages/wallet-import-passphrase/wallet-import-passphrase.html @@ -15,8 +15,8 @@ formControlName="passphrase" [(ngModel)]="passphrase" (ionChange)="onPassphraseChanged()" - class="passphrase-input" - [placeholder]="'import_passphrase.passphrase_hint' | translate"> + [placeholder]="'import_passphrase.passphrase_hint' | translate" + [attr.data-cy]="'passphrase-input'"> @@ -25,9 +25,9 @@ + (ionChange)="onPasswordChanged()" + [attr.data-cy]="'password-input'"> @@ -36,18 +36,18 @@ + (ionChange)="onPasswordChanged()" + [attr.data-cy]="'password-confirm-input'"> {{ 'import_passphrase.wallet_name' | translate }} - +
@@ -55,36 +55,38 @@ {{ 'import_passphrase.wallet_index' | translate }} - + [(ngModel)]="walletIndex" + [attr.data-cy]="'wallet-index-input'">
-
+
{{ passwordStatus.message }}
-
+
+ class="error-box"> {{ passphraseStatus.errorMessage }}
-
- +
+ {{ 'import_passphrase.errors.wallet_index' | translate }}
- +
-
@@ -92,7 +94,7 @@
-
From 492a0c1cbd8caad95d9d6705319430d447e6e93e Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 22 Aug 2018 16:56:27 +0200 Subject: [PATCH 2/7] Moved the goToPage call to the beforeEach --- cypress/integration/import-private-key-page.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/cypress/integration/import-private-key-page.ts b/cypress/integration/import-private-key-page.ts index 0f3816a..2a9191f 100644 --- a/cypress/integration/import-private-key-page.ts +++ b/cypress/integration/import-private-key-page.ts @@ -5,11 +5,11 @@ describe("ImportPrivateKeyPage", () => { cleanIndexedDB(); cy.visit("http://localhost:8100"); - }); - it("should not show the import button initially", () => { goToPage(); + }); + it("should not show the import button initially", () => { cy.get("page-wallet-import-privatekey").then( (page) => { expect(page.find("[data-cy=import-privatekey-button]")).to.have.length(0); @@ -18,8 +18,6 @@ describe("ImportPrivateKeyPage", () => { }); it("should show a password warning if the passwords do not match", () => { - goToPage(); - cy.get("[data-cy=password-input] input").type("pass123"); cy.get("[data-cy=password-confirm-input] input").type("321ssap"); @@ -27,8 +25,6 @@ describe("ImportPrivateKeyPage", () => { }); it("should show the import button once all fields have been filled correctly", () => { - goToPage(); - cy.get("[data-cy=private-key-input] textarea").type("PrivateKey"); cy.get("[data-cy=wallet-name-input] input").type("Wallet Name"); cy.get("[data-cy=password-input] input").type("pass123"); @@ -41,8 +37,6 @@ describe("ImportPrivateKeyPage", () => { }); it("should show a password explanation dialog", () => { - goToPage(); - // Open modal cy.get("[data-cy=password-explanation]").click(); From d79af6c96aa37ef152c52ab0fd65f861783f51e7 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 22 Aug 2018 17:12:22 +0200 Subject: [PATCH 3/7] Continued working on the E2E tests for the import passphrase page --- cypress/integration/import-passphrase-page.ts | 46 +++++++++++++++++++ cypress/plugins/helpers/element-exists.ts | 9 ++++ cypress/plugins/helpers/element-not-exists.ts | 9 ++++ .../wallet-import-passphrase.html | 2 +- 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 cypress/plugins/helpers/element-exists.ts create mode 100644 cypress/plugins/helpers/element-not-exists.ts diff --git a/cypress/integration/import-passphrase-page.ts b/cypress/integration/import-passphrase-page.ts index db65ceb..e2bf984 100644 --- a/cypress/integration/import-passphrase-page.ts +++ b/cypress/integration/import-passphrase-page.ts @@ -1,16 +1,62 @@ import { cleanIndexedDB } from "../plugins/helpers/clean-indexed-db"; +import { elementExists } from "../plugins/helpers/element-exists"; +import { elementNotExists } from "../plugins/helpers/element-not-exists"; describe("ImportPassphrasePage", () => { beforeEach(() => { cleanIndexedDB(); cy.visit("http://localhost:8100"); + + goToPage(); }); it("should not show the import button initially", () => { + cy.get("page-wallet-import-passphrase").then( + (page) => { + expect(page.find("[data-cy=import-button]")).to.have.length(0); + } + ); + }); + + it("should show a warning if the passwords do not match", () => { + cy.get("[data-cy=password-input] input").type("pass123"); + cy.get("[data-cy=password-confirm-input] input").type("321ssap"); + + cy.get("[data-cy=password-error-box]"); + }); + + it("should show a warning if the passphrase is invalid", () => { + cy.get("[data-cy=passphrase-input] textarea").type("bla bla bla"); + + cy.get("[data-cy=passphrase-error-box]"); + }); + it("should show the import button once all fields have been filled correctly", () => { + cy.get("[data-cy=passphrase-input] textarea").type("one two three"); + + cy.get("[data-cy=password-input] input").type("pass123"); + cy.get("[data-cy=password-confirm-input] input").type("pass123"); + + cy.get("[data-cy=wallet-name-input] input").type("Wallet Name"); + + cy.get("[data-cy=import-button]").click(); + + cy.get("page-prepare-wallet"); }); + it("should work correctly with the advanced options", () => { + // ToDo + }); + + function advancedOptionsAreVisible(visible: boolean): Cypress.Chainable { + return cy.get("page-wallet-import-passphrase").then( + (page) => { + expect(page.find("[data-cy=wallet-index-input]")).to.have.length(visible ? 1 : 0); + } + ) + } + function goToPage() { cy.get("[data-cy=restore-backup-button]").click(); diff --git a/cypress/plugins/helpers/element-exists.ts b/cypress/plugins/helpers/element-exists.ts new file mode 100644 index 0000000..501b3fd --- /dev/null +++ b/cypress/plugins/helpers/element-exists.ts @@ -0,0 +1,9 @@ +/// + +export function elementExists(baseSelector: string, selector: string): Cypress.Chainable { + return cy.get(baseSelector).then( + (baseElement) => { + expect(baseElement.find(selector)).to.have.length(1); + } + ) +} \ No newline at end of file diff --git a/cypress/plugins/helpers/element-not-exists.ts b/cypress/plugins/helpers/element-not-exists.ts new file mode 100644 index 0000000..254feaa --- /dev/null +++ b/cypress/plugins/helpers/element-not-exists.ts @@ -0,0 +1,9 @@ +/// + +export function elementNotExists(baseSelector: string, selector: string): Cypress.Chainable { + return cy.get(baseSelector).then( + (baseElement) => { + expect(baseElement.find(selector)).to.have.length(0); + } + ) +} \ No newline at end of file diff --git a/src/pages/wallet-import-passphrase/wallet-import-passphrase.html b/src/pages/wallet-import-passphrase/wallet-import-passphrase.html index 98ea5d7..d5294ea 100644 --- a/src/pages/wallet-import-passphrase/wallet-import-passphrase.html +++ b/src/pages/wallet-import-passphrase/wallet-import-passphrase.html @@ -86,7 +86,7 @@
From 1ce872da1d5c61fe30f594b9c7571539903e944b Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 30 Aug 2018 08:54:17 +0200 Subject: [PATCH 4/7] Finished e2e tests for the import from passphrase page --- cypress/integration/import-passphrase-page.ts | 43 ++++++++++++------- cypress/plugins/helpers/element-exists.ts | 9 ---- 2 files changed, 28 insertions(+), 24 deletions(-) delete mode 100644 cypress/plugins/helpers/element-exists.ts diff --git a/cypress/integration/import-passphrase-page.ts b/cypress/integration/import-passphrase-page.ts index e2bf984..f7a2349 100644 --- a/cypress/integration/import-passphrase-page.ts +++ b/cypress/integration/import-passphrase-page.ts @@ -1,5 +1,4 @@ import { cleanIndexedDB } from "../plugins/helpers/clean-indexed-db"; -import { elementExists } from "../plugins/helpers/element-exists"; import { elementNotExists } from "../plugins/helpers/element-not-exists"; describe("ImportPassphrasePage", () => { @@ -12,11 +11,7 @@ describe("ImportPassphrasePage", () => { }); it("should not show the import button initially", () => { - cy.get("page-wallet-import-passphrase").then( - (page) => { - expect(page.find("[data-cy=import-button]")).to.have.length(0); - } - ); + elementNotExists("page-wallet-import-passphrase", "[data-cy=import-button]"); }); it("should show a warning if the passwords do not match", () => { @@ -45,17 +40,35 @@ describe("ImportPassphrasePage", () => { cy.get("page-prepare-wallet"); }); - it("should work correctly with the advanced options", () => { - // ToDo - }); + it("should toggle the advanced options correctly", () => { + elementNotExists("page-wallet-import-passphrase", "[data-cy=wallet-index-input] input").then( + () => { + cy.get("[data-cy=toggle-advanced-button").click(); + + cy.get("[data-cy=wallet-index-input] input"); - function advancedOptionsAreVisible(visible: boolean): Cypress.Chainable { - return cy.get("page-wallet-import-passphrase").then( - (page) => { - expect(page.find("[data-cy=wallet-index-input]")).to.have.length(visible ? 1 : 0); + cy.get("[data-cy=toggle-advanced-button").click(); + + elementNotExists("page-wallet-import-passphrase", "[data-cy=wallet-index-input] input"); } - ) - } + ); + }); + + it("should show a warning when entering incorrect address index input", () => { + cy.get("[data-cy=toggle-advanced-button").click(); + + cy.get("[data-cy=wallet-index-input] input").clear(); + + cy.get("[data-cy=wallet-index-input] input").type("wrong input"); + + cy.get("[data-cy=wallet-index-error-box]"); + + cy.get("[data-cy=wallet-index-input] input").clear(); + + cy.get("[data-cy=wallet-index-input] input").type("100"); + + elementNotExists("page-wallet-import-passphrase", "[data-cy=wallet-index-error-box]"); + }); function goToPage() { cy.get("[data-cy=restore-backup-button]").click(); diff --git a/cypress/plugins/helpers/element-exists.ts b/cypress/plugins/helpers/element-exists.ts deleted file mode 100644 index 501b3fd..0000000 --- a/cypress/plugins/helpers/element-exists.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// - -export function elementExists(baseSelector: string, selector: string): Cypress.Chainable { - return cy.get(baseSelector).then( - (baseElement) => { - expect(baseElement.find(selector)).to.have.length(1); - } - ) -} \ No newline at end of file From 21c0bd15000a8cb44364ebd9e3f4c1b98a8b3823 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 30 Aug 2018 09:54:31 +0200 Subject: [PATCH 5/7] Possible fix for failing test --- cypress/integration/import-passphrase-page.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cypress/integration/import-passphrase-page.ts b/cypress/integration/import-passphrase-page.ts index f7a2349..fe23b7d 100644 --- a/cypress/integration/import-passphrase-page.ts +++ b/cypress/integration/import-passphrase-page.ts @@ -35,6 +35,8 @@ describe("ImportPassphrasePage", () => { cy.get("[data-cy=wallet-name-input] input").type("Wallet Name"); + cy.wait(2000); + cy.get("[data-cy=import-button]").click(); cy.get("page-prepare-wallet"); From 96e566d6ab3db24438e9271f688361e1eebf4a57 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 3 Sep 2018 11:47:31 +0200 Subject: [PATCH 6/7] Potential fix for failing e2e tests --- cypress/integration/import-passphrase-page.ts | 4 +--- cypress/integration/import-private-key-page.ts | 2 +- cypress/plugins/helpers/clean-indexed-db.ts | 4 +++- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cypress/integration/import-passphrase-page.ts b/cypress/integration/import-passphrase-page.ts index fe23b7d..5cc8248 100644 --- a/cypress/integration/import-passphrase-page.ts +++ b/cypress/integration/import-passphrase-page.ts @@ -4,7 +4,7 @@ import { elementNotExists } from "../plugins/helpers/element-not-exists"; describe("ImportPassphrasePage", () => { beforeEach(() => { cleanIndexedDB(); - + cy.visit("http://localhost:8100"); goToPage(); @@ -35,8 +35,6 @@ describe("ImportPassphrasePage", () => { cy.get("[data-cy=wallet-name-input] input").type("Wallet Name"); - cy.wait(2000); - cy.get("[data-cy=import-button]").click(); cy.get("page-prepare-wallet"); diff --git a/cypress/integration/import-private-key-page.ts b/cypress/integration/import-private-key-page.ts index 2a9191f..9742940 100644 --- a/cypress/integration/import-private-key-page.ts +++ b/cypress/integration/import-private-key-page.ts @@ -47,7 +47,7 @@ describe("ImportPrivateKeyPage", () => { cy.get("[data-cy=password-explain-ok-button]").click(); // Wait to allow the modal animation to end - cy.wait(2000); + cy.wait(10000); cy.get("body").then( (body) => { diff --git a/cypress/plugins/helpers/clean-indexed-db.ts b/cypress/plugins/helpers/clean-indexed-db.ts index 4e7ced2..069f966 100644 --- a/cypress/plugins/helpers/clean-indexed-db.ts +++ b/cypress/plugins/helpers/clean-indexed-db.ts @@ -1,3 +1,5 @@ +/// + export function cleanIndexedDB() { - indexedDB.deleteDatabase("_ionicstorage"); + indexedDB.deleteDatabase("smilo-wallet"); } \ No newline at end of file From fa7a4cd162f9624090cf2445f233a96efb5c01cd Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 7 Sep 2018 09:30:07 +0200 Subject: [PATCH 7/7] Continued tweaking E2E tests --- cypress.json | 2 +- cypress/tsconfig.json | 4 ++++ package.json | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cypress.json b/cypress.json index 0f0f794..5ded01a 100644 --- a/cypress.json +++ b/cypress.json @@ -1,3 +1,3 @@ { - "video": false + "video": true } diff --git a/cypress/tsconfig.json b/cypress/tsconfig.json index c36bdf8..06e5c75 100644 --- a/cypress/tsconfig.json +++ b/cypress/tsconfig.json @@ -4,6 +4,10 @@ "module": "commonjs", "skipLibCheck": true, "strict": true, + "lib": [ + "es2015", + "dom" + ], "types": [ "node", "cypress" diff --git a/package.json b/package.json index d7ea497..79774f7 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "test-ci": "karma start ./test-config/karma.conf.js --coverage --single-run", "e2e": "cypress open", "e2e-ci": "nohup ionic serve --no-open --no-livereload --no-interactive &> /dev/null & (wait-on http://localhost:8100 && cypress run && pkill -f ionic)", + "e2e-electron-headed": "cypress run --headed", "ionic:build": "ionic-app-scripts build", "ionic:serve": "ionic-app-scripts serve", "release:android": "./scripts/release-android.sh",