-
Notifications
You must be signed in to change notification settings - Fork 43
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
feat: sending a custom rdme user agent with all requests #436
Conversation
"jest": true | ||
}, | ||
"rules": { | ||
"jest/expect-expect": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All tests have explicit expect()
s now so we don't need add these exclusions for nock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of small notes but otherwise LGTM! The refactor is real nice 👏🏽
Also quite bummed we hadn't been adding the user agent until now 😞
await expect(docs.run({ folder: './__tests__/__fixtures__/new-docs', key, version })).resolves.toStrictEqual([ | ||
{ | ||
slug: 'new-doc', | ||
body: '\nBody\n', | ||
category: '5ae122e10fdf4e39bb34db6f', | ||
title: 'This is the document title', | ||
lastUpdatedHash: 'a23046c1e9d8ab47f8875ae7c5e429cb95be1c48', | ||
}, | ||
]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ugh we really had these tests in so many places lol 😭
}); | ||
await expect(docs.run({ folder: './__tests__/__fixtures__/slug-docs', key, version })).resolves.toStrictEqual([ | ||
{ | ||
slug: 'marc-actually-wrote-a-test', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lmao @mjcuva
@@ -1,3 +1,4 @@ | |||
/* eslint-disable jest/no-conditional-expect */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we disable it for each line or is it affecting the whole file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every test in this one has a conditional expect unfortunately.
🧰 Changes
Much to my surprise and chagrin we weren't already sending a custom
rdme/(major).(minor).(patch)
user agent with all API requests. This fixes that!🧬 QA & Testing
I've slightly shuffled around the
cleanHeaders
andhandleRes
libraries we had insrc/lib
into this newfetch
wrapper insrc/lib/fetch
. Anything that once loadednode-fetch
now loads this (which in turn loadsnode-fetch
).I've also added some unit tests for this to make sure that user agents are getting sent, changed every command test that mocks calls to our API to mock that API call + the user agent, and also cleaned up a few command tests that didn't have any explicit assertions (they were just silently testing either the mocks would succeed or that the command wouldn't fail).