Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Dapp visibility save/load tests #4150

Merged
merged 10 commits into from
Jan 23, 2017
Merged

Dapp visibility save/load tests #4150

merged 10 commits into from
Jan 23, 2017

Conversation

jacogr
Copy link
Contributor

@jacogr jacogr commented Jan 12, 2017

Tests to verify save/load works as expected

(Now able to replicate https://github.com/ethcore/parity/issues/4147 via testing, if it does occur)

@jacogr jacogr added A0-pleasereview 🤓 Pull request needs code review. M7-ui labels Jan 12, 2017
@ngotchac
Copy link
Contributor

Would be nice to have tests that actually call the hideApp and showApp method and checks that the data gets written to local storage and that displayApps is correctly modified / reloaded.

@ngotchac ngotchac added A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jan 12, 2017
@jacogr
Copy link
Contributor Author

jacogr commented Jan 13, 2017

Yes, was not meant to be a comprehensive suite test at all. (Just the slice where issues were found previously).

@jacogr
Copy link
Contributor Author

jacogr commented Jan 13, 2017

Extended read/write tests (non-previously encountered bugs, pre-emptive)

@jacogr jacogr added A0-pleasereview 🤓 Pull request needs code review. and removed A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. labels Jan 13, 2017
let globalFetch;

function stubGlobals () {
globalContractsGet = Contracts.get;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use a sinon sandbox here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't use it anywhere. Stubs are called and restored in one place setup right up front, so no need to go down the unknown road.

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 using another properly documented, tested feature of a library that we already use instead of a homegrown solution which fails if stubGlobals gets called twice without a restoreGlobals in between.


global.fetch = (url) => {
switch (url) {
case '/api/apps':
Copy link
Contributor

Choose a reason for hiding this comment

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

You might want to use sinon stubs here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not yet. First ensure nothjng else is called, hence the default case with logging. At the same time need to see how the local tests develop, would need a variety of returns.

(Wish I could do everything at once for the full store, however just had to do the tests to verify an issue. Anybody with time and a non-overfull queue can jump in.)

Copy link
Contributor

@derhuerst derhuerst Jan 16, 2017

Choose a reason for hiding this comment

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

In this case and in general, I don't have strong opinions about sinon stubs so do whatever you prefer.

let api;
let store;

function create () {
Copy link
Contributor

Choose a reason for hiding this comment

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

[tiny grumble] Would prefer a more meaningful name here.

Why did you make api and store global?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternatives are to moving it in the describe block & then using putting create in there as well. Or using a beforeEach to set it with results, which means we need to call multiple times or always assign when created. Overall, since it local to the spec, this is concise. (api however is not really used yet, however as the tests expand, will be - see other store implemehtations.)


it('disables visibility', () => {
store.hideApp(APPID_DAPPREG);
store.writeDisplayApps();
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't needed write ? The write to localStorage should be automatic right?

@ngotchac ngotchac added A6-mustntgrumble 💦 Pull request has areas for improvement. The author need not address them before merging. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jan 23, 2017
@jacogr jacogr merged commit 3d1162e into master Jan 23, 2017
@jacogr jacogr deleted the jg-dapp-save-tests branch January 23, 2017 15:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A6-mustntgrumble 💦 Pull request has areas for improvement. The author need not address them before merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants