Skip to content

Commit

Permalink
test: add e2e tests for wallet pages
Browse files Browse the repository at this point in the history
  • Loading branch information
faustbrian committed Aug 9, 2019
1 parent 55690e7 commit d22a89d
Show file tree
Hide file tree
Showing 11 changed files with 469 additions and 251 deletions.
57 changes: 33 additions & 24 deletions .circleci/config.yml
@@ -1,26 +1,35 @@
version: 2
jobs:
node-12:
docker:
- image: circleci/node:12
working_directory: ~/paper-wallet
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "yarn.lock" }}
- v1-dependencies-
- run: yarn install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "yarn.lock" }}
- run: yarn build
- run: yarn test:unit
# - run: yarn test:e2e
- run: ./node_modules/.bin/codecov
version: 2.1
orbs:
cypress: cypress-io/cypress@1
workflows:
version: 2
build_and_test:
build:
jobs:
- node-12
- cypress/run:
yarn: true
- unit:
docker:
- image: circleci/node:12
working_directory: ~/paper-wallet
steps:
- checkout
- restore_cache:
keys:
- v1-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}
- v1-deps-{{ .Branch }}
- v1-deps
- run:
name: Install Dependencies
command: yarn install --frozen-lockfile
- save_cache:
paths:
- ~/.cache
key: v1-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}
- run:
name: Build
command: yarn build
- run:
name: Unit Tests
command: yarn test:unit
- run:
name: Codecov
command: ./node_modules/.bin/codecov
8 changes: 4 additions & 4 deletions CHANGELOG.md
Expand Up @@ -11,15 +11,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Added

- Message signing and verifying ([#25])
- Message signing and verifying ([#25])

### Fixed

- Remove wallet data from url ([#23])
- Resolved an issue with saving generated wallets on iOS ([#22])
- Remove wallet data from url ([#23])
- Resolved an issue with saving generated wallets on iOS ([#22])

## 3.0.0 - 25-07-2019

### Added

- New ARK Paper Wallet version built from scratch, made with Vue.JS and TailwindCSS
- New ARK Paper Wallet version built from scratch, made with Vue.JS and TailwindCSS
12 changes: 6 additions & 6 deletions src/router.ts
Expand Up @@ -13,14 +13,14 @@ export default new Router({
},
// Wallet...
{
path: "/entropy",
name: "entropy",
component: () => import(/* webpackChunkName: "entropy" */ "./views/WalletFromEntropy.vue"),
path: "/wallet/entropy",
name: "wallet:entropy",
component: () => import(/* webpackChunkName: "wallet:entropy" */ "./views/WalletFromEntropy.vue"),
},
{
path: "/passphrase",
name: "passphrase",
component: () => import(/* webpackChunkName: "passphrase" */ "./views/WalletFromPassphrase.vue"),
path: "/wallet/passphrase",
name: "wallet:passphrase",
component: () => import(/* webpackChunkName: "wallet:passphrase" */ "./views/WalletFromPassphrase.vue"),
},
{
path: "/wallet",
Expand Down
14 changes: 8 additions & 6 deletions src/views/Home.vue
@@ -1,11 +1,13 @@
<template>
<div class="home">
<div v-if="!showMessageButtons" class="flex flex-col sm:flex-row flex-wrap mt-5 mb-5">
<router-link class="primary-action-button mb-5 sm:mb-0 sm:mr-5 whitespace-no-wrap" :to="{ name: 'entropy' }"
<router-link
class="primary-action-button mb-5 sm:mb-0 sm:mr-5 whitespace-no-wrap"
:to="{ name: 'wallet:entropy' }"
>Create a new wallet</router-link
>

<router-link class="light-button whitespace-no-wrap" :to="{ name: 'passphrase' }"
<router-link class="light-button whitespace-no-wrap" :to="{ name: 'wallet:passphrase' }"
>Enter a secret passphrase</router-link
>
</div>
Expand All @@ -22,9 +24,7 @@
>
</div>

<button class="text-gray-500 inline-link" @click="toggle()" type="button">
{{ toggleMessage }}
</button>
<button class="text-gray-500 inline-link" @click="toggle()" type="button">{{ toggleMessage }}</button>
</div>
</template>

Expand All @@ -39,7 +39,9 @@ export default class App extends Vue {
public toggle(): void {
this.showMessageButtons = !this.showMessageButtons;
this.showMessageButtons ? this.toggleMessage = "Or generate / import a wallet" : this.toggleMessage = "Or sign / verify a message";
this.showMessageButtons
? (this.toggleMessage = "Or generate / import a wallet")
: (this.toggleMessage = "Or sign / verify a message");
}
}
</script>
4 changes: 3 additions & 1 deletion src/views/MessageSign.vue
Expand Up @@ -22,7 +22,9 @@

<div class="flex flex-col items-center" v-if="errorText">
<Alert :message="errorText" type="error" />
<button v-if="showForceSign" class="text-gray-500 inline-link mt-3" @click.prevent="forceSignMessage">Sign Anyway</button>
<button v-if="showForceSign" class="text-gray-500 inline-link mt-3" @click.prevent="forceSignMessage">
Sign Anyway
</button>
</div>
</div>
</template>
Expand Down
10 changes: 5 additions & 5 deletions src/views/Wallet.vue
@@ -1,8 +1,8 @@
<template>
<div v-if="wallet">
<div id="wallet-details" v-if="wallet">
<input type="hidden" id="wallet-passphrase" :value="wallet.passphrase" />
<input type="hidden" id="wallet-address" :value="wallet.address" />
<input type="hidden" id="wallet-passphrase" :value="wallet.passphrase" />

<div class="bg-white rounded-t-lg mt-10 px-6 sm:px-10 py-6 lg:px-16 lg:py-10">
<div class="text-center border-b border-dashed border-gray-400 pb-3 mb-3">
Expand Down Expand Up @@ -35,7 +35,7 @@
</svg>
</button>
</div>
<span class="font-semibold sm:text-lg break-all">{{ wallet.address }}</span>
<span class="font-semibold sm:text-lg break-all" id="w-address">{{ wallet.address }}</span>
</div>
</div>
<div class="flex flex-col sm:flex-row items-center pt-6">
Expand Down Expand Up @@ -78,15 +78,15 @@
<div class="bg-gray-100 rounded-b-lg px-6 sm:px-10 py-6 lg:px-16 lg:py-10">
<div class="flex flex-col wallet-property-row" v-if="wallet.entropy">
<span>Entropy</span>
<span class="font-semibold text-sm break-all">{{ wallet.entropy }}</span>
<span class="font-semibold text-sm break-all" id="w-entropy">{{ wallet.entropy }}</span>
</div>
<div class="flex flex-col wallet-property-row pb-6" :class="{ 'pt-6': wallet.entropy }">
<span>Public Key</span>
<span class="font-semibold text-sm break-all">{{ wallet.publicKey }}</span>
<span class="font-semibold text-sm break-all" id="w-publicKey">{{ wallet.publicKey }}</span>
</div>
<div class="flex flex-col pt-6">
<span>WIF</span>
<span class="font-semibold text-sm break-all">{{ wallet.wif }}</span>
<span class="font-semibold text-sm break-all" id="w-wif">{{ wallet.wif }}</span>
</div>
</div>
</div>
Expand Down
13 changes: 12 additions & 1 deletion src/views/WalletFromPassphrase.vue
@@ -1,7 +1,13 @@
<template>
<div>
<div class="flex items-center wallet-from-passphrase mt-5">
<input type="text" placeholder="Enter your passphrase" v-model="passphrase" class="border p-4 mr-5" />
<input
type="text"
placeholder="Enter your passphrase"
v-model="passphrase"
class="border p-4 mr-5"
id="wallet-passphrase"
/>
<button class="primary-action-button" @click.prevent="generateWallet">Generate</button>
</div>
<div class="flex flex-col items-center" v-if="errorText">
Expand All @@ -25,6 +31,11 @@ export default class WalletFromPassphrase extends Vue {
public errorText: string | null = null;
public generateWallet(): void {
if (!this.passphrase) {
this.errorText = "Please fill out the passphrase.";
return;
}
if (!validateMnemonic(this.passphrase)) {
this.errorText = "The passphrase does not appear to be BIP39";
return;
Expand Down
2 changes: 1 addition & 1 deletion tests/__fixtures__/identity.json
Expand Up @@ -2,7 +2,7 @@
"data": {
"privateKey": "d8839c2432bfd0a67ef10a804ba991eabba19f154a3d707917681d45822a5712",
"publicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192",
"address": "D61mfSggzbvQgTUe6JhYKH2doHaqJ3Dyib",
"address": "AGeYmgbg2LgGxRW2vNNJvQ88PknEJsYizC",
"wif": "SGq4xLgZKCGxs7bjmwnBrWcT4C1ADFEermj846KC97FSv1WFD1dA"
},
"passphrase": "this is a top secret passphrase"
Expand Down
9 changes: 9 additions & 0 deletions tests/e2e/specs/message.js
Expand Up @@ -4,6 +4,7 @@ import fixture from "../../__fixtures__/message.json";
describe("Message - Sign", () => {
it("should fail if no message is given", () => {
cy.visit("/");
cy.contains("Or sign / verify a message").click();
cy.contains("a", "Sign Message");
cy.contains("Sign Message").click();
cy.url().should("eq", "http://localhost:8080/#/message/sign");
Expand All @@ -15,6 +16,7 @@ describe("Message - Sign", () => {

it("should fail if no passphrase is given", () => {
cy.visit("/");
cy.contains("Or sign / verify a message").click();
cy.contains("a", "Sign Message");
cy.contains("Sign Message").click();
cy.url().should("eq", "http://localhost:8080/#/message/sign");
Expand All @@ -27,6 +29,7 @@ describe("Message - Sign", () => {

it("should sign a message (bip39)", () => {
cy.visit("/");
cy.contains("Or sign / verify a message").click();
cy.contains("a", "Sign Message");
cy.contains("Sign Message").click();
cy.url().should("eq", "http://localhost:8080/#/message/sign");
Expand All @@ -48,6 +51,7 @@ describe("Message - Sign", () => {

it("should sign a message (no bip39)", () => {
cy.visit("/");
cy.contains("Or sign / verify a message").click();
cy.contains("a", "Sign Message");
cy.contains("Sign Message").click();
cy.url().should("eq", "http://localhost:8080/#/message/sign");
Expand All @@ -67,6 +71,7 @@ describe("Message - Sign", () => {
describe("Message - Verify", () => {
it("should fail if no message is given", () => {
cy.visit("/");
cy.contains("Or sign / verify a message").click();
cy.contains("a", "Verify Message");
cy.contains("Verify Message").click();
cy.url().should("eq", "http://localhost:8080/#/message/verify");
Expand All @@ -78,6 +83,7 @@ describe("Message - Verify", () => {

it("should fail if no public key is given", () => {
cy.visit("/");
cy.contains("Or sign / verify a message").click();
cy.contains("a", "Verify Message");
cy.contains("Verify Message").click();
cy.url().should("eq", "http://localhost:8080/#/message/verify");
Expand All @@ -90,6 +96,7 @@ describe("Message - Verify", () => {

it("should fail if no signature is given", () => {
cy.visit("/");
cy.contains("Or sign / verify a message").click();
cy.contains("a", "Verify Message");
cy.contains("Verify Message").click();
cy.url().should("eq", "http://localhost:8080/#/message/verify");
Expand All @@ -103,6 +110,7 @@ describe("Message - Verify", () => {

it("should pass to verify a valid message", () => {
cy.visit("/");
cy.contains("Or sign / verify a message").click();
cy.contains("a", "Verify Message");
cy.contains("Verify Message").click();
cy.url().should("eq", "http://localhost:8080/#/message/verify");
Expand All @@ -117,6 +125,7 @@ describe("Message - Verify", () => {

it("should fail to verify an invalid message", () => {
cy.visit("/");
cy.contains("Or sign / verify a message").click();
cy.contains("a", "Verify Message");
cy.contains("Verify Message").click();
cy.url().should("eq", "http://localhost:8080/#/message/verify");
Expand Down
68 changes: 68 additions & 0 deletions tests/e2e/specs/wallet.js
@@ -0,0 +1,68 @@
import fixture from "../../__fixtures__/identity.json";

describe("Wallet - From Entropy", () => {
it("should generate a wallet", () => {
cy.visit("/");
cy.contains("a", "Create a new wallet");
cy.contains("Create a new wallet").click();
cy.url().should("eq", "http://localhost:8080/#/wallet/entropy");
cy.wait(5000);
cy.url().should("eq", "http://localhost:8080/#/wallet");

cy.get("#w-address").should($lis => expect($lis.text()).to.have.length(34));
cy.get("#w-entropy").should($lis => expect($lis.text()).to.have.length(32));
cy.get("#w-publicKey").should($lis => expect($lis.text()).to.have.length(66));
cy.get("#w-wif").should($lis => expect($lis.text()).to.have.length(52));
});
});

describe("Wallet - From Passphrase", () => {
it("should fail if no passphrase is given", () => {
cy.visit("/");
cy.contains("a", "Enter a secret passphrase");
cy.contains("Enter a secret passphrase").click();
cy.url().should("eq", "http://localhost:8080/#/wallet/passphrase");

cy.contains("button", "Generate").click();

cy.contains("div", "Please fill out the passphrase.");
});

it("should generate a wallet (bip39)", () => {
cy.visit("/");
cy.contains("a", "Enter a secret passphrase");
cy.contains("Enter a secret passphrase").click();
cy.url().should("eq", "http://localhost:8080/#/wallet/passphrase");

cy.get("#wallet-passphrase").type(
"size another stool celery ball secret burden giant alter gravity jacket brief",
);
cy.contains("button", "Generate").click();

cy.url().should("eq", "http://localhost:8080/#/wallet");

cy.contains("span", "AUc8f2A1gn33a7zbubTym55u2ERHc8tt9k");
cy.contains("span", "c9e1335992811f8507a30d076cc1dc0d");
cy.contains("span", "039387c299adb4c9f7ba532934d3e210eb21d374cb285926d3d49c8c71e18bc4de");
cy.contains("span", "SBic9QRyBxVw5xeacLocLiULN6NYy9o93tmizq2WcESgJM4EzyvK");
});

it("should generate a wallet (no bip39)", () => {
cy.visit("/");
cy.contains("a", "Enter a secret passphrase");
cy.contains("Enter a secret passphrase").click();
cy.url().should("eq", "http://localhost:8080/#/wallet/passphrase");

cy.get("#wallet-passphrase").type(fixture.passphrase);
cy.contains("button", "Generate").click();

cy.contains("div", "The passphrase does not appear to be BIP39");
cy.contains("button", "Generate Anyway").click();

cy.url().should("eq", "http://localhost:8080/#/wallet");

cy.contains("span", fixture.data.address);
cy.contains("span", fixture.data.publicKey);
cy.contains("span", fixture.data.wif);
});
});

0 comments on commit d22a89d

Please sign in to comment.