Skip to content

Commit

Permalink
feat: allow auto applied with universal link via toggle (#1204)
Browse files Browse the repository at this point in the history
  • Loading branch information
brobro10000 authored Oct 9, 2024
1 parent bcfbe24 commit 5a1e7a6
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/app/data/services/subsidies/subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,14 @@ export async function getAutoAppliedSubscriptionLicense({

const hasSubscriptionForAutoAppliedLicenses = !!customerAgreement.subscriptionForAutoAppliedLicenses;
const hasIdentityProvider = enterpriseCustomer.identityProvider;
const hasAutoAppliedWithUniversalLink = !!customerAgreement.enableAutoAppliedSubscriptionsWithUniversalLink;
const hasIdpOrAutoAppliedWithUniversalLink = hasIdentityProvider || hasAutoAppliedWithUniversalLink;

// If customer agreement has no configured subscription plan for auto-applied
// licenses, or the enterprise customer does not have an identity provider,
// licenses, or the enterprise customer does not have either a identity provider or
// the field `enableAutoAppliedSubscriptionsWithUniversalLink` enabled
// return early.
if (!hasSubscriptionForAutoAppliedLicenses || !hasIdentityProvider) {
if (!(hasSubscriptionForAutoAppliedLicenses && hasIdpOrAutoAppliedWithUniversalLink)) {
return null;
}

Expand Down
42 changes: 42 additions & 0 deletions src/components/app/data/services/subsidies/subscriptions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,36 +377,77 @@ describe('activateOrAutoApplySubscriptionLicense', () => {
{
identityProvider: null,
subscriptionForAutoAppliedLicenses: null,
enableAutoAppliedSubscriptionsWithUniversalLink: false,
isLinkedToEnterpriseCustomer: false,
shouldAutoApply: false,
},
{
identityProvider: null,
subscriptionForAutoAppliedLicenses: mockSubscriptionPlanUUID,
enableAutoAppliedSubscriptionsWithUniversalLink: false,
isLinkedToEnterpriseCustomer: false,
shouldAutoApply: false,
},
{
identityProvider: 'identity-provider',
subscriptionForAutoAppliedLicenses: null,
enableAutoAppliedSubscriptionsWithUniversalLink: false,
isLinkedToEnterpriseCustomer: false,
shouldAutoApply: false,
},
{
identityProvider: 'identity-provider',
subscriptionForAutoAppliedLicenses: mockSubscriptionPlanUUID,
enableAutoAppliedSubscriptionsWithUniversalLink: false,
isLinkedToEnterpriseCustomer: false,
shouldAutoApply: false,
},
{
identityProvider: 'identity-provider',
subscriptionForAutoAppliedLicenses: mockSubscriptionPlanUUID,
enableAutoAppliedSubscriptionsWithUniversalLink: false,
isLinkedToEnterpriseCustomer: true,
shouldAutoApply: true,
},
{
identityProvider: null,
subscriptionForAutoAppliedLicenses: null,
enableAutoAppliedSubscriptionsWithUniversalLink: true,
isLinkedToEnterpriseCustomer: false,
shouldAutoApply: false,
},
{
identityProvider: null,
subscriptionForAutoAppliedLicenses: mockSubscriptionPlanUUID,
enableAutoAppliedSubscriptionsWithUniversalLink: true,
isLinkedToEnterpriseCustomer: false,
shouldAutoApply: false,
},
{
identityProvider: 'identity-provider',
subscriptionForAutoAppliedLicenses: null,
enableAutoAppliedSubscriptionsWithUniversalLink: true,
isLinkedToEnterpriseCustomer: false,
shouldAutoApply: false,
},
{
identityProvider: 'identity-provider',
subscriptionForAutoAppliedLicenses: mockSubscriptionPlanUUID,
enableAutoAppliedSubscriptionsWithUniversalLink: true,
isLinkedToEnterpriseCustomer: false,
shouldAutoApply: false,
},
{
identityProvider: 'identity-provider',
subscriptionForAutoAppliedLicenses: mockSubscriptionPlanUUID,
enableAutoAppliedSubscriptionsWithUniversalLink: true,
isLinkedToEnterpriseCustomer: true,
shouldAutoApply: true,
},
])('auto-applies subscription license (%s)', async ({
identityProvider,
subscriptionForAutoAppliedLicenses,
enableAutoAppliedSubscriptionsWithUniversalLink,
isLinkedToEnterpriseCustomer,
shouldAutoApply,
}) => {
Expand All @@ -418,6 +459,7 @@ describe('activateOrAutoApplySubscriptionLicense', () => {
const mockCustomerAgreementWithAutoApplied = {
...mockCustomerAgreement,
subscriptionForAutoAppliedLicenses,
enableAutoAppliedSubscriptionsWithUniversalLink,
};
const mockSubscriptionsData = {
customerAgreement: mockCustomerAgreementWithAutoApplied,
Expand Down

0 comments on commit 5a1e7a6

Please sign in to comment.