mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 03:26:07 +00:00
5346182807
From the large-screen review (visual findings of the shell and the top-level screens): - Rail: 80px wide, one caption size for every name (no shrinking per item), balanced two-line names with every entry as tall as the tallest, short rail names where a language's word is too long (mobileNav.rail*, all locales), and near-opaque glass so a map's colours no longer smear through it. - Rail head: always one 56px circle, so the entries never jump between pages: the create action, the screen's own action (the vacation calendar's year/editor switch moves there instead of floating over the days) or the quiet logo on settings and administration. It stays put while a short rail scrolls. - Vacation calendar: weekday letters over each month on a wide window; the editor's mode switch sits at the foot with room kept for it. - Docks: More is marked with a ring rather than the centre button's fill, the dock glass is denser, and lists fade out under the dock instead of showing in the gap below it. - Dashboard: trip names get the card's width with the dates under them, the hero's facts wrap as whole chips, the filter chips scroll with a fade, the hero ends above the dock on a phone on its side and its buttons sit on a dark ground; the header bar stands in the content's column. - Journeys: on a wide window the header is the same glass bar, in the column of the cards, and the other journeys' label starts with them. - Notifications: the round chevron back button, in the list's column. - Settings and administration share one frame and width. Admin's new-user action sits under the section list's title, the users card header wraps inside the card, stat labels ellipsize, role badges read in dark mode. - Collections: one card per place with the status inside it, worded in a readable mix of its colour. - Atlas and the journey map frame clear of the rail and the header; the journey's day bar sits on a glass plate, and a phone on its side gets smaller cards. - Rail label tests rewritten for the new rule; FE-MOB-PANES-016 duplicate renumbered to 017.
76 lines
2.7 KiB
TypeScript
76 lines
2.7 KiB
TypeScript
import React from 'react'
|
|
import { describe, it, expect, vi } from 'vitest'
|
|
import { render, screen, fireEvent } from '../../../helpers/render'
|
|
import MCollPlaceRow from '../../../../src/mobile/screens/collections/MCollPlaceRow'
|
|
import type { CollectionPlace } from '@trek/shared'
|
|
|
|
// FE-MOB-COLL-010 onwards
|
|
|
|
const place: CollectionPlace = {
|
|
id: 7,
|
|
collection_id: 1,
|
|
name: 'Jungfernstieg',
|
|
address: 'Jungfernstieg 12, Hamburg',
|
|
status: 'want',
|
|
category_id: 3,
|
|
category: { id: 3, name: 'Attraction', color: '#8b5cf6', icon: null },
|
|
}
|
|
|
|
const t = (key: string) => ({
|
|
'collections.status.want': 'Want to go',
|
|
'collections.status.visited': 'Visited',
|
|
}[key] ?? key)
|
|
|
|
function renderRow(overrides: Partial<React.ComponentProps<typeof MCollPlaceRow>> = {}) {
|
|
const props = {
|
|
place,
|
|
selectMode: false,
|
|
selected: false,
|
|
canEdit: true,
|
|
onOpen: vi.fn(),
|
|
onToggleSelect: vi.fn(),
|
|
onSetStatus: vi.fn(),
|
|
t,
|
|
...overrides,
|
|
}
|
|
render(<MCollPlaceRow {...props} />)
|
|
return props
|
|
}
|
|
|
|
describe('MCollPlaceRow', () => {
|
|
it('FE-MOB-COLL-010: renders name, address, status pill and category pill; tap opens the place', () => {
|
|
const props = renderRow()
|
|
expect(screen.getByText('Jungfernstieg')).toBeInTheDocument()
|
|
expect(screen.getByText('Jungfernstieg 12, Hamburg')).toBeInTheDocument()
|
|
expect(screen.getByText('Want to go')).toBeInTheDocument()
|
|
expect(screen.getByText('Attraction')).toBeInTheDocument()
|
|
|
|
fireEvent.click(screen.getByText('Jungfernstieg'))
|
|
expect(props.onOpen).toHaveBeenCalledWith(7)
|
|
expect(props.onToggleSelect).not.toHaveBeenCalled()
|
|
})
|
|
|
|
it('FE-MOB-COLL-011: the status pill cycles want → visited', () => {
|
|
const props = renderRow()
|
|
fireEvent.click(screen.getByRole('button', { name: 'Want to go' }))
|
|
expect(props.onSetStatus).toHaveBeenCalledWith(7, 'visited')
|
|
})
|
|
|
|
it('FE-MOB-COLL-012: in select mode a tap toggles the selection instead of opening', () => {
|
|
const props = renderRow({ selectMode: true })
|
|
fireEvent.click(screen.getByText('Jungfernstieg'))
|
|
expect(props.onToggleSelect).toHaveBeenCalledWith(7)
|
|
expect(props.onOpen).not.toHaveBeenCalled()
|
|
})
|
|
|
|
it('FE-MOB-COLL-013: one card holds the place and its pills, the status worded in a readable mix of its colour', () => {
|
|
renderRow()
|
|
const status = screen.getByRole('button', { name: 'Want to go' })
|
|
const place = screen.getByText('Jungfernstieg').closest('button') as HTMLElement
|
|
// Both inside the same card, not in a card of their own beside it.
|
|
expect(status.closest('.rounded-2xl')).toBe(place.parentElement)
|
|
expect(status.style.color).toContain('color-mix')
|
|
expect(status.style.color).toContain('var(--m-ink)')
|
|
})
|
|
})
|