fix: Do not show the estimated removal times label and CSAT banner to free users

This commit is contained in:
Florian Zia 2024-10-30 13:38:30 +01:00
Родитель 916a3c90b9
Коммит 7800c01b79
Не найден ключ, соответствующий данной подписи
7 изменённых файлов: 64 добавлений и 22 удалений

Просмотреть файл

@ -3645,7 +3645,7 @@ describe("CSAT survey banner", () => {
expect(answerButton).not.toBeInTheDocument();
});
it("displays the removal time estimates CSAT survey on the “fixed” tab for users on the treatment branch", () => {
it("displays the removal time estimates CSAT survey on the “fixed” tab to Plus users on the treatment branch", () => {
const ComposedDashboard = composeStory(
DashboardUsPremiumResolvedScanNoBreaches,
Meta,
@ -3669,7 +3669,7 @@ describe("CSAT survey banner", () => {
expect(answerButton).toBeInTheDocument();
});
it("displays the removal time estimates CSAT survey on the “fixed” tab for users on the control branch", () => {
it("displays the removal time estimates CSAT survey on the “fixed” tab to Plus users on the control branch", () => {
const ComposedDashboard = composeStory(
DashboardUsPremiumResolvedScanNoBreaches,
Meta,
@ -3693,7 +3693,7 @@ describe("CSAT survey banner", () => {
expect(answerButton).toBeInTheDocument();
});
it("does not display the removal time estimates CSAT survey on the ”action needed” tab for users on the treatment branch", () => {
it("does not display the removal time estimates CSAT survey on the “action needed” tab to Plus users on the treatment branch", () => {
const ComposedDashboard = composeStory(
DashboardUsPremiumResolvedScanNoBreaches,
Meta,
@ -3705,7 +3705,31 @@ describe("CSAT survey banner", () => {
experimentData={{
...defaultExperimentData,
"data-broker-removal-time-estimates": {
enabled: false,
enabled: true,
},
}}
/>,
);
const answerButton = screen.queryByRole("button", {
name: "Neutral",
});
expect(answerButton).not.toBeInTheDocument();
});
it("does not display the removal time estimates CSAT survey on the “fixed” tab to free users on the treatment branch", () => {
const ComposedDashboard = composeStory(
DashboardUsNoPremiumUnresolvedScanNoBreaches,
Meta,
);
render(
<ComposedDashboard
activeTab="fixed"
enabledFeatureFlags={["DataBrokerRemovalTimeEstimateCsat"]}
experimentData={{
...defaultExperimentData,
"data-broker-removal-time-estimates": {
enabled: true,
},
}}
/>,

Просмотреть файл

@ -45,11 +45,12 @@ it("shows and hides the exposure type explainer", async () => {
expect(explainerDialog).not.toBeInTheDocument();
});
it("shows and hides the removal time explainer dialog by clicking the “Got it” button", async () => {
it("shows and hides the removal time explainer dialog by clicking the “Got it” button to Plus subscribers", async () => {
const user = userEvent.setup();
const ExposuresFilter = composeStory(ExposuresFilterDefault, Meta);
render(
<ExposuresFilter
isPlusSubscriber
enabledFeatureFlags={["DataBrokerRemovalTimeEstimateLabel"]}
experimentData={{
...defaultExperimentData,
@ -75,11 +76,12 @@ it("shows and hides the removal time explainer dialog by clicking the “Got it
expect(explainerDialog).not.toBeInTheDocument();
});
it("shows and hides the removal time explainer dialog by clicking the close button", async () => {
it("shows and hides the removal time explainer dialog by clicking the close button to Plus subscribers", async () => {
const user = userEvent.setup();
const ExposuresFilter = composeStory(ExposuresFilterDefault, Meta);
render(
<ExposuresFilter
isPlusSubscriber
enabledFeatureFlags={["DataBrokerRemovalTimeEstimateLabel"]}
experimentData={{
...defaultExperimentData,

Просмотреть файл

@ -302,7 +302,10 @@ export const ExposuresFilter = ({
<li className={styles.hideOnMobile}>
{l10n.getString("dashboard-exposures-filter-date-found")}
</li>
{enabledFeatureFlags.includes("DataBrokerRemovalTimeEstimateLabel") &&
{isPlusSubscriber &&
enabledFeatureFlags.includes(
"DataBrokerRemovalTimeEstimateLabel",
) &&
experimentData["data-broker-removal-time-estimates"].enabled && (
<li className={styles.hideOnMobile}>
{l10n.getString(

Просмотреть файл

@ -18,11 +18,6 @@ const surveyData: SurveyData = {
},
],
variations: [
{
id: "free-user",
showForUser: ["free-user"],
showOnTab: ["fixed"],
},
{
id: "plus-user",
showForUser: ["plus-user"],

Просмотреть файл

@ -148,7 +148,19 @@ describe("DataBreachCard", () => {
it("does not show the estimated removal time if the feature flag `DataBrokerRemovalTimeEstimates` is disabled", () => {
const ComposedExposureCard = composeStory(DataBrokerActionNeeded, Meta);
render(<ComposedExposureCard />);
render(<ComposedExposureCard isPremiumUser />);
const removalTimeTitle = screen.queryByText("Removal time");
expect(removalTimeTitle).not.toBeInTheDocument();
});
it("does not show the estimated removal time for free users", () => {
const ComposedExposureCard = composeStory(DataBrokerActionNeeded, Meta);
render(
<ComposedExposureCard
enabledFeatureFlags={["DataBrokerRemovalTimeEstimateLabel"]}
/>,
);
const removalTimeTitle = screen.queryByText("Removal time");
expect(removalTimeTitle).not.toBeInTheDocument();
@ -168,11 +180,12 @@ describe("DataBreachCard", () => {
label: "181+ days",
},
])(
"shows a label with the estimated removal time if available: %s",
"shows a label with the estimated removal time if available to Plus subscribers: %s",
({ removalTime, label }) => {
const ComposedExposureCard = composeStory(DataBrokerActionNeeded, Meta);
render(
<ComposedExposureCard
isPremiumUser
enabledFeatureFlags={["DataBrokerRemovalTimeEstimateLabel"]}
removalTimeEstimate={removalTime}
/>,
@ -185,10 +198,11 @@ describe("DataBreachCard", () => {
},
);
it("shows a label displaying “unknown” if the removal time is not available", () => {
it("shows a label displaying “unknown” if the removal time is not available to Plus subscribers", () => {
const ComposedExposureCard = composeStory(DataBrokerActionNeeded, Meta);
render(
<ComposedExposureCard
isPremiumUser
enabledFeatureFlags={["DataBrokerRemovalTimeEstimateLabel"]}
/>,
);
@ -199,10 +213,11 @@ describe("DataBreachCard", () => {
expect(removalTimeLabel).toBeInTheDocument();
});
it("shows a label displaying “N/A” on data breach cards", () => {
it("shows a label displaying “N/A” on data breach cards to Plus subscribers", () => {
const ComposedExposureCard = composeStory(DataBreachActionNeeded, Meta);
render(
<ComposedExposureCard
isPremiumUser
enabledFeatureFlags={["DataBrokerRemovalTimeEstimateLabel"]}
/>,
);

Просмотреть файл

@ -266,9 +266,10 @@ export const ScanResultCard = (props: ScanResultCardProps) => {
<dd className={styles.hideOnMobile}>
{dateFormatter.format(scanResult.created_at)}
</dd>
{props.enabledFeatureFlags?.includes(
"DataBrokerRemovalTimeEstimateLabel",
) &&
{props.isPremiumUser &&
props.enabledFeatureFlags?.includes(
"DataBrokerRemovalTimeEstimateLabel",
) &&
props.experimentData?.["data-broker-removal-time-estimates"]
.enabled && (
<>

Просмотреть файл

@ -34,6 +34,7 @@ export type SubscriberBreachCardProps = {
locale: string;
resolutionCta: ReactNode;
isEligibleForPremium: boolean;
isPremiumUser: boolean;
isExpanded: boolean;
enabledFeatureFlags: FeatureFlagName[];
experimentData: ExperimentData;
@ -211,9 +212,10 @@ export const SubscriberBreachCard = (props: SubscriberBreachCardProps) => {
<dd className={styles.hideOnMobile}>
{dateFormatter.format(subscriberBreach.addedDate)}
</dd>
{props.enabledFeatureFlags.includes(
"DataBrokerRemovalTimeEstimateLabel",
) &&
{props.isPremiumUser &&
props.enabledFeatureFlags.includes(
"DataBrokerRemovalTimeEstimateLabel",
) &&
props.experimentData["data-broker-removal-time-estimates"]
.enabled && (
<>