diff --git a/apps/web/src/app/billing/clients/organization-billing.client.spec.ts b/apps/web/src/app/billing/clients/organization-billing.client.spec.ts index e5796f2d31d..20da72669b7 100644 --- a/apps/web/src/app/billing/clients/organization-billing.client.spec.ts +++ b/apps/web/src/app/billing/clients/organization-billing.client.spec.ts @@ -159,6 +159,31 @@ describe("OrganizationBillingClient", () => { }); }); + describe("purchasePrivilegedControls", () => { + it("calls the purchase route with the request body", async () => { + mockApiService.send.mockResolvedValue(undefined); + + await sut.purchasePrivilegedControls(orgId, { seats: 10, maxAutoscaleSeats: 20 }); + + expect(mockApiService.send).toHaveBeenCalledWith( + "POST", + `/organizations/${orgId}/billing/subscription/privileged-controls/purchase`, + { seats: 10, maxAutoscaleSeats: 20 }, + true, + false, + ); + }); + + it("propagates errors from the API", async () => { + const serverError = new ErrorResponse(null, 400); + mockApiService.send.mockRejectedValue(serverError); + + await expect( + sut.purchasePrivilegedControls(orgId, { seats: 10, maxAutoscaleSeats: null }), + ).rejects.toBe(serverError); + }); + }); + describe("updatePrivilegedControlsSubscription", () => { it("sends the seat adjustment and limit to the correct route", async () => { mockApiService.send.mockResolvedValue(undefined); diff --git a/apps/web/src/app/billing/clients/organization-billing.client.ts b/apps/web/src/app/billing/clients/organization-billing.client.ts index 22f40138e6e..568a63c2630 100644 --- a/apps/web/src/app/billing/clients/organization-billing.client.ts +++ b/apps/web/src/app/billing/clients/organization-billing.client.ts @@ -7,6 +7,11 @@ import { OrganizationWarningsResponse } from "@bitwarden/web-vault/app/billing/o type ChurnMitigationOfferDuration = "once" | "repeating"; +export type PurchasePrivilegedControlsRequest = { + seats: number; + maxAutoscaleSeats: number | null; +}; + export type UpdatePrivilegedControlsSubscriptionRequest = { seatAdjustment: number; maxAutoscaleSeats: number | null; @@ -106,6 +111,19 @@ export class OrganizationBillingClient { ); }; + purchasePrivilegedControls = async ( + organizationId: OrganizationId, + request: PurchasePrivilegedControlsRequest, + ): Promise => { + await this.apiService.send( + "POST", + `/organizations/${organizationId}/billing/subscription/privileged-controls/purchase`, + request, + true, + false, + ); + }; + updatePrivilegedControlsSubscription = async ( organizationId: OrganizationId, request: UpdatePrivilegedControlsSubscriptionRequest, diff --git a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html index cc52d67d7c3..e53c6134080 100644 --- a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html +++ b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html @@ -89,6 +89,22 @@ } + @if (showPrivilegedControlsPurchase() && orgSub && org) { +
+ @if (!showSecretsManagerSubscribe()) { +

{{ "moreFromBitwarden" | i18n }}

+ } + +
+ } + @if (showPrivilegedControlsContactSalesToAdd()) {

{{ "privilegedControls" | i18n }}

diff --git a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.spec.ts b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.spec.ts index 5c0dc4ee36a..42a94613293 100644 --- a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.spec.ts +++ b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.spec.ts @@ -1,6 +1,7 @@ import { DatePipe } from "@angular/common"; import { ChangeDetectionStrategy, Component, input, output } from "@angular/core"; import { ComponentFixture, TestBed } from "@angular/core/testing"; +import { By } from "@angular/platform-browser"; import { ActivatedRoute, convertToParamMap, ParamMap, Router } from "@angular/router"; import { mock } from "jest-mock-extended"; import { BehaviorSubject, Observable, of, Subject, throwError } from "rxjs"; @@ -34,6 +35,7 @@ import { import { OrganizationSubscriptionCloudComponent } from "./organization-subscription-cloud.component"; import { OrganizationSubscriptionDataService } from "./organization-subscription-data.service"; import { PrivilegedControlsAdjustSubscriptionComponent } from "./privileged-controls-adjust-subscription.component"; +import { PrivilegedControlsPurchaseComponent } from "./privileged-controls-purchase.component"; import * as restartSubscriptionDialog from "./restart-subscription-dialog.component"; import { RestartSubscriptionDialogResultType } from "./restart-subscription-dialog.component"; import { SecretsManagerAdjustSubscriptionComponent } from "./sm-adjust-subscription.component"; @@ -79,6 +81,20 @@ class MockSmSubscribeStandaloneComponent { readonly onSubscribe = output(); } +@Component({ + selector: "billing-privileged-controls-purchase", + template: "", + changeDetection: ChangeDetectionStrategy.OnPush, +}) +class MockPrivilegedControlsPurchaseComponent { + readonly plan = input(); + readonly organizationId = input(); + readonly customerDiscount = input(); + readonly passwordManagerSeats = input(); + readonly passwordManagerMaxAutoscaleSeats = input(); + readonly purchased = output(); +} + @Component({ selector: "app-sm-adjust-subscription", template: "", @@ -287,6 +303,7 @@ describe("OrganizationSubscriptionCloudComponent", () => { SecretsManagerAdjustSubscriptionComponent, PrivilegedControlsAdjustSubscriptionComponent, OrganizationScheduledPriceIncreaseWarningComponent, + PrivilegedControlsPurchaseComponent, ], }, add: { @@ -297,6 +314,7 @@ describe("OrganizationSubscriptionCloudComponent", () => { MockSmAdjustSubscriptionComponent, MockPrivilegedControlsAdjustSubscriptionComponent, MockScheduledPriceIncreaseWarningComponent, + MockPrivilegedControlsPurchaseComponent, ], }, }); @@ -1047,6 +1065,166 @@ describe("OrganizationSubscriptionCloudComponent", () => { }); }); + describe("privileged controls purchase gating", () => { + const buildEligibleOrganization = (overrides: Partial = {}) => + buildOrganization({ + canEditSubscription: true, + usePam: false, + productTierType: ProductTierType.Enterprise, + ...overrides, + }); + + const buildEnterpriseSubscription = ( + planOverrides: Record = {}, + overrides: Partial = {}, + ) => { + const base = buildSubscriptionResponse(); + return buildSubscriptionResponse({ + planType: PlanType.EnterpriseAnnually, + plan: { + ...base.plan, + productTier: ProductTierType.Enterprise, + PrivilegedControls: { seatPrice: 120 }, + ...planOverrides, + } as OrganizationSubscriptionResponse["plan"], + ...overrides, + }); + }; + + const mockFlags = (billing: boolean, pam: boolean) => + configService.getFeatureFlag$.mockImplementation( + (flag) => + of( + (flag === FeatureFlag.PamBillingSupport && billing) || + (flag === FeatureFlag.Pam && pam), + ) as any, + ); + + beforeEach(() => mockFlags(true, true)); + + /** Renders and waits for the subscription resource so each gate is evaluated on loaded data. */ + const render = async (options: { + organization: Organization; + subscription: OrganizationSubscriptionResponse; + }) => { + createComponent({ ...options, detectChanges: true }); + await fixture.whenStable(); + expect(component.organizationSubscription()).not.toBeNull(); + }; + + it("shows the purchase block for an eligible Enterprise organization", async () => { + await render({ + organization: buildEligibleOrganization(), + subscription: buildEnterpriseSubscription(), + }); + expect(component.showPrivilegedControlsPurchase()).toBe(true); + }); + + it("hides it when the billing flag is off", async () => { + mockFlags(false, true); + await render({ + organization: buildEligibleOrganization(), + subscription: buildEnterpriseSubscription(), + }); + expect(component.showPrivilegedControlsPurchase()).toBe(false); + }); + + it("hides it when the PAM product flag is off", async () => { + mockFlags(true, false); + await render({ + organization: buildEligibleOrganization(), + subscription: buildEnterpriseSubscription(), + }); + expect(component.showPrivilegedControlsPurchase()).toBe(false); + }); + + it("hides it when the organization already has Privileged Controls", async () => { + await render({ + organization: buildEligibleOrganization({ usePam: true }), + subscription: buildEnterpriseSubscription({}, { usePam: true }), + }); + expect(component.showPrivilegedControlsPurchase()).toBe(false); + }); + + it("hides it when the server reports Privileged Controls before the local organization syncs", async () => { + await render({ + organization: buildEligibleOrganization({ usePam: false }), + subscription: buildEnterpriseSubscription({}, { usePam: true }), + }); + expect(component.showPrivilegedControlsPurchase()).toBe(false); + }); + + it("hides it for a non-Enterprise plan", async () => { + await render({ + organization: buildEligibleOrganization(), + subscription: buildEnterpriseSubscription({ productTier: ProductTierType.Teams }), + }); + expect(component.showPrivilegedControlsPurchase()).toBe(false); + }); + + it("hides it when the plan has no Privileged Controls pricing", async () => { + await render({ + organization: buildEligibleOrganization(), + subscription: buildEnterpriseSubscription({ PrivilegedControls: null }), + }); + expect(component.showPrivilegedControlsPurchase()).toBe(false); + }); + + it("hides it when the subscription is cancelled", async () => { + await render({ + organization: buildEligibleOrganization(), + subscription: buildEnterpriseSubscription({}, { subscription: { cancelled: true } as any }), + }); + expect(component.showPrivilegedControlsPurchase()).toBe(false); + }); + + it("hides it when the organization has a provider", async () => { + await render({ + organization: buildEligibleOrganization({ hasProvider: true }), + subscription: buildEnterpriseSubscription(), + }); + expect(component.showPrivilegedControlsPurchase()).toBe(false); + }); + + it("passes the Password Manager seats and seat limit to the purchase block", async () => { + await render({ + organization: buildEligibleOrganization(), + subscription: buildEnterpriseSubscription({}, { seats: 25, maxAutoscaleSeats: 40 }), + }); + fixture.detectChanges(); + + const block: MockPrivilegedControlsPurchaseComponent = fixture.debugElement.query( + By.directive(MockPrivilegedControlsPurchaseComponent), + ).componentInstance; + expect(block.passwordManagerSeats()).toBe(25); + expect(block.passwordManagerMaxAutoscaleSeats()).toBe(40); + }); + + const moreFromBitwardenHeadings = (): HTMLElement[] => + Array.from(fixture.nativeElement.querySelectorAll("h3")).filter( + (heading) => heading.textContent?.trim() === "moreFromBitwarden", + ); + + it("shows its own More from Bitwarden heading when Secrets Manager subscribe is hidden", async () => { + await render({ + organization: buildEligibleOrganization({ useSecretsManager: true }), + subscription: buildEnterpriseSubscription(), + }); + fixture.detectChanges(); + expect(moreFromBitwardenHeadings().length).toBe(1); + }); + + it("leaves the More from Bitwarden heading to Secrets Manager subscribe when it is shown", async () => { + await render({ + organization: buildEligibleOrganization({ useSecretsManager: false }), + subscription: buildEnterpriseSubscription(), + }); + fixture.detectChanges(); + expect(component.showSecretsManagerSubscribe()).toBe(true); + expect(moreFromBitwardenHeadings().length).toBe(0); + }); + }); + describe("privileged controls adjust gating", () => { const enablePamBillingSupport = () => configService.getFeatureFlag$.mockImplementation( diff --git a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts index 4a563510512..ff183496e3d 100644 --- a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts +++ b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts @@ -61,6 +61,7 @@ import { PrivilegedControlsAdjustSubscriptionComponent, PrivilegedControlsSubscriptionOptions, } from "./privileged-controls-adjust-subscription.component"; +import { PrivilegedControlsPurchaseComponent } from "./privileged-controls-purchase.component"; import { resolveOrgSubscriptionAccess } from "./resolve-org-subscription-access"; import { openRestartSubscriptionDialog, @@ -116,6 +117,7 @@ const SubscriptionStatusLabels: Record = { AdjustSubscription, SecretsManagerSubscribeStandaloneComponent, SecretsManagerAdjustSubscriptionComponent, + PrivilegedControlsPurchaseComponent, PrivilegedControlsAdjustSubscriptionComponent, ErrorCardComponent, CalloutComponent, @@ -329,6 +331,38 @@ export class OrganizationSubscriptionCloudComponent { ); }); + private readonly pamBillingSupportEnabled = toSignal( + this.configService.getFeatureFlag$(FeatureFlag.PamBillingSupport), + { initialValue: false }, + ); + + /** Privileged Controls itself; without it the product is reachable nowhere, so no Contact sales call to action. */ + private readonly pamEnabled = toSignal(this.configService.getFeatureFlag$(FeatureFlag.Pam), { + initialValue: false, + }); + + /** + * Determines if the "Privileged Controls purchase" section should be shown. + * @returns True if the section should be displayed, false otherwise. + */ + readonly showPrivilegedControlsPurchase = computed(() => { + const org = this.organization(); + const subscription = this.organizationSubscription(); + const plan = subscription?.plan; + if (org == null || subscription == null || plan == null) { + return false; + } + return ( + !org.hasProvider && + this.pamBillingSupportEnabled() && + this.pamEnabled() && + !subscription.usePam && + plan.productTier === ProductTierType.Enterprise && + plan.PrivilegedControls != null && + !this.isSubscriptionCanceledOrPendingCancellation() + ); + }); + /** * Determines if the "Adjust Secrets Manager" section should be shown. * @returns True if the section should be displayed, false otherwise. @@ -348,16 +382,6 @@ export class OrganizationSubscriptionCloudComponent { ); }); - private readonly pamBillingSupportEnabled = toSignal( - this.configService.getFeatureFlag$(FeatureFlag.PamBillingSupport), - { initialValue: false }, - ); - - /** Privileged Controls itself; without it the product is reachable nowhere, so no Contact sales call to action. */ - private readonly pamEnabled = toSignal(this.configService.getFeatureFlag$(FeatureFlag.Pam), { - initialValue: false, - }); - /** Self-serve Privileged Controls: seat and limit adjustment, shown only while PAM billing support is on. */ readonly showAdjustPrivilegedControls = computed(() => { const org = this.organization(); diff --git a/apps/web/src/app/billing/organizations/privileged-controls-purchase.component.html b/apps/web/src/app/billing/organizations/privileged-controls-purchase.component.html new file mode 100644 index 00000000000..d9a5d70b5f9 --- /dev/null +++ b/apps/web/src/app/billing/organizations/privileged-controls-purchase.component.html @@ -0,0 +1,92 @@ +
+ +
+ {{ "privilegedControlsPurchaseDesc" | i18n }} +

{{ "whatsIncluded" | i18n }}

+
    +
  • {{ "privilegedControlsFeatureCredentialLeasing" | i18n }}
  • +
  • {{ "privilegedControlsFeatureAccessRules" | i18n }}
  • +
  • {{ "privilegedControlsFeatureRotation" | i18n }}
  • +
  • {{ "privilegedControlsFeatureAuditLog" | i18n }}
  • +
  • {{ "privilegedControlsFeatureGovernanceDashboard" | i18n }}
  • +
+
+ +
+ {{ "pricePerMember" | i18n: (monthlyCostPerSeat() | currency: "$") }} / {{ "month" | i18n }} +
+ + + + {{ "addPrivilegedControls" | i18n }} + + + @if (enabled()) { +
+ + {{ "seats" | i18n }} + + +
+ + + {{ "limitSubscription" | i18n }} + {{ "privilegedControlsSeatLimitDesc" | i18n }} + + @if (limitSubscription()) { +
+ + {{ "seatLimit" | i18n }} + + + {{ "maxSeatCost" | i18n }}: + {{ maxAutoscaleSeats() || 0 }} × {{ seatPrice() | currency: "$" }} = + {{ maxSeatTotal() | currency: "$" }} / {{ interval() | i18n }} + + +
+ } + + + } +
+
diff --git a/apps/web/src/app/billing/organizations/privileged-controls-purchase.component.spec.ts b/apps/web/src/app/billing/organizations/privileged-controls-purchase.component.spec.ts new file mode 100644 index 00000000000..8e38cc09c34 --- /dev/null +++ b/apps/web/src/app/billing/organizations/privileged-controls-purchase.component.spec.ts @@ -0,0 +1,426 @@ +import { ComponentFixture, TestBed } from "@angular/core/testing"; +import { mock } from "jest-mock-extended"; + +import { BillingCustomerDiscount } from "@bitwarden/common/billing/models/response/organization-subscription.response"; +import { PlanResponse } from "@bitwarden/common/billing/models/response/plan.response"; +import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; +import { OrganizationId } from "@bitwarden/common/types/guid"; +import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; +import { ToastService } from "@bitwarden/components"; + +import { OrganizationBillingClient } from "../clients/organization-billing.client"; + +import { PrivilegedControlsPurchaseComponent } from "./privileged-controls-purchase.component"; + +describe("PrivilegedControlsPurchaseComponent", () => { + let fixture: ComponentFixture; + let component: PrivilegedControlsPurchaseComponent; + let billingClient: jest.Mocked; + let syncService: jest.Mocked; + let toastService: jest.Mocked; + + const organizationId = "org-id" as OrganizationId; + + const buildPlan = (overrides: { isAnnual?: boolean; seatPrice?: number } = {}): PlanResponse => + ({ + isAnnual: overrides.isAnnual ?? true, + PrivilegedControls: { seatPrice: overrides.seatPrice ?? 120 }, + }) as PlanResponse; + + const createComponent = (options?: { + plan?: PlanResponse; + customerDiscount?: BillingCustomerDiscount | null; + passwordManagerSeats?: number; + passwordManagerMaxAutoscaleSeats?: number | null; + }) => { + fixture = TestBed.createComponent(PrivilegedControlsPurchaseComponent); + component = fixture.componentInstance; + fixture.componentRef.setInput("plan", options?.plan ?? buildPlan()); + fixture.componentRef.setInput("organizationId", organizationId); + fixture.componentRef.setInput("customerDiscount", options?.customerDiscount ?? null); + fixture.componentRef.setInput("passwordManagerSeats", options?.passwordManagerSeats ?? 50); + fixture.componentRef.setInput( + "passwordManagerMaxAutoscaleSeats", + options?.passwordManagerMaxAutoscaleSeats ?? null, + ); + fixture.detectChanges(); + }; + + const form = () => component["formGroup"]; + + const enableAndFill = (seats: number, maxAutoscaleSeats: number | null) => { + component["enabledControl"].setValue(true); + form().controls.seats.setValue(seats); + form().controls.maxAutoscaleSeats.setValue(maxAutoscaleSeats); + }; + + beforeEach(async () => { + billingClient = mock(); + syncService = mock(); + toastService = mock(); + const i18nService = mock(); + i18nService.t.mockImplementation((key: string) => key); + + await TestBed.configureTestingModule({ + imports: [PrivilegedControlsPurchaseComponent], + providers: [ + { provide: OrganizationBillingClient, useValue: billingClient }, + { provide: SyncService, useValue: syncService }, + { provide: ToastService, useValue: toastService }, + { provide: I18nService, useValue: i18nService }, + ], + }).compileComponents(); + }); + + describe("price", () => { + it("shows the monthly price for an annual plan", () => { + createComponent(); + expect(component["monthlyCostPerSeat"]()).toBe(10); + }); + + it("shows the plan price for a monthly plan", () => { + createComponent({ plan: buildPlan({ isAnnual: false, seatPrice: 11 }) }); + expect(component["monthlyCostPerSeat"]()).toBe(11); + }); + + it("applies an active percentage discount", () => { + createComponent({ + customerDiscount: { active: true, percentOff: 20 } as BillingCustomerDiscount, + }); + expect(component["monthlyCostPerSeat"]()).toBe(8); + }); + + it("ignores an inactive discount", () => { + createComponent({ + customerDiscount: { active: false, percentOff: 20 } as BillingCustomerDiscount, + }); + expect(component["monthlyCostPerSeat"]()).toBe(10); + }); + }); + + describe("form", () => { + it("defaults seats to 1", () => { + createComponent(); + expect(form().controls.seats.value).toBe(1); + }); + + it("accepts 1 seat", () => { + createComponent(); + enableAndFill(1, null); + expect(form().controls.seats.valid).toBe(true); + }); + + it("rejects zero seats", () => { + createComponent(); + enableAndFill(0, null); + expect(form().controls.seats.hasError("min")).toBe(true); + }); + + it("accepts seats equal to the Password Manager seat count", () => { + createComponent({ passwordManagerSeats: 50 }); + enableAndFill(50, null); + expect(form().controls.seats.valid).toBe(true); + }); + + it("rejects seats above the Password Manager seat count", () => { + createComponent({ passwordManagerSeats: 50 }); + enableAndFill(51, null); + expect(form().controls.seats.getError("seatsAbovePasswordManagerSeats")).toEqual({ + message: "privilegedControlsSeatsAbovePasswordManagerSeats", + }); + }); + + it("rejects seats above 100,000", () => { + createComponent(); + enableAndFill(100001, null); + expect(form().controls.seats.hasError("max")).toBe(true); + }); + + it("rejects decimal seats", () => { + createComponent(); + enableAndFill(10.5, null); + expect(form().controls.seats.hasError("wholeNumber")).toBe(true); + }); + + it("requires seats", () => { + createComponent(); + enableAndFill(null, null); + expect(form().controls.seats.hasError("required")).toBe(true); + }); + + it("accepts a seat limit above seats", () => { + createComponent(); + enableAndFill(12, 13); + expect(form().controls.maxAutoscaleSeats.hasError("maxAutoscaleSeatsNotAboveSeats")).toBe( + false, + ); + }); + + it("rejects a seat limit equal to seats", () => { + createComponent(); + enableAndFill(12, 12); + expect(form().controls.maxAutoscaleSeats.getError("maxAutoscaleSeatsNotAboveSeats")).toEqual({ + message: "privilegedControlsSeatLimitNotAboveSeats", + }); + }); + + it("rejects a negative seat limit", () => { + createComponent(); + enableAndFill(12, -5); + expect(form().controls.maxAutoscaleSeats.hasError("maxAutoscaleSeatsNotAboveSeats")).toBe( + true, + ); + }); + + it("rejects a decimal seat limit", () => { + createComponent(); + enableAndFill(12, 20.5); + expect(form().controls.maxAutoscaleSeats.hasError("wholeNumber")).toBe(true); + }); + + it("caps the seat limit at the Password Manager seat limit when one is set", () => { + createComponent({ passwordManagerSeats: 50, passwordManagerMaxAutoscaleSeats: 30 }); + enableAndFill(12, 30); + expect(form().controls.maxAutoscaleSeats.valid).toBe(true); + + form().controls.maxAutoscaleSeats.setValue(31); + expect( + form().controls.maxAutoscaleSeats.getError("maxAutoscaleSeatsAbovePasswordManager"), + ).toEqual({ + message: "privilegedControlsSeatLimitAbovePasswordManagerSeatLimit", + }); + }); + + it("caps the seat limit at the Password Manager seat count when there is no Password Manager seat limit", () => { + createComponent({ passwordManagerSeats: 50, passwordManagerMaxAutoscaleSeats: null }); + enableAndFill(12, 50); + expect(form().controls.maxAutoscaleSeats.valid).toBe(true); + + form().controls.maxAutoscaleSeats.setValue(51); + expect( + form().controls.maxAutoscaleSeats.getError("maxAutoscaleSeatsAbovePasswordManager"), + ).toEqual({ + message: "privilegedControlsSeatLimitAbovePasswordManagerSeats", + }); + }); + + it("flags the seat limit when seats are raised to it", () => { + createComponent(); + enableAndFill(12, 13); + + form().controls.seats.setValue(13); + expect(form().controls.maxAutoscaleSeats.hasError("maxAutoscaleSeatsNotAboveSeats")).toBe( + true, + ); + }); + + it("clears the seat limit error when seats are lowered below it", () => { + createComponent(); + enableAndFill(12, 12); + + form().controls.seats.setValue(11); + expect(form().controls.maxAutoscaleSeats.valid).toBe(true); + }); + + it("keeps the seat limit's own errors when the seats comparison passes", () => { + createComponent({ passwordManagerSeats: 50 }); + enableAndFill(12, 51); + + form().controls.seats.setValue(10); + expect( + form().controls.maxAutoscaleSeats.hasError("maxAutoscaleSeatsAbovePasswordManager"), + ).toBe(true); + }); + + it("hides the seat fields until Privileged Controls is checked", () => { + createComponent(); + + expect( + fixture.nativeElement.querySelector("#privileged-controls-purchase_input_seats"), + ).toBeNull(); + + fixture.nativeElement.querySelector("#privileged-controls-purchase_input_enabled").click(); + fixture.detectChanges(); + + expect( + fixture.nativeElement.querySelector("#privileged-controls-purchase_input_seats"), + ).not.toBeNull(); + }); + + it("hides the seat limit field until the subscription limit is checked", () => { + createComponent(); + fixture.nativeElement.querySelector("#privileged-controls-purchase_input_enabled").click(); + fixture.detectChanges(); + + expect( + fixture.nativeElement.querySelector("#privileged-controls-purchase_input_seat-limit"), + ).toBeNull(); + + fixture.nativeElement + .querySelector("#privileged-controls-purchase_input_limit-subscription") + .click(); + fixture.detectChanges(); + + expect( + fixture.nativeElement.querySelector("#privileged-controls-purchase_input_seat-limit"), + ).not.toBeNull(); + }); + + it("shows the seat limit description under the subscription limit checkbox", () => { + createComponent(); + fixture.nativeElement.querySelector("#privileged-controls-purchase_input_enabled").click(); + fixture.detectChanges(); + + const limitSubscriptionInput: HTMLElement = fixture.nativeElement.querySelector( + "#privileged-controls-purchase_input_limit-subscription", + ); + expect(limitSubscriptionInput.closest("bit-form-control")?.textContent).toContain( + "privilegedControlsSeatLimitDesc", + ); + }); + + it("clears the seat limit when the subscription limit is unchecked", () => { + createComponent(); + component["limitSubscriptionControl"].setValue(true); + enableAndFill(12, 20); + + component["limitSubscriptionControl"].setValue(false); + + expect(form().controls.maxAutoscaleSeats.value).toBeNull(); + }); + }); + + describe("max seat cost", () => { + it("multiplies the seat limit by the plan seat price", () => { + createComponent(); + enableAndFill(12, 20); + expect(component["maxSeatTotal"]()).toBe(2400); + }); + + it("applies an active percentage discount", () => { + createComponent({ + customerDiscount: { active: true, percentOff: 20 } as BillingCustomerDiscount, + }); + enableAndFill(12, 20); + expect(component["maxSeatTotal"]()).toBe(1920); + }); + + it("is zero when the seat limit is empty", () => { + createComponent(); + enableAndFill(12, null); + expect(component["maxSeatTotal"]()).toBe(0); + }); + + it("uses the plan billing interval", () => { + createComponent({ plan: buildPlan({ isAnnual: false, seatPrice: 11 }) }); + expect(component["interval"]()).toBe("month"); + }); + }); + + describe("submit", () => { + it("sends the seats and seat limit on submit", async () => { + createComponent(); + enableAndFill(15, 20); + + await component["submit"](); + + expect(billingClient.purchasePrivilegedControls).toHaveBeenCalledWith(organizationId, { + seats: 15, + maxAutoscaleSeats: 20, + }); + }); + + it("sends a null seat limit when the subscription limit is unchecked", async () => { + createComponent(); + component["limitSubscriptionControl"].setValue(true); + enableAndFill(15, 20); + component["limitSubscriptionControl"].setValue(false); + + await component["submit"](); + + expect(billingClient.purchasePrivilegedControls).toHaveBeenCalledWith(organizationId, { + seats: 15, + maxAutoscaleSeats: null, + }); + }); + + it("sends a null seat limit when the field is cleared", async () => { + createComponent(); + enableAndFill(15, 20); + form().controls.maxAutoscaleSeats.setValue(null); + + await component["submit"](); + + expect(billingClient.purchasePrivilegedControls).toHaveBeenCalledWith(organizationId, { + seats: 15, + maxAutoscaleSeats: null, + }); + }); + + it("does not purchase when seats are above the Password Manager seat count", async () => { + createComponent({ passwordManagerSeats: 50 }); + enableAndFill(51, null); + + await component["submit"](); + + expect(billingClient.purchasePrivilegedControls).not.toHaveBeenCalled(); + }); + + it("does not purchase when the seat limit is not above seats", async () => { + createComponent(); + enableAndFill(12, 12); + + await component["submit"](); + + expect(billingClient.purchasePrivilegedControls).not.toHaveBeenCalled(); + }); + + it("does not purchase when seats are a decimal", async () => { + createComponent(); + enableAndFill(10.5, null); + + await component["submit"](); + + expect(billingClient.purchasePrivilegedControls).not.toHaveBeenCalled(); + }); + + it("does not purchase when seats are empty", async () => { + createComponent(); + enableAndFill(null, null); + + await component["submit"](); + + expect(billingClient.purchasePrivilegedControls).not.toHaveBeenCalled(); + }); + + it("shows a toast, syncs, and emits after a successful purchase", async () => { + createComponent(); + const emitted = jest.fn(); + component.purchased.subscribe(emitted); + enableAndFill(15, null); + + await component["submit"](); + + expect(toastService.showToast).toHaveBeenCalledWith( + expect.objectContaining({ variant: "success", message: "privilegedControlsPurchased" }), + ); + expect(syncService.fullSync).toHaveBeenCalledWith(true); + expect(emitted).toHaveBeenCalledTimes(1); + }); + + it("does not toast, sync, or emit when the purchase fails", async () => { + createComponent(); + const emitted = jest.fn(); + component.purchased.subscribe(emitted); + const error = new Error("Your card was declined."); + billingClient.purchasePrivilegedControls.mockRejectedValue(error); + enableAndFill(15, null); + + await expect(component["submit"]()).rejects.toBe(error); + + expect(toastService.showToast).not.toHaveBeenCalled(); + expect(syncService.fullSync).not.toHaveBeenCalled(); + expect(emitted).not.toHaveBeenCalled(); + }); + }); +}); diff --git a/apps/web/src/app/billing/organizations/privileged-controls-purchase.component.ts b/apps/web/src/app/billing/organizations/privileged-controls-purchase.component.ts new file mode 100644 index 00000000000..9a7821ea870 --- /dev/null +++ b/apps/web/src/app/billing/organizations/privileged-controls-purchase.component.ts @@ -0,0 +1,208 @@ +import { + ChangeDetectionStrategy, + Component, + computed, + inject, + input, + OnInit, + output, +} from "@angular/core"; +import { takeUntilDestroyed, toSignal } from "@angular/core/rxjs-interop"; +import { + AbstractControl, + FormControl, + FormGroup, + ValidationErrors, + Validators, +} from "@angular/forms"; + +import { BillingCustomerDiscount } from "@bitwarden/common/billing/models/response/organization-subscription.response"; +import { PlanResponse } from "@bitwarden/common/billing/models/response/plan.response"; +import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; +import { OrganizationId } from "@bitwarden/common/types/guid"; +import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; +import { AccordionComponent, ToastService } from "@bitwarden/components"; + +import { SharedModule } from "../../shared"; +import { OrganizationBillingClient } from "../clients/organization-billing.client"; + +const MAX_PURCHASABLE_QUANTITY = 100000; + +@Component({ + selector: "billing-privileged-controls-purchase", + templateUrl: "privileged-controls-purchase.component.html", + changeDetection: ChangeDetectionStrategy.OnPush, + imports: [SharedModule, AccordionComponent], +}) +export class PrivilegedControlsPurchaseComponent implements OnInit { + private readonly organizationBillingClient = inject(OrganizationBillingClient); + private readonly syncService = inject(SyncService); + private readonly toastService = inject(ToastService); + private readonly i18nService = inject(I18nService); + + readonly plan = input.required(); + readonly organizationId = input.required(); + readonly customerDiscount = input(null); + readonly passwordManagerSeats = input.required(); + readonly passwordManagerMaxAutoscaleSeats = input(null); + + readonly purchased = output(); + + protected readonly enabledControl = new FormControl(false, { nonNullable: true }); + + protected readonly enabled = toSignal(this.enabledControl.valueChanges, { + initialValue: this.enabledControl.value, + }); + + protected readonly limitSubscriptionControl = new FormControl(false, { nonNullable: true }); + + protected readonly limitSubscription = toSignal(this.limitSubscriptionControl.valueChanges, { + initialValue: this.limitSubscriptionControl.value, + }); + + protected readonly maxAutoscaleSeatsCap = computed( + () => this.passwordManagerMaxAutoscaleSeats() ?? this.passwordManagerSeats(), + ); + + protected readonly seatPrice = computed(() => + this.discountPrice(this.plan().PrivilegedControls.seatPrice), + ); + + protected readonly monthlyCostPerSeat = computed(() => + this.plan().isAnnual ? this.seatPrice() / 12 : this.seatPrice(), + ); + + protected readonly interval = computed(() => (this.plan().isAnnual ? "year" : "month")); + + private readonly seatsControl = new FormControl(null, [ + Validators.required, + Validators.min(1), + Validators.max(MAX_PURCHASABLE_QUANTITY), + (control: AbstractControl) => this.validateWholeNumber(control), + (control: AbstractControl) => this.validateSeatsWithinPasswordManagerSeats(control), + ]); + + private readonly maxAutoscaleSeatsControl = new FormControl(null, [ + Validators.max(MAX_PURCHASABLE_QUANTITY), + (control: AbstractControl) => this.validateWholeNumber(control), + (control: AbstractControl) => this.validateMaxAutoscaleSeatsAboveSeats(control), + (control: AbstractControl) => this.validateMaxAutoscaleSeatsWithinCap(control), + ]); + + protected readonly formGroup = new FormGroup({ + seats: this.seatsControl, + maxAutoscaleSeats: this.maxAutoscaleSeatsControl, + }); + + protected readonly seats = toSignal(this.seatsControl.valueChanges, { + initialValue: this.seatsControl.value, + }); + + protected readonly maxAutoscaleSeats = toSignal(this.maxAutoscaleSeatsControl.valueChanges, { + initialValue: this.maxAutoscaleSeatsControl.value, + }); + + protected readonly maxSeatTotal = computed( + () => (this.maxAutoscaleSeats() ?? 0) * this.seatPrice(), + ); + + constructor() { + this.seatsControl.valueChanges + .pipe(takeUntilDestroyed()) + .subscribe(() => this.maxAutoscaleSeatsControl.updateValueAndValidity()); + + this.limitSubscriptionControl.valueChanges + .pipe(takeUntilDestroyed()) + .subscribe((limitSubscription) => { + if (!limitSubscription) { + this.maxAutoscaleSeatsControl.setValue(null); + } + }); + } + + ngOnInit() { + // Set after inputs are bound, since the seats validators read the required passwordManagerSeats input. + this.seatsControl.setValue(1); + } + + protected readonly submit = async () => { + this.formGroup.markAllAsTouched(); + const { seats, maxAutoscaleSeats } = this.formGroup.getRawValue(); + if (this.formGroup.invalid || seats == null) { + return; + } + + await this.organizationBillingClient.purchasePrivilegedControls(this.organizationId(), { + seats, + maxAutoscaleSeats: maxAutoscaleSeats ?? null, + }); + + this.toastService.showToast({ + variant: "success", + message: this.i18nService.t("privilegedControlsPurchased"), + }); + + await this.syncService.fullSync(true); + + this.purchased.emit(); + }; + + private discountPrice(price: number): number { + const discount = this.customerDiscount(); + return discount?.active ? price - price * ((discount.percentOff ?? 0) / 100) : price; + } + + private validateWholeNumber(control: AbstractControl): ValidationErrors | null { + if (control.value == null || Number.isInteger(control.value)) { + return null; + } + return { wholeNumber: { message: this.i18nService.t("integerInputError") } }; + } + + private validateSeatsWithinPasswordManagerSeats( + control: AbstractControl, + ): ValidationErrors | null { + if (control.value == null) { + return null; + } + const passwordManagerSeats = this.passwordManagerSeats(); + return control.value > passwordManagerSeats + ? { + seatsAbovePasswordManagerSeats: { + message: this.i18nService.t( + "privilegedControlsSeatsAbovePasswordManagerSeats", + passwordManagerSeats, + ), + }, + } + : null; + } + + private validateMaxAutoscaleSeatsAboveSeats(control: AbstractControl): ValidationErrors | null { + if (control.value == null || control.value > (this.seatsControl.value ?? 0)) { + return null; + } + return { + maxAutoscaleSeatsNotAboveSeats: { + message: this.i18nService.t("privilegedControlsSeatLimitNotAboveSeats"), + }, + }; + } + + private validateMaxAutoscaleSeatsWithinCap(control: AbstractControl): ValidationErrors | null { + if (control.value == null) { + return null; + } + const cap = this.maxAutoscaleSeatsCap(); + if (control.value <= cap) { + return null; + } + const messageKey = + this.passwordManagerMaxAutoscaleSeats() == null + ? "privilegedControlsSeatLimitAbovePasswordManagerSeats" + : "privilegedControlsSeatLimitAbovePasswordManagerSeatLimit"; + return { + maxAutoscaleSeatsAbovePasswordManager: { message: this.i18nService.t(messageKey, cap) }, + }; + } +} diff --git a/apps/web/src/app/billing/shared/billing-shared.module.ts b/apps/web/src/app/billing/shared/billing-shared.module.ts index d4f83ee7551..06f21e2017c 100644 --- a/apps/web/src/app/billing/shared/billing-shared.module.ts +++ b/apps/web/src/app/billing/shared/billing-shared.module.ts @@ -1,6 +1,11 @@ import { NgModule } from "@angular/core"; -import { BannerModule, FileUploadComponent, SpinnerComponent } from "@bitwarden/components"; +import { + AccordionComponent, + BannerModule, + FileUploadComponent, + SpinnerComponent, +} from "@bitwarden/components"; import { CartSummaryComponent, DiscountBadgeComponent } from "@bitwarden/pricing"; import { Vfo1I18nPipe } from "@bitwarden/vault"; import { @@ -24,6 +29,7 @@ import { UpdateLicenseComponent } from "./update-license.component"; @NgModule({ imports: [ + AccordionComponent, BannerModule, CartSummaryComponent, DiscountBadgeComponent, diff --git a/apps/web/src/app/billing/shared/sm-subscribe.component.html b/apps/web/src/app/billing/shared/sm-subscribe.component.html index 70990d2ee4c..41f3fecc57b 100644 --- a/apps/web/src/app/billing/shared/sm-subscribe.component.html +++ b/apps/web/src/app/billing/shared/sm-subscribe.component.html @@ -1,17 +1,15 @@

{{ "moreFromBitwarden" | i18n }}

-
-
- -
-
-
-

{{ "secretsManagerForPlan" | i18n: planName }}

-
- {{ "secretsManagerForPlanDesc" | i18n }} -
    +
    + {{ "secretsManagerPurchaseDesc" | i18n }} +

    {{ "whatsIncluded" | i18n }}

    +
    • {{ "limitedUsers" | i18n: maxUsers }}
    • {{ "unlimitedSecrets" | i18n }}
    • @@ -20,7 +18,7 @@
    • {{ "unlimitedProjects" | i18n }}
    • -
    • {{ "machineAccountsIncluded" | i18n: serviceAccountsIncluded }}
    • +
    • {{ "includedMachineAccountsV2" | i18n: serviceAccountsIncluded }}
    • {{ "additionalMachineAccountCost" | i18n: (monthlyCostPerServiceAccount | currency: "$") @@ -29,9 +27,9 @@
    -
    +
    - {{ "costPerUser" | i18n: (monthlyCostPerUser | currency: "$") }} /{{ "month" | i18n }} + {{ "pricePerMember" | i18n: (monthlyCostPerUser | currency: "$") }} / {{ "month" | i18n }} {{ "freeForever" | i18n }} @@ -40,7 +38,7 @@ - {{ "subscribeToSecretsManager" | i18n }} + {{ "addSecretsManager" | i18n }} {{ "addSecretsManagerUpgradeDesc" | i18n }} @@ -69,5 +67,5 @@ {{ "save" | i18n }} -
    +
    diff --git a/apps/web/src/app/billing/shared/sm-subscribe.component.ts b/apps/web/src/app/billing/shared/sm-subscribe.component.ts index c3c2f27d327..668aa922617 100644 --- a/apps/web/src/app/billing/shared/sm-subscribe.component.ts +++ b/apps/web/src/app/billing/shared/sm-subscribe.component.ts @@ -1,17 +1,13 @@ // FIXME: Update this file to be type safe and remove this and next line // @ts-strict-ignore import { Component, Input, OnDestroy, OnInit, inject } from "@angular/core"; -import { toSignal } from "@angular/core/rxjs-interop"; import { FormBuilder, FormGroup, Validators } from "@angular/forms"; import { Subject, startWith, takeUntil } from "rxjs"; import { ControlsOf } from "@bitwarden/angular/types/controls-of"; -import { SecretsManagerAlt } from "@bitwarden/assets/svg"; import { ProductTierType } from "@bitwarden/common/billing/enums"; import { BillingCustomerDiscount } from "@bitwarden/common/billing/models/response/organization-subscription.response"; import { PlanResponse } from "@bitwarden/common/billing/models/response/plan.response"; -import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; -import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; export interface SecretsManagerSubscription { @@ -41,7 +37,6 @@ export const secretsManagerSubscribeFormFactory = ( }) export class SecretsManagerSubscribeComponent implements OnInit, OnDestroy { private i18nService = inject(I18nService); - private configService = inject(ConfigService); // FIXME(https://bitwarden.atlassian.net/browse/CL-903): Migrate to Signals // eslint-disable-next-line @angular-eslint/prefer-signals @@ -59,16 +54,10 @@ export class SecretsManagerSubscribeComponent implements OnInit, OnDestroy { // eslint-disable-next-line @angular-eslint/prefer-signals @Input() customerDiscount: BillingCustomerDiscount; - logo = SecretsManagerAlt; productTypes = ProductTierType; private destroy$ = new Subject(); - protected readonly vfo1Enabled = toSignal( - this.configService.getFeatureFlag$(FeatureFlag.VFO1Foundation), - { initialValue: false }, - ); - ngOnInit() { this.formGroup.controls.enabled.valueChanges .pipe(startWith(this.formGroup.value.enabled), takeUntil(this.destroy$)) @@ -101,20 +90,6 @@ export class SecretsManagerSubscribeComponent implements OnInit, OnDestroy { return this.selectedPlan.productTier; } - get planName() { - switch (this.product) { - case ProductTierType.Free: - return this.vfo1Enabled() - ? this.i18nService.t("freePlanWithSharedVault") - : this.i18nService.t("free2PersonOrganization"); - case ProductTierType.Teams: - case ProductTierType.TeamsStarter: - return this.i18nService.t("planNameTeams"); - case ProductTierType.Enterprise: - return this.i18nService.t("planNameEnterprise"); - } - } - get serviceAccountsIncluded() { return this.selectedPlan.SecretsManager.baseServiceAccount; } diff --git a/apps/web/src/locales/en/messages.json b/apps/web/src/locales/en/messages.json index a5fa508d013..324965b6604 100644 --- a/apps/web/src/locales/en/messages.json +++ b/apps/web/src/locales/en/messages.json @@ -13029,6 +13029,86 @@ "message": "Privileged Controls", "description": "'Privileged Controls' is a product name and should not be translated." }, + "privilegedControlsPurchaseDesc": { + "message": "Quickly and easily protect your privileged and business-critical accounts with this add-on for Bitwarden Password Manager.", + "description": "'Bitwarden Password Manager' is a product name and should not be translated." + }, + "privilegedControlsFeatureCredentialLeasing": { + "message": "Credential leasing" + }, + "privilegedControlsFeatureAccessRules": { + "message": "Advanced access rules" + }, + "privilegedControlsFeatureRotation": { + "message": "Automated password rotation" + }, + "privilegedControlsFeatureAuditLog": { + "message": "Compliance-ready audit logs" + }, + "privilegedControlsFeatureGovernanceDashboard": { + "message": "Governance dashboard" + }, + "addPrivilegedControls": { + "message": "Add Privileged Controls", + "description": "'Privileged Controls' is a product name and should not be translated." + }, + "seatLimit": { + "message": "Seat limit", + "description": "Upper limit of seats to allow through autoscaling" + }, + "whatsIncluded": { + "message": "What's included" + }, + "pricePerMember": { + "message": "$COST$ per member", + "placeholders": { + "cost": { + "content": "$1", + "example": "$10.00" + } + } + }, + "privilegedControlsSeatsAbovePasswordManagerSeats": { + "message": "Seats can't be more than your Password Manager seats ($COUNT$).", + "description": "'Password Manager' is a product name and should not be translated.", + "placeholders": { + "count": { + "content": "$1", + "example": "50" + } + } + }, + "privilegedControlsSeatLimitAbovePasswordManagerSeats": { + "message": "Seat limit can't be more than your Password Manager seats ($COUNT$).", + "description": "'Password Manager' is a product name and should not be translated.", + "placeholders": { + "count": { + "content": "$1", + "example": "50" + } + } + }, + "privilegedControlsSeatLimitAbovePasswordManagerSeatLimit": { + "message": "Seat limit can't be more than your Password Manager seat limit ($COUNT$).", + "description": "'Password Manager' is a product name and should not be translated.", + "placeholders": { + "count": { + "content": "$1", + "example": "75" + } + } + }, + "privilegedControlsSeatLimitDesc": { + "message": "Set a seat limit for your Privileged Controls subscription. Once this limit is reached, you won't be able to give more members access to Privileged Controls.", + "description": "'Privileged Controls' is a product name and should not be translated." + }, + "privilegedControlsSeatLimitNotAboveSeats": { + "message": "Seat limit must be greater than the number of seats." + }, + "privilegedControlsPurchased": { + "message": "Subscription updated. You now have Privileged Controls.", + "description": "'Privileged Controls' is a product name and should not be translated." + }, "privilegedControlsAccessDescription": { "message": "Activate user access to Privileged Controls.", "description": "'Privileged Controls' is a product name and should not be translated." @@ -13780,23 +13860,8 @@ "inviteUsers": { "message": "Invite Users" }, - "secretsManagerForPlan": { - "message": "Secrets Manager for $PLAN$", - "placeholders": { - "plan": { - "content": "$1", - "example": "Teams" - } - } - }, - "secretsManagerForPlanDesc": { - "message": "For engineering and DevOps teams to manage secrets throughout the software development lifecycle." - }, - "free2PersonOrganization": { - "message": "Free 2-person Organizations" - }, - "freePlanWithSharedVault": { - "message": "Free plan with shared vault" + "secretsManagerPurchaseDesc": { + "message": "Enable your engineering and DevOps teams to centrally store, manage, and deploy secrets throughout the software development lifecycle." }, "unlimitedSecrets": { "message": "Unlimited secrets" @@ -13831,8 +13896,9 @@ } } }, - "subscribeToSecretsManager": { - "message": "Subscribe to Secrets Manager" + "addSecretsManager": { + "message": "Add Secrets Manager", + "description": "'Secrets Manager' is a product name and should not be translated." }, "addSecretsManagerUpgradeDesc": { "message": "Add Secrets Manager to your upgraded plan to maintain access to any secrets created with your previous plan." @@ -14728,15 +14794,6 @@ "smAccessRemovalWarningMaMessage": { "message": "This action will remove your access to the machine account." }, - "machineAccountsIncluded": { - "message": "$COUNT$ machine accounts included", - "placeholders": { - "count": { - "content": "$1", - "example": "3" - } - } - }, "additionalMachineAccountCost": { "message": "$COST$ per month for additional machine accounts", "placeholders": { diff --git a/libs/assets/src/svg/svgs/index.ts b/libs/assets/src/svg/svgs/index.ts index 37a48af47a6..5413c213fca 100644 --- a/libs/assets/src/svg/svgs/index.ts +++ b/libs/assets/src/svg/svgs/index.ts @@ -94,7 +94,6 @@ export * from "./report-breach.icon"; export * from "./report-exposed-passwords.icon"; export * from "./report-unsecured-websites.icon"; export * from "./restricted-view"; -export * from "./secrets-manager-alt"; export { default as SecretsManagerLogo } from "./secrets-manager"; export * from "./search-folder"; export * from "./security"; diff --git a/libs/assets/src/svg/svgs/secrets-manager-alt.ts b/libs/assets/src/svg/svgs/secrets-manager-alt.ts deleted file mode 100644 index 70fa7d6386c..00000000000 --- a/libs/assets/src/svg/svgs/secrets-manager-alt.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { svg } from "../svg"; - -export const SecretsManagerAlt = svg` - - - - - -`; diff --git a/libs/common/src/billing/models/response/plan.response.spec.ts b/libs/common/src/billing/models/response/plan.response.spec.ts index 670b6e7bd54..d51317f7736 100644 --- a/libs/common/src/billing/models/response/plan.response.spec.ts +++ b/libs/common/src/billing/models/response/plan.response.spec.ts @@ -3,11 +3,19 @@ import { PlanResponse, PrivilegedControlsPlanFeaturesResponse } from "./plan.res describe("PlanResponse", () => { it("parses PrivilegedControls when present", () => { const response = new PlanResponse({ - PrivilegedControls: { SeatPrice: 5 }, + PrivilegedControls: { + StripeSeatPlanId: "privileged-controls-enterprise-seat-annually", + SeatPrice: 5, + BaseSeats: 0, + }, }); expect(response.PrivilegedControls).toBeInstanceOf(PrivilegedControlsPlanFeaturesResponse); expect(response.PrivilegedControls!.seatPrice).toBe(5); + expect(response.PrivilegedControls!.baseSeats).toBe(0); + expect(response.PrivilegedControls!.stripeSeatPlanId).toBe( + "privileged-controls-enterprise-seat-annually", + ); }); it("leaves PrivilegedControls null when absent", () => {