Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow auto applied with universal link via toggle #1204

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading