From c5ec2b98d464c97f51664d6a5de68e7203a1d4ad Mon Sep 17 00:00:00 2001 From: Paul Schreiber Date: Tue, 27 Feb 2024 15:01:28 -0500 Subject: [PATCH 1/4] fix: add fallback page title when first name is missing --- src/home/components/Home.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/home/components/Home.js b/src/home/components/Home.js index 598cbd345..21af0b929 100644 --- a/src/home/components/Home.js +++ b/src/home/components/Home.js @@ -93,7 +93,13 @@ const Home = () => { return ( - + From b9db46777d7be754c2e338f4dc197f9f638f520a Mon Sep 17 00:00:00 2001 From: Paul Schreiber Date: Thu, 29 Feb 2024 11:14:58 -0500 Subject: [PATCH 2/4] fix: correctly pass external param to --- src/tool/components/ToolCard.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tool/components/ToolCard.js b/src/tool/components/ToolCard.js index db2efea5d..68f44eb41 100644 --- a/src/tool/components/ToolCard.js +++ b/src/tool/components/ToolCard.js @@ -153,7 +153,11 @@ const ToolCard = ({ tool }) => {
- +
From 09c51cc2b2b9c84000dbe45c6ddc95316053f623 Mon Sep 17 00:00:00 2001 From: Paul Schreiber Date: Thu, 29 Feb 2024 11:16:14 -0500 Subject: [PATCH 3/4] test: add home page title tests --- src/home/components/Home.test.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/home/components/Home.test.js b/src/home/components/Home.test.js index 6995d22ee..95308f84f 100644 --- a/src/home/components/Home.test.js +++ b/src/home/components/Home.test.js @@ -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(); +}); From 5c35ee2830d49b8f6cc831aea014bf7e416af42d Mon Sep 17 00:00:00 2001 From: Paul Schreiber Date: Thu, 7 Mar 2024 11:34:17 -0500 Subject: [PATCH 4/4] fix: add parameter to setup; fix default title test --- src/home/components/Home.test.js | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/home/components/Home.test.js b/src/home/components/Home.test.js index 95308f84f..7e34a843a 100644 --- a/src/home/components/Home.test.js +++ b/src/home/components/Home.test.js @@ -29,16 +29,15 @@ jest.mock('home/homeService', () => ({ fetchHomeData: jest.fn(), })); -const setup = async () => { +const setup = async ( + currentUserData = { firstName: 'First', lastName: 'Last' } +) => { await render(, { account: { hasToken: true, currentUser: { fetching: false, - data: { - firstName: 'First', - lastName: 'Last', - }, + data: currentUserData, }, }, }); @@ -262,20 +261,12 @@ test('Home: Display title', async () => { }); 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: [] }, - }, - {} - ) - ) + fetchHomeData.mockReturnValue( + Promise.resolve({ + groups: [], + landscapes: [], + }) ); - await setup(); + await setup({ firstName: undefined, lastName: undefined }); expect(screen.getByText(/Terraso Home/i)).toBeInTheDocument(); });