mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 08:30:05 +00:00
feat(mobile): the trip's tabs, administration, collections and the journal use the large screen
On an iPad or an unfolded foldable the list screens kept one phone-wide column in the middle of the page. They now lay out for the room they have: - Transports, bookings, polls and tasks put their cards in a grid of as many phone-wide columns as the page holds (CardGrid), three on a 13" iPad on its side, two upright, one in a narrow Split View. - Costs: with room for two panes (split size class) the summary (total, owe and owed, settle up, final budget, categories) stands in a pane of its own beside the expenses, each scrolling on its own (TabPanes). The search field sits in the expenses' column again instead of running past it. - Files: a grid of tiles with each photo's picture; with room for two panes the picked file is previewed beside the grid with what it belongs to and its actions, the way Files on an iPad does. The signed preview address comes through fileRepo.previewUrl. - Packing: the categories stand in columns, each card whole in its column; the action menu drops from its button at a popover's width. - To-dos: the four smart filters as tiles and the trip's lists in a pane beside the tasks, which take the filter's name as their head. - Collab: the chat stays in view at the trailing edge beside the notes, links or polls, and the header switches only the board. The chat keeps its place in the tree, so a fold or a rotation into two panes keeps the draft; a chat at its newest message stays there when its box changes size. Notes stand as a board in columns. - Administration and settings share a section list beside the page (MSectionNav); the stats grid takes four columns. - Collections: the lists stand in a column beside the places, which take two columns, and the head names the list on show. - Journal: the entries become a feed beside the map, under their days, with photo, place and the start of the story, in step with the map like the strip of cards it replaces; it fades out under the header. - The assistant opens as a tall panel at the trailing edge over a dimmed page, as Slide Over would, instead of covering the whole screen. - The rail fits every name: a word too wide for it shrinks the label before it is hyphenated, and the admin entry uses its short name. - The journeys and notifications headers keep to their column. - The address screen of the native shell sets the photo as a panel beside the choices on a large screen on its side. On a foldable that reports its fold, a leading pane ends at the fold and a trailing one starts there. Phones keep their layout.
This commit is contained in:
@@ -62,10 +62,12 @@ describe('MNavRail', () => {
|
||||
expect(screen.getByTestId('loc').textContent).toBe('/settings');
|
||||
});
|
||||
|
||||
it('FE-MOB-RAIL-003: administration sits at the foot for an admin', () => {
|
||||
it('FE-MOB-RAIL-003: administration sits at the foot for an admin, under its short name', () => {
|
||||
useAuthStore.setState({ user: buildUser({ role: 'admin' }) });
|
||||
render(<MNavRail />, { initialEntries: ['/dashboard'] });
|
||||
expect(within(rail()).getByRole('button', { name: 'Admin Settings' })).toBeInTheDocument();
|
||||
// The rail names it "Admin" (nav.admin): the avatar menu's "Admin Settings"
|
||||
// ran to two lines in English and was cut in German.
|
||||
expect(within(rail()).getByRole('button', { name: 'Admin' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("FE-MOB-RAIL-004: the create button keeps the dock's meaning and its exceptions", () => {
|
||||
|
||||
@@ -2,7 +2,8 @@ import React from 'react';
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
||||
import { Route, Routes } from 'react-router';
|
||||
import { http, HttpResponse } from 'msw';
|
||||
import { fireEvent, render, screen, waitFor } from '../../../helpers/render';
|
||||
import { fireEvent, render, screen, waitFor, within } from '../../../helpers/render';
|
||||
import { setSizeClass } from '../../../helpers/sizeClass';
|
||||
import { server } from '../../../helpers/msw/server';
|
||||
import { resetAllStores, seedStore } from '../../../helpers/store';
|
||||
import { buildAdmin } from '../../../helpers/factories';
|
||||
@@ -429,4 +430,22 @@ describe('MAdmin', () => {
|
||||
fireEvent.click(await screen.findByRole('button', { name: 'Administration' }));
|
||||
expect(screen.queryByRole('button', { name: 'Storage' })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-MOB-ADMIN-019: with room for two panes the sections stand in a list beside the page', async () => {
|
||||
setSizeClass('split');
|
||||
render(<MAdmin />);
|
||||
await waitFor(() => expect(screen.getByText('alice')).toBeInTheDocument());
|
||||
|
||||
const sections = screen.getByRole('navigation', { name: 'Administration' });
|
||||
expect(within(sections).getByRole('button', { name: 'Users' })).toHaveAttribute('aria-current', 'page');
|
||||
// No dropdown pill on top of the page: the list beside it is the switcher.
|
||||
expect(screen.queryByRole('button', { name: 'Administration', expanded: false })).not.toBeInTheDocument();
|
||||
|
||||
fireEvent.click(within(sections).getByRole('button', { name: 'Settings' }));
|
||||
await waitFor(() => expect(screen.getByText('Authentication Methods')).toBeInTheDocument());
|
||||
expect(within(sections).getByRole('button', { name: 'Settings' })).toHaveAttribute('aria-current', 'page');
|
||||
|
||||
fireEvent.click(within(sections).getByRole('button', { name: 'Create User' }));
|
||||
expect(screen.getByRole('dialog', { name: 'Create User' })).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// FE-MOB-COLSCR-001 to FE-MOB-COLSCR-033
|
||||
// FE-MOB-COLSCR-001 to FE-MOB-COLSCR-034
|
||||
import React from 'react'
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { render, screen, fireEvent, waitFor } from '../../../helpers/render'
|
||||
import { render, screen, fireEvent, waitFor, within } from '../../../helpers/render'
|
||||
import { setSizeClass } from '../../../helpers/sizeClass'
|
||||
import MCollections from '../../../../src/mobile/screens/collections/MCollections'
|
||||
import { ALL_SAVED } from '../../../../src/store/collectionStore'
|
||||
|
||||
@@ -695,4 +696,17 @@ describe('MCollections: invites (#2645)', () => {
|
||||
expect(names).toEqual(['Lisbon', 'Rome'])
|
||||
expect(screen.getByPlaceholderText('collections.search')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-MOB-COLSCR-034: with room for two panes the lists stand beside the places and the head names the list', () => {
|
||||
setSizeClass('split')
|
||||
render(<MCollections />)
|
||||
const lists = screen.getByRole('navigation', { name: 'collections.title' })
|
||||
expect(within(lists).getByRole('button', { name: /Hamburg/ })).toHaveAttribute('aria-current', 'page')
|
||||
expect(screen.getByRole('heading', { name: 'Hamburg' })).toBeInTheDocument()
|
||||
|
||||
fireEvent.click(within(lists).getByRole('button', { name: /collections.allSaved/ }))
|
||||
expect(fn('handleSelectList')).toHaveBeenCalledWith(ALL_SAVED)
|
||||
fireEvent.click(within(lists).getByRole('button', { name: /collections.newList/ }))
|
||||
expect(fn('setEditorTarget')).toHaveBeenCalledWith('new')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// FE-MOB-JDET-001 to FE-MOB-JDET-046
|
||||
// FE-MOB-JDET-001 to FE-MOB-JDET-048
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
||||
import { render, screen, fireEvent, waitFor, act } from '../../../helpers/render';
|
||||
import { setSizeClass } from '../../../helpers/sizeClass';
|
||||
import MJourneyDetail from '../../../../src/mobile/screens/journey/MJourneyDetail';
|
||||
import { addonsApi, journeyApi, memoriesApi } from '../../../../src/api/client';
|
||||
import { useJourneyStore } from '../../../../src/store/journeyStore';
|
||||
@@ -782,4 +783,24 @@ describe('MJourneyDetail', () => {
|
||||
expect(screen.getByTestId('day-import-sheet')).toBeInTheDocument();
|
||||
expect(mocks.captured.dayImport.prep).toBe(recordingPrep);
|
||||
});
|
||||
|
||||
it('FE-MOB-JDET-047: with room for two panes the entries stand as a feed beside the map, in step with it', () => {
|
||||
setSizeClass('split');
|
||||
setup();
|
||||
// Each entry once, in the feed: the strip of cards over the map is gone.
|
||||
expect(screen.getAllByText('Arrival')).toHaveLength(1);
|
||||
// The test's translator returns the key, so both day heads read the same.
|
||||
expect(screen.getAllByText('journey.detail.day')).toHaveLength(2);
|
||||
|
||||
// A tap brings the entry to the map, a second one opens it.
|
||||
fireEvent.click(screen.getByRole('button', { name: /Kyoto/ }));
|
||||
expect(mocks.focusMarker).toHaveBeenCalledWith('2');
|
||||
expect(screen.getByRole('button', { name: /Kyoto/ })).toHaveAttribute('aria-current', 'true');
|
||||
});
|
||||
|
||||
it('FE-MOB-JDET-048: the gallery takes the page, feed or not', () => {
|
||||
setSizeClass('split');
|
||||
setup({ view: 'gallery' });
|
||||
expect(screen.queryByText('journey.detail.day')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,417 @@
|
||||
import { Settings2, Users } from 'lucide-react';
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { MRailButton } from '../../../src/mobile/components/MRail';
|
||||
import MSectionNav from '../../../src/mobile/components/MSectionNav';
|
||||
import MCollListNav from '../../../src/mobile/screens/collections/MCollListNav';
|
||||
import MJourneyFeed from '../../../src/mobile/screens/journey/MJourneyFeed';
|
||||
import { storyExcerpt } from '../../../src/mobile/screens/journey/mobileJourneyMeta';
|
||||
import { CollabSegment } from '../../../src/mobile/screens/trip/MTripShellParts';
|
||||
import { collabBoardFor, collabBoards, collabSideBySide } from '../../../src/mobile/screens/trip/tabs/collabPanes';
|
||||
import { FilePreviewPane, FileTile } from '../../../src/mobile/screens/trip/tabs/MFilesBoard';
|
||||
import MTodoSidebar from '../../../src/mobile/screens/trip/tabs/MTodoSidebar';
|
||||
import { CardGrid, TabPanes } from '../../../src/mobile/screens/trip/tabs/tabChrome';
|
||||
import { fileRepo } from '../../../src/repo/fileRepo';
|
||||
import { ALL_SAVED } from '../../../src/store/collectionStore';
|
||||
import type { JourneyEntry } from '../../../src/store/journeyStore';
|
||||
import type { Reservation, TripFile } from '../../../src/types';
|
||||
import { buildPlanner } from '../../helpers/mobileTrip';
|
||||
import { fireEvent, render, screen, waitFor, within } from '../../helpers/render';
|
||||
import { setSizeClass } from '../../helpers/sizeClass';
|
||||
|
||||
// FE-MOB-PANES-001 onwards: the panes, grids and labels the touch shell uses on a wide window.
|
||||
|
||||
const echo = (key: string, params?: Record<string, string | number>) =>
|
||||
params ? `${key}:${Object.values(params).join(',')}` : key;
|
||||
|
||||
describe('rail labels that fit', () => {
|
||||
// jsdom lays nothing out, so the label measures what these getters say: a word
|
||||
// `width` px wide at full size in a 64px box, narrower once it may hyphenate.
|
||||
function measureLike(width: number, hyphenated: number) {
|
||||
const proto = HTMLSpanElement.prototype;
|
||||
vi.spyOn(proto, 'scrollWidth', 'get').mockImplementation(function (this: HTMLElement) {
|
||||
const fit = Number(this.style.getPropertyValue('--fit') || 1);
|
||||
return (this.style.hyphens === 'auto' ? hyphenated : width) * fit;
|
||||
});
|
||||
vi.spyOn(proto, 'clientWidth', 'get').mockReturnValue(64);
|
||||
}
|
||||
|
||||
afterEach(() => vi.restoreAllMocks());
|
||||
|
||||
function label() {
|
||||
return screen.getByText('Einstellungen');
|
||||
}
|
||||
|
||||
it('FE-MOB-PANES-001: a name that fits keeps its size and its words whole', () => {
|
||||
measureLike(60, 60);
|
||||
render(
|
||||
<MRailButton label="Einstellungen" active={false} onClick={() => {}}>
|
||||
x
|
||||
</MRailButton>
|
||||
);
|
||||
expect(label().style.getPropertyValue('--fit')).toBe('1');
|
||||
expect(label().style.hyphens).toBe('manual');
|
||||
expect(label().style.overflowWrap).toBe('normal');
|
||||
});
|
||||
|
||||
it('FE-MOB-PANES-002: a word a little too wide shrinks the name instead of splitting it', () => {
|
||||
measureLike(72, 40);
|
||||
render(
|
||||
<MRailButton label="Einstellungen" active={false} onClick={() => {}}>
|
||||
x
|
||||
</MRailButton>
|
||||
);
|
||||
const fit = Number(label().style.getPropertyValue('--fit'));
|
||||
expect(fit).toBeLessThan(1);
|
||||
expect(72 * fit).toBeLessThanOrEqual(64.5);
|
||||
expect(label().style.hyphens).toBe('manual');
|
||||
});
|
||||
|
||||
it('FE-MOB-PANES-003: a word too long even when small is hyphenated, and broken only past that', () => {
|
||||
measureLike(140, 60);
|
||||
const { unmount } = render(
|
||||
<MRailButton label="Einstellungen" active={false} onClick={() => {}}>
|
||||
x
|
||||
</MRailButton>
|
||||
);
|
||||
expect(label().style.hyphens).toBe('auto');
|
||||
expect(label().style.overflowWrap).toBe('normal');
|
||||
unmount();
|
||||
|
||||
vi.restoreAllMocks();
|
||||
measureLike(140, 140);
|
||||
render(
|
||||
<MRailButton label="Einstellungen" active={false} onClick={() => {}}>
|
||||
x
|
||||
</MRailButton>
|
||||
);
|
||||
expect(label().style.overflowWrap).toBe('anywhere');
|
||||
});
|
||||
});
|
||||
|
||||
describe('collab panes', () => {
|
||||
const on = { chat: true, notes: true, links: true, polls: true };
|
||||
|
||||
it('FE-MOB-PANES-004: the boards beside the chat follow the trip switches, in header order', () => {
|
||||
expect(collabBoards(on)).toEqual(['notes', 'links', 'polls']);
|
||||
expect(collabBoards({ ...on, notes: false, links: false })).toEqual(['polls']);
|
||||
expect(collabSideBySide(true, on)).toBe(true);
|
||||
expect(collabSideBySide(false, on)).toBe(false);
|
||||
expect(collabSideBySide(true, { ...on, chat: false })).toBe(false);
|
||||
expect(collabSideBySide(true, { chat: true, notes: false, links: false, polls: false })).toBe(false);
|
||||
});
|
||||
|
||||
it('FE-MOB-PANES-005: a tab still set to the chat shows the first board beside it', () => {
|
||||
expect(collabBoardFor('chat', on)).toBe('notes');
|
||||
expect(collabBoardFor('polls', on)).toBe('polls');
|
||||
expect(collabBoardFor('notes', { ...on, notes: false })).toBe('links');
|
||||
});
|
||||
|
||||
it('FE-MOB-PANES-006: the header switches the board alone and names the chat over its pane', () => {
|
||||
const onPick = vi.fn();
|
||||
const { rerender } = render(<CollabSegment active="chat" onPick={onPick} features={on} split={false} t={echo} />);
|
||||
expect(screen.getAllByRole('button').map((b) => b.textContent)).toEqual([
|
||||
'collab.tabs.chat',
|
||||
'collab.tabs.notes',
|
||||
'collab.tabs.links',
|
||||
'collab.tabs.polls',
|
||||
]);
|
||||
|
||||
rerender(<CollabSegment active="chat" onPick={onPick} features={on} split t={echo} />);
|
||||
expect(screen.getAllByRole('button').map((b) => b.textContent)).toEqual([
|
||||
'collab.tabs.notes',
|
||||
'collab.tabs.links',
|
||||
'collab.tabs.polls',
|
||||
]);
|
||||
expect(screen.getByRole('button', { name: 'collab.tabs.notes' })).toHaveAttribute('aria-pressed', 'true');
|
||||
expect(screen.getByText('collab.tabs.chat').tagName).toBe('SPAN');
|
||||
fireEvent.click(screen.getByRole('button', { name: 'collab.tabs.polls' }));
|
||||
expect(onPick).toHaveBeenCalledWith('polls');
|
||||
});
|
||||
});
|
||||
|
||||
describe('section lists beside the page', () => {
|
||||
const sections = [
|
||||
{ id: 'users', label: 'Users', icon: Users },
|
||||
{ id: 'settings', label: 'Settings', icon: Settings2 },
|
||||
];
|
||||
|
||||
it('FE-MOB-PANES-007: names the screen, leads back and marks the section on show', () => {
|
||||
const onBack = vi.fn();
|
||||
const onPick = vi.fn();
|
||||
render(
|
||||
<MSectionNav
|
||||
title="Administration"
|
||||
backLabel="Back"
|
||||
onBack={onBack}
|
||||
sections={sections}
|
||||
activeId="settings"
|
||||
onPick={onPick}
|
||||
action={<button type="button">New user</button>}
|
||||
/>
|
||||
);
|
||||
const nav = screen.getByRole('navigation', { name: 'Administration' });
|
||||
expect(within(nav).getByRole('button', { name: 'Settings' })).toHaveAttribute('aria-current', 'page');
|
||||
expect(within(nav).getByRole('button', { name: 'Users' })).not.toHaveAttribute('aria-current');
|
||||
fireEvent.click(within(nav).getByRole('button', { name: 'Back' }));
|
||||
fireEvent.click(within(nav).getByRole('button', { name: 'Users' }));
|
||||
expect(onBack).toHaveBeenCalled();
|
||||
expect(onPick).toHaveBeenCalledWith('users');
|
||||
expect(within(nav).getByRole('button', { name: 'New user' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("FE-MOB-PANES-008: the collections' lists, with their counts, the one on show and a new one", () => {
|
||||
const onSelect = vi.fn();
|
||||
const onNewList = vi.fn();
|
||||
render(
|
||||
<MCollListNav
|
||||
lists={[
|
||||
{ id: 1, name: 'Coffee in Kyoto', color: '#a16207', place_count: 4 },
|
||||
{ id: 2, name: 'Tokyo next time', color: '#2563eb', place_count: 5 },
|
||||
]}
|
||||
allSaved={false}
|
||||
activeId={2}
|
||||
onSelect={onSelect}
|
||||
onNewList={onNewList}
|
||||
t={echo}
|
||||
/>
|
||||
);
|
||||
const tokyo = screen.getByRole('button', { name: /Tokyo next time/ });
|
||||
expect(tokyo).toHaveAttribute('aria-current', 'page');
|
||||
expect(tokyo).toHaveTextContent('5');
|
||||
fireEvent.click(screen.getByRole('button', { name: /collections.allSaved/ }));
|
||||
fireEvent.click(screen.getByRole('button', { name: /Coffee in Kyoto/ }));
|
||||
fireEvent.click(screen.getByRole('button', { name: /collections.newList/ }));
|
||||
expect(onSelect).toHaveBeenNthCalledWith(1, ALL_SAVED);
|
||||
expect(onSelect).toHaveBeenNthCalledWith(2, 1);
|
||||
expect(onNewList).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('list tabs on a wide window', () => {
|
||||
it('FE-MOB-PANES-009: cards take as many columns of a phone width as the page holds', () => {
|
||||
const { container } = render(
|
||||
<CardGrid>
|
||||
<div>a</div>
|
||||
</CardGrid>
|
||||
);
|
||||
expect((container.firstChild as HTMLElement).className).toContain(
|
||||
'wide:grid-cols-[repeat(auto-fill,minmax(min(100%,340px),1fr))]'
|
||||
);
|
||||
});
|
||||
|
||||
it('FE-MOB-PANES-010: the summary stacks above the list, and stands beside it with room for two panes', () => {
|
||||
const { rerender } = render(
|
||||
<TabPanes aside={<p>summary</p>} asideLabel="Budget">
|
||||
<p>list</p>
|
||||
</TabPanes>
|
||||
);
|
||||
expect(screen.queryByRole('complementary')).not.toBeInTheDocument();
|
||||
expect(screen.getByText('summary').parentElement).toBe(screen.getByText('list').parentElement);
|
||||
|
||||
setSizeClass('split');
|
||||
rerender(
|
||||
<TabPanes aside={<p>summary</p>} asideLabel="Budget">
|
||||
<p>list</p>
|
||||
</TabPanes>
|
||||
);
|
||||
const aside = screen.getByRole('complementary', { name: 'Budget' });
|
||||
expect(aside).toHaveClass('m-pane-aside');
|
||||
expect(within(aside).getByText('summary')).toBeInTheDocument();
|
||||
expect(within(aside).queryByText('list')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-MOB-PANES-011: the to-do filters as tiles and lists, each one a filter to pick', () => {
|
||||
const onPick = vi.fn();
|
||||
render(
|
||||
<MTodoSidebar
|
||||
active={{ kind: 'smart', id: 'all' }}
|
||||
onPick={onPick}
|
||||
counts={{ total: 6, open: 4, done: 2, overdue: 1, my: 3 }}
|
||||
categories={['Tickets', 'Money']}
|
||||
catCount={(name) => (name === 'Tickets' ? 2 : 1)}
|
||||
smartLabel={(id) => `filter.${id}`}
|
||||
listsLabel="Lists"
|
||||
/>
|
||||
);
|
||||
const all = screen.getByRole('button', { name: /filter\.all/ });
|
||||
expect(all).toHaveAttribute('aria-pressed', 'true');
|
||||
expect(all).toHaveTextContent('4');
|
||||
expect(screen.getByRole('button', { name: /filter\.overdue/ })).toHaveTextContent('1');
|
||||
fireEvent.click(screen.getByRole('button', { name: /filter\.done/ }));
|
||||
fireEvent.click(screen.getByRole('button', { name: /Tickets/ }));
|
||||
expect(onPick).toHaveBeenNthCalledWith(1, { kind: 'smart', id: 'done' });
|
||||
expect(onPick).toHaveBeenNthCalledWith(2, { kind: 'category', name: 'Tickets' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('the journey as a feed beside its map', () => {
|
||||
function entry(id: number, date: string, overrides: Partial<JourneyEntry> = {}): JourneyEntry {
|
||||
return {
|
||||
id,
|
||||
journey_id: 1,
|
||||
type: 'entry',
|
||||
entry_date: date,
|
||||
title: `Entry ${id}`,
|
||||
photos: [],
|
||||
...overrides,
|
||||
} as JourneyEntry;
|
||||
}
|
||||
const days = [
|
||||
{ date: '2026-11-05', color: '#6366f1' },
|
||||
{ date: '2026-11-06', color: '#f97316' },
|
||||
];
|
||||
|
||||
it('FE-MOB-PANES-012: the start of a story reads as plain text', () => {
|
||||
expect(storyExcerpt('# Day one\n\nThe **bamboo** grove, see [the map](https://x.y).\n')).toBe(
|
||||
'Day one The bamboo grove, see the map.'
|
||||
);
|
||||
expect(storyExcerpt(null)).toBe('');
|
||||
});
|
||||
|
||||
it('FE-MOB-PANES-013: entries under their day, the active one marked, a tap handed back with its place', () => {
|
||||
const onCardTap = vi.fn();
|
||||
const cardRefs = { current: new Map<number, HTMLDivElement>() };
|
||||
const entries = [
|
||||
entry(1, '2026-11-05', { story: 'Landed **late**', mood: 'amazing' }),
|
||||
entry(2, '2026-11-05'),
|
||||
entry(3, '2026-11-06', { type: 'skeleton' }),
|
||||
];
|
||||
render(
|
||||
<MJourneyFeed
|
||||
entries={entries}
|
||||
days={days}
|
||||
activeIndex={1}
|
||||
cardRefs={cardRefs}
|
||||
onCardTap={onCardTap}
|
||||
showMood
|
||||
showWeather
|
||||
t={echo}
|
||||
locale="en-US"
|
||||
/>
|
||||
);
|
||||
expect(screen.getAllByText(/journey\.detail\.day:/).map((n) => n.textContent)).toEqual([
|
||||
'journey.detail.day:1',
|
||||
'journey.detail.day:2',
|
||||
]);
|
||||
expect(screen.getByText('Landed late')).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: /Entry 2/ })).toHaveAttribute('aria-current', 'true');
|
||||
fireEvent.click(screen.getByRole('button', { name: /Entry 3/ }));
|
||||
expect(onCardTap).toHaveBeenCalledWith(entries[2], 2);
|
||||
expect(cardRefs.current.size).toBe(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe('files as tiles and a preview', () => {
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
// The setup's observer never reports; a tile asks for its picture once it is near the screen.
|
||||
class InView {
|
||||
constructor(private readonly report: IntersectionObserverCallback) {}
|
||||
observe(target: Element) {
|
||||
this.report(
|
||||
[{ isIntersecting: true, target } as IntersectionObserverEntry],
|
||||
this as unknown as IntersectionObserver
|
||||
);
|
||||
}
|
||||
disconnect() {}
|
||||
unobserve() {}
|
||||
takeRecords() {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
const photo = {
|
||||
id: 6,
|
||||
trip_id: 1,
|
||||
original_name: 'Fushimi Inari gates.jpg',
|
||||
mime_type: 'image/jpeg',
|
||||
file_size: 402200,
|
||||
created_at: '2026-11-07T10:00:00Z',
|
||||
url: '/api/trips/1/files/6/download',
|
||||
} as unknown as TripFile;
|
||||
const pass = {
|
||||
id: 1,
|
||||
trip_id: 1,
|
||||
original_name: 'Boarding pass LH 740.pdf',
|
||||
mime_type: 'application/pdf',
|
||||
file_size: 46100,
|
||||
created_at: '2026-11-07T10:00:00Z',
|
||||
url: '/api/trips/1/files/1/download',
|
||||
reservation_id: 6,
|
||||
uploaded_by_name: 'Alex',
|
||||
} as unknown as TripFile;
|
||||
|
||||
it('FE-MOB-PANES-014: a tile shows its picture, and picks, stars and opens its menu', async () => {
|
||||
vi.stubGlobal('IntersectionObserver', InView);
|
||||
const preview = vi.spyOn(fileRepo, 'previewUrl').mockResolvedValue('/signed/6');
|
||||
const onPick = vi.fn();
|
||||
const onStar = vi.fn();
|
||||
const onMenu = vi.fn();
|
||||
const { container } = render(
|
||||
<FileTile file={photo} selected canStar onPick={onPick} onStar={onStar} onMenu={onMenu} t={echo} />
|
||||
);
|
||||
await waitFor(() => expect(container.querySelector('img')).toHaveAttribute('src', '/signed/6'));
|
||||
expect(preview).toHaveBeenCalledWith('/api/trips/1/files/6/download');
|
||||
fireEvent.click(screen.getByRole('button', { name: /Fushimi Inari gates\.jpg/ }));
|
||||
fireEvent.click(screen.getByRole('button', { name: 'files.star' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: 'files.menu' }));
|
||||
expect(onPick).toHaveBeenCalled();
|
||||
expect(onStar).toHaveBeenCalled();
|
||||
expect(onMenu).toHaveBeenCalled();
|
||||
expect(screen.getByRole('button', { name: /Fushimi Inari gates\.jpg/ })).toHaveAttribute('aria-pressed', 'true');
|
||||
});
|
||||
|
||||
it('FE-MOB-PANES-015: the preview names the file, what it belongs to, and what to do with it', () => {
|
||||
vi.spyOn(fileRepo, 'previewUrl').mockResolvedValue('/signed/1');
|
||||
const reservations = [{ id: 6, title: 'LH 740', type: 'flight' }] as unknown as Reservation[];
|
||||
const planner = buildPlanner({ reservations, TRANSPORT_TYPES: new Set(['flight']) } as never);
|
||||
const onOpen = vi.fn();
|
||||
const onStar = vi.fn();
|
||||
const onLinks = vi.fn();
|
||||
const onMenu = vi.fn();
|
||||
render(
|
||||
<FilePreviewPane
|
||||
file={pass}
|
||||
planner={planner}
|
||||
onOpen={onOpen}
|
||||
onStar={onStar}
|
||||
onLinks={onLinks}
|
||||
onMenu={onMenu}
|
||||
/>
|
||||
);
|
||||
expect(screen.getByRole('heading', { name: 'Boarding pass LH 740.pdf' })).toBeInTheDocument();
|
||||
expect(screen.getByText('files.sourceTransport')).toBeInTheDocument();
|
||||
expect(screen.getByText('LH 740')).toBeInTheDocument();
|
||||
expect(screen.getByText('Alex')).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button', { name: /common\.open/ }));
|
||||
fireEvent.click(screen.getByRole('button', { name: /files\.star/ }));
|
||||
fireEvent.click(screen.getByRole('button', { name: /files\.link/ }));
|
||||
fireEvent.click(screen.getByRole('button', { name: 'files.menu' }));
|
||||
expect(onOpen).toHaveBeenCalled();
|
||||
expect(onStar).toHaveBeenCalled();
|
||||
expect(onLinks).toHaveBeenCalled();
|
||||
expect(onMenu).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('FE-MOB-PANES-016: without the right to edit files the preview only opens', () => {
|
||||
vi.spyOn(fileRepo, 'previewUrl').mockResolvedValue('/signed/1');
|
||||
const planner = buildPlanner({ can: vi.fn(() => false) } as never);
|
||||
render(
|
||||
<FilePreviewPane
|
||||
file={pass}
|
||||
planner={planner}
|
||||
onOpen={vi.fn()}
|
||||
onStar={vi.fn()}
|
||||
onLinks={vi.fn()}
|
||||
onMenu={vi.fn()}
|
||||
/>
|
||||
);
|
||||
expect(screen.getByRole('button', { name: /common\.open/ })).toBeInTheDocument();
|
||||
expect(screen.queryByRole('button', { name: /files\.star/ })).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole('button', { name: /files\.link/ })).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -7,8 +7,9 @@ import MAssistantScreen from '../../../../src/mobile/screens/trip/assistant/MAss
|
||||
import { chatOf, useAssistantStore } from '../../../../src/store/assistantStore';
|
||||
import { buildPlanner, buildShell } from '../../../helpers/mobileTrip';
|
||||
import { act, cleanup, fireEvent, render, screen } from '../../../helpers/render';
|
||||
import { setSizeClass } from '../../../helpers/sizeClass';
|
||||
|
||||
// FE-MOB-ASSIST-001 to FE-MOB-ASSIST-017
|
||||
// FE-MOB-ASSIST-001 to FE-MOB-ASSIST-018
|
||||
//
|
||||
// The phone's full-screen chat around the shared chat surface, which is
|
||||
// replaced here: what is tested is the frame, the header and the way to the
|
||||
@@ -322,4 +323,16 @@ describe('MAssistantScreen', () => {
|
||||
});
|
||||
expect(useAssistantStore.getState().window.open).toBe(false);
|
||||
});
|
||||
|
||||
it('FE-MOB-ASSIST-018: on a wide window the chat is a panel at the trailing edge over a dimmed page, which closes it', () => {
|
||||
setSizeClass('wide');
|
||||
renderScreen();
|
||||
const panel = screen.getByRole('dialog', { name: 'Assistant' });
|
||||
expect(panel.className).toContain('wide:end-3');
|
||||
expect(panel.className).toContain('m-panel-in');
|
||||
const scrim = panel.previousElementSibling as HTMLElement;
|
||||
expect(scrim).toHaveAttribute('aria-hidden', 'true');
|
||||
fireEvent.click(scrim);
|
||||
expect(useAssistantStore.getState().window.open).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -327,4 +327,12 @@ describe('MBookingsTab', () => {
|
||||
expect(screen.getByText('Hotel Granvia')).toBeInTheDocument()
|
||||
expect(screen.queryByTestId('plugin-frame')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-MOB-BKTAB-024: a section lays its cards in a grid that takes as many columns as the page holds', () => {
|
||||
renderTab()
|
||||
const header = screen.getByRole('button', { name: 'reservations.confirmed2' })
|
||||
const grid = header.nextElementSibling as HTMLElement
|
||||
expect(grid.className).toContain('wide:grid-cols-[repeat(auto-fill,minmax(min(100%,340px),1fr))]')
|
||||
expect(within(grid).getByText('Hotel Granvia')).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -3,8 +3,9 @@ import MCollabTab from '../../../../src/mobile/screens/trip/tabs/MCollabTab'
|
||||
import type { MTripCollabTab, TripPlanner } from '../../../../src/mobile/screens/trip/MTripShell'
|
||||
import { buildPlanner, buildShell } from '../../../helpers/mobileTrip'
|
||||
import { render, screen } from '../../../helpers/render'
|
||||
import { setSizeClass } from '../../../helpers/sizeClass'
|
||||
|
||||
// FE-MOB-CTAB-001 to FE-MOB-CTAB-009
|
||||
// FE-MOB-CTAB-001 to FE-MOB-CTAB-012
|
||||
|
||||
// The three sub-panels are self-contained (own API calls + WebSocket listener)
|
||||
// and covered by their own suites — here only the routing is under test.
|
||||
@@ -82,4 +83,39 @@ describe('MCollabTab', () => {
|
||||
expect(container).toBeEmptyDOMElement()
|
||||
expect(screen.queryByText('mobileTrip.collabFeatureDisabled')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-MOB-CTAB-010: with room for two panes the chat stays beside the board, and the chat tab shows the first board', () => {
|
||||
setSizeClass('split')
|
||||
const { rerender } = renderTab('chat')
|
||||
expect(screen.getByTestId('chat')).toBeInTheDocument()
|
||||
expect(screen.getByTestId('notes')).toBeInTheDocument()
|
||||
|
||||
rerender(
|
||||
<MCollabTab
|
||||
planner={buildPlanner({ collabFeatures: { chat: true, notes: true, polls: true } as TripPlanner['collabFeatures'] })}
|
||||
shell={buildShell({ collabTab: 'polls' })}
|
||||
/>,
|
||||
)
|
||||
expect(screen.getByTestId('chat')).toBeInTheDocument()
|
||||
expect(screen.getByTestId('polls')).toBeInTheDocument()
|
||||
expect(screen.queryByTestId('notes')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-MOB-CTAB-011: without the chat there is nothing to stand beside, so the board takes the page', () => {
|
||||
setSizeClass('split')
|
||||
renderTab('polls', { chat: false })
|
||||
expect(screen.getByTestId('polls')).toBeInTheDocument()
|
||||
expect(screen.queryByTestId('chat')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-MOB-CTAB-012: turning into two panes and back keeps the same chat, draft and scroll included', () => {
|
||||
renderTab('chat')
|
||||
const before = screen.getByTestId('chat')
|
||||
setSizeClass('split')
|
||||
expect(screen.getByTestId('notes')).toBeInTheDocument()
|
||||
expect(screen.getByTestId('chat')).toBe(before)
|
||||
setSizeClass('compact')
|
||||
expect(screen.queryByTestId('notes')).not.toBeInTheDocument()
|
||||
expect(screen.getByTestId('chat')).toBe(before)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -16,6 +16,7 @@ import { buildPlanner, buildShell } from '../../../helpers/mobileTrip'
|
||||
import { resetAllStores, seedStore } from '../../../helpers/store'
|
||||
import { server } from '../../../helpers/msw/server'
|
||||
import { fireEvent, render, screen, waitFor, within } from '../../../helpers/render'
|
||||
import { setSizeClass } from '../../../helpers/sizeClass'
|
||||
|
||||
// FE-MOB-COSTT-001 to FE-MOB-COSTT-053
|
||||
|
||||
@@ -931,4 +932,16 @@ describe('MCostsTab', () => {
|
||||
expect(screen.queryByText('sheet editing 12')).not.toBeInTheDocument()
|
||||
expect(reload).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('FE-MOB-COSTT-054: with room for two panes the summary stands beside the expenses, and the search keeps to their column', async () => {
|
||||
setSizeClass('split')
|
||||
await renderTab()
|
||||
const summary = screen.getByRole('complementary', { name: 'budget.title' })
|
||||
expect(within(summary).getByText('costs.totalSpend')).toBeInTheDocument()
|
||||
expect(within(summary).queryByPlaceholderText('costs.searchPlaceholder')).not.toBeInTheDocument()
|
||||
|
||||
const expenses = screen.getByRole('region', { name: 'costs.expenses' })
|
||||
expect(within(expenses).getByPlaceholderText('costs.searchPlaceholder')).toBeInTheDocument()
|
||||
expect(within(expenses).getByRole('heading', { name: 'costs.expenses' })).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -6,9 +6,11 @@ import { openFile } from '../../../../src/utils/fileDownload'
|
||||
import type { MTripShellApi, TripPlanner } from '../../../../src/mobile/screens/trip/MTripShell'
|
||||
import type { Place, TripFile } from '../../../../src/types'
|
||||
import { buildPlanner, buildShell, buildTripActions } from '../../../helpers/mobileTrip'
|
||||
import { act, fireEvent, render, screen, waitFor } from '../../../helpers/render'
|
||||
import { setSizeClass } from '../../../helpers/sizeClass'
|
||||
import { fileRepo } from '../../../../src/repo/fileRepo'
|
||||
import { act, fireEvent, render, screen, waitFor, within } from '../../../helpers/render'
|
||||
|
||||
// FE-MOB-FTAB-001 to FE-MOB-FTAB-025
|
||||
// FE-MOB-FTAB-001 to FE-MOB-FTAB-027
|
||||
|
||||
vi.mock('../../../../src/utils/fileDownload', () => ({
|
||||
downloadFile: vi.fn(async () => undefined),
|
||||
@@ -391,6 +393,34 @@ describe('MFilesTab', () => {
|
||||
expect(planner.tripActions.addFile).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('FE-MOB-FTAB-026: a wide window shows the files as tiles, and a tile opens its file', () => {
|
||||
setSizeClass('wide')
|
||||
vi.spyOn(fileRepo, 'previewUrl').mockResolvedValue('/signed')
|
||||
renderTab()
|
||||
expect(screen.queryByRole('complementary')).not.toBeInTheDocument()
|
||||
expect(rowNames()).toEqual(['beach.jpg', 'guide.pdf', 'notes.txt', 'board.pkpass', 'idea.png'])
|
||||
fireEvent.click(screen.getByText('guide.pdf').closest('button') as HTMLButtonElement)
|
||||
expect(openFile).toHaveBeenCalledWith('/api/trips/1/files/1/download', 'guide.pdf')
|
||||
})
|
||||
|
||||
it('FE-MOB-FTAB-027: with room for two panes a tap picks the file and the pane beside the tiles previews it', () => {
|
||||
setSizeClass('split')
|
||||
vi.spyOn(fileRepo, 'previewUrl').mockResolvedValue('/signed')
|
||||
renderTab()
|
||||
const pane = screen.getByRole('complementary', { name: 'common.preview' })
|
||||
// The first file in the grid's order is on show until another is picked.
|
||||
expect(within(pane).getByRole('heading', { name: 'beach.jpg' })).toBeInTheDocument()
|
||||
|
||||
fireEvent.click(screen.getAllByText('guide.pdf')[0].closest('button') as HTMLButtonElement)
|
||||
expect(within(pane).getByRole('heading', { name: 'guide.pdf' })).toBeInTheDocument()
|
||||
expect(openFile).not.toHaveBeenCalled()
|
||||
|
||||
fireEvent.click(within(pane).getByRole('button', { name: /common\.open/ }))
|
||||
expect(openFile).toHaveBeenCalledWith('/api/trips/1/files/1/download', 'guide.pdf')
|
||||
fireEvent.click(within(pane).getByRole('button', { name: /files\.link/ }))
|
||||
expect(screen.getByTestId('link-sheet')).toHaveAttribute('data-file', '1')
|
||||
})
|
||||
|
||||
it('FE-MOB-FTAB-025: the header trash signal opens the trash sheet', () => {
|
||||
const { rerenderWith } = renderTab()
|
||||
expect(screen.queryByTestId('trash-sheet')).not.toBeInTheDocument()
|
||||
|
||||
@@ -994,4 +994,11 @@ describe('MPackingListTab', () => {
|
||||
expect(within(itemRow('Socks')).getByText('1/3')).toBeInTheDocument()
|
||||
expect(screen.queryByRole('button', { name: 'packing.packedMore' })).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-MOB-PACKTAB-070: on a wide window the categories stand in columns, each card whole', async () => {
|
||||
await setup()
|
||||
const card = screen.getAllByRole('button', { expanded: true })[0].parentElement as HTMLElement
|
||||
expect(card.className).toContain('wide:break-inside-avoid')
|
||||
expect((card.parentElement as HTMLElement).className).toContain('wide:columns-[300px]')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -7,7 +7,8 @@ import type { TodoItem, TripMember } from '../../../../src/types'
|
||||
import { buildUser } from '../../../helpers/factories'
|
||||
import { buildPlanner, buildTripActions } from '../../../helpers/mobileTrip'
|
||||
import { resetAllStores, seedStore } from '../../../helpers/store'
|
||||
import { fireEvent, render, screen } from '../../../helpers/render'
|
||||
import { fireEvent, render, screen, within } from '../../../helpers/render'
|
||||
import { setSizeClass } from '../../../helpers/sizeClass'
|
||||
|
||||
// FE-MOB-TODO-001 to FE-MOB-TODO-019
|
||||
|
||||
@@ -337,4 +338,25 @@ describe('MTodoListTab', () => {
|
||||
|
||||
expect(screen.getByText('sometime')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-MOB-TODO-021: with room for two panes the filters stand beside the tasks, which take their name as a head', () => {
|
||||
setSizeClass('split')
|
||||
setup([
|
||||
todo({ id: 1, name: 'Visa', category: 'Before' }),
|
||||
todo({ id: 2, name: 'Insurance', checked: 1 }),
|
||||
])
|
||||
const filters = screen.getByRole('complementary', { name: 'todo.sidebar.tasks' })
|
||||
expect(within(filters).getByText('todo.sidebar.categories')).toBeInTheDocument()
|
||||
expect(screen.getByRole('heading', { name: 'todo.filter.all' })).toBeInTheDocument()
|
||||
expect(screen.getByText('Visa')).toBeInTheDocument()
|
||||
expect(screen.queryByText('Insurance')).not.toBeInTheDocument()
|
||||
|
||||
fireEvent.click(within(filters).getByRole('button', { name: /todo.filter.done/ }))
|
||||
expect(screen.getByRole('heading', { name: 'todo.filter.done' })).toBeInTheDocument()
|
||||
expect(screen.getByText('Insurance')).toBeInTheDocument()
|
||||
|
||||
fireEvent.click(within(filters).getByRole('button', { name: /Before/ }))
|
||||
expect(screen.getByRole('heading', { name: 'Before' })).toBeInTheDocument()
|
||||
expect(screen.getByText('Visa')).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -194,4 +194,24 @@ describe('MTripShell on a wide window', () => {
|
||||
expect(shellApi().mapFront).toBe(false);
|
||||
expect(screen.getByRole('button', { name: 'mobileTrip.mapView' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-MOB-SHELLW-008: beside the plan there is no all-days switch to empty it, on the bare map and beside the places there is', () => {
|
||||
setSizeClass('split');
|
||||
renderShell();
|
||||
expect(screen.queryByRole('button', { name: 'mobileTrip.allDays' })).not.toBeInTheDocument();
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'trip.mobilePlaces' }));
|
||||
expect(screen.getByRole('button', { name: 'mobileTrip.allDays' })).toBeInTheDocument();
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'mobileTrip.hidePane' }));
|
||||
expect(screen.getByRole('button', { name: 'mobileTrip.allDays' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-MOB-SHELLW-009: leaving the places for the plan after an all-days deselect brings a day back', () => {
|
||||
setSizeClass('split');
|
||||
renderShell({ selectedDayId: null });
|
||||
fireEvent.click(screen.getByRole('button', { name: 'trip.mobilePlaces' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: 'mobileTrip.travel' }));
|
||||
expect(mocks.planner.handleSelectDay).toHaveBeenCalledWith(expect.any(Number), true);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user