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

[DDW-617] Move all tests into same folder #1378

Merged
merged 20 commits into from
Apr 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5a800a7
[DDW-617] WIP: refactor all tests into same folder
DominikGuzei Mar 27, 2019
06f720a
[DDW-617] WIP: refactor all tests into same folder
DominikGuzei Mar 27, 2019
404ed8b
[DDW-617] remove general test watch mode
DominikGuzei Apr 2, 2019
8fc2302
[DDW-617] watch features files in unit tests watch mode
DominikGuzei Apr 2, 2019
c39b2c4
[DDW-617] cleanup npm and gulp tasks
DominikGuzei Apr 2, 2019
0a8e722
[DDW-617] fix ignored files generated by tests
DominikGuzei Apr 2, 2019
bc29494
[DDW-617] fix conflicts
DominikGuzei Apr 2, 2019
0bd6061
[DDW-617] fix conflicts with develop
DominikGuzei Apr 8, 2019
4bacffd
[DDW-617] rename watch mode to previous style
DominikGuzei Apr 8, 2019
bb52d1b
[DDW-617] remove test screenshots from git repo
DominikGuzei Apr 8, 2019
681394e
[DDW-614] add unit tests for wallet recovery mnemonics generation and…
DominikGuzei Apr 8, 2019
13b5ebd
[DDW-614] add unbound mnemonics test case
DominikGuzei Apr 8, 2019
8e3c798
[DDW-617] add changelog entry
DominikGuzei Apr 8, 2019
5ea7ee3
[DDW-617] update readme and pr template
DominikGuzei Apr 8, 2019
5e69268
Merge branch 'chore/ddw-617-move-all-tests-into-same-folder' into cho…
DominikGuzei Apr 8, 2019
ac38deb
[DDW-614] add changelog and updates testing readme
DominikGuzei Apr 8, 2019
8897248
Merge pull request #1379 from input-output-hk/chore/ddw-614-add-unit-…
nikolaglumac Apr 9, 2019
c8b8d06
[DDW-617] rename ui tests to e2e
DominikGuzei Apr 9, 2019
f0ba157
[DDW-617] update testing readme with e2e change
DominikGuzei Apr 9, 2019
33c9584
[DDW-617] fix ignore files for eslint and prettier
DominikGuzei Apr 9, 2019
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
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ logs
node_modules
translations
tests
features/support/default-wallet.json
features/tests/e2e/documents/*
mainnet-genesis-dryrun-with-stakeholders.json
source/renderer/app/i18n/locales
nodemon.json
16 changes: 8 additions & 8 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ This PR CHANGES.
- [ ] PR is updated to the most recent version of the target branch (and there are no conflicts)
- [ ] PR has a good description that summarizes all changes and shows some screenshots or animated GIFs of important UI changes
- [ ] CHANGELOG entry has been added to the top of the appropriate section (*Features*, *Fixes*, *Chores*) and is linked to the correct PR on GitHub
- [ ] Automated tests: All acceptance and unit tests are passing (`yarn run test` and `yarn run test:unit`)
- [ ] Manual tests (minimum tests should cover newly added feature/fix): App works correctly in *development* build (`yarn run dev`)
- [ ] Manual tests (minimum tests should cover newly added feature/fix): App works correctly in *production* build (`yarn run package` / CI builds)
- [ ] There are no *flow* errors or warnings (`yarn run flow:test`)
- [ ] There are no *lint* errors or warnings (`yarn run lint`)
- [ ] There are no *prettier* errors or warnings (`yarn run prettier:check`)
- [ ] There are no missing translations (running `yarn run manage:translations` produces no changes)
- [ ] Automated tests: All acceptance and unit tests are passing (`yarn test`)
- [ ] Manual tests (minimum tests should cover newly added feature/fix): App works correctly in *development* build (`yarn dev`)
- [ ] Manual tests (minimum tests should cover newly added feature/fix): App works correctly in *production* build (`yarn package` / CI builds)
- [ ] There are no *flow* errors or warnings (`yarn flow:test`)
- [ ] There are no *lint* errors or warnings (`yarn lint`)
- [ ] There are no *prettier* errors or warnings (`yarn prettier:check`)
- [ ] There are no missing translations (running `yarn manage:translations` produces no changes)
- [ ] Text changes are proofread and approved (Jane Wild / Amy Reeve)
- [ ] Japanese text changes are proofread and approved (Junko Oda)
- [ ] UI changes look good in all themes (Alexander Rukin)
- [ ] Storybook works and no stories are broken (`yarn run storybook`)
- [ ] Storybook works and no stories are broken (`yarn storybook`)
- [ ] In case of dependency changes `yarn.lock` file is updated

### Code Quality
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ translations/messages
translations/reports

# 'Screenshots' and 'Paper wallet ceritifcate PDF file' generated by acceptance tests
features/support/paper_wallet_certificates/paper-wallet-certificate.pdf
features/screenshots
features/tests/e2e/documents/paper_wallet_certificates/paper-wallet-certificate.pdf
features/tests/e2e/screenshots

# Webpack
.cache
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@

# Ignore the following special folders and files
source/renderer/app/i18n/locales/
features/support/default-wallet.json
features/tests/e2e/documents/*
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Changelog

### Chores

- Added unit tests for mnemonic generation and validation ([PR 1379](https://github.com/input-output-hk/daedalus/pull/1379))
- Simplified the test setup ([PR 1378](https://github.com/input-output-hk/daedalus/pull/1378))
- Updated PR template ([PR 1376](https://github.com/input-output-hk/daedalus/pull/1376))
- Implemented new About Us dialog design with a close button ([PR 1369](https://github.com/input-output-hk/daedalus/pull/1369)
- Refactored store async functions to use mobx runInAction calls ([PR 1367](https://github.com/input-output-hk/daedalus/pull/1367)
Expand Down
42 changes: 34 additions & 8 deletions features/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,61 @@
<sub>Document maintainer: Nikola Glumac<br/>Document status: Active</sub>
</blockquote>

# Running Daedalus acceptance tests

# Install Daedalus

1. Make sure you have node and yarn installed on your machine
2. Clone Daedalus repository to your machine (`git clone git@github.com:input-output-hk/daedalus.git`)
3. Install dependencies from within Daedalus directory:

```bash
$ cd daedalus/
$ yarn install
```

4. Build and run the backend (Cardano SL) following the instructions from [Daedalus](https://github.com/input-output-hk/daedalus/blob/master/README.md#development---with-cardano-wallet) README file.
5. Run Daedalus frontend tests:
# Run unit tests

Make sure Daedalus is properly installed (see above).

```bash
$ yarn test:unit
```

## Unbound tests

Unbound tests run as long as you keep them running
(never end except if an error occurs).

Example:
`yarn test:unit:unbound --tags @mnemonics`
generates and validates mnemonics as long as you keep it
running (the number of executions is updated in the terminal)

# Run end-to-end tests

1. Make sure Daedalus is properly installed (see above).
2. Build and run the backend (Cardano SL) following the instructions from [Daedalus](https://github.com/input-output-hk/daedalus/blob/master/README.md#development---with-cardano-wallet) README file.
3. Run Daedalus frontend tests:

```bash
$ cd daedalus/
$ nix-shell --arg autoStartBackend true --arg systemStart XXX # XXX = cardano system startup time
$ yarn nix:dev XXX # XXX = cardano system startup time
$ yarn build
$ yarn test:e2e
```

# Run all tests

```bash
$ yarn test
```

Once tests are complete you will get a summary of passed/failed tests in the Terminal window.

## Keeping Daedalus Alive After Tests
## Keeping Daedalus alive after end-to-end tests

While working on the tests it's often useful to keep Daedalus alive after the tests have run
(e.g: to inspect the app state). You can pass a special environment var to tell the test script
not to close the app:

````bash
$ KEEP_APP_AFTER_TESTS=true yarn test
$ KEEP_APP_AFTER_TESTS=true yarn test:e2e
````
1 change: 1 addition & 0 deletions features/about-dialog.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: About Dialog

Background:
Expand Down
1 change: 1 addition & 0 deletions features/accept-terms-of-use.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: Accept "Terms of use"

Background:
Expand Down
1 change: 1 addition & 0 deletions features/ada-redemption.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: Ada Redemption

Background:
Expand Down
1 change: 1 addition & 0 deletions features/add-wallet-via-sidebar.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: Add Wallet via Sidebar

Background:
Expand Down
1 change: 1 addition & 0 deletions features/block-consolidation-page.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: Display Block Consolidation Page

Background:
Expand Down
1 change: 1 addition & 0 deletions features/data-layer-migration.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: Data Layer Migration

Background:
Expand Down
1 change: 1 addition & 0 deletions features/delete-wallet-via-settings.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: Delete Wallet via Settings

Background:
Expand Down
1 change: 1 addition & 0 deletions features/import-wallet-via-sidebar.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: Import Wallet via Sidebar

Background:
Expand Down
1 change: 1 addition & 0 deletions features/local-time-difference.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: Local Time Difference

Scenario: Wrong local time
Expand Down
13 changes: 13 additions & 0 deletions features/mnemonics-generation-and-validation.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Feature: Mnemonics generation and validation

As a developer I want to be sure our mnemonic
(12-word recovery phrase) is correctly generated/validated

@unit @slow
Scenario: All generated wallet recovery mnemonics are valid
Given I generate 10000 wallet recovery mnemonics
Then all generated wallet recovery mnemonics should be valid

@unbound @mnemonics
Scenario: Unbound manual test run gives no invalid mnemeonics
Given I generate and validate an unbound number of wallet recovery mnemonics
1 change: 1 addition & 0 deletions features/navigate-general-settings-menu.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: General Settings

Background:
Expand Down
1 change: 1 addition & 0 deletions features/navigate-sidebar-categories.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: Navigate Sidebar Categories

Background:
Expand Down
1 change: 1 addition & 0 deletions features/navigate-wallet-tabs.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: Navigate Wallet Tabs

Background:
Expand Down
1 change: 1 addition & 0 deletions features/no-disk-space.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: No Disk Space Overlay

Background:
Expand Down
1 change: 1 addition & 0 deletions features/node-update-exit.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: Node Update Exit

Background:
Expand Down
1 change: 1 addition & 0 deletions features/node-update-notification.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: Node Update Notification

Background:
Expand Down
1 change: 1 addition & 0 deletions features/paper-wallets-certificate.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: Paper Wallets Certificate generation

Background:
Expand Down
1 change: 1 addition & 0 deletions features/quit-app.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: Quitting Daedalus

Daedalus can be quit in multiple (and unexpected) ways and
Expand Down
1 change: 1 addition & 0 deletions features/receive-money.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: Receive money

Background:
Expand Down
1 change: 1 addition & 0 deletions features/restore-wallet-via-sidebar.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: Add Wallet via Sidebar

Background:
Expand Down
1 change: 1 addition & 0 deletions features/select-language.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: Select Language

Scenario: User Selects Language
Expand Down
1 change: 1 addition & 0 deletions features/send-money-to-receiver.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: Send Money to Receiver

Background:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@unit
Feature: Spending password validation

- should contain at least one digit
Expand Down
1 change: 0 additions & 1 deletion features/support/default-wallet.json

This file was deleted.

1 change: 1 addition & 0 deletions features/switching-between-wallets.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@e2e
Feature: Switching Between Wallets

Background:
Expand Down
14 changes: 14 additions & 0 deletions features/tests/e2e/documents/default-wallet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"wallet": {
"accounts": [{ "name": "Genesis account", "index": 2147483648 }],
"walletSecretKey": "WIAwbsQgbz9X0WhvOnVeH+yRs7Ri93ESTdMspBHzeLnPUR6hLZL/NazfB40z2x8FZhLwNIt83DCuMR1nGG+ZqvsD/ouyzg3ec729fnrqEMO4A+qPTJmpiRgQZfYO2KDJDRxLtMyofXl90VVZOEke/QddnZ8CGHoR/lCemJgZuvzBpw==",
"walletMeta": {
"name": "Imported Wallet",
"assurance": "normal",
"unit": "ADA"
},
"passwordHash": "WGQxNHw4fDF8V0NERGRHY0JGcThzelVyeFdza00wM1VjYnloeVBBQXBvdWtwdWFsUTExNGVFdz09fFJXMk5kUmVJYmg2REtsa2lsWG8rQ1lvTStRZmJkMzRmRVd0MG4rSy82YUU9"
},
"fileType": "WALLETS_EXPORT",
"fileVersion": "1.0.0"
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import type { WebdriverClient } from '../global-types';
import { getProcessesByName } from '../../../source/main/utils/processes';
import type { WebdriverClient } from '../setup/global-types';
import { getProcessesByName } from '../../../../source/main/utils/processes';

export const waitForDaedalusToExit = async (
client: WebdriverClient,
Expand All @@ -15,5 +15,5 @@ export const waitForDaedalusToExit = async (
};

export const refreshClient = async (client: WebdriverClient) => {
await client.url(`file://${__dirname}/../../../dist/renderer/index.html`);
await client.url(`file://${__dirname}/../../../../dist/renderer/index.html`);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import type { Daedalus, WebdriverClient } from '../global-types';
import { getProcessesByName } from '../../../source/main/utils/processes';
import type { Daedalus, WebdriverClient } from '../setup/global-types';
import { getProcessesByName } from '../../../../source/main/utils/processes';

declare var daedalus: Daedalus;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WalletSyncStateTags } from '../../../source/renderer/app/domains/Wallet';
import { WalletSyncStateTags } from '../../../../source/renderer/app/domains/Wallet';

export const isActiveWalletBeingRestored = async client => {
const result = await client.execute(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import fs from 'fs';
import path from 'path';
import { generateFileNameWithTimestamp } from '../../../source/common/utils/files';
import ensureDirectoryExists from '../../../source/main/utils/ensureDirectoryExists';
import { generateFileNameWithTimestamp } from '../../../../source/common/utils/files';
import ensureDirectoryExists from '../../../../source/main/utils/ensureDirectoryExists';

export const generateScreenshotFilePath = testName => {
const filePath = path.resolve(__dirname, '../../screenshots', testName);
const filePath = path.resolve(__dirname, '../screenshots', testName);
const fileName = generateFileNameWithTimestamp(testName, 'png');
ensureDirectoryExists(filePath);
return `${filePath}/${fileName}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import {
setDefaultTimeout,
} from 'cucumber';
import electronPath from 'electron';
import { TEST } from '../../source/common/types/environment.types';
import { TEST } from '../../../../source/common/types/environment.types';
import {
generateScreenshotFilePath,
getTestNameFromTestFile,
saveScreenshot,
} from './helpers/screenshot';
import { refreshClient } from './helpers/app-helpers';
} from '../helpers/screenshot';
import { refreshClient } from '../helpers/app-helpers';

/* eslint-disable consistent-return */

Expand Down Expand Up @@ -42,8 +42,11 @@ const startApp = async () => {
NODE_ENV: TEST,
}),
waitTimeout: DEFAULT_TIMEOUT,
chromeDriverLogPath: path.join(__dirname, '../../logs/chrome-driver.log'),
webdriverLogPath: path.join(__dirname, '../../logs/webdriver'),
chromeDriverLogPath: path.join(
__dirname,
'../../../../logs/chrome-driver.log'
),
webdriverLogPath: path.join(__dirname, '../../../../logs/webdriver'),
});
await app.start();
await app.client.waitUntilWindowLoaded();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
import type { Api } from '../../source/renderer/app/api';
import type { ActionsMap } from '../../source/renderer/app/actions';
import type { StoresMap } from '../../source/renderer/app/stores';
import type { Api } from '../../../../source/renderer/app/api';
import type { ActionsMap } from '../../../../source/renderer/app/actions';
import type { StoresMap } from '../../../../source/renderer/app/stores';

export type Daedalus = {
api: Api,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Given, When, Then } from 'cucumber';
import { expect } from 'chai';
import packageJson from '../../package.json';
import packageJson from '../../../../package.json';

Given(/^I open the About dialog$/, async function() {
this.client.execute(() => daedalus.actions.app.openAboutDialog.trigger());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Given, When, Then } from 'cucumber';
import { expect } from 'chai';
import termsOfUse from '../support/helpers/terms-of-use-helpers';
import termsOfUse from '../helpers/terms-of-use-helpers';

const TERMS_OF_USE_FORM = '.TermsOfUseForm_component';

Expand Down
Loading