mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
Remove FF: pm-17772-admin-initiated-sponsorships (#16873)
* Remove FF * Fix test
This commit is contained in:
@@ -38,7 +38,6 @@ describe("FreeFamiliesPolicyService", () => {
|
||||
describe("showSponsoredFamiliesDropdown$", () => {
|
||||
it("should return true when all conditions are met", async () => {
|
||||
// Configure mocks
|
||||
configService.getFeatureFlag$.mockReturnValue(of(true));
|
||||
policyService.policiesByType$.mockReturnValue(of([]));
|
||||
|
||||
// Create a test organization that meets all criteria
|
||||
@@ -58,7 +57,6 @@ describe("FreeFamiliesPolicyService", () => {
|
||||
|
||||
it("should return false when organization is not Enterprise", async () => {
|
||||
// Configure mocks
|
||||
configService.getFeatureFlag$.mockReturnValue(of(true));
|
||||
policyService.policiesByType$.mockReturnValue(of([]));
|
||||
|
||||
// Create a test organization that is not Enterprise tier
|
||||
@@ -74,27 +72,8 @@ describe("FreeFamiliesPolicyService", () => {
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false when feature flag is disabled", async () => {
|
||||
// Configure mocks to disable feature flag
|
||||
configService.getFeatureFlag$.mockReturnValue(of(false));
|
||||
policyService.policiesByType$.mockReturnValue(of([]));
|
||||
|
||||
// Create a test organization that meets other criteria
|
||||
const organization = {
|
||||
id: "org-id",
|
||||
productTierType: ProductTierType.Enterprise,
|
||||
useAdminSponsoredFamilies: true,
|
||||
isAdmin: true,
|
||||
} as Organization;
|
||||
|
||||
// Test the method
|
||||
const result = await firstValueFrom(service.showSponsoredFamiliesDropdown$(of(organization)));
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false when families feature is disabled by policy", async () => {
|
||||
// Configure mocks with a policy that disables the feature
|
||||
configService.getFeatureFlag$.mockReturnValue(of(true));
|
||||
policyService.policiesByType$.mockReturnValue(
|
||||
of([{ organizationId: "org-id", enabled: true } as Policy]),
|
||||
);
|
||||
@@ -114,7 +93,6 @@ describe("FreeFamiliesPolicyService", () => {
|
||||
|
||||
it("should return false when useAdminSponsoredFamilies is false", async () => {
|
||||
// Configure mocks
|
||||
configService.getFeatureFlag$.mockReturnValue(of(true));
|
||||
policyService.policiesByType$.mockReturnValue(of([]));
|
||||
|
||||
// Create a test organization with useAdminSponsoredFamilies set to false
|
||||
@@ -132,7 +110,6 @@ describe("FreeFamiliesPolicyService", () => {
|
||||
|
||||
it("should return true when user is an owner but not admin", async () => {
|
||||
// Configure mocks
|
||||
configService.getFeatureFlag$.mockReturnValue(of(true));
|
||||
policyService.policiesByType$.mockReturnValue(of([]));
|
||||
|
||||
// Create a test organization where user is owner but not admin
|
||||
@@ -152,7 +129,6 @@ describe("FreeFamiliesPolicyService", () => {
|
||||
|
||||
it("should return true when user can manage users but is not admin or owner", async () => {
|
||||
// Configure mocks
|
||||
configService.getFeatureFlag$.mockReturnValue(of(true));
|
||||
policyService.policiesByType$.mockReturnValue(of([]));
|
||||
|
||||
// Create a test organization where user can manage users but is not admin or owner
|
||||
@@ -172,7 +148,6 @@ describe("FreeFamiliesPolicyService", () => {
|
||||
|
||||
it("should return false when user has no admin permissions", async () => {
|
||||
// Configure mocks
|
||||
configService.getFeatureFlag$.mockReturnValue(of(true));
|
||||
policyService.policiesByType$.mockReturnValue(of([]));
|
||||
|
||||
// Create a test organization where user has no admin permissions
|
||||
|
||||
@@ -8,8 +8,6 @@ import { Organization } from "@bitwarden/common/admin-console/models/domain/orga
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
import { ProductTierType } from "@bitwarden/common/billing/enums";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
|
||||
interface EnterpriseOrgStatus {
|
||||
isFreeFamilyPolicyEnabled: boolean;
|
||||
@@ -23,7 +21,6 @@ export class FreeFamiliesPolicyService {
|
||||
private policyService: PolicyService,
|
||||
private organizationService: OrganizationService,
|
||||
private accountService: AccountService,
|
||||
private configService: ConfigService,
|
||||
) {}
|
||||
|
||||
organizations$ = this.accountService.activeAccount$.pipe(
|
||||
@@ -58,20 +55,14 @@ export class FreeFamiliesPolicyService {
|
||||
userId,
|
||||
);
|
||||
|
||||
return combineLatest([
|
||||
enterpriseOrganization$,
|
||||
this.configService.getFeatureFlag$(FeatureFlag.PM17772_AdminInitiatedSponsorships),
|
||||
organization,
|
||||
policies$,
|
||||
]).pipe(
|
||||
map(([isEnterprise, featureFlagEnabled, org, policies]) => {
|
||||
return combineLatest([enterpriseOrganization$, organization, policies$]).pipe(
|
||||
map(([isEnterprise, org, policies]) => {
|
||||
const familiesFeatureDisabled = policies.some(
|
||||
(policy) => policy.organizationId === org.id && policy.enabled,
|
||||
);
|
||||
|
||||
return (
|
||||
isEnterprise &&
|
||||
featureFlagEnabled &&
|
||||
!familiesFeatureDisabled &&
|
||||
org.useAdminSponsoredFamilies &&
|
||||
(org.isAdmin || org.isOwner || org.canManageUsers)
|
||||
|
||||
Reference in New Issue
Block a user