From d20052bf3e25cc0dc3dad78c67afd8b755d5a65e Mon Sep 17 00:00:00 2001 From: Miguel Serrano Date: Tue, 4 Aug 2026 12:44:36 +0200 Subject: [PATCH] [web] Read subscription.features on Group Management rendering (#36168) * [web] Read subscription.features on Group Management rendering Fixes 'ai-toggling' not properly read on Group Management rendering, causing the Feature Controls option not being displayed in certain scenarios. GitOrigin-RevId: 4465fea15279d650d9d231e85072f1d85f2358be --- .../Subscription/SubscriptionController.mjs | 1 + .../dashboard/managed-group-subscriptions.tsx | 5 +- .../managed-group-subscriptions.test.tsx | 90 +++++++++++++++++++ .../subscription/dashboard/subscription.ts | 1 + 4 files changed, 96 insertions(+), 1 deletion(-) diff --git a/services/web/app/src/Features/Subscription/SubscriptionController.mjs b/services/web/app/src/Features/Subscription/SubscriptionController.mjs index 8c0f95b420..a4cd0d6127 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionController.mjs +++ b/services/web/app/src/Features/Subscription/SubscriptionController.mjs @@ -171,6 +171,7 @@ async function userSubscriptionPage(req, res) { res, 'group-discount-10' ) + await SplitTestHandler.promises.getAssignment(req, res, 'ai-toggling') const showGroupDiscount = groupPricingDiscount.variant === 'enabled' diff --git a/services/web/frontend/js/features/subscription/components/dashboard/managed-group-subscriptions.tsx b/services/web/frontend/js/features/subscription/components/dashboard/managed-group-subscriptions.tsx index 752785e068..aefa2dda13 100644 --- a/services/web/frontend/js/features/subscription/components/dashboard/managed-group-subscriptions.tsx +++ b/services/web/frontend/js/features/subscription/components/dashboard/managed-group-subscriptions.tsx @@ -100,6 +100,7 @@ export default function ManagedGroupSubscriptions() { const isSharingPermissionsEnabled = useFeatureFlag( 'sharing-updates-sharing-permissions' ) + const aiTogglingSplitTestEnabled = useFeatureFlag('ai-toggling') if (!managedGroupSubscriptions) { return null @@ -116,9 +117,11 @@ export default function ManagedGroupSubscriptions() { // Feature controls are currently rendered only for managed groups, where the admin can // toggle AI Feature on/off. For non-managed groups, the section only displays notifications - // for features that have been disabled by Overleaf Support. + // for features that have been disabled by Overleaf Support. When the `ai-toggling` split + // test is enabled, it's always displayed for non-managed groups that have the feature on. // This flag will be deleted once AI Features toggling is available to all groups. const shouldDisplayFeatureControls = + (subscription.features?.aiToggling && aiTogglingSplitTestEnabled) || subscription.managedUsersEnabled || subscription.groupPolicy?.userCannotUseAIFeatures || subscription.groupPolicy?.userCannotUseChat || diff --git a/services/web/test/frontend/features/subscription/components/dashboard/managed-group-subscriptions.test.tsx b/services/web/test/frontend/features/subscription/components/dashboard/managed-group-subscriptions.test.tsx index 96521b1640..e30accd1f4 100644 --- a/services/web/test/frontend/features/subscription/components/dashboard/managed-group-subscriptions.test.tsx +++ b/services/web/test/frontend/features/subscription/components/dashboard/managed-group-subscriptions.test.tsx @@ -441,5 +441,95 @@ describe('', function () { expect(screen.queryByText('Feature controls')).to.be.null }) }) + + describe('AI toggling', function () { + it('renders the feature controls row when the "ai-toggling" split test is enabled and the group has the aiToggling feature', async function () { + renderWithSubscriptionDashContext(, { + metaTags: [ + { + name: 'ol-managedGroupSubscriptions', + value: makeSubscription({ + features: { + groupSSO: false, + managedUsers: false, + aiToggling: true, + }, + }), + }, + { name: 'ol-usersEmail', value: adminEmail }, + { + name: 'ol-splitTestVariants', + value: { 'ai-toggling': 'enabled' }, + }, + ], + }) + await screen.findByText('Feature controls') + }) + + it('does not render the feature controls row when the "ai-toggling" split test is enabled but the group lacks the aiToggling feature', function () { + renderWithSubscriptionDashContext(, { + metaTags: [ + { + name: 'ol-managedGroupSubscriptions', + value: makeSubscription({ + features: { + groupSSO: false, + managedUsers: false, + aiToggling: false, + }, + }), + }, + { name: 'ol-usersEmail', value: adminEmail }, + { + name: 'ol-splitTestVariants', + value: { 'ai-toggling': 'enabled' }, + }, + ], + }) + expect(screen.queryByText('Feature controls')).to.be.null + }) + + it('does not render the feature controls row when the group has the aiToggling feature but the "ai-toggling" split test is disabled', function () { + renderWithSubscriptionDashContext(, { + metaTags: [ + { + name: 'ol-managedGroupSubscriptions', + value: makeSubscription({ + features: { + groupSSO: false, + managedUsers: false, + aiToggling: true, + }, + }), + }, + { name: 'ol-usersEmail', value: adminEmail }, + ], + }) + expect(screen.queryByText('Feature controls')).to.be.null + }) + + it('does not render the feature controls row when the user is not the group admin', function () { + renderWithSubscriptionDashContext(, { + metaTags: [ + { + name: 'ol-managedGroupSubscriptions', + value: makeSubscription({ + features: { + groupSSO: false, + managedUsers: false, + aiToggling: true, + }, + }), + }, + { name: 'ol-usersEmail', value: 'other@example.com' }, + { + name: 'ol-splitTestVariants', + value: { 'ai-toggling': 'enabled' }, + }, + ], + }) + expect(screen.queryByText('Feature controls')).to.be.null + }) + }) }) }) diff --git a/services/web/types/subscription/dashboard/subscription.ts b/services/web/types/subscription/dashboard/subscription.ts index fdeb0f67aa..46d007afa1 100644 --- a/services/web/types/subscription/dashboard/subscription.ts +++ b/services/web/types/subscription/dashboard/subscription.ts @@ -102,6 +102,7 @@ export type ManagedGroupSubscription = { features: { groupSSO: boolean | null managedUsers: boolean | null + aiToggling?: boolean | null } managedUsersEnabled: boolean groupPolicy?: GroupPolicy