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
13 changes: 12 additions & 1 deletion packages/fxa-settings/src/components/CardHeader/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ describe('CardHeader', () => {
).toBeInTheDocument();
});

it('falls back to default heading when cmsHeadline is null (Strapi unset field)', () => {
renderWithLocalizationProvider(
<CardHeader headingText={MOCK_HEADING} cmsHeadline={null} />
);
expect(
screen.getByRole('heading', { name: MOCK_HEADING })
).toBeInTheDocument();
});

it('falls back to default heading when only description is provided (no headline)', () => {
renderWithLocalizationProvider(
<CardHeader
Expand All @@ -113,7 +122,9 @@ describe('CardHeader', () => {
expect(
screen.getByRole('heading', { name: MOCK_HEADING })
).toBeInTheDocument();
expect(screen.queryByAltText(MOCK_CMS_LOGO_ALT_TEXT)).not.toBeInTheDocument();
expect(
screen.queryByAltText(MOCK_CMS_LOGO_ALT_TEXT)
).not.toBeInTheDocument();
});

it('renders CMS header with default font size', () => {
Expand Down
8 changes: 3 additions & 5 deletions packages/fxa-settings/src/components/CardHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ interface CardHeaderBasicWithDefaultSubheadingProps
interface CardHeaderCmsProps extends CardHeaderRequiredProps {
cmsLogoUrl?: string;
cmsLogoAltText?: string;
cmsHeadline?: string;
cmsHeadline?: string | null;
cmsDescription?: string;
cmsHeadlineFontSize?: HeadlineFontSize | string | null;
cmsHeadlineTextColor?: string | null;
Expand Down Expand Up @@ -111,7 +111,7 @@ function isDefaultService(
}

function isCmsHeader(props: CardHeaderProps): props is CardHeaderCmsProps {
return (props as CardHeaderCmsProps).cmsHeadline !== undefined;
return !!(props as CardHeaderCmsProps).cmsHeadline;
}

function isBasicWithCustomSubheading(
Expand Down Expand Up @@ -215,9 +215,7 @@ const CardHeader = (props: CardHeaderProps) => {
>
{cmsHeadline}
</h1>
{cmsDescription && (
<p className="card-subheader">{cmsDescription}</p>
)}
{cmsDescription && <p className="card-subheader">{cmsDescription}</p>}
</>
);
}
Expand Down
Loading