Skip to content

Commit 0702fd0

Browse files
committed
fix(home): add a button to the beach list on the no-featured-beaches notice
The "no featured beaches today" message already told the user to check the full list, but gave them no way to get there — the sentence was the whole UI. Adds a button next to it that navigates to /playas, reusing the same button treatment as the adjacent error state's retry action.
1 parent e1a9d77 commit 0702fd0

5 files changed

Lines changed: 29 additions & 2 deletions

File tree

frontend/src/pages/HomePage.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@
682682
}
683683

684684
.hp-empty-msg p {
685-
margin: 0;
685+
margin: 0 0 10px;
686686
}
687687

688688
.hp-error-msg {

frontend/src/pages/HomePage.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,9 @@ const HomePage: React.FC = () => {
584584
<h2 className="section-kicker">{t('home.mejorHoy')}</h2>
585585
<div className="hp-empty-msg">
586586
<p>{t('home.sinDestacadas')}</p>
587+
<button className="hp-retry-btn" onClick={() => history.push('/playas')}>
588+
{t('home.sinDestacadasBoton')}
589+
</button>
587590
</div>
588591
</section>
589592
)}

frontend/src/shared/i18n/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export const en = {
7171
'home.verEnMapaDe': 'View {nombre} on the map',
7272
'home.puntuacionAria': 'Score {n} out of 100',
7373
'home.sinDestacadas': 'No featured beaches today — check the full list',
74+
'home.sinDestacadasBoton': 'View beach list',
7475
'home.errorCondiciones': 'Could not load current conditions',
7576
'home.reintentar': 'Retry',
7677
'home.revisarAntes': 'Better check before you go',

frontend/src/shared/i18n/es.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export const es = {
7979
'home.verEnMapaDe': 'Ver {nombre} en el mapa',
8080
'home.puntuacionAria': 'Puntuación {n} de 100',
8181
'home.sinDestacadas': 'Hoy no hay playas destacadas — consulta el listado completo',
82+
'home.sinDestacadasBoton': 'Ver listado de playas',
8283
'home.errorCondiciones': 'No se pudieron cargar las condiciones actuales',
8384
'home.reintentar': 'Reintentar',
8485
'home.revisarAntes': 'Mejor revisar antes de ir',

frontend/src/test/characterization/homePage.empty.test.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
*/
1212

1313
import React from 'react';
14-
import { screen } from '@testing-library/react';
14+
import { fireEvent, screen } from '@testing-library/react';
15+
import { Route } from 'react-router-dom';
1516
import type { FeaturedBeachesResponse } from '../../services/api';
1617
import HomePage from '../../pages/HomePage';
1718
import { renderWithProviders } from '../render';
@@ -48,3 +49,24 @@ it('muestra el aviso de "sin destacadas" cuando ninguna playa llega a 60', async
4849
// The "revisar" section is rendered: it does not depend on the threshold.
4950
expect(screen.getByText('Mejor revisar antes de ir')).toBeInTheDocument();
5051
});
52+
53+
it('el aviso de "sin destacadas" lleva un botón al listado completo', async () => {
54+
Object.defineProperty(navigator, 'geolocation', { configurable: true, value: undefined });
55+
installFetchMock([
56+
route(FEATURED, { json: sinDestacadas }),
57+
route(BEACHES, { json: beachesResponse }),
58+
]);
59+
60+
renderWithProviders(
61+
<>
62+
<HomePage />
63+
<Route path="/playas" render={() => <div>EN-LISTADO</div>} />
64+
</>,
65+
{ route: '/' },
66+
);
67+
68+
const boton = await screen.findByRole('button', { name: 'Ver listado de playas' });
69+
fireEvent.click(boton);
70+
71+
expect(await screen.findByText('EN-LISTADO')).toBeInTheDocument();
72+
});

0 commit comments

Comments
 (0)