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

Finish tests for reading lists service #1055

Merged
merged 5 commits into from
Sep 2, 2018
Merged

Finish tests for reading lists service #1055

merged 5 commits into from
Sep 2, 2018

Conversation

thesocialdev
Copy link
Contributor

@thesocialdev thesocialdev commented Aug 30, 2018

Continuing from @tgr PR

  1. Updating existing tests and removing order endpoints that were outdated
  2. Adding test cases for batches endpoints

Bug: T184545

tgr and others added 2 commits August 30, 2018 09:59
1) Making all tests work and removing outdated order endpoints
2) Adding test cases for batches endpoints

Bug: T184545
if (!req.href.startsWith(`${config.baseURL}/data/lists/`)) {
throw Error(`Unmocked request to ${req.href}`);
}
}));
Copy link
Contributor

@Pchelolo Pchelolo Aug 30, 2018

Choose a reason for hiding this comment

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

Judging by massive Travis failures this is not a great approach. The nock interceptor once installed never goes anywhere, so you need to manually remove this listener.

Copy link
Contributor

@Pchelolo Pchelolo left a comment

Choose a reason for hiding this comment

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

inline

Removing nock event after the the reading lists test is complete

Bug: T184545
});

after(function() {
nock.emitter.removeAllListeners('no match');
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm.... Don't think this is a good idea either. What if other test suites or nock internals have set something.. Let's store the callback function we set in a variable and use removeListener?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Pchelolo I tried that and kept the same error as before, maybe I did it wrong somehow, I will try it again. Also, I am not sure if it is necessary to check for unmocked requests on no match events, there is no request besides /data/lists/* and to the mw api. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ouch, clicked the wrong button..

Hm... Not sure why wouldn't it work, it should if you're doing it like in the doc.. https://nodejs.org/api/events.html#events_emitter_removelistener_eventname_listener

In general, I'm not sure it worths bothering with it - you are mocking en.wikipedia.org domain and all requests go to it, and for mocked domains unmocked requests will throw anyway. Something really wrong should happen for us to start talking to some unmocked domain.

To some up, if removeListener doesn't work, no need to bother with this IMHO, just remove the whole thing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, nevermind I was still using an anonymous function, my mistake. New commit on the way.

Copy link
Contributor

@Pchelolo Pchelolo left a comment

Choose a reason for hiding this comment

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

One more inline

Changing removeAllListeners to removeListener

Bug: T184545
@Pchelolo
Copy link
Contributor

Pchelolo commented Aug 30, 2018

Ok, travis's happy - good. I didn't really look closely into all the individual mocks, but I guess they're fine.

In the meantime, can you ./node_modules/.bin/eslint ./test/features/lists.js and fix some obvious issues like use function instead of => etc. Even just ./node_modules/.bin/eslint --fix ./test/features/lists.js is ok.

We don't really lint the tests all the time, but it's better if new tests had less linting errors.

Skiping console-log rules in one line
@thesocialdev
Copy link
Contributor Author

@Pchelolo thank you for reviewing it. Do you think is a good idea adding the linting check to a pre-commit hook or something like it?

@thesocialdev
Copy link
Contributor Author

The fail is related to should stop redirect cycles, cross-origin, caused by a timeout with 504 status. And happened on node 8 check, maybe restart the build can have a different output.

@mdholloway
Copy link
Contributor

If there are timeout problems, they are at least transient. I just restarted the CI jobs a couple of times; the first timed out before the test suite started, and the second run passed.

@mdholloway
Copy link
Contributor

LGTM 👍

@Pchelolo
Copy link
Contributor

Pchelolo commented Sep 1, 2018

Do you think is a good idea adding the linting check to a pre-commit hook or something like it?

We do have linting running as a part of the test suite, but we don't lint tests - mainly because neither of us have time to actually re-write the tests so that they pass linting :) My request for linting for you was driven by the desire not to introduce tech debt with the new tests.

@Pchelolo
Copy link
Contributor

Pchelolo commented Sep 1, 2018

Did you run the lint on the new tests? How did it go?

@thesocialdev
Copy link
Contributor Author

thesocialdev commented Sep 1, 2018

We do have linting running as a part of the test suite, but we don't lint tests

Oh, ok. I understand.

Did you run the lint on the new tests? How did it go?

Yes, after it I fixed over 100 lint issues (mostly indentation), it now has no lint issues for test/features/lists.js file.

@Pchelolo
Copy link
Contributor

Pchelolo commented Sep 2, 2018

Yes, after it I fixed over 100 lint issues (mostly indentation), it now has no lint issues for test/features/lists.js file.

😘

@Pchelolo Pchelolo merged commit 42b42b1 into wikimedia:master Sep 2, 2018
@d00rman d00rman added the tests label Sep 11, 2018
@thesocialdev thesocialdev deleted the readinglists-tests branch September 25, 2018 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 participants