-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into PM-11777-browser-extension-totp-not-copied-w…
…hen-autofilling-passkey
- Loading branch information
Showing
10 changed files
with
115 additions
and
47 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 |
---|---|---|
|
@@ -13,6 +13,7 @@ import { CollectionView } from "@bitwarden/admin-console/common"; | |
import { AuditService } from "@bitwarden/common/abstractions/audit.service"; | ||
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service"; | ||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; | ||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; | ||
import { AutofillSettingsServiceAbstraction } from "@bitwarden/common/autofill/services/autofill-settings.service"; | ||
import { DomainSettingsService } from "@bitwarden/common/autofill/services/domain-settings.service"; | ||
import { ClientType } from "@bitwarden/common/enums"; | ||
|
@@ -183,6 +184,12 @@ export default { | |
getClientType: () => ClientType.Browser, | ||
}, | ||
}, | ||
{ | ||
provide: AccountService, | ||
useValue: { | ||
activeAccount$: new BehaviorSubject({ email: "[email protected]" }), | ||
}, | ||
}, | ||
], | ||
}), | ||
componentWrapperDecorator( | ||
|
This file contains 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 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 |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import { CommonModule } from "@angular/common"; | ||
import { ComponentFixture, fakeAsync, TestBed, tick } from "@angular/core/testing"; | ||
import { ReactiveFormsModule } from "@angular/forms"; | ||
import { By } from "@angular/platform-browser"; | ||
import { mock, MockProxy } from "jest-mock-extended"; | ||
import { BehaviorSubject } from "rxjs"; | ||
|
||
import { CollectionView } from "@bitwarden/admin-console/common"; | ||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; | ||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; | ||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; | ||
import { CollectionId, OrganizationId } from "@bitwarden/common/types/guid"; | ||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; | ||
import { SelectComponent } from "@bitwarden/components"; | ||
|
||
import { CipherFormConfig } from "../../abstractions/cipher-form-config.service"; | ||
import { CipherFormContainer } from "../../cipher-form-container"; | ||
|
@@ -20,6 +24,8 @@ describe("ItemDetailsSectionComponent", () => { | |
let cipherFormProvider: MockProxy<CipherFormContainer>; | ||
let i18nService: MockProxy<I18nService>; | ||
|
||
const activeAccount$ = new BehaviorSubject<{ email: string }>({ email: "[email protected]" }); | ||
|
||
beforeEach(async () => { | ||
cipherFormProvider = mock<CipherFormContainer>(); | ||
i18nService = mock<I18nService>(); | ||
|
@@ -29,6 +35,7 @@ describe("ItemDetailsSectionComponent", () => { | |
providers: [ | ||
{ provide: CipherFormContainer, useValue: cipherFormProvider }, | ||
{ provide: I18nService, useValue: i18nService }, | ||
{ provide: AccountService, useValue: { activeAccount$ } }, | ||
], | ||
}).compileComponents(); | ||
|
||
|
@@ -207,6 +214,35 @@ describe("ItemDetailsSectionComponent", () => { | |
}); | ||
}); | ||
|
||
describe("showPersonalOwnerOption", () => { | ||
it("should show personal ownership when the configuration allows", () => { | ||
component.config.mode = "edit"; | ||
component.config.allowPersonalOwnership = true; | ||
component.config.organizations = [{ id: "134-433-22" } as Organization]; | ||
fixture.detectChanges(); | ||
|
||
const select = fixture.debugElement.query(By.directive(SelectComponent)); | ||
const { value, label } = select.componentInstance.items[0]; | ||
|
||
expect(value).toBeNull(); | ||
expect(label).toBe("[email protected]"); | ||
}); | ||
|
||
it("should show personal ownership when the control is disabled", async () => { | ||
component.config.mode = "edit"; | ||
component.config.allowPersonalOwnership = false; | ||
component.config.organizations = [{ id: "134-433-22" } as Organization]; | ||
await component.ngOnInit(); | ||
fixture.detectChanges(); | ||
|
||
const select = fixture.debugElement.query(By.directive(SelectComponent)); | ||
|
||
const { value, label } = select.componentInstance.items[0]; | ||
expect(value).toBeNull(); | ||
expect(label).toBe("[email protected]"); | ||
}); | ||
}); | ||
|
||
describe("showOwnership", () => { | ||
it("should return true if ownership change is allowed or in edit mode with at least one organization", () => { | ||
jest.spyOn(component, "allowOwnershipChange", "get").mockReturnValue(true); | ||
|
This file contains 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