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

users with writefull already enabled dont care about split tests

GitOrigin-RevId: aa986cc42fb9aecf8004b55e5e233c319040748f
This commit is contained in:
Jimmy Domagala-Tang 2023-12-20 12:22:54 -05:00 committed by Copybot
parent 944753c9b5
commit 5fc2535842
6 changed files with 24 additions and 16 deletions

View file

@ -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 ? (
<WritefullPremiumPromoBanner
show={showWritefull}
setShow={setShowWritefull}

View file

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

View file

@ -53,8 +53,11 @@ function LinkingSection() {
}: { splitTestVariants: Record<string, string | undefined> } =
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 =

View file

@ -982,6 +982,9 @@ describe('<UserNotifications />', 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('<UserNotifications />', 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'
)
})

View file

@ -51,6 +51,8 @@ describe('<ProjectListRoot />', 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({

View file

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