mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 09:54:14 +00:00
fix(trips): add titles to Unsplash search thumbnails
This commit is contained in:
@@ -379,6 +379,7 @@ describe('TripFormModal', () => {
|
||||
await user.type(screen.getByPlaceholderText(/Summer in Japan/i), 'Alpine Trip');
|
||||
await user.type(screen.getByPlaceholderText('Search destination photos'), 'alps');
|
||||
await user.click(screen.getByRole('button', { name: /Search Unsplash/i }));
|
||||
expect(await screen.findByAltText('Mountain lake')).toHaveAttribute('title', 'Mountain lake');
|
||||
await user.click(await screen.findByRole('button', { name: /Use Unsplash photo by Alice/i }));
|
||||
|
||||
const submitBtn = screen.getAllByText('Create New Trip').find(el => el.closest('button'))!;
|
||||
@@ -777,6 +778,7 @@ describe('TripFormModal', () => {
|
||||
|
||||
const photoBtn = await screen.findByRole('button', { name: 'Use Unsplash photo by Unsplash' });
|
||||
expect(photoBtn.querySelector('img')).toHaveAttribute('alt', '');
|
||||
expect(photoBtn.querySelector('img')).not.toHaveAttribute('title');
|
||||
expect(photoBtn.querySelector('span')).toBeNull();
|
||||
|
||||
// An empty url is not selectable — nothing is staged.
|
||||
|
||||
@@ -494,6 +494,7 @@ export default function TripFormModal({
|
||||
<img
|
||||
src={photo.thumb}
|
||||
alt={photo.description || ''}
|
||||
title={photo.description || undefined}
|
||||
loading="lazy"
|
||||
className="h-full w-full object-cover"
|
||||
/>
|
||||
|
||||
@@ -440,7 +440,13 @@ function CoverField({ cover, title }: { cover: ReturnType<typeof useTripCoverPic
|
||||
coverPreview === photo.url ? 'border-[color:var(--m-act)]' : 'border-[color:var(--m-rowbr)]'
|
||||
}`}
|
||||
>
|
||||
<img src={photo.thumb} alt={photo.description || ''} loading="lazy" className="h-full w-full object-cover" />
|
||||
<img
|
||||
src={photo.thumb}
|
||||
alt={photo.description || ''}
|
||||
title={photo.description || undefined}
|
||||
loading="lazy"
|
||||
className="h-full w-full object-cover"
|
||||
/>
|
||||
{photo.photographer && (
|
||||
<span className="absolute inset-x-0 bottom-0 truncate bg-black/55 px-[6px] py-1 text-start font-geist text-[0.625rem] text-white">
|
||||
{photo.photographer}
|
||||
|
||||
@@ -321,7 +321,7 @@ describe('MNewTripSheet', () => {
|
||||
|
||||
it('FE-MOB-NTSH-017: create mode previews the picked Unsplash photo without a request', async () => {
|
||||
vi.spyOn(tripsApi, 'searchCoverImages').mockResolvedValue({
|
||||
photos: [{ id: 'p1', url: 'https://img/full.jpg', thumb: 'https://img/thumb.jpg', photographer: 'Ada' }],
|
||||
photos: [{ id: 'p1', url: 'https://img/full.jpg', thumb: 'https://img/thumb.jpg', description: 'Icelandic waterfall', photographer: 'Ada' }],
|
||||
});
|
||||
const update = vi.spyOn(tripsApi, 'update');
|
||||
render(<MNewTripSheet open trip={null} onClose={() => {}} onSave={() => {}} />);
|
||||
@@ -330,6 +330,7 @@ describe('MNewTripSheet', () => {
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Search Unsplash' }));
|
||||
|
||||
const pick = await screen.findByRole('button', { name: 'Use Unsplash photo by Ada' });
|
||||
expect(screen.getByAltText('Icelandic waterfall')).toHaveAttribute('title', 'Icelandic waterfall');
|
||||
expect(screen.getByText('Ada')).toBeInTheDocument();
|
||||
fireEvent.click(pick);
|
||||
|
||||
@@ -355,7 +356,10 @@ describe('MNewTripSheet', () => {
|
||||
|
||||
fireEvent.change(screen.getByPlaceholderText('e.g. Summer in Japan'), { target: { value: 'Iceland' } });
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Search Unsplash' }));
|
||||
fireEvent.click(await screen.findByRole('button', { name: 'Use Unsplash photo by Unsplash' }));
|
||||
const pick = await screen.findByRole('button', { name: 'Use Unsplash photo by Unsplash' });
|
||||
expect(pick.querySelector('img')).toHaveAttribute('alt', '');
|
||||
expect(pick.querySelector('img')).not.toHaveAttribute('title');
|
||||
fireEvent.click(pick);
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Create New Trip' }));
|
||||
|
||||
await waitFor(() => expect(update).toHaveBeenCalledWith(77, { cover_image: 'https://img/full.jpg' }));
|
||||
|
||||
Reference in New Issue
Block a user