-
Notifications
You must be signed in to change notification settings - Fork 293
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
fix(vue): remove mock facade values code #4061
Conversation
|
…o vue-refactor/facade-cleanup
export const facade = { | ||
error: '', |
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.
socialProvider
was in particular broken because this object didn't have it.
packages/vue/src/composables/__tests__/useAuthenticator.spec.ts
Outdated
Show resolved
Hide resolved
@@ -20,6 +20,7 @@ class MockAuthService { | |||
|
|||
const mockServiceFacade = { | |||
authStatus: 'authenticated', | |||
socialProviders: ['amazon'], |
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.
Added this because socialProviders
was previously broken.
const useAuthenticatorValue = reactive({ | ||
...facade, | ||
send, | ||
state, | ||
}) as any; | ||
// TODO(BREAKING): remove the cast to any | ||
const useAuthenticatorValue = reactive({}) as any; |
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.
This initial value is not needed, because watchEffect
below is guaranteed to run immediately (see comment below). And ...facade
was spreading a mock value anyway, so we aren't losing anything.
I actually prefer this because now we only have one place where we populate useAuthenticatorValue
.
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.
LGTM
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.
LGTM, please wait till liveness package release goes out before merging
But I will, it's a feature branch ;) |
* Remove dependency on mock facade * Update comment * Remove //@ts-ignore * useAuthenticatorValue cleanup * Update packages/vue/src/composables/useAuth.ts * Update packages/vue/src/composables/useAuth.ts * Update packages/vue/src/composables/useAuth.ts * Update tests * fix typo * Update packages/vue/src/composables/__tests__/useAuthenticator.spec.ts
* Remove dependency on mock facade * Update comment * Remove //@ts-ignore * useAuthenticatorValue cleanup * Update packages/vue/src/composables/useAuth.ts * Update packages/vue/src/composables/useAuth.ts * Update packages/vue/src/composables/useAuth.ts * Update tests * fix typo * Update packages/vue/src/composables/__tests__/useAuthenticator.spec.ts
Problem
Previously,
useAuthenticator
relied on a mock facade value object to to infer the shape ofuseAuthenticator
return value.This is problematic, because the object is not strongly typed and manually maintained. For example, it already was missing
socialProviders
, and so it was never picked up in the return value.Solution
This PR uses the return value of
getServiceContextFacade
directly as a source of truth.Description of how you validated changes
Existing e2e tests and unit tests, as well as basic smoke testing:
Screen.Recording.2023-06-08.at.11.59.37.AM.mov
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.