Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add fallback page title when first name is missing #1573

Merged
merged 4 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 7 additions & 1 deletion src/home/components/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,13 @@ const Home = () => {

return (
<PageContainer>
<PageHeader header={t('home.page_title', { name: user.firstName })} />
<PageHeader
header={
user.firstName
? t('home.page_title', { name: user.firstName })
: t('home.document_title')
}
/>
<Grid container spacing={3}>
<Grid item xs={12} md={6}>
<Stack spacing={3}>
Expand Down
30 changes: 30 additions & 0 deletions src/home/components/Home.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,33 @@ test('Home: Display defaults', async () => {
)
).toBeInTheDocument();
});

test('Home: Display title', async () => {
fetchHomeData.mockReturnValue(
Promise.resolve({
groups: [],
landscapes: [],
})
);
await setup();
expect(screen.getByText(/First’s Terraso/i)).toBeInTheDocument();
});

test('Home: Display title (default)', async () => {
terrasoApi.requestGraphQL.mockReturnValue(
Promise.resolve(
_.set(
'users.edges[0].node',
{
firstName: undefined,
lastName: undefined,
profileImage: 'test.com',
preferences: { edges: [] },
},
{}
)
)
);
await setup();
expect(screen.getByText(/Terraso Home/i)).toBeInTheDocument();
});
6 changes: 5 additions & 1 deletion src/tool/components/ToolCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@ const ToolCard = ({ tool }) => {
</section>

<section>
<ToolIconAndLink tool={tool} title={toolTitle} external />
<ToolIconAndLink
tool={tool}
title={toolTitle}
external={external}
/>
</section>
</Stack>
</Card>
Expand Down
Loading