-
Notifications
You must be signed in to change notification settings - Fork 2k
[PM-40867] feat: Show email verification status and verify action on My account settings page #22387
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
Draft
enmande
wants to merge
9
commits into
main
Choose a base branch
from
auth/pm-40867/show-email-verification-status-on-my-account-settings
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
[PM-40867] feat: Show email verification status and verify action on My account settings page #22387
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
aa05f51
feat(verify-email): Add "verified" and CTA inline with user email.
enmande e6511b3
feat(verify-email): Remove verify-email banner; no longer used.
enmande 380475a
feat(verify-email): Remove verifyEmailDesc localization key; no longeβ¦
enmande b21dffb
test(verify-email): Add profile component test.
enmande bd664a4
test(vault-banners): Remove emailVerified mocks.
enmande 7b0db83
Merge branch 'main' into auth/pm-40867/show-email-verification-statusβ¦
enmande 80deeaf
feat(verify-email): Improve badge reactivity and surface "already verβ¦
enmande b86c8c5
Update apps/web/src/app/auth/settings/account/profile.component.ts
enmande 5cf8806
Merge branch 'main' into auth/pm-40867/show-email-verification-statusβ¦
enmande File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
apps/web/src/app/auth/settings/account/profile.component.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| import { ComponentFixture, TestBed } from "@angular/core/testing"; | ||
| import { mock } from "jest-mock-extended"; | ||
| import { of } from "rxjs"; | ||
|
|
||
| import { ApiService } from "@bitwarden/common/abstractions/api.service"; | ||
| import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; | ||
| import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; | ||
| import { AvatarService } from "@bitwarden/common/auth/abstractions/avatar.service"; | ||
| import { ProfileResponse } from "@bitwarden/common/models/response/profile.response"; | ||
| import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; | ||
| import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; | ||
| import { FakeAccountService, mockAccountServiceWith } from "@bitwarden/common/spec"; | ||
| import { UserId } from "@bitwarden/common/types/guid"; | ||
| import { DialogService, ToastService } from "@bitwarden/components"; | ||
| import { KeyService } from "@bitwarden/key-management"; | ||
|
|
||
| import { ProfileComponent } from "./profile.component"; | ||
|
|
||
| describe("ProfileComponent", () => { | ||
| let component: ProfileComponent; | ||
| let fixture: ComponentFixture<ProfileComponent>; | ||
| let apiService: ReturnType<typeof mock<ApiService>>; | ||
| let toastService: ReturnType<typeof mock<ToastService>>; | ||
| let accountService: FakeAccountService; | ||
|
|
||
| const userId = "user-id" as UserId; | ||
|
|
||
| function buildProfile(emailVerified: boolean): ProfileResponse { | ||
| return new ProfileResponse({ | ||
| Id: userId, | ||
| Name: "Test User", | ||
| Email: "test@bitwarden.com", | ||
| EmailVerified: emailVerified, | ||
| }); | ||
| } | ||
|
|
||
| beforeEach(async () => { | ||
| apiService = mock<ApiService>(); | ||
| toastService = mock<ToastService>(); | ||
| accountService = mockAccountServiceWith(userId); | ||
|
|
||
| apiService.getProfile.mockResolvedValue(buildProfile(false)); | ||
|
|
||
| await TestBed.configureTestingModule({ | ||
| imports: [ProfileComponent], | ||
| providers: [ | ||
| { provide: ApiService, useValue: apiService }, | ||
| { | ||
| provide: OrganizationService, | ||
| useValue: mock<OrganizationService>({ organizations$: () => of([]) }), | ||
| }, | ||
| { provide: AccountService, useValue: accountService }, | ||
| { provide: I18nService, useValue: { t: (key: string) => key } }, | ||
| { provide: LogService, useValue: mock<LogService>() }, | ||
| { provide: DialogService, useValue: mock<DialogService>() }, | ||
| { provide: ToastService, useValue: toastService }, | ||
| { provide: KeyService, useValue: mock<KeyService>({ userPublicKey$: () => of(null) }) }, | ||
| { provide: AvatarService, useValue: mock<AvatarService>({ avatarColor$: of(null) }) }, | ||
| ], | ||
| }).compileComponents(); | ||
|
|
||
| fixture = TestBed.createComponent(ProfileComponent); | ||
| component = fixture.componentInstance; | ||
| }); | ||
|
|
||
| describe("email verification indicator", () => { | ||
| it("shows the verified badge when the email is verified", async () => { | ||
| apiService.getProfile.mockResolvedValue(buildProfile(true)); | ||
|
|
||
| await component.ngOnInit(); | ||
| fixture.detectChanges(); | ||
|
|
||
| const badge = fixture.debugElement.nativeElement.querySelector("[bitbadge]"); | ||
| const verifyButton = fixture.debugElement.nativeElement.querySelector( | ||
| "#profile_button_verifyEmail", | ||
| ); | ||
|
|
||
| expect(badge).not.toBeNull(); | ||
| expect(verifyButton).toBeNull(); | ||
| }); | ||
|
|
||
| it("shows the verify email button when the email is not verified", async () => { | ||
| apiService.getProfile.mockResolvedValue(buildProfile(false)); | ||
|
|
||
| await component.ngOnInit(); | ||
| fixture.detectChanges(); | ||
|
|
||
| const badge = fixture.debugElement.nativeElement.querySelector("[bitbadge]"); | ||
| const verifyButton = fixture.debugElement.nativeElement.querySelector( | ||
| "#profile_button_verifyEmail", | ||
| ); | ||
|
|
||
| expect(badge).toBeNull(); | ||
| expect(verifyButton).not.toBeNull(); | ||
| }); | ||
| }); | ||
|
|
||
| describe("verifyEmail", () => { | ||
| it("sends the verification email and shows a success toast", async () => { | ||
| await component["verifyEmail"](); | ||
|
|
||
| expect(apiService.postAccountVerifyEmail).toHaveBeenCalled(); | ||
| expect(toastService.showToast).toHaveBeenCalledWith({ | ||
| variant: "success", | ||
| message: "checkInboxForVerification", | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
apps/web/src/app/auth/settings/verify-email.component.html
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.