Files
TREK/client/tests/unit/mobile/journey/MJourneyEntryCard.test.tsx
T
Maurice 6cbefd23e8 feat(studio): filter photos by entry, upload from Studio, and switch stops off
The content browser gets a filter over the journey's pictures: all of them,
the ones no entry holds, or one entry at a time, with the day and the place
under each name. An entry card in the Entries tab reaches its own pictures
the same way. Pictures can now come in without leaving Studio, into the
entry the filter names or into the gallery, from the panel or dropped
straight onto the page, and a photo element can fill its page or the whole
spread in one press.

Stops can be taken out of the arithmetic. A journal entry carries a
stats_excluded flag; an entry that has it is off the route, out of the
distance, out of the countries and not a step, while staying in the
journal. Studio lists every stop in the travel panel with a switch, the
entry editor carries the same switch on desktop and phone, and the entry
card says when a day is off the route.
2026-09-03 10:47:08 +02:00

58 lines
2.1 KiB
TypeScript

import React from 'react';
import { describe, it, expect, vi } from 'vitest';
import { render, screen, fireEvent } from '../../../helpers/render';
import MJourneyEntryCard from '../../../../src/mobile/screens/journey/MJourneyEntryCard';
import type { JourneyEntry } from '../../../../src/store/journeyStore';
// FE-MOB-JRN-004 onwards
function makeEntry(overrides: Partial<JourneyEntry> = {}): JourneyEntry {
return {
id: 5,
journey_id: 1,
author_id: 1,
type: 'entry',
title: 'Sunrise Pier',
story: 'A **peaceful** morning at the pier.',
entry_date: '2026-05-04',
location_name: 'Ginza, Japan',
mood: 'amazing',
weather: 'cloudy',
visibility: 'private',
sort_order: 0,
photos: [],
created_at: 0,
updated_at: 0,
...overrides,
} as JourneyEntry;
}
describe('MJourneyEntryCard', () => {
it('FE-MOB-JRN-004: renders number badge, title, stripped story preview and location pill', () => {
render(<MJourneyEntryCard entry={makeEntry()} number={1} onClick={() => {}} />);
expect(screen.getByText('1')).toBeInTheDocument();
expect(screen.getByText('Sunrise Pier')).toBeInTheDocument();
// Markdown is stripped for the 2-line preview.
expect(screen.getByText(/A peaceful morning/)).toBeInTheDocument();
expect(screen.getByText(/Ginza/)).toBeInTheDocument();
});
it('FE-MOB-JRN-005: tapping the card fires onClick', () => {
const onClick = vi.fn();
render(<MJourneyEntryCard entry={makeEntry()} number={2} onClick={onClick} />);
fireEvent.click(screen.getByText('Sunrise Pier'));
expect(onClick).toHaveBeenCalledTimes(1);
});
// #2064: a stop switched off the printed route says so beside its date.
it('FE-MOB-JRN-006: marks an entry left out of the route', () => {
render(<MJourneyEntryCard entry={makeEntry({ stats_excluded: true })} number={1} onClick={() => {}} />);
expect(screen.getByText('Off route')).toBeInTheDocument();
});
it('FE-MOB-JRN-007: carries no such mark on an ordinary entry', () => {
render(<MJourneyEntryCard entry={makeEntry()} number={1} onClick={() => {}} />);
expect(screen.queryByText('Off route')).not.toBeInTheDocument();
});
});