mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-19 13:21:46 +00:00
test(journey): fix getByText assertions broken by keep-mounted tab change
Tabs are now always mounted (visibility toggled via hidden class), so the same entry title can appear in multiple tab views simultaneously. Replace getByText with getAllByText for presence checks; scope the FE-086 click target to the cursor-pointer container.
This commit is contained in:
@@ -265,8 +265,8 @@ describe('JourneyDetailPage', () => {
|
|||||||
await renderAndWait();
|
await renderAndWait();
|
||||||
const timelineBtn = screen.getByRole('button', { name: /timeline/i });
|
const timelineBtn = screen.getByRole('button', { name: /timeline/i });
|
||||||
expect(timelineBtn).toBeInTheDocument();
|
expect(timelineBtn).toBeInTheDocument();
|
||||||
// Timeline entries are visible by default
|
// Timeline entries are visible by default (gallery also mounted but hidden, so multiple matches are expected)
|
||||||
expect(screen.getByText('Arrived in Rome')).toBeInTheDocument();
|
expect(screen.getAllByText('Arrived in Rome').length).toBeGreaterThanOrEqual(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -274,8 +274,8 @@ describe('JourneyDetailPage', () => {
|
|||||||
describe('FE-PAGE-JOURNEYDETAIL-004: Shows entry cards with titles', () => {
|
describe('FE-PAGE-JOURNEYDETAIL-004: Shows entry cards with titles', () => {
|
||||||
it('renders all entry titles in timeline view', async () => {
|
it('renders all entry titles in timeline view', async () => {
|
||||||
await renderAndWait();
|
await renderAndWait();
|
||||||
expect(screen.getByText('Arrived in Rome')).toBeInTheDocument();
|
expect(screen.getAllByText('Arrived in Rome').length).toBeGreaterThanOrEqual(1);
|
||||||
expect(screen.getByText('Florence Day')).toBeInTheDocument();
|
expect(screen.getAllByText('Florence Day').length).toBeGreaterThanOrEqual(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -615,7 +615,7 @@ describe('JourneyDetailPage', () => {
|
|||||||
|
|
||||||
render(<JourneyDetailPage />);
|
render(<JourneyDetailPage />);
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(screen.getByText('Venice Visit')).toBeInTheDocument();
|
expect(screen.getAllByText('Venice Visit').length).toBeGreaterThanOrEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Skeleton card shows "Add Entry" CTA
|
// Skeleton card shows "Add Entry" CTA
|
||||||
@@ -655,10 +655,10 @@ describe('JourneyDetailPage', () => {
|
|||||||
|
|
||||||
render(<JourneyDetailPage />);
|
render(<JourneyDetailPage />);
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(screen.getByText('Quick stop at cafe')).toBeInTheDocument();
|
expect(screen.getAllByText('Quick stop at cafe').length).toBeGreaterThanOrEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(screen.getByText(/Cafe Roma/)).toBeInTheDocument();
|
expect(screen.getAllByText(/Cafe Roma/).length).toBeGreaterThanOrEqual(1);
|
||||||
expect(screen.getByText('Grabbed an espresso')).toBeInTheDocument();
|
expect(screen.getByText('Grabbed an espresso')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1117,8 +1117,9 @@ describe('JourneyDetailPage', () => {
|
|||||||
|
|
||||||
// Map view renders a location list with entry titles/location names
|
// Map view renders a location list with entry titles/location names
|
||||||
// The MapView component shows entry names in clickable location items
|
// The MapView component shows entry names in clickable location items
|
||||||
expect(screen.getByText('Arrived in Rome')).toBeInTheDocument();
|
// (timeline is still mounted but hidden, so multiple matches are expected)
|
||||||
expect(screen.getByText('Florence Day')).toBeInTheDocument();
|
expect(screen.getAllByText('Arrived in Rome').length).toBeGreaterThanOrEqual(1);
|
||||||
|
expect(screen.getAllByText('Florence Day').length).toBeGreaterThanOrEqual(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1177,8 +1178,8 @@ describe('JourneyDetailPage', () => {
|
|||||||
expect(dayBadges.length).toBeGreaterThanOrEqual(2);
|
expect(dayBadges.length).toBeGreaterThanOrEqual(2);
|
||||||
|
|
||||||
// Each day group shows its entries
|
// Each day group shows its entries
|
||||||
expect(screen.getByText('Arrived in Rome')).toBeInTheDocument();
|
expect(screen.getAllByText('Arrived in Rome').length).toBeGreaterThanOrEqual(1);
|
||||||
expect(screen.getByText('Florence Day')).toBeInTheDocument();
|
expect(screen.getAllByText('Florence Day').length).toBeGreaterThanOrEqual(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1878,8 +1879,10 @@ describe('JourneyDetailPage', () => {
|
|||||||
expect(screen.getAllByTestId('journey-map').length).toBeGreaterThanOrEqual(1);
|
expect(screen.getAllByTestId('journey-map').length).toBeGreaterThanOrEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Click the "Arrived in Rome" location item
|
// Click the "Arrived in Rome" location item in the map view's location list
|
||||||
const romeItem = screen.getByText('Arrived in Rome');
|
// (timeline is still mounted but hidden, so find the one inside a cursor-pointer container)
|
||||||
|
const romeItems = screen.getAllByText('Arrived in Rome');
|
||||||
|
const romeItem = romeItems.find(el => el.closest('[class*="cursor-pointer"]')) ?? romeItems[0];
|
||||||
await user.click(romeItem);
|
await user.click(romeItem);
|
||||||
|
|
||||||
// After clicking, the item should gain active styles (translate-x-0.5 on the container)
|
// After clicking, the item should gain active styles (translate-x-0.5 on the container)
|
||||||
|
|||||||
Reference in New Issue
Block a user