From 39d27a135bb605f149da870affeba8d60c203a09 Mon Sep 17 00:00:00 2001 From: Jimmy Domagala-Tang Date: Wed, 20 Dec 2023 12:22:54 -0500 Subject: [PATCH] Merge pull request #16325 from overleaf/jdt-writefull-split-test-overrides users with writefull already enabled dont care about split tests GitOrigin-RevId: aa986cc42fb9aecf8004b55e5e233c319040748f --- .../notifications/user-notifications.tsx | 25 +++++++++---------- .../writefull-premium-promo-banner.tsx | 2 +- .../settings/components/linking-section.tsx | 5 +++- .../components/notifications.test.tsx | 5 +++- .../components/project-list-root.test.tsx | 2 ++ .../project-tools-rename.test.tsx | 1 + 6 files changed, 24 insertions(+), 16 deletions(-) diff --git a/services/web/frontend/js/features/project-list/components/notifications/user-notifications.tsx b/services/web/frontend/js/features/project-list/components/notifications/user-notifications.tsx index 68c60f274d..36637bee1b 100644 --- a/services/web/frontend/js/features/project-list/components/notifications/user-notifications.tsx +++ b/services/web/frontend/js/features/project-list/components/notifications/user-notifications.tsx @@ -49,6 +49,7 @@ function UserNotifications() { const writefullIntegrationSplitTestEnabled = isSplitTestEnabled( 'writefull-integration' ) + const user = getMeta('ol-user') // Temporary workaround to prevent also showing groups/enterprise banner const [showWritefull, setShowWritefull] = useState(() => { @@ -59,23 +60,21 @@ function UserNotifications() { return false } - let show = false - if (writefullIntegrationSplitTestEnabled) { - // only show to users who have writefull installed once the integration is live - const user = getMeta('ol-user') - show = user.writefull?.enabled === true - } else { - // Only show the Writefull extension promo on Chrome browsers - show = isChromium() && getMeta('ol-showWritefullPromoBanner') - } + const show = + user.writefull?.enabled === true || // show to any users who have writefull enabled regardless of split test + (!writefullIntegrationSplitTestEnabled && // show old banner to users who are not in the split test, who are on chrome and havent dismissed + isChromium() && + getMeta('ol-showWritefullPromoBanner')) if (show) { sendMB('promo-prompt', { location: 'dashboard-banner', page: '/project', - name: writefullIntegrationSplitTestEnabled - ? 'writefull-premium' - : 'writefull', + name: + user.writefull?.enabled === true || + writefullIntegrationSplitTestEnabled + ? 'writefull-premium' + : 'writefull', }) } @@ -111,7 +110,7 @@ function UserNotifications() { splitTestName={inrGeoBannerSplitTestName} /> ) : null} - {writefullIntegrationSplitTestEnabled ? ( + {writefullIntegrationSplitTestEnabled || user.writefull?.enabled ? ( { diff --git a/services/web/frontend/js/features/settings/components/linking-section.tsx b/services/web/frontend/js/features/settings/components/linking-section.tsx index e5d81901ad..61189d7b5f 100644 --- a/services/web/frontend/js/features/settings/components/linking-section.tsx +++ b/services/web/frontend/js/features/settings/components/linking-section.tsx @@ -53,8 +53,11 @@ function LinkingSection() { }: { splitTestVariants: Record } = useSplitTestContext() + // even if they arent in the split test, if they have it enabled let them toggle it off + const user = getMeta('ol-user') const shouldLoadWritefull = - splitTestVariants['writefull-integration'] === 'enabled' && + (splitTestVariants['writefull-integration'] === 'enabled' || + user.writefull?.enabled === true) && !window.writefull // check if the writefull extension is installed, in which case we dont handle the integration const haslangFeedbackLinkingWidgets = diff --git a/services/web/test/frontend/features/project-list/components/notifications.test.tsx b/services/web/test/frontend/features/project-list/components/notifications.test.tsx index 36d9354800..9979c7fe8b 100644 --- a/services/web/test/frontend/features/project-list/components/notifications.test.tsx +++ b/services/web/test/frontend/features/project-list/components/notifications.test.tsx @@ -982,6 +982,9 @@ describe('', function () { window.metaAttributesCache.set('ol-splitTestVariants', { 'writefull-integration': 'default', }) + window.metaAttributesCache.set('ol-user', { + writefull: { enabled: false }, + }) }) it('shows the older banner', function () { @@ -1033,7 +1036,7 @@ describe('', function () { name: 'Get Writefull Premium', }) expect(ctaLink.getAttribute('href')).to.equal( - 'https://my.writefull.com/plans' + 'https://my.writefull.com/overleaf-invite?code=OVERLEAF10&redirect=plans' ) }) diff --git a/services/web/test/frontend/features/project-list/components/project-list-root.test.tsx b/services/web/test/frontend/features/project-list/components/project-list-root.test.tsx index 4ff31b189f..1ce5e43ed6 100644 --- a/services/web/test/frontend/features/project-list/components/project-list-root.test.tsx +++ b/services/web/test/frontend/features/project-list/components/project-list-root.test.tsx @@ -51,6 +51,8 @@ describe('', function () { window.metaAttributesCache.set('ol-userEmails', [ { email: 'test@overleaf.com', default: true }, ]) + // we need a blank user here since its used in checking if we should display certain ads + window.metaAttributesCache.set('ol-user', {}) window.user_id = userId assignStub = sinon.stub() this.locationStub = sinon.stub(useLocationModule, 'useLocation').returns({ diff --git a/services/web/test/frontend/features/project-list/components/table/project-tools/project-tools-rename.test.tsx b/services/web/test/frontend/features/project-list/components/table/project-tools/project-tools-rename.test.tsx index b2554a410a..580035ea6f 100644 --- a/services/web/test/frontend/features/project-list/components/table/project-tools/project-tools-rename.test.tsx +++ b/services/web/test/frontend/features/project-list/components/table/project-tools/project-tools-rename.test.tsx @@ -48,6 +48,7 @@ const projects: Project[] = [ describe('', function () { beforeEach(function () { window.metaAttributesCache.set('ol-ExposedSettings', {}) + window.metaAttributesCache.set('ol-user', {}) window.metaAttributesCache.set('ol-prefetchedProjectsBlob', { projects, totalSize: 100,