Procházet zdrojové kódy

Merge pull request #16325 from overleaf/jdt-writefull-split-test-overrides

users with writefull already enabled dont care about split tests

GitOrigin-RevId: aa986cc42fb9aecf8004b55e5e233c319040748f
Jimmy Domagala-Tang před 2 roky
rodič
revize
5fc2535842

+ 12 - 13
services/web/frontend/js/features/project-list/components/notifications/user-notifications.tsx

@@ -49,6 +49,7 @@ function UserNotifications() {
   const writefullIntegrationSplitTestEnabled = isSplitTestEnabled(
   const writefullIntegrationSplitTestEnabled = isSplitTestEnabled(
     'writefull-integration'
     'writefull-integration'
   )
   )
+  const user = getMeta('ol-user')
 
 
   // Temporary workaround to prevent also showing groups/enterprise banner
   // Temporary workaround to prevent also showing groups/enterprise banner
   const [showWritefull, setShowWritefull] = useState(() => {
   const [showWritefull, setShowWritefull] = useState(() => {
@@ -59,23 +60,21 @@ function UserNotifications() {
       return false
       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) {
     if (show) {
       sendMB('promo-prompt', {
       sendMB('promo-prompt', {
         location: 'dashboard-banner',
         location: 'dashboard-banner',
         page: '/project',
         page: '/project',
-        name: writefullIntegrationSplitTestEnabled
-          ? 'writefull-premium'
-          : 'writefull',
+        name:
+          user.writefull?.enabled === true ||
+          writefullIntegrationSplitTestEnabled
+            ? 'writefull-premium'
+            : 'writefull',
       })
       })
     }
     }
 
 
@@ -111,7 +110,7 @@ function UserNotifications() {
             splitTestName={inrGeoBannerSplitTestName}
             splitTestName={inrGeoBannerSplitTestName}
           />
           />
         ) : null}
         ) : null}
-        {writefullIntegrationSplitTestEnabled ? (
+        {writefullIntegrationSplitTestEnabled || user.writefull?.enabled ? (
           <WritefullPremiumPromoBanner
           <WritefullPremiumPromoBanner
             show={showWritefull}
             show={showWritefull}
             setShow={setShowWritefull}
             setShow={setShowWritefull}

+ 1 - 1
services/web/frontend/js/features/project-list/components/notifications/writefull-premium-promo-banner.tsx

@@ -45,7 +45,7 @@ function WritefullPremiumPromoBanner({
       action={
       action={
         <a
         <a
           className="btn btn-secondary"
           className="btn btn-secondary"
-          href="https://my.writefull.com/plans"
+          href="https://my.writefull.com/overleaf-invite?code=OVERLEAF10&redirect=plans"
           target="_blank"
           target="_blank"
           rel="noreferrer"
           rel="noreferrer"
           onClick={() => {
           onClick={() => {

+ 4 - 1
services/web/frontend/js/features/settings/components/linking-section.tsx

@@ -53,8 +53,11 @@ function LinkingSection() {
   }: { splitTestVariants: Record<string, string | undefined> } =
   }: { splitTestVariants: Record<string, string | undefined> } =
     useSplitTestContext()
     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 =
   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
     !window.writefull // check if the writefull extension is installed, in which case we dont handle the integration
 
 
   const haslangFeedbackLinkingWidgets =
   const haslangFeedbackLinkingWidgets =

+ 4 - 1
services/web/test/frontend/features/project-list/components/notifications.test.tsx

@@ -982,6 +982,9 @@ describe('<UserNotifications />', function () {
         window.metaAttributesCache.set('ol-splitTestVariants', {
         window.metaAttributesCache.set('ol-splitTestVariants', {
           'writefull-integration': 'default',
           'writefull-integration': 'default',
         })
         })
+        window.metaAttributesCache.set('ol-user', {
+          writefull: { enabled: false },
+        })
       })
       })
 
 
       it('shows the older banner', function () {
       it('shows the older banner', function () {
@@ -1033,7 +1036,7 @@ describe('<UserNotifications />', function () {
             name: 'Get Writefull Premium',
             name: 'Get Writefull Premium',
           })
           })
           expect(ctaLink.getAttribute('href')).to.equal(
           expect(ctaLink.getAttribute('href')).to.equal(
-            'https://my.writefull.com/plans'
+            'https://my.writefull.com/overleaf-invite?code=OVERLEAF10&redirect=plans'
           )
           )
         })
         })
 
 

+ 2 - 0
services/web/test/frontend/features/project-list/components/project-list-root.test.tsx

@@ -51,6 +51,8 @@ describe('<ProjectListRoot />', function () {
     window.metaAttributesCache.set('ol-userEmails', [
     window.metaAttributesCache.set('ol-userEmails', [
       { email: 'test@overleaf.com', default: true },
       { 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
     window.user_id = userId
     assignStub = sinon.stub()
     assignStub = sinon.stub()
     this.locationStub = sinon.stub(useLocationModule, 'useLocation').returns({
     this.locationStub = sinon.stub(useLocationModule, 'useLocation').returns({

+ 1 - 0
services/web/test/frontend/features/project-list/components/table/project-tools/project-tools-rename.test.tsx

@@ -48,6 +48,7 @@ const projects: Project[] = [
 describe('<ProjectTools />', function () {
 describe('<ProjectTools />', function () {
   beforeEach(function () {
   beforeEach(function () {
     window.metaAttributesCache.set('ol-ExposedSettings', {})
     window.metaAttributesCache.set('ol-ExposedSettings', {})
+    window.metaAttributesCache.set('ol-user', {})
     window.metaAttributesCache.set('ol-prefetchedProjectsBlob', {
     window.metaAttributesCache.set('ol-prefetchedProjectsBlob', {
       projects,
       projects,
       totalSize: 100,
       totalSize: 100,