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

fix(vue): remove mock facade values code #4061

Merged
merged 12 commits into from
Jun 9, 2023

Conversation

wlee221
Copy link
Contributor

@wlee221 wlee221 commented Jun 8, 2023

Problem

Previously, useAuthenticator relied on a mock facade value object to to infer the shape of useAuthenticator 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.

@wlee221 wlee221 requested a review from a team as a code owner June 8, 2023 17:02
@changeset-bot
Copy link

changeset-bot bot commented Jun 8, 2023

⚠️ No Changeset found

Latest commit: 3e7f360

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Comment on lines -3 to -4
export const facade = {
error: '',
Copy link
Contributor Author

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.

@wlee221 wlee221 temporarily deployed to ci June 8, 2023 18:32 — with GitHub Actions Inactive
@wlee221 wlee221 temporarily deployed to ci June 8, 2023 18:32 — with GitHub Actions Inactive
@wlee221 wlee221 temporarily deployed to ci June 8, 2023 18:32 — with GitHub Actions Inactive
@@ -20,6 +20,7 @@ class MockAuthService {

const mockServiceFacade = {
authStatus: 'authenticated',
socialProviders: ['amazon'],
Copy link
Contributor Author

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.

@wlee221 wlee221 marked this pull request as ready for review June 8, 2023 19:03
const useAuthenticatorValue = reactive({
...facade,
send,
state,
}) as any;
// TODO(BREAKING): remove the cast to any
const useAuthenticatorValue = reactive({}) as any;
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 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.

Copy link
Member

@thaddmt thaddmt left a comment

Choose a reason for hiding this comment

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

LGTM

@wlee221 wlee221 temporarily deployed to ci June 8, 2023 22:04 — with GitHub Actions Inactive
@wlee221 wlee221 temporarily deployed to ci June 8, 2023 22:04 — with GitHub Actions Inactive
@wlee221 wlee221 temporarily deployed to ci June 8, 2023 22:04 — with GitHub Actions Inactive
@wlee221 wlee221 temporarily deployed to ci June 8, 2023 22:04 — with GitHub Actions Inactive
Copy link
Contributor

@reesscot reesscot left a 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

@wlee221
Copy link
Contributor Author

wlee221 commented Jun 9, 2023

LGTM, please wait till liveness package release goes out before merging

But I will, it's a feature branch ;)

@wlee221 wlee221 merged commit c5796bf into vue-refactor/main Jun 9, 2023
@wlee221 wlee221 deleted the vue-refactor/facade-cleanup branch June 9, 2023 18:08
wlee221 added a commit that referenced this pull request Jul 14, 2023
* 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
wlee221 added a commit that referenced this pull request Jul 14, 2023
* 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
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.

3 participants