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-298] Add acceptance tests for update mechanism #977

Merged

Conversation

MarcusHurney
Copy link
Contributor

@MarcusHurney MarcusHurney commented Jun 14, 2018

This PR adds acceptance tests for the NodeUpdateNotification.js component's rendering behavior when a node update is made available. Two test scenarios include one where the node update is postponed and another when the update is accepted.

Todo:

  • Mocks an API call making a node update available.
  • Checks that all UI elements in the notification, including the update's version number, have rendered properly.
  • Scenario 1: Tests functionality for postponing (declining) an update.
  • Scenario 2: Tests functionality for accepting a node update and that the Daedalus electron window has closed.
  • All tests after "Scenario 2" fail

Review Checklist:

Basics

  • PR is updated to the most recent version of target branch (and there are no conflicts)
  • PR has good description that summarizes all changes and shows some screenshots or animated GIFs of important UI changes
  • CHANGELOG entry has been added and is linked to the correct PR on GitHub
  • Automated tests: All acceptance tests are passing (npm run test)
  • Manual tests (minimum tests should cover newly added feature/fix): App works correctly in development build (npm run dev)
  • Manual tests (minimum tests should cover newly added feature/fix): App works correctly in production build (npm run package / CI builds)
  • There are no flow errors or warnings (npm run flow:test)
  • There are no lint errors or warnings (npm run lint)
  • Text changes are proofread and approved (Jane Wild)
  • There are no missing translations (running npm run manage:translations produces no changes)
  • UI changes look good in all themes (Alexander Rukin)
  • Storybook works and no stories are broken (npm run storybook)
  • In case of npm dependency changes both package-lock.json and yarn.lock files are updated

Code Quality

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

Testing

  • New feature / change is covered by acceptance tests
  • 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 PR
  • Delete source branch
  • Move ticket to done on the Youtrack board

.then(() => daedalus.stores.NodeUpdateStore.refreshNextUpdate())
.then(done)
.catch((error) => done(error));
}, { version: 50 });
Copy link
Contributor

Choose a reason for hiding this comment

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

@MarcusHurney please extract this version value to a constant which we can use in later steps where you check if the version shown in the notification matches this expected one.

});

Then(/^I should see the correct version in the notification's title bar$/, async function () {
const version = 50;
Copy link
Contributor

Choose a reason for hiding this comment

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

@MarcusHurney this is actually expected version - please use the constant like described in https://github.com/input-output-hk/daedalus/pull/977/files#r195338177

Copy link
Contributor

@nikolaglumac nikolaglumac left a comment

Choose a reason for hiding this comment

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

@MarcusHurney great work!
There are just 2 minor details I would like to get solved before merging it!

@nikolaglumac
Copy link
Contributor

@MarcusHurney looks like all tests after the one which applies the update fail (due to chrome unavailable). We need to fix that!

…' of github.com:input-output-hk/daedalus into chore/ddw-298-add-acceptance-tests-for-update-mechanism

Pulls in changes to CHANGELOG
Copy link
Contributor

@nikolaglumac nikolaglumac left a comment

Choose a reason for hiding this comment

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

Thanks for fixing those two issues @MarcusHurney - code now looks great!
We still need to see how to fix the failing tests though :(

…' of github.com:input-output-hk/daedalus into chore/ddw-298-add-acceptance-tests-for-update-mechanism

[DDW-298] Pulls in latest changes
…ore/ddw-298-add-acceptance-tests-for-update-mechanism

[DDW-298] Pulls in latest changes from develop branch
@nikolaglumac nikolaglumac changed the title [DDW-298] add acceptance tests for update mechanism [DDW-298] Add acceptance tests for update mechanism Jun 15, 2018
@MarcusHurney
Copy link
Contributor Author

@nikolaglumac @DominikGuzei
When you're reviewing this and run npm run test, you'll notice that the accept node update scenario shuts down the window and there is a message in the console saying that a session id must be present for one of electron's or spectron's window methods that runs when the window is opening or closing via app.start() or maybe app.quit(), I'm not sure when it runs. It doesn't cause any of the tests to fail nor does it have any direct consequence on our suite of tests, but just keep any eye out for it and see what you think.

@DominikGuzei
Copy link
Member

@MarcusHurney is this ready to be reviewed?

@nikolaglumac
Copy link
Contributor

@DominikGuzei AFAIK it should be ready. Please see last comment @MarcusHurney posted in this thread...

// 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: '@preventAppQuit' }, async function () {
Copy link
Member

Choose a reason for hiding this comment

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

maybe @preventAppQuit should be renamed to @restartApp

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Your request has been processed!

// if (event.sender !== mainWindow.webContents) return;
// TODO: fix this
process.exit(20);
Copy link
Member

Choose a reason for hiding this comment

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

@MarcusHurney please be careful with this change - exit code 20 might be necessary for cardano-launcher … @cleverca22 can you take a look at this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DominikGuzei
Changing this line to app.quit ended up being unnecessary so I've changed it back. All tests still pass.

@DominikGuzei DominikGuzei removed the WIP label Jun 21, 2018
@DominikGuzei
Copy link
Member

@nikolaglumac from my side this PR is ready for merging!

Copy link
Contributor

@nikolaglumac nikolaglumac left a comment

Choose a reason for hiding this comment

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

Works great! 👍

@nikolaglumac nikolaglumac merged commit fac4beb into develop Jun 21, 2018
@nikolaglumac nikolaglumac deleted the chore/ddw-298-add-acceptance-tests-for-update-mechanism branch June 21, 2018 10:58
This was referenced Oct 16, 2018
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.

3 participants