Skip to content

Commit

Permalink
Indicate that no subscriber might be found
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinnl committed Jan 28, 2025
1 parent 875eedf commit 5378ef8
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2533,4 +2533,33 @@ describe("Settings page", () => {
expect(mockedSessionUpdate).toHaveBeenCalledTimes(1);
});
});

it("does not crash if no email preferences were found for the current user", () => {
const component = (
<SettingsWrapper>
<SettingsView
activeTab="edit-info"
l10n={getL10n()}
user={mockedUser}
subscriber={mockedSubscriber}
breachCountByEmailAddress={{
[mockedUser.email]: 42,
[mockedSecondaryVerifiedEmail.email]: 42,
}}
emailAddresses={[mockedSecondaryVerifiedEmail]}
fxaSettingsUrl=""
fxaSubscriptionsUrl=""
yearlySubscriptionUrl=""
monthlySubscriptionUrl=""
subscriptionBillingAmount={mockedSubscriptionBillingAmount}
enabledFeatureFlags={[]}
experimentData={defaultExperimentData["Features"]}
isMonthlySubscriber={true}
data={undefined}
/>
</SettingsWrapper>
);

expect(() => render(component)).not.toThrow();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type Props = {
l10n: ExtendedReactLocalization;
user: Session["user"];
subscriber: SubscriberRow;
data: SubscriberEmailPreferencesOutput;
data?: SubscriberEmailPreferencesOutput;
monthlySubscriptionUrl: string;
yearlySubscriptionUrl: string;
subscriptionBillingAmount: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { onRemoveEmail } from "../actions";

export type SettingsPanelEditInfoProps = {
breachCountByEmailAddress: Record<string, number>;
data: SubscriberEmailPreferencesOutput;
data?: SubscriberEmailPreferencesOutput;
emailAddresses: SanitizedEmailAddressRow[];
subscriber: SubscriberRow;
user: Session["user"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { RadioInput } from "../../../../../../../components/client/RadioInput";
import { CONST_URL_MOZILLA_BASKET } from "../../../../../../../../constants";

export type SettingsPanelNotificationsProps = {
data: SubscriberEmailPreferencesOutput;
data?: SubscriberEmailPreferencesOutput;
subscriber: SubscriberRow;
user: Session["user"];
};
Expand Down
2 changes: 1 addition & 1 deletion src/db/tables/subscriber_email_preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ async function unsubscribeMonthlyMonitorReportForUnsubscribeToken(

async function getEmailPreferenceForPrimaryEmail(
email: string,
): Promise<SubscriberEmailPreferencesOutput> {
): Promise<SubscriberEmailPreferencesOutput | undefined> {
logger.info("get_email_preference_for_primary_email", {
email,
});
Expand Down

0 comments on commit 5378ef8

Please sign in to comment.