Skip to content

Commit

Permalink
Merge pull request #977 from input-output-hk/chore/ddw-298-add-accept…
Browse files Browse the repository at this point in the history
…ance-tests-for-update-mechanism

[DDW-298] Add acceptance tests for update mechanism
  • Loading branch information
nikolaglumac authored Jun 21, 2018
2 parents 32ddc39 + fa51b35 commit fac4beb
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 19,799 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Changelog
- Log expected errors as debug messages only ([PR 916](https://github.com/input-output-hk/daedalus/pull/916))
- Created hide show used addresses acceptance test ([PR 957](https://github.com/input-output-hk/daedalus/pull/957))
- Improved text display by reducing letter-spacing ([PR 973](https://github.com/input-output-hk/daedalus/pull/973))
- Added acceptance tests for node update notification with apply and postpone update scenarios ([PR 977](https://github.com/input-output-hk/daedalus/pull/977))
- Added acceptance tests for maximum wallets limit ([PR 979](https://github.com/input-output-hk/daedalus/pull/979))
- Added acceptance tests for the About dialog ([PR 975](https://github.com/input-output-hk/daedalus/pull/975))

Expand Down
25 changes: 25 additions & 0 deletions features/node-update-notification.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Feature: Node Update Notification

Background:
Given I have completed the basic setup
And I have the following wallets:
| name |
| Test wallet |
When I am on the "Test wallet" wallet "summary" screen
When I make a node update available
Then I should see the node update notification component
Then I should see the notification's title bar
Then I should see the expected update version in the notification's title bar
Then I should see the notification's toggle button
Then I should see the notification's update message
Then I should see the notification's accept button
Then I should see the notification's postpone button

Scenario: User postpones a node update notification
When I click the notification's postpone button
Then I should not see the notification component anymore

@restartApp
Scenario: User accepts a node update notification
When I click the notification's accept button
Then I should see the Daedalus window close
73 changes: 73 additions & 0 deletions features/step_definitions/node-update-notification-steps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { When, Then } from 'cucumber';
import { expect } from 'chai';

const NODE_UPDATE_COMPONENT = '.NodeUpdateNotification_component';
const TITLE_BAR = '.NodeUpdateNotification_titleBar';
const TOGGLE_BUTTON = '.NodeUpdateNotification_toggleButton';
const UPDATE_MESSAGE = '.NodeUpdateNotification_message';
const ACTIONS = '.NodeUpdateNotification_actions';
const ACCEPT_BTN = '.NodeUpdateNotification_acceptButton';
const DENY_BTN = '.NodeUpdateNotification_denyButton';

const UPDATE_VERSION = 50;

When(/^I make a node update available$/, async function () {
await this.client.executeAsync((nextVersion, done) => {
daedalus.api.ada.setNextUpdate(nextVersion)
.then(() => daedalus.stores.NodeUpdateStore.refreshNextUpdate())
.then(done)
.catch((error) => done(error));
}, { version: UPDATE_VERSION });
});

Then(/^I should see the node update notification component$/, async function () {
await this.client.waitForVisible(`${NODE_UPDATE_COMPONENT}`);
});

Then(/^I should see the notification's title bar$/, async function () {
await this.client.waitForVisible(`${NODE_UPDATE_COMPONENT} ${TITLE_BAR}`);
});

Then(/^I should see the expected update version in the notification's title bar$/, async function () {
const titleBarSelector = `${NODE_UPDATE_COMPONENT} ${TITLE_BAR}`;
await this.client.waitForText(titleBarSelector);
const versionText = await this.client.getText(titleBarSelector);
const expectedVersionText = await this.intl('cardano.node.update.notification.titleWithVersion', { version: UPDATE_VERSION });
expect(versionText).to.equal(expectedVersionText);
});

Then(/^I should see the notification's toggle button$/, async function () {
await this.client.waitForVisible(`${NODE_UPDATE_COMPONENT} ${TITLE_BAR} ${TOGGLE_BUTTON}`);
});

Then(/^I should see the notification's update message$/, async function () {
await this.client.waitForVisible(`${NODE_UPDATE_COMPONENT} ${UPDATE_MESSAGE}`);
});

Then(/^I should see the notification's accept button/, async function () {
await this.client.waitForVisible(`${NODE_UPDATE_COMPONENT} ${ACTIONS} ${ACCEPT_BTN}`);
});

Then(/^I should see the notification's postpone button$/, async function () {
await this.client.waitForVisible(`${NODE_UPDATE_COMPONENT} ${ACTIONS} ${DENY_BTN}`);
});

When(/^I click the notification's postpone button$/, async function () {
await this.waitAndClick(`${NODE_UPDATE_COMPONENT} ${ACTIONS} ${DENY_BTN}`);
});

When(/^I click the notification's accept button$/, async function () {
await this.waitAndClick(`${NODE_UPDATE_COMPONENT} ${ACTIONS} ${ACCEPT_BTN}`);
});

Then(/^I should not see the notification component anymore$/, async function () {
await this.client.waitForVisible(NODE_UPDATE_COMPONENT, null, true);
});

Then(/^I should see the Daedalus window close$/, async function () {
// there is latency between the window closing and this test running, so setTimeout
await setTimeout(async () => {
const windowCount = await this.client.getWindowCount();
expect(windowCount).to.equal(0);
}, 1500);
});
10 changes: 10 additions & 0 deletions features/support/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ defineSupportCode(({ BeforeAll, Before, After, AfterAll, setDefaultTimeout }) =>
});
});

// this ensures that the spectron instance of the app restarts
// after the node update acceptance test shuts it down via 'kill-process'
// eslint-disable-next-line prefer-arrow-callback
After({ tags: '@restartApp' }, async function () {
await context.app.restart();
});

// eslint-disable-next-line prefer-arrow-callback
After(async function ({ result }) {
scenariosCount++;
Expand All @@ -95,9 +102,12 @@ defineSupportCode(({ BeforeAll, Before, After, AfterAll, setDefaultTimeout }) =>

// eslint-disable-next-line prefer-arrow-callback
AfterAll(async function () {
if (!context.app.running) return;

if (scenariosCount === 0) {
await printMainProcessLogs();
}

return context.app.stop();
});
});
Loading

0 comments on commit fac4beb

Please sign in to comment.