Skip to content
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
23 changes: 1 addition & 22 deletions packages/shared/src/features/feedWidgets/FeedWidgetRail.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
} from '@testing-library/react';
import { mockAllIsIntersecting } from 'react-intersection-observer/test-utils';
import { QueryClient } from '@tanstack/react-query';
import { GrowthBook } from '@growthbook/growthbook-react';
import type { NextRouter } from 'next/router';
import { useRouter } from 'next/router';
import basePost from '../../../__tests__/fixture/post';
Expand Down Expand Up @@ -93,20 +92,11 @@ beforeEach(() => {
clearHeldFeedHeroLeads();
});

const renderRail = (
flags: Partial<SettingsFlags> = {},
columns = 4,
isTipsOn = true,
) =>
const renderRail = (flags: Partial<SettingsFlags> = {}, columns = 4) =>
render(
<TestBootProvider
client={new QueryClient()}
settings={{ flags: flags as SettingsFlags, setSettings }}
gb={
new GrowthBook({
features: { feed_widget_tips: { defaultValue: isTipsOn } },
})
}
>
{/* Four columns by default, so the pinned slot is on the first screen. */}
<FeedContext.Provider
Expand Down Expand Up @@ -635,17 +625,6 @@ describe('FeedWidgetRail', () => {
});
});

it('leaves the ad its whole column where the tips are off', async () => {
mockHero();

renderRail({}, 4, false);
await revealWidgets();

expect(screen.queryByTestId('feedWidgetTip')).not.toBeInTheDocument();
const slot = screen.getByTestId('feedWidgetAdSlot');
expect(within(slot).getByTestId('adItem')).not.toHaveClass('group/ad');
});

it('gives the ad its whole column once the tips are removed', async () => {
mockHero();

Expand Down
13 changes: 2 additions & 11 deletions packages/shared/src/features/feedWidgets/FeedWidgetRail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import { IconSize } from '../../components/Icon';
import { useLogContext } from '../../contexts/LogContext';
import { LogEvent, Origin, TargetType } from '../../lib/log';
import { useToastNotification } from '../../hooks/useToastNotification';
import { useConditionalFeature } from '../../hooks/useConditionalFeature';
import { featureFeedWidgetTips } from '../../lib/featureManagement';
import type { FeedWidget, FeedWidgetKind } from './types';
import { FeedWidgetSize, feedWidgetSizeLabel } from './types';
import type { RailPlacement } from './layout';
Expand Down Expand Up @@ -175,12 +173,7 @@ export const FeedWidgetRail = ({
// One tip per page view, over our slot: it is known from the settings and
// the slot alone, so it is there from the first paint.
const [tip] = useState(pickFeedWidgetTip);
// Its own flag, so the compact ad it brings can be measured on its own.
const { value: isTipsOn } = useConditionalFeature({
feature: featureFeedWidgetTips,
shouldEvaluate: showAd,
});
const showTip = showAd && isTipsOn && !isTipHidden;
const showTip = showAd && !isTipHidden;

const logWidgetEvent = useCallback(
(eventName: LogEvent, widget?: FeedWidget, extra?: object) =>
Expand Down Expand Up @@ -736,9 +729,7 @@ export const FeedWidgetRail = ({
onAdd={onAdd}
// Only where the slot shows, so the reader sees the tips come back.
onRestoreTips={
isTipHidden && showAd && isTipsOn && !isReadOnly
? onRestoreTips
: undefined
isTipHidden && showAd && !isReadOnly ? onRestoreTips : undefined
}
onRequestClose={() => setIsGalleryOpen(false)}
/>
Expand Down
4 changes: 0 additions & 4 deletions packages/shared/src/lib/featureManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,6 @@ export const featureGqlBatching = new Feature('gql_batching', false);
// readers on the list layout are enrolled.
export const featureListCardTldr = new Feature('list_card_tldr', false);

// Experiment: a daily.dev tip over the rail's ad slot, which makes the ad
// compact. Apart from `feed_widgets` so the slot's ad impact reads on its own.
export const featureFeedWidgetTips = new Feature('feed_widget_tips', false);

// The widget rail a reader who never customized gets. A flag rather than a
// constant, so the default composition can be tested without a deploy and
// older extension builds stop carrying a stale one. `id` is recorded on the
Expand Down
12 changes: 1 addition & 11 deletions packages/webapp/__tests__/TipsPage.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import {
within,
} from '@testing-library/react';
import { QueryClient } from '@tanstack/react-query';
import {
TestBootProvider,
createReadyGrowthBook,
} from '@dailydotdev/shared/__tests__/helpers/boot';
import { TestBootProvider } from '@dailydotdev/shared/__tests__/helpers/boot';
import { getFeedWidgetTips } from '@dailydotdev/shared/src/features/feedWidgets/tips';
import { LogEvent, Origin } from '@dailydotdev/shared/src/lib/log';
import loggedUser from '@dailydotdev/shared/__tests__/fixture/loggedUser';
Expand Down Expand Up @@ -51,12 +48,6 @@ it('lists every tip, each linking to its feature', () => {
);
});

const tipsOn = () => {
const gb = createReadyGrowthBook();
gb.setFeatures({ feed_widget_tips: { defaultValue: true } });
return gb;
};

describe('showing tips in the feed again', () => {
const setSettings = jest.fn();
const rail = {
Expand All @@ -77,7 +68,6 @@ describe('showing tips in the feed again', () => {
setSettings,
}}
log={{ logEvent }}
gb={tipsOn()}
>
<TipsPage />
</TestBootProvider>,
Expand Down
8 changes: 1 addition & 7 deletions packages/webapp/pages/tips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import { readStoredFeedRail } from '@dailydotdev/shared/src/features/feedWidgets
import { useAuthContext } from '@dailydotdev/shared/src/contexts/AuthContext';
import { useSettingsContext } from '@dailydotdev/shared/src/contexts/SettingsContext';
import { useToastNotification } from '@dailydotdev/shared/src/hooks/useToastNotification';
import { useConditionalFeature } from '@dailydotdev/shared/src/hooks/useConditionalFeature';
import { featureFeedWidgetTips } from '@dailydotdev/shared/src/lib/featureManagement';
import { Button } from '@dailydotdev/shared/src/components/buttons/Button';
import {
ButtonSize,
Expand Down Expand Up @@ -151,13 +149,9 @@ const ShowTipsInFeed = (): ReactElement | null => {
const { user } = useAuthContext();
const { flags } = useSettingsContext();
const isHidden = readStoredFeedRail(flags?.feedWidgets)?.tipsHidden === true;
const { value: isTipsOn } = useConditionalFeature({
feature: featureFeedWidgetTips,
shouldEvaluate: !!user && isHidden,
});

// The rail's hook only mounts for the readers who can use it.
return user && isHidden && isTipsOn ? <RestoreTipsButton /> : null;
return user && isHidden ? <RestoreTipsButton /> : null;
};

function TipsPage(): ReactElement {
Expand Down
Loading