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

Routine maintenance 2023-07 #111

Merged
merged 14 commits into from
Aug 7, 2023
Merged

Routine maintenance 2023-07 #111

merged 14 commits into from
Aug 7, 2023

Conversation

chawes13
Copy link
Contributor

@chawes13 chawes13 commented Aug 1, 2023

Items addressed

  • Resolves Dependency Dashboard #99
  • Adds guard for requiring url option
    • If it was blank before an uncaught exception would be thrown by join from url-join in the add-root-to-url middleware. If root wasn't defined, then the exception wouldn't be thrown but then the user would see "Uncaught TypeError: Failed to execute 'fetch' on 'Window': 1 argument required, but only 0 present." So either way, errors would be thrown (making this a backwards compatible change)
  • Moves test coverage up to 100%.
    Previous:

    Current:

Out of Scope

  • Upgrading the remaining two packages from yarn outdated. They both switched to ESM only packages, which by itself is not a huge issue but causes a real headache with eslint and jest, so we're not ready to accommodate that switch yet. I spiked on it for a few hours and didn't make much progress – an unfortunate reality of the schism in the community.

package.json Show resolved Hide resolved
jest.config.js Show resolved Hide resolved
docs.md Outdated
@@ -301,7 +301,7 @@ getAuthenticationContext() // undefined
*
```

Returns **[String][32]**
Returns **[String][32]** 
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is weird, I need to look into it

Copy link
Contributor Author

@chawes13 chawes13 Aug 7, 2023

Choose a reason for hiding this comment

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

Later version(s?) of documentation expect an explanation for the return value. We were defining that in the description of both of these, instead of here.

@@ -14,16 +14,16 @@ test('getAuthenticationContext returns undefined when lp_auth cookie is set to a
})

test('getAuthenticationContext returns undefined when lp_auth cookie does not contain a token', () => {
Cookies.set('lp_auth', {})
Cookies.set('lp_auth', JSON.stringify({}))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In v3, Cookies.set no longer implicitly calls stringify. We aren't using this method in the code and we weren't using toJson() either, so it doesn't affect any source code.

https://github.com/js-cookie/js-cookie/releases/tag/v3.0.0

Copy link

Choose a reason for hiding this comment

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

Sounds good. Any value in creating a testing util function/interface to Cookies that handles the JSON.stringify. There are 3 examples here 😏 (I'm good on holding off too but figured I would at least mention it)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could be convinced if the source code was using it, but I'm pretty ok with being repetitive in tests!

Comment on lines +54 to +55
const spyDocument = jest.spyOn(global, 'document', 'get')
spyDocument.mockImplementation(() => undefined)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This gets us test coverage for line 11 of getTokenFromDocument

@@ -286,6 +305,16 @@ test('http sets basic auth header if `auth` is present', () => {
})
})

// Note: this isn't recommended and is super insecure, but technically the HTTP spec does allow it
test('http sets basic auth, even if username and password are not provided', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a test for behavior that already exists. It gives us test coverage for the right-hand expression of auth.username || "" and auth.password || ""

expect(isAuthenticated({ foo: 'bar' })).toEqual(true)
})

test('isAuthenticated returns false when lp_auth cookie is empty', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gets us test coverage for line 55 of is-authenticated

Copy link

@bhennes2 bhennes2 left a comment

Choose a reason for hiding this comment

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

LGTM code-wise! Added in a few clarifying/non-blocking comments.

@@ -14,16 +14,16 @@ test('getAuthenticationContext returns undefined when lp_auth cookie is set to a
})

test('getAuthenticationContext returns undefined when lp_auth cookie does not contain a token', () => {
Cookies.set('lp_auth', {})
Cookies.set('lp_auth', JSON.stringify({}))
Copy link

Choose a reason for hiding this comment

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

Sounds good. Any value in creating a testing util function/interface to Cookies that handles the JSON.stringify. There are 3 examples here 😏 (I'm good on holding off too but figured I would at least mention it)

test/http/http.test.js Show resolved Hide resolved
@chawes13 chawes13 merged commit bc88751 into main Aug 7, 2023
@chawes13 chawes13 deleted the chore/maintenance-2023-07 branch August 7, 2023 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dependency Dashboard
2 participants