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

Automated Tests to cover Stake Pool Settings and Wallet Currency Display Settings screens #2622

Open
wants to merge 54 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
bd3a212
Added tests for Stake-pool Settings and Wallet Currency Display Settings
ManusMcCole Jul 14, 2021
57bee26
Deleted old comments and unneeded timeout
ManusMcCole Jul 14, 2021
8d51456
Fixing typo in stakepool-settings.feature that was preventing code fr…
ManusMcCole Jul 14, 2021
7e43bdd
Minor Code reorganising
ManusMcCole Jul 14, 2021
27f3f13
Merge branch 'develop' into chore/manus-automation
ManusMcCole Jul 14, 2021
45593b2
Minor Code reorganisation
ManusMcCole Jul 14, 2021
7eb5338
Correcting lint spelling errors
ManusMcCole Jul 14, 2021
7788106
Added entry to CHANGELOG.md
ManusMcCole Jul 14, 2021
f822ed5
Adding an extra feature step to improve code reliability
ManusMcCole Jul 14, 2021
f26c24d
Added link to CHANGELOG.md
ManusMcCole Jul 14, 2021
96bb304
Some code review code improvements
ManusMcCole Jul 16, 2021
c07285e
Added PR number to CHANGELOG.md
ManusMcCole Jul 19, 2021
579f202
Code review enhancements
ManusMcCole Jul 19, 2021
7dbcd18
Merge branch 'develop' into chore/manus-automation
ManusMcCole Jul 19, 2021
fe946ab
Added new custom error messages "The url should start with" and "prot…
ManusMcCole Jul 22, 2021
14214a2
Resaving changes
ManusMcCole Jul 22, 2021
9ba9b73
Added template literals for all embedded expressions
ManusMcCole Jul 23, 2021
e429627
Removed @watch annotation
ManusMcCole Jul 23, 2021
daf2d09
Minor code improvements
ManusMcCole Jul 29, 2021
3f3adc1
Adding ternary operators
ManusMcCole Aug 4, 2021
c880921
Removed Watch Flags
ManusMcCole Aug 4, 2021
2a678ae
Created constant SERVER_URL
ManusMcCole Aug 4, 2021
00fce2a
Removed step I clicked outside of the input-box to change focus
ManusMcCole Aug 4, 2021
f5f4dc7
Merge branch 'develop' into chore/manus-automation
thedanheller Aug 5, 2021
3501c5a
Updating stakepool-settings.feature
ManusMcCole Aug 5, 2021
0f68d01
Code improvements
ManusMcCole Aug 5, 2021
f3df743
Updated CHANGELOG.MD entry to vNext category
ManusMcCole Aug 16, 2021
e30e36f
Deleted file __tests__/numbers.specs.js
ManusMcCole Aug 16, 2021
41c342e
Merge branch 'develop' into chore/manus-automation
nikolaglumac Aug 23, 2021
6284b6c
Reorder CHANGELOG
nikolaglumac Aug 23, 2021
e1b67fb
Importing Daedalus text and labels from file en-US.json
ManusMcCole Aug 24, 2021
3d6c606
Merge branch 'develop' into chore/manus-automation
ManusMcCole Aug 24, 2021
1dcbe14
Merge remote-tracking branch 'origin/chore/manus-automation' into cho…
ManusMcCole Aug 24, 2021
37d678b
Added 'Your changes have been saved' success message from en-US.json …
ManusMcCole Aug 30, 2021
da08491
Removed @watch flags
ManusMcCole Aug 30, 2021
5091d6a
Merge branch 'develop' into chore/manus-automation
ManusMcCole Aug 30, 2021
671f211
Readding entry to CHANGELOG.md
ManusMcCole Aug 30, 2021
bb44af7
Merge branch 'develop' into chore/manus-automation
ManusMcCole Sep 3, 2021
b97a867
Merges develop
nikolaglumac Sep 13, 2021
fb3d023
Updating constant name for linking to en-US.json' file
ManusMcCole Sep 13, 2021
56a4dc8
Merge branch 'develop' into chore/manus-automation
nikolaglumac Sep 14, 2021
9132303
Merge branch 'develop' into chore/manus-automation
ManusMcCole Sep 20, 2021
ff47a9e
Upgraded cucumber and spectron
danielmain Sep 21, 2021
b3d951c
Fix wrong path for starting electron
danielmain Sep 21, 2021
a54f6e3
Code refactor.Adding condition for testnet
ManusMcCole Sep 21, 2021
a20c465
Merge remote-tracking branch 'origin/chore/manus-automation' into cho…
ManusMcCole Sep 21, 2021
9c723b9
Minor formatting
ManusMcCole Sep 21, 2021
f5aee02
Starting Spectron like the official documentation suggests
danielmain Sep 22, 2021
b5dced4
Merge branch 'develop' into chore/manus-automation
ManusMcCole Sep 28, 2021
88970fb
Merges develop
nikolaglumac Oct 21, 2021
a4335f2
Merge branch 'develop' into chore/manus-automation
ManusMcCole Oct 22, 2021
be36f43
Merge branch 'chore/manus-automation' of https://github.com/input-out…
ManusMcCole Oct 22, 2021
f668343
Merge branch 'develop' into chore/manus-automation
ManusMcCole Jan 25, 2022
fdcff17
Renamed all js files to ts
danielmain Jan 17, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Changelog

### Chores

- Added tests for currency display settings and stake-pool settings screens ([PR](https://github.com/input-output-hk/daedalus/pull/2622/))
- Disabled Fund5 voting registration ([PR 2608](https://github.com/input-output-hk/daedalus/pull/2608))
- Updated Fund5 registaration start date ([PR 2607](https://github.com/input-output-hk/daedalus/pull/2607))
- Removed Jormungandr integration and legacy clusters ([PR 2579](https://github.com/input-output-hk/daedalus/pull/2579))
Expand Down
33 changes: 33 additions & 0 deletions tests/settings/e2e/features/currency-display-settings.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@e2e @watch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ManusMcCole Please remove the watch flag

Feature: Wallet currency display settings

Background:
Given I have completed the basic setup
And I have the following wallets:
| name |
| Test Wallet |

Scenario Outline: User selects alternative currency's to display wallet balance
Given I am on the General Settings "wallets" screen
And I open currency selection dropdown
When I select "<currency>" as the selected displayed currency
And I am on the "Test Wallet" wallet "summary" screen
Then I should see "<ticker>" displayed beside wallet balance

Examples:
| currency | ticker |
| Litecoin | LTC |
| Stellar | XLM |

Scenario: User hits toggle button to show/not show ada wallet balance in other currency's
Given I am on the General Settings "wallets" screen
When I toggle the button off to change if I want to see my ada balance in other currency's
Then the currency selection box is hidden
And I am on the "Test Wallet" wallet "summary" screen
Then The wallet summary screen does not show ada balance in other currency's placeholder
When I am on the General Settings "wallets" screen
And I toggle the button on to change if I want to see my ada balance in other currency's
When I am on the General Settings "wallets" screen
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ManusMcCole I don't think we need multiple of these When I am on the General Settings "wallets" screen steps?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ManusMcCole you can remove this, you are already there

Then the currency selection box is visible
And I am on the "Test Wallet" wallet "summary" screen
Then The wallet summary screen does show ada balance in other currency's placeholder
34 changes: 34 additions & 0 deletions tests/settings/e2e/features/stakepool-settings.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@e2e @watch
Feature: Stake-pool server settings

Background:
Given I have completed the basic setup
And I have the following wallets:
| name |
| Test Wallet |

Scenario: Navigating to Stake-pool settings screen and selecting custom stake-pool server
Given I am on the General Settings "stake-pools" screen
When custom server is the default option
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step is not very clear. In case another option is selected, is it supposed to select the Custom option? If so, it should instead click the dropdown, then click the Custom option, rather than select the input element

And The smash server input textBox is visible
And I enter custom server "https://smash.cardano-testnet.iohkdev.io/" as the custom server option
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the default server for testnet, so it might be better to replace it with a generic text, like

And I enter a custom server URL as custom server option

and have the correct URL chosen in the JS file

And I click on Daedalus logo to change focus
And I click the stake-pool custom server input box submit button
And I see the your changes have been saved success message
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can declare a message like "your changes have been saved" and check if that is correct.
e.g. And I see the "Your changes have been saved" success message

And I am on the Delegation "stake-pools" screen
Then "https://smash.cardano-testnet.iohkdev.io/" is visible on stake-pool screen above stake-pool list and is clickable
And I am brought back to the stake-pool server settings screen

Scenario: Verify stake-pool custom server text box is visible and error message verification
Given I am on the General Settings "stake-pools" screen
When I open stake pool server dropdown
And I select custom server option
Then The smash server input textBox is visible
And I enter invalid url "www.test" without https
Then Stake-pool custom input box error message is displayed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe would be good to check if correct error message is shown

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, you could have something like this

Then Stake-pool custom input box "https" error message is displayed

And in the JS you capture "https" and check if it's the correct error message. In other tests you could have something like

Then Stake-pool custom input box "invalidUrl" error message is displayed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed now :)

And I delete values in smash server custom url input box
And I enter invalid server "https://www.google.ie" containing https
And I click on Daedalus logo to change focus
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of declaring where you exactly clicked you can say, "I clicked outside something"

And I click the stake-pool custom server input box submit button
Then I see the "This url is not a valid SMASH server" error message displayed

43 changes: 43 additions & 0 deletions tests/settings/e2e/steps/currency-display-settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// @flow
import { When, Then} from 'cucumber';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you execute prettier in this file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ManusMcCole add a space after "Then"
e.g. import { When, Then } from 'cucumber';
or run yarn prettier:format


const CONVERTED_CURRENCY_WALLET_DISPLAY_GENERAL = '//*[@class="WalletSummaryCurrency_currencyRate"]';
const DISPLAY_BALANCE_OTHER_CURRENCYS_TOGGLE_STATUS_OFF = '//*[@class="SimpleSwitch_switch SwitchOverrides_switch"]';
const DISPLAY_BALANCE_OTHER_CURRENCYS_TOGGLE_STATUS_ON = '//*[@class="NormalSwitch_component SimpleSwitch_root SwitchOverrides_root SimpleSwitch_checked SwitchOverrides_checked"]';
const SELECT_CURRENCY_DROPDOWN = '//*[@label="Select currency"]';

When(/^I open currency selection dropdown$/, function() {
return this.waitAndClick(SELECT_CURRENCY_DROPDOWN);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that you can use just click since you don't need to wait for something. Please try... :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must have not implemented this right ?
Screenshot 2021-07-19 at 16 54 06
Screenshot 2021-07-19 at 16 54 16

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ManusMcCole for native methods, it needs this.client. .... waitAndClick is a helper method created by us, therefore client is not needed.

});

When(/^I select "([^"]*)" as the selected displayed currency$/, function(currency) {
thedanheller marked this conversation as resolved.
Show resolved Hide resolved
return this.waitAndClick(`//*[contains(text(), "${currency}")]`);
});

Then(/^I should see "([^"]*)" displayed beside wallet balance$/, function(ticker) {
return this.client.waitForVisible(`//*[@class="WalletSummaryCurrency_currencyRate" and text()="${ticker}"]`);
});

When(/^I toggle the button (on|off) to change if I want to see my ada balance in other currency's$/, function(switchStatus) {
let selector = DISPLAY_BALANCE_OTHER_CURRENCYS_TOGGLE_STATUS_ON;
if(switchStatus === 'on'){
selector = DISPLAY_BALANCE_OTHER_CURRENCYS_TOGGLE_STATUS_OFF;
}
return this.waitAndClick(selector);
});

Then(/^the currency selection box is (hidden|visible)$/, function(state) {
let invisibility = false;
if (state === 'hidden') {
invisibility = true;
}
return this.client.waitForVisible(SELECT_CURRENCY_DROPDOWN, null, invisibility);
});

Then(/^The wallet summary screen (does|does not) show ada balance in other currency's placeholder$/, function(switchstatus) {
let invisible = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could write this in one line const invisible:boolean = switchstatus !== 'does'

The return of a comparison is always a boolean.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this solution very much. It condenses 4 lines of code in to 1 awesome 👍

if (switchstatus === 'does') {
invisible = false;
}
return this.client.waitForVisible(CONVERTED_CURRENCY_WALLET_DISPLAY_GENERAL, null, invisible);
});
84 changes: 84 additions & 0 deletions tests/settings/e2e/steps/stakepool-settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { When, Then,} from 'cucumber';

const CHANGES_SAVED_SUCCESS_MESSAGE = '//*[@class="StakePoolsSettings_savingResultLabel"]';
const CUSTOM_SERVER_DROPDOWN_OPTION = '//*[@class="SimpleInput_customValueWrapper"]//*[@value="Custom server"]';
const DAEDALUS_TOP_BAR_LOGO = '//*[@class="TopBar_topBar TopBar_withoutWallet"]';
const IS_ERROR_MESSAGE_ACTIVATED = '//*[@class="SimpleInput_input SimpleInput_errored"]';
const NONE_FETCH_DATA_DIRECTLY_OPTION = '//*[@class="SimpleInput_customValueWrapper"]//*[@value="None - fetch the data directly"]';
const NOT_A_VALID_SMASH_SERVER_ERROR_MESSAGE_ACTIVATED = '//*[@class="InlineEditingInput_errorMessage" and text()="This URL is not a valid SMASH server"]';
const OFF_CHAIN_METADATA_SERVER_SMASH_LABEL = '//*[contains(text(), "Off-chain metadata server (SMASH)")]';
const SMASH_SERVER_URL_INPUT_BOX = '//*[@label="SMASH server URL"]';
const STAKE_POOL_CUSTOM_SERVER_INPUT_BOX_SUBMIT_BUTTON = '//*[@class="InlineEditingInput_button InlineEditingInput_okButton SimpleButton_root ButtonOverrides_root"]';
const STAKE_POOL_CUSTOM_SERVER_INPUT_BOX_X_BUTTON = '//*[@class="InlineEditingInput_button InlineEditingInput_cancelButton SimpleButton_root ButtonOverrides_root"]';
const STAKE_POOL_SERVER_DROPDOWN = '//*[@class="SimpleFormField_inputWrapper"]';
const STAKE_POOL_SERVER_DROPDOWN_CUSTOM_OPTION = '//*[@class="ScrollbarsCustom-Content"]//span[text()="Custom server"]';
const STAKE_POOLS_SUBMENU_SETTINGS = '//*[@class="SettingsMenu_component"]//button[text()="Stake pools"]';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ManusMcCole we should avoid using text in selectors. If it can not be avoided then we should use rather use the translation directly. @daniloprates can assist you with this.


When(/^none fetch the data directly is the default option$/, function() {
return this.waitAndClick(NONE_FETCH_DATA_DIRECTLY_OPTION);
});

When(/^custom server is the default option$/, function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Custom Server option should not be the default one. It should be IOHK (Recommended). If Custom Server is appearing by default there might be a problem with environment variables.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @daniloprates. Thank you for the review. On my side in selfnode all i can see are options for custom and "None fetch the data directly screenshot I had presumed that it was the same for everybody. What environment variables do i need to update ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are these environment variables set ? @daniloprates

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manus the variable can be found at daedalus.stores.staking.smashServerUrl.

For testnet, the default server url is https://smash.cardano-testnet.iohkdev.io. For mainnet, it's something like https://smash.cardano.iohk.io, but I didn't have time to check, because mainnet was too outdated in my computer.

You can indeed use this URL for testing a custom server, but you need to check the network, because if it's testnet, it will lead to a different behaviour in the app, as it's the default server, not a custom one. In this case, you need to use another URL, like the mainnet one.

Screen Shot 2021-09-17 at 17 21 32

return this.waitAndClick(CUSTOM_SERVER_DROPDOWN_OPTION);
});

When(/^I click on Daedalus logo to change focus$/, function() {
// This step was necessary as when the error message for this box is displayed the submit button could not receive the click and i got a "Element is not clickable at point error"
return this.waitAndClick(DAEDALUS_TOP_BAR_LOGO);
});

Then(/^"([^"]*)" is visible on stake-pool screen above stake-pool list and is clickable$/, function(serverUrl) {
return this.waitAndClick('//*[@class="StakePools_smashSettings"]//span[text()="Moderated by '+ serverUrl + '"]');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to write modern Javascript you could use Template_literals this instead string concatenation https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals 😉

I would look like this:
image

});

Then(/^I am brought back to the stake-pool server settings screen$/, function() {
return this.client.waitForVisible(OFF_CHAIN_METADATA_SERVER_SMASH_LABEL);
});

When(/^I select custom server option$/, function() {
return this.waitAndClick(STAKE_POOL_SERVER_DROPDOWN_CUSTOM_OPTION);
});

When(/^I open stake pool server dropdown$/, function() {
return this.waitAndClick(STAKE_POOL_SERVER_DROPDOWN);
});

Then(/^The smash server input textBox is visible$/, function() {
return this.client.waitForVisible(SMASH_SERVER_URL_INPUT_BOX);
});

When(/^I enter custom server "([^"]*)" as the custom server option$/, function(customServer) {
this.client.setValue(SMASH_SERVER_URL_INPUT_BOX, customServer);
});

When(/^I enter invalid url "([^"]*)" without https$/, function(invalidUrl) {
this.client.setValue(SMASH_SERVER_URL_INPUT_BOX, invalidUrl);
});

Then(/^Stake-pool custom input box error message is displayed$/, function() {
return this.client.waitForVisible(IS_ERROR_MESSAGE_ACTIVATED);
});

When(/^I enter invalid server "([^"]*)" containing https$/, function(value) {
this.client.setValue(SMASH_SERVER_URL_INPUT_BOX, value);
});

When(/^I delete values in smash server custom url input box$/, function() {
return this.waitAndClick(STAKE_POOL_CUSTOM_SERVER_INPUT_BOX_X_BUTTON);
});

When(/^I click the stake-pool custom server input box submit button$/, function() {
return this.waitAndClick(STAKE_POOL_CUSTOM_SERVER_INPUT_BOX_SUBMIT_BUTTON);
});

Then(/^I see the "This url is not a valid SMASH server" error message displayed$/, function() {
return this.client.waitForVisible(NOT_A_VALID_SMASH_SERVER_ERROR_MESSAGE_ACTIVATED);
});

When(/^I click on stakepool subtab$/, function() {
return this.waitAndClick(STAKE_POOLS_SUBMENU_SETTINGS);
});

Then(/^I see the your changes have been saved success message$/, function() {
return this.client.waitForVisible(CHANGES_SAVED_SUCCESS_MESSAGE);
});