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

Conversation

ManusMcCole
Copy link

@ManusMcCole ManusMcCole commented Jul 14, 2021

This PR adds automated tests for the Stake-pool server settings and also the Wallet currency display settings screens.


Testing Checklist


Review Checklist

Basics

  • PR has been assigned and has appropriate labels (feature/bug/chore, release-x.x.x)
  • 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
  • PR has default-sized Daedalus window screenshots or animated GIFs of important UI changes:
    • In English
    • In Japanese
  • 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 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 storybook)
  • In case of dependency changes yarn.lock file is updated

Code Quality

  • Important parts of the code are properly commented and documented
  • Code is properly typed with flow
  • React components are split-up enough to avoid unnecessary re-renderings
  • Any code that only works in main process is neatly separated from components

Testing

  • New feature/change is covered by acceptance tests
  • New feature/change is manually tested and approved by QA team
  • All existing acceptance tests are still up-to-date
  • New feature/change is covered by Daedalus Testing scenario
  • All existing Daedalus Testing scenarios are still up-to-date

After Review

  • Merge the PR
  • Delete the source branch
  • Move the ticket to done column on the YouTrack board
  • Update Slack QA thread by marking it with a green checkmark

@ManusMcCole ManusMcCole changed the title Chore/manus automation Automated Tests to cover Stake Pool settings Screen and Wallet Currency Display settings Jul 14, 2021
@ManusMcCole ManusMcCole changed the title Automated Tests to cover Stake Pool settings Screen and Wallet Currency Display settings Automated Tests to cover Stake Pool settings and Wallet Currency Display settings screens Jul 14, 2021
@ManusMcCole ManusMcCole changed the title Automated Tests to cover Stake Pool settings and Wallet Currency Display settings screens Automated Tests to cover Stake Pool Settings and Wallet Currency Display Settings screens Jul 14, 2021
@ManusMcCole ManusMcCole requested review from nikolaglumac and a team July 14, 2021 15:05
Copy link
Contributor

@danielmain danielmain left a comment

Choose a reason for hiding this comment

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

Looks pretty good! 😎

@@ -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

tests/settings/e2e/steps/currency-display-settings.js Outdated Show resolved Hide resolved
});

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 👍

});

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

@nikolaglumac
Copy link
Contributor

@daniloprates @tomislavhoracek please review this one 🙏

@@ -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

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?

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 you can remove this, you are already there

And I enter custom server "https://smash.cardano-testnet.iohkdev.io/" as the custom server option
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 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 :)

Then Stake-pool custom input box error message is displayed
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"

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.

@ManusMcCole
Copy link
Author

Hi @input-output-hk/daedalus-dev. If somebody could review and possibly approve this PR soon it would be much appreciated. @nikolaglumac is keen to get it merged soon

Copy link
Contributor

@thedanheller thedanheller left a comment

Choose a reason for hiding this comment

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

Nice work @ManusMcCole. I've left some comments.

@@ -0,0 +1,83 @@
import { When, Then } from 'cucumber';
import en from '../../../../source/renderer/app/i18n/locales/en-US.json';
Copy link
Contributor

Choose a reason for hiding this comment

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

It's important to give variables meaningful and easy-to-understand names. In this case, it could be something a bit less vague, like enLocales or enCopy

Copy link
Author

Choose a reason for hiding this comment

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

Fixed 👍

const STAKE_POOL_SERVER_DROPDOWN_CUSTOM_OPTION = `//*[@class="ScrollbarsCustom-Content"]//span[text()="${CUSTOM_SERVER_TEXT}"]`;
const STAKE_POOLS_SUBMENU_SETTINGS = `//*[@class="SettingsMenu_component"]//button[text()="${STAKE_POOL_TEXT}"]`;

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


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

@nikolaglumac
Copy link
Contributor

@ManusMcCole please try to get this one done today 🙏

@nikolaglumac
Copy link
Contributor

FYI. @ManusMcCole I have merged in latest develop branch so please pull before committing new changes 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants