Skip to content

Commit

Permalink
Disable braze when running Playwright accross LLD
Browse files Browse the repository at this point in the history
  • Loading branch information
sshmaxime committed Feb 5, 2024
1 parent 4a38f16 commit 5aa7799
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 7 additions & 0 deletions apps/ledger-live-desktop/src/renderer/hooks/useBraze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useDispatch, useSelector } from "react-redux";
import { setNotificationsCards, setPortfolioCards } from "../actions/dynamicContent";
import getUser from "~/helpers/user";
import { developerModeSelector } from "../reducers/settings";
import { getEnv } from "@ledgerhq/live-env";

const getDesktopCards = (elem: braze.ContentCards) =>
elem.cards.filter(card => card.extras?.platform === Platform.Desktop);
Expand Down Expand Up @@ -62,6 +63,7 @@ export const mapAsNotificationContentCard = (card: ClassicCard): NotificationCon
export async function useBraze() {
const dispatch = useDispatch();
const devMode = useSelector(developerModeSelector);
const isPlaywright = !!getEnv("PLAYWRIGHT_RUN");

const initBraze = useCallback(async () => {
const user = await getUser();
Expand All @@ -75,6 +77,11 @@ export async function useBraze() {
sessionTimeoutInSeconds: devMode ? 1 : 1800,
});

// If it's playwright, we don't want to fetch content cards
if (isPlaywright) {
return;
}

if (user) {
braze.changeUser(user.id);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useFeature } from "@ledgerhq/live-common/featureFlags/index";
import { getEnv } from "@ledgerhq/live-env";
import { Carousel } from "@ledgerhq/react-ui";
import { ABTestingVariants } from "@ledgerhq/types-live";
import React, { PropsWithChildren } from "react";
Expand Down Expand Up @@ -42,14 +41,13 @@ const PortfolioContentCards = ({ variant }: { variant: ABTestingVariants }) => {
const lldPortfolioCarousel = useFeature("lldPortfolioCarousel");
const totalAccounts = useSelector(accountsSelector).length;
const hasInstalledApps = useSelector(hasInstalledAppsSelector);
const isPlaywright = !!getEnv("PLAYWRIGHT_RUN");

const showCarousel = lldPortfolioCarousel?.enabled && hasInstalledApps && totalAccounts >= 0;
useRefreshAccountsOrderingEffect({
onMount: true,
});

if (isPlaywright || !showCarousel || slides.length === 0) return null;
if (!showCarousel || slides.length === 0) return null;
if (
lldPortfolioCarousel?.params?.variant === ABTestingVariants.variantA &&
variant === ABTestingVariants.variantA
Expand Down

0 comments on commit 5aa7799

Please sign in to comment.