1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-12 06:13:38 +00:00

Remove FF: pm-17772-admin-initiated-sponsorships (#16873)

* Remove FF

* Fix test
This commit is contained in:
Alex Morask
2025-10-29 07:41:35 -05:00
committed by GitHub
parent ff30df3dd6
commit 460d66d624
3 changed files with 2 additions and 38 deletions

View File

@@ -38,7 +38,6 @@ describe("FreeFamiliesPolicyService", () => {
describe("showSponsoredFamiliesDropdown$", () => { describe("showSponsoredFamiliesDropdown$", () => {
it("should return true when all conditions are met", async () => { it("should return true when all conditions are met", async () => {
// Configure mocks // Configure mocks
configService.getFeatureFlag$.mockReturnValue(of(true));
policyService.policiesByType$.mockReturnValue(of([])); policyService.policiesByType$.mockReturnValue(of([]));
// Create a test organization that meets all criteria // Create a test organization that meets all criteria
@@ -58,7 +57,6 @@ describe("FreeFamiliesPolicyService", () => {
it("should return false when organization is not Enterprise", async () => { it("should return false when organization is not Enterprise", async () => {
// Configure mocks // Configure mocks
configService.getFeatureFlag$.mockReturnValue(of(true));
policyService.policiesByType$.mockReturnValue(of([])); policyService.policiesByType$.mockReturnValue(of([]));
// Create a test organization that is not Enterprise tier // Create a test organization that is not Enterprise tier
@@ -74,27 +72,8 @@ describe("FreeFamiliesPolicyService", () => {
expect(result).toBe(false); 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 () => { it("should return false when families feature is disabled by policy", async () => {
// Configure mocks with a policy that disables the feature // Configure mocks with a policy that disables the feature
configService.getFeatureFlag$.mockReturnValue(of(true));
policyService.policiesByType$.mockReturnValue( policyService.policiesByType$.mockReturnValue(
of([{ organizationId: "org-id", enabled: true } as Policy]), of([{ organizationId: "org-id", enabled: true } as Policy]),
); );
@@ -114,7 +93,6 @@ describe("FreeFamiliesPolicyService", () => {
it("should return false when useAdminSponsoredFamilies is false", async () => { it("should return false when useAdminSponsoredFamilies is false", async () => {
// Configure mocks // Configure mocks
configService.getFeatureFlag$.mockReturnValue(of(true));
policyService.policiesByType$.mockReturnValue(of([])); policyService.policiesByType$.mockReturnValue(of([]));
// Create a test organization with useAdminSponsoredFamilies set to false // 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 () => { it("should return true when user is an owner but not admin", async () => {
// Configure mocks // Configure mocks
configService.getFeatureFlag$.mockReturnValue(of(true));
policyService.policiesByType$.mockReturnValue(of([])); policyService.policiesByType$.mockReturnValue(of([]));
// Create a test organization where user is owner but not admin // 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 () => { it("should return true when user can manage users but is not admin or owner", async () => {
// Configure mocks // Configure mocks
configService.getFeatureFlag$.mockReturnValue(of(true));
policyService.policiesByType$.mockReturnValue(of([])); policyService.policiesByType$.mockReturnValue(of([]));
// Create a test organization where user can manage users but is not admin or owner // 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 () => { it("should return false when user has no admin permissions", async () => {
// Configure mocks // Configure mocks
configService.getFeatureFlag$.mockReturnValue(of(true));
policyService.policiesByType$.mockReturnValue(of([])); policyService.policiesByType$.mockReturnValue(of([]));
// Create a test organization where user has no admin permissions // Create a test organization where user has no admin permissions

View File

@@ -8,8 +8,6 @@ import { Organization } from "@bitwarden/common/admin-console/models/domain/orga
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { getUserId } from "@bitwarden/common/auth/services/account.service"; import { getUserId } from "@bitwarden/common/auth/services/account.service";
import { ProductTierType } from "@bitwarden/common/billing/enums"; 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 { interface EnterpriseOrgStatus {
isFreeFamilyPolicyEnabled: boolean; isFreeFamilyPolicyEnabled: boolean;
@@ -23,7 +21,6 @@ export class FreeFamiliesPolicyService {
private policyService: PolicyService, private policyService: PolicyService,
private organizationService: OrganizationService, private organizationService: OrganizationService,
private accountService: AccountService, private accountService: AccountService,
private configService: ConfigService,
) {} ) {}
organizations$ = this.accountService.activeAccount$.pipe( organizations$ = this.accountService.activeAccount$.pipe(
@@ -58,20 +55,14 @@ export class FreeFamiliesPolicyService {
userId, userId,
); );
return combineLatest([ return combineLatest([enterpriseOrganization$, organization, policies$]).pipe(
enterpriseOrganization$, map(([isEnterprise, org, policies]) => {
this.configService.getFeatureFlag$(FeatureFlag.PM17772_AdminInitiatedSponsorships),
organization,
policies$,
]).pipe(
map(([isEnterprise, featureFlagEnabled, org, policies]) => {
const familiesFeatureDisabled = policies.some( const familiesFeatureDisabled = policies.some(
(policy) => policy.organizationId === org.id && policy.enabled, (policy) => policy.organizationId === org.id && policy.enabled,
); );
return ( return (
isEnterprise && isEnterprise &&
featureFlagEnabled &&
!familiesFeatureDisabled && !familiesFeatureDisabled &&
org.useAdminSponsoredFamilies && org.useAdminSponsoredFamilies &&
(org.isAdmin || org.isOwner || org.canManageUsers) (org.isAdmin || org.isOwner || org.canManageUsers)

View File

@@ -23,7 +23,6 @@ export enum FeatureFlag {
/* Billing */ /* Billing */
TrialPaymentOptional = "PM-8163-trial-payment", TrialPaymentOptional = "PM-8163-trial-payment",
PM17772_AdminInitiatedSponsorships = "pm-17772-admin-initiated-sponsorships",
PM21821_ProviderPortalTakeover = "pm-21821-provider-portal-takeover", PM21821_ProviderPortalTakeover = "pm-21821-provider-portal-takeover",
PM22415_TaxIDWarnings = "pm-22415-tax-id-warnings", PM22415_TaxIDWarnings = "pm-22415-tax-id-warnings",
PM24032_NewNavigationPremiumUpgradeButton = "pm-24032-new-navigation-premium-upgrade-button", PM24032_NewNavigationPremiumUpgradeButton = "pm-24032-new-navigation-premium-upgrade-button",
@@ -109,7 +108,6 @@ export const DefaultFeatureFlagValue = {
/* Billing */ /* Billing */
[FeatureFlag.TrialPaymentOptional]: FALSE, [FeatureFlag.TrialPaymentOptional]: FALSE,
[FeatureFlag.PM17772_AdminInitiatedSponsorships]: FALSE,
[FeatureFlag.PM21821_ProviderPortalTakeover]: FALSE, [FeatureFlag.PM21821_ProviderPortalTakeover]: FALSE,
[FeatureFlag.PM22415_TaxIDWarnings]: FALSE, [FeatureFlag.PM22415_TaxIDWarnings]: FALSE,
[FeatureFlag.PM24032_NewNavigationPremiumUpgradeButton]: FALSE, [FeatureFlag.PM24032_NewNavigationPremiumUpgradeButton]: FALSE,