mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-25 22:27:32 +00:00
test(components): cover map, collections, settings, journey and admin
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
// FE-W4CTX-001 to FE-W4CTX-010
|
||||
import { describe, it, expect, vi, afterEach } from 'vitest'
|
||||
import { Trash2 } from 'lucide-react'
|
||||
import { renderHook, act } from '@testing-library/react'
|
||||
import { render, screen, fireEvent } from '../../../tests/helpers/render'
|
||||
import { ContextMenu, useContextMenu } from './ContextMenu'
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
describe('useContextMenu', () => {
|
||||
it('FE-W4CTX-001: opening stores the pointer position and the items', () => {
|
||||
const { result } = renderHook(() => useContextMenu())
|
||||
const preventDefault = vi.fn()
|
||||
const stopPropagation = vi.fn()
|
||||
const items = [{ label: 'Delete' }]
|
||||
|
||||
act(() => {
|
||||
result.current.open({ clientX: 120, clientY: 40, preventDefault, stopPropagation } as unknown as React.MouseEvent, items)
|
||||
})
|
||||
|
||||
expect(result.current.menu).toEqual({ x: 120, y: 40, items })
|
||||
expect(preventDefault).toHaveBeenCalled()
|
||||
expect(stopPropagation).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('FE-W4CTX-002: closing clears the menu', () => {
|
||||
const { result } = renderHook(() => useContextMenu())
|
||||
act(() => {
|
||||
result.current.open({ clientX: 0, clientY: 0, preventDefault() {}, stopPropagation() {} } as unknown as React.MouseEvent, [])
|
||||
})
|
||||
|
||||
act(() => { result.current.close() })
|
||||
|
||||
expect(result.current.menu).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('ContextMenu', () => {
|
||||
it('FE-W4CTX-003: renders nothing without a menu', () => {
|
||||
const { container, baseElement } = render(<ContextMenu menu={null} onClose={() => {}} />)
|
||||
|
||||
expect(container).toBeEmptyDOMElement()
|
||||
expect(baseElement.querySelector('.trek-popover-enter')).toBeNull()
|
||||
})
|
||||
|
||||
it('FE-W4CTX-004: renders one button per item at the pointer position', () => {
|
||||
const { baseElement } = render(
|
||||
<ContextMenu menu={{ x: 40, y: 20, items: [{ label: 'Open' }, { label: 'Delete', icon: Trash2, danger: true }] }} onClose={() => {}} />,
|
||||
)
|
||||
|
||||
expect(screen.getAllByRole('button')).toHaveLength(2)
|
||||
expect(baseElement.querySelector('.trek-popover-enter')).toHaveStyle({ left: '40px', top: '20px' })
|
||||
})
|
||||
|
||||
it('FE-W4CTX-005: a danger item is red and carries its icon', () => {
|
||||
render(<ContextMenu menu={{ x: 0, y: 0, items: [{ label: 'Delete', icon: Trash2, danger: true }] }} onClose={() => {}} />)
|
||||
const button = screen.getByRole('button', { name: 'Delete' })
|
||||
|
||||
expect(button).toHaveStyle({ color: 'rgb(239, 68, 68)' })
|
||||
expect(button.querySelector('svg')).not.toBeNull()
|
||||
})
|
||||
|
||||
it('FE-W4CTX-006: a divider entry renders a rule instead of a button', () => {
|
||||
render(<ContextMenu menu={{ x: 0, y: 0, items: [{ label: 'Open' }, { divider: true }, { label: 'Delete' }] }} onClose={() => {}} />)
|
||||
|
||||
expect(screen.getAllByRole('button')).toHaveLength(2)
|
||||
})
|
||||
|
||||
it('FE-W4CTX-007: clicking an item runs it and closes the menu', () => {
|
||||
const onClick = vi.fn()
|
||||
const onClose = vi.fn()
|
||||
render(<ContextMenu menu={{ x: 0, y: 0, items: [{ label: 'Open', onClick }] }} onClose={onClose} />)
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Open' }))
|
||||
|
||||
expect(onClick).toHaveBeenCalledOnce()
|
||||
expect(onClose).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('FE-W4CTX-008: an item without a handler still closes the menu', () => {
|
||||
const onClose = vi.fn()
|
||||
render(<ContextMenu menu={{ x: 0, y: 0, items: [{ label: 'Open' }] }} onClose={onClose} />)
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Open' }))
|
||||
|
||||
expect(onClose).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('FE-W4CTX-009: a document click or right-click dismisses the menu', () => {
|
||||
const onClose = vi.fn()
|
||||
const { unmount } = render(<ContextMenu menu={{ x: 0, y: 0, items: [{ label: 'Open' }] }} onClose={onClose} />)
|
||||
|
||||
fireEvent.click(document)
|
||||
fireEvent.contextMenu(document)
|
||||
expect(onClose).toHaveBeenCalledTimes(2)
|
||||
|
||||
unmount()
|
||||
fireEvent.click(document)
|
||||
expect(onClose).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it('FE-W4CTX-010: flips the menu back inside the viewport when it would overflow', () => {
|
||||
vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockReturnValue({
|
||||
width: 200, height: 120, top: 0, left: 0, right: 0, bottom: 0, x: 0, y: 0, toJSON: () => ({}),
|
||||
} as DOMRect)
|
||||
Object.defineProperty(window, 'innerWidth', { writable: true, configurable: true, value: 400 })
|
||||
Object.defineProperty(window, 'innerHeight', { writable: true, configurable: true, value: 300 })
|
||||
|
||||
const { baseElement } = render(<ContextMenu menu={{ x: 380, y: 290, items: [{ label: 'Open' }] }} onClose={() => {}} />)
|
||||
|
||||
const menu = baseElement.querySelector('.trek-popover-enter') as HTMLElement
|
||||
expect(menu.style.left).toBe('192px')
|
||||
expect(menu.style.top).toBe('172px')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,97 @@
|
||||
// FE-W4CTD-001 to FE-W4CTD-009
|
||||
import type { ComponentProps } from 'react'
|
||||
import { describe, it, expect, vi } from 'vitest'
|
||||
import { render, screen, fireEvent } from '../../../tests/helpers/render'
|
||||
import CopyTripDialog from './CopyTripDialog'
|
||||
|
||||
function setup(overrides: Partial<ComponentProps<typeof CopyTripDialog>> = {}) {
|
||||
const onClose = vi.fn()
|
||||
const onConfirm = vi.fn()
|
||||
const utils = render(
|
||||
<CopyTripDialog isOpen tripTitle="Iceland 2026" onClose={onClose} onConfirm={onConfirm} {...overrides} />,
|
||||
)
|
||||
return { onClose, onConfirm, ...utils }
|
||||
}
|
||||
|
||||
describe('CopyTripDialog', () => {
|
||||
it('FE-W4CTD-001: renders nothing while closed', () => {
|
||||
const { container } = render(
|
||||
<CopyTripDialog isOpen={false} tripTitle="Iceland 2026" onClose={() => {}} onConfirm={() => {}} />,
|
||||
)
|
||||
|
||||
expect(container).toBeEmptyDOMElement()
|
||||
expect(screen.queryByText('Iceland 2026')).toBeNull()
|
||||
})
|
||||
|
||||
it('FE-W4CTD-002: shows the trip title and both copy lists', () => {
|
||||
setup()
|
||||
|
||||
expect(screen.getByText('Iceland 2026')).toBeInTheDocument()
|
||||
// 6 "will copy" + 4 "won't copy" bullets.
|
||||
expect(screen.getAllByRole('listitem')).toHaveLength(10)
|
||||
})
|
||||
|
||||
it('FE-W4CTD-003: confirming calls onConfirm and then closes', () => {
|
||||
const { onClose, onConfirm } = setup()
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: /copy/i }))
|
||||
|
||||
expect(onConfirm).toHaveBeenCalledOnce()
|
||||
expect(onClose).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('FE-W4CTD-004: cancel closes without confirming', () => {
|
||||
const { onClose, onConfirm } = setup()
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: /cancel/i }))
|
||||
|
||||
expect(onClose).toHaveBeenCalledOnce()
|
||||
expect(onConfirm).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('FE-W4CTD-005: clicking the backdrop closes the dialog', () => {
|
||||
const { onClose, baseElement } = setup()
|
||||
const backdrop = baseElement.querySelector('.trek-backdrop-enter')!
|
||||
|
||||
fireEvent.click(backdrop)
|
||||
|
||||
expect(onClose).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('FE-W4CTD-006: clicking inside the card does not close it', () => {
|
||||
const { onClose, baseElement } = setup()
|
||||
|
||||
fireEvent.click(baseElement.querySelector('.trek-modal-enter')!)
|
||||
|
||||
expect(onClose).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('FE-W4CTD-007: Escape closes the dialog', () => {
|
||||
const { onClose } = setup()
|
||||
|
||||
fireEvent.keyDown(document, { key: 'Escape' })
|
||||
|
||||
expect(onClose).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('FE-W4CTD-008: other keys are ignored and the listener is dropped on close', () => {
|
||||
const onClose = vi.fn()
|
||||
const { rerender } = render(
|
||||
<CopyTripDialog isOpen tripTitle="Iceland 2026" onClose={onClose} onConfirm={() => {}} />,
|
||||
)
|
||||
|
||||
fireEvent.keyDown(document, { key: 'Enter' })
|
||||
expect(onClose).not.toHaveBeenCalled()
|
||||
|
||||
rerender(<CopyTripDialog isOpen={false} tripTitle="Iceland 2026" onClose={onClose} onConfirm={() => {}} />)
|
||||
fireEvent.keyDown(document, { key: 'Escape' })
|
||||
expect(onClose).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('FE-W4CTD-009: portals the dialog to document.body', () => {
|
||||
const { container, baseElement } = setup()
|
||||
|
||||
expect(container).toBeEmptyDOMElement()
|
||||
expect(baseElement.querySelector('.trek-backdrop-enter')).not.toBeNull()
|
||||
})
|
||||
})
|
||||
@@ -367,3 +367,351 @@ describe('CustomDateTimePicker', () => {
|
||||
expect(yr2026.getAttribute('aria-pressed')).toBe('true');
|
||||
});
|
||||
});
|
||||
|
||||
// FE-W5DP-001 to FE-W5DP-021 — the remaining calendar branches: year/month
|
||||
// wrapping, the locale-order parser arms, viewport clamping of the popup,
|
||||
// compact/borderless layout and the hover styling of every grid cell.
|
||||
describe('CustomDatePicker branches', () => {
|
||||
const onChange = vi.fn();
|
||||
const openCalendar = () => fireEvent.click(screen.getAllByRole('button')[0]);
|
||||
const dayCell = (label: string) =>
|
||||
screen.getAllByRole('button').find((b) => b.textContent?.trim() === label) as HTMLButtonElement;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('FE-W5DP-001: a mousedown inside the trigger or the popup keeps the calendar open', () => {
|
||||
const { container } = render(<CustomDatePicker value="2026-03-15" onChange={onChange} />);
|
||||
openCalendar();
|
||||
const dialog = screen.getByRole('dialog');
|
||||
|
||||
fireEvent.mouseDown(container.firstElementChild!);
|
||||
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
||||
|
||||
fireEvent.mouseDown(dialog);
|
||||
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-W5DP-002: with only a max bound the calendar opens on that month', () => {
|
||||
render(<CustomDatePicker value="" onChange={onChange} max="2026-11-20" />);
|
||||
openCalendar();
|
||||
expect(screen.getByText(/november 2026/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-W5DP-003: paging back from January lands on the previous December', () => {
|
||||
render(<CustomDatePicker value="2026-01-15" onChange={onChange} />);
|
||||
openCalendar();
|
||||
fireEvent.click(screen.getByRole('button', { name: /previous month/i }));
|
||||
expect(screen.getByText(/december 2025/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-W5DP-004: paging forward from December lands on the next January', () => {
|
||||
render(<CustomDatePicker value="2026-12-15" onChange={onChange} />);
|
||||
openCalendar();
|
||||
fireEvent.click(screen.getByRole('button', { name: /next month/i }));
|
||||
expect(screen.getByText(/january 2027/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-W5DP-005: the months view pages the year in both directions', () => {
|
||||
render(<CustomDatePicker value="2026-03-15" onChange={onChange} />);
|
||||
openCalendar();
|
||||
fireEvent.click(screen.getByRole('button', { name: /select month/i }));
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: /next year/i }));
|
||||
expect(screen.getByRole('button', { name: 'March 2027' })).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button', { name: /previous year/i }));
|
||||
expect(screen.getByRole('button', { name: 'March 2026' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-W5DP-006: the years view pages the grid in both directions', () => {
|
||||
render(<CustomDatePicker value="2026-03-15" onChange={onChange} />);
|
||||
openCalendar();
|
||||
fireEvent.click(screen.getByRole('button', { name: /select month/i }));
|
||||
fireEvent.click(screen.getByRole('button', { name: /select year/i }));
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: /previous years/i }));
|
||||
expect(screen.getByRole('button', { name: '2014' })).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button', { name: /next years/i }));
|
||||
expect(screen.getByRole('button', { name: '2026' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-W5DP-007: compact mode renders the short numeric date and drops the calendar glyph', () => {
|
||||
const { container } = render(<CustomDatePicker value="2026-03-15" onChange={onChange} compact />);
|
||||
expect(screen.getByText('03/15/26')).toBeInTheDocument();
|
||||
expect(container.querySelector('.lucide-calendar')).toBeNull();
|
||||
});
|
||||
|
||||
it('FE-W5DP-008: borderless mode drops the border and the inline keyboard trigger', () => {
|
||||
render(<CustomDatePicker value="2026-03-15" onChange={onChange} borderless />);
|
||||
const trigger = screen.getAllByRole('button')[0];
|
||||
expect(trigger.style.borderStyle).toBe('none');
|
||||
expect(trigger.style.background).toBe('transparent');
|
||||
expect(screen.queryByRole('button', { name: /enter date manually/i })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-W5DP-009: the trigger only resets its border colour while the calendar is closed', () => {
|
||||
render(<CustomDatePicker value="" onChange={onChange} />);
|
||||
const trigger = screen.getAllByRole('button')[0];
|
||||
|
||||
fireEvent.mouseEnter(trigger);
|
||||
expect(trigger.style.borderColor).toBe('var(--text-faint)');
|
||||
fireEvent.mouseLeave(trigger);
|
||||
expect(trigger.style.borderColor).toBe('var(--border-primary)');
|
||||
|
||||
fireEvent.click(trigger);
|
||||
fireEvent.mouseEnter(trigger);
|
||||
fireEvent.mouseLeave(trigger);
|
||||
expect(trigger.style.borderColor).toBe('var(--text-faint)');
|
||||
});
|
||||
|
||||
it('FE-W5DP-022: the inline manual-entry trigger highlights on hover', () => {
|
||||
render(<CustomDatePicker value="" onChange={onChange} />);
|
||||
const keyboard = screen.getByRole('button', { name: /enter date manually/i });
|
||||
|
||||
fireEvent.mouseEnter(keyboard);
|
||||
expect(keyboard.style.color).toBe('var(--text-primary)');
|
||||
expect(keyboard.style.borderColor).toBe('var(--text-faint)');
|
||||
fireEvent.mouseLeave(keyboard);
|
||||
expect(keyboard.style.color).toBe('var(--text-faint)');
|
||||
expect(keyboard.style.borderColor).toBe('var(--border-primary)');
|
||||
});
|
||||
|
||||
it('FE-W5DP-023: the compact footer trigger opens an empty manual entry when no date is set', () => {
|
||||
render(<CustomDatePicker value="" onChange={onChange} compact />);
|
||||
openCalendar();
|
||||
fireEvent.click(screen.getByRole('button', { name: /enter date manually/i }));
|
||||
|
||||
expect(screen.getByPlaceholderText('DD.MM.YYYY')).toHaveProperty('value', '');
|
||||
});
|
||||
|
||||
it('FE-W5DP-010: submitting an empty manual entry does nothing', () => {
|
||||
render(<CustomDatePicker value="" onChange={onChange} />);
|
||||
fireEvent.click(screen.getByRole('button', { name: /enter date manually/i }));
|
||||
fireEvent.blur(screen.getByPlaceholderText('DD.MM.YYYY'));
|
||||
|
||||
expect(onChange).not.toHaveBeenCalled();
|
||||
expect(screen.queryByPlaceholderText('DD.MM.YYYY')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-W5DP-011: a manual entry without three number groups is ignored', () => {
|
||||
render(<CustomDatePicker value="" onChange={onChange} />);
|
||||
fireEvent.click(screen.getByRole('button', { name: /enter date manually/i }));
|
||||
const input = screen.getByPlaceholderText('DD.MM.YYYY');
|
||||
fireEvent.change(input, { target: { value: '17.07' } });
|
||||
fireEvent.keyDown(input, { key: 'Enter' });
|
||||
|
||||
expect(onChange).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('FE-W5DP-012: a manual entry already in locale order is taken as typed', () => {
|
||||
render(<CustomDatePicker value="" onChange={onChange} />);
|
||||
fireEvent.click(screen.getByRole('button', { name: /enter date manually/i }));
|
||||
const input = screen.getByPlaceholderText('DD.MM.YYYY');
|
||||
fireEvent.change(input, { target: { value: '07/17/2026' } });
|
||||
fireEvent.keyDown(input, { key: 'Enter' });
|
||||
|
||||
expect(onChange).toHaveBeenCalledWith('2026-07-17');
|
||||
});
|
||||
|
||||
it('FE-W5DP-013: a two-digit year is expanded into the 2000s', () => {
|
||||
render(<CustomDatePicker value="" onChange={onChange} />);
|
||||
fireEvent.click(screen.getByRole('button', { name: /enter date manually/i }));
|
||||
const input = screen.getByPlaceholderText('DD.MM.YYYY');
|
||||
fireEvent.change(input, { target: { value: '07/17/26' } });
|
||||
fireEvent.keyDown(input, { key: 'Enter' });
|
||||
|
||||
expect(onChange).toHaveBeenCalledWith('2026-07-17');
|
||||
});
|
||||
|
||||
it('FE-W5DP-014: an impossible day/month combination is rejected', () => {
|
||||
render(<CustomDatePicker value="" onChange={onChange} />);
|
||||
fireEvent.click(screen.getByRole('button', { name: /enter date manually/i }));
|
||||
const input = screen.getByPlaceholderText('DD.MM.YYYY');
|
||||
fireEvent.change(input, { target: { value: '13/45/2026' } });
|
||||
fireEvent.keyDown(input, { key: 'Enter' });
|
||||
|
||||
expect(onChange).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('FE-W5DP-015: a localised manual entry outside [min,max] is rejected', () => {
|
||||
render(<CustomDatePicker value="" onChange={onChange} min="2026-03-10" max="2026-03-20" />);
|
||||
fireEvent.click(screen.getByRole('button', { name: /enter date manually/i }));
|
||||
const input = screen.getByPlaceholderText('DD.MM.YYYY');
|
||||
fireEvent.change(input, { target: { value: '03/25/2026' } });
|
||||
fireEvent.keyDown(input, { key: 'Enter' });
|
||||
|
||||
expect(onChange).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('FE-W5DP-016: the popup is clamped back into a narrow viewport', () => {
|
||||
const originalRect = Element.prototype.getBoundingClientRect;
|
||||
const originalWidth = window.innerWidth;
|
||||
Element.prototype.getBoundingClientRect = function () {
|
||||
return { left: 900, top: 700, right: 1100, bottom: 740, width: 200, height: 40, x: 900, y: 700, toJSON: () => ({}) } as DOMRect;
|
||||
};
|
||||
Object.defineProperty(window, 'innerWidth', { value: 320, configurable: true });
|
||||
|
||||
try {
|
||||
render(<CustomDatePicker value="2026-03-15" onChange={onChange} />);
|
||||
openCalendar();
|
||||
const dialog = screen.getByRole('dialog');
|
||||
// vw < 360 centres the 268px popup; the popup flips above the trigger
|
||||
expect(dialog.style.left).toBe('26px');
|
||||
expect(dialog.style.top).toBe('336px');
|
||||
} finally {
|
||||
Element.prototype.getBoundingClientRect = originalRect;
|
||||
Object.defineProperty(window, 'innerWidth', { value: originalWidth, configurable: true });
|
||||
}
|
||||
});
|
||||
|
||||
it('FE-W5DP-017: the popup prefers the visual viewport height when one is reported', () => {
|
||||
const originalRect = Element.prototype.getBoundingClientRect;
|
||||
Element.prototype.getBoundingClientRect = function () {
|
||||
return { left: 20, top: 40, right: 220, bottom: 80, width: 200, height: 40, x: 20, y: 40, toJSON: () => ({}) } as DOMRect;
|
||||
};
|
||||
Object.defineProperty(window, 'visualViewport', { value: { height: 900 }, configurable: true });
|
||||
|
||||
try {
|
||||
render(<CustomDatePicker value="2026-03-15" onChange={onChange} />);
|
||||
openCalendar();
|
||||
const dialog = screen.getByRole('dialog');
|
||||
expect(dialog.style.left).toBe('20px');
|
||||
expect(dialog.style.top).toBe('84px');
|
||||
} finally {
|
||||
Element.prototype.getBoundingClientRect = originalRect;
|
||||
Object.defineProperty(window, 'visualViewport', { value: undefined, configurable: true });
|
||||
}
|
||||
});
|
||||
|
||||
it('FE-W5DP-018: the header arrows and the label highlight on hover', () => {
|
||||
render(<CustomDatePicker value="2026-03-15" onChange={onChange} />);
|
||||
openCalendar();
|
||||
|
||||
for (const name of [/previous month/i, /next month/i]) {
|
||||
const btn = screen.getByRole('button', { name });
|
||||
fireEvent.mouseEnter(btn);
|
||||
expect(btn.style.color).toBe('var(--text-primary)');
|
||||
fireEvent.mouseLeave(btn);
|
||||
expect(btn.style.color).toBe('var(--text-faint)');
|
||||
}
|
||||
|
||||
const header = screen.getByRole('button', { name: /select month/i });
|
||||
fireEvent.mouseEnter(header);
|
||||
expect(header.style.background).toBe('var(--bg-hover)');
|
||||
fireEvent.mouseLeave(header);
|
||||
expect(header.style.background).toBe('none');
|
||||
});
|
||||
|
||||
it('FE-W5DP-019: only free day cells take the hover background', () => {
|
||||
render(<CustomDatePicker value="2026-03-15" onChange={onChange} min="2026-03-10" max="2026-03-20" />);
|
||||
openCalendar();
|
||||
|
||||
const free = dayCell('12');
|
||||
fireEvent.mouseEnter(free);
|
||||
expect(free.style.background).toBe('var(--bg-hover)');
|
||||
fireEvent.mouseLeave(free);
|
||||
expect(free.style.background).toBe('transparent');
|
||||
|
||||
const selected = dayCell('15');
|
||||
fireEvent.mouseEnter(selected);
|
||||
expect(selected.style.background).toBe('var(--accent)');
|
||||
fireEvent.mouseLeave(selected);
|
||||
expect(selected.style.background).toBe('var(--accent)');
|
||||
|
||||
const blocked = dayCell('5');
|
||||
fireEvent.mouseEnter(blocked);
|
||||
expect(blocked.style.background).toBe('transparent');
|
||||
});
|
||||
|
||||
it('FE-W5DP-020: month and year cells take the hover background unless selected', () => {
|
||||
render(<CustomDatePicker value="2026-03-15" onChange={onChange} />);
|
||||
openCalendar();
|
||||
fireEvent.click(screen.getByRole('button', { name: /select month/i }));
|
||||
|
||||
const may = screen.getByRole('button', { name: 'May 2026' });
|
||||
fireEvent.mouseEnter(may);
|
||||
expect(may.style.background).toBe('var(--bg-hover)');
|
||||
fireEvent.mouseLeave(may);
|
||||
expect(may.style.background).toBe('transparent');
|
||||
|
||||
const march = screen.getByRole('button', { name: 'March 2026' });
|
||||
fireEvent.mouseEnter(march);
|
||||
fireEvent.mouseLeave(march);
|
||||
expect(march.style.background).toBe('var(--accent)');
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: /select year/i }));
|
||||
const y2027 = screen.getByRole('button', { name: '2027' });
|
||||
fireEvent.mouseEnter(y2027);
|
||||
expect(y2027.style.background).toBe('var(--bg-hover)');
|
||||
fireEvent.mouseLeave(y2027);
|
||||
expect(y2027.style.background).toBe('transparent');
|
||||
|
||||
const y2026 = screen.getByRole('button', { name: '2026' });
|
||||
fireEvent.mouseEnter(y2026);
|
||||
fireEvent.mouseLeave(y2026);
|
||||
expect(y2026.style.background).toBe('var(--accent)');
|
||||
});
|
||||
|
||||
it('FE-W5DP-021: in compact mode the manual-entry trigger moves into the popup footer', () => {
|
||||
render(<CustomDatePicker value="2026-03-15" onChange={onChange} compact />);
|
||||
openCalendar();
|
||||
|
||||
const keyboard = screen.getByRole('button', { name: /enter date manually/i });
|
||||
fireEvent.mouseEnter(keyboard);
|
||||
expect(keyboard.style.color).toBe('var(--text-primary)');
|
||||
fireEvent.mouseLeave(keyboard);
|
||||
expect(keyboard.style.color).toBe('var(--text-faint)');
|
||||
|
||||
const clear = screen.getByRole('button', { name: /clear date/i });
|
||||
fireEvent.mouseEnter(clear);
|
||||
expect(clear.style.color).toBe('rgb(239, 68, 68)');
|
||||
fireEvent.mouseLeave(clear);
|
||||
expect(clear.style.color).toBe('var(--text-faint)');
|
||||
|
||||
fireEvent.click(keyboard);
|
||||
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
||||
expect(screen.getByPlaceholderText('DD.MM.YYYY')).toHaveProperty('value', '03/15/2026');
|
||||
});
|
||||
});
|
||||
|
||||
// FE-W5DTP-001 to FE-W5DTP-002
|
||||
describe('CustomDateTimePicker branches', () => {
|
||||
const onChange = vi.fn();
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
useSettingsStore.setState({
|
||||
settings: { ...useSettingsStore.getState().settings, time_format: '24h' },
|
||||
});
|
||||
});
|
||||
|
||||
it('FE-W5DTP-001: clearing the date clears the whole value', () => {
|
||||
render(<CustomDateTimePicker value="2026-03-15T09:30" onChange={onChange} />);
|
||||
fireEvent.click(screen.getAllByRole('button')[0]);
|
||||
fireEvent.click(screen.getByRole('button', { name: /clear date/i }));
|
||||
|
||||
expect(onChange).toHaveBeenCalledWith('');
|
||||
});
|
||||
|
||||
it('FE-W5DTP-003: setting a time without a date falls back to today', () => {
|
||||
render(<CustomDateTimePicker value="" onChange={onChange} />);
|
||||
const clockBtn = screen.getAllByRole('button').filter((b) => b.textContent?.trim() === '').pop();
|
||||
fireEvent.click(clockBtn!);
|
||||
// hour up on an empty time yields 01:00 on today's date
|
||||
const steppers = screen.getAllByRole('button').filter((b) => b.textContent?.trim() === '');
|
||||
fireEvent.click(steppers[steppers.length - 4]);
|
||||
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
expect(onChange).toHaveBeenCalledWith(`${today}T01:00`);
|
||||
});
|
||||
|
||||
it('FE-W5DTP-002: clearing the time keeps the date part', () => {
|
||||
render(<CustomDateTimePicker value="2026-03-15T09:30" onChange={onChange} />);
|
||||
const clockBtn = screen.getAllByRole('button').filter((b) => b.textContent?.trim() === '').pop();
|
||||
fireEvent.click(clockBtn!);
|
||||
fireEvent.click(screen.getByText('✕'));
|
||||
|
||||
expect(onChange).toHaveBeenCalledWith('2026-03-15');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -206,3 +206,273 @@ describe('CustomTimePicker', () => {
|
||||
expect(screen.queryByText('✕')).toBeNull(); // clear button gone = dropdown closed
|
||||
});
|
||||
});
|
||||
|
||||
// FE-W5TP-001 to FE-W5TP-024 — remaining branches: 12h display arms, null-hour
|
||||
// stepping, the minute-down button, handleInput/handleBlur parse arms and the
|
||||
// hover styling of the stepper buttons.
|
||||
describe('CustomTimePicker branches', () => {
|
||||
const onChange = vi.fn();
|
||||
|
||||
// [0] clock trigger, [1] hour up, [2] hour down, [3] min up, [4] min down,
|
||||
// [5]/[6] AM/PM up/down (12h only). The clear button carries a glyph.
|
||||
const steppers = () => screen.getAllByRole('button').filter(b => b.textContent?.trim() === '');
|
||||
const openDropdown = () => fireEvent.click(steppers()[0]);
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
resetAllStores();
|
||||
seedStore(useSettingsStore, { settings: buildSettings({ time_format: '24h' }) });
|
||||
});
|
||||
|
||||
const use12h = () => seedStore(useSettingsStore, { settings: buildSettings({ time_format: '12h' }) });
|
||||
|
||||
it('FE-W5TP-001: renders midnight as 12 AM in 12h mode', () => {
|
||||
use12h();
|
||||
render(<CustomTimePicker value="00:15" onChange={onChange} />);
|
||||
expect(screen.getByRole('textbox')).toHaveProperty('value', '12:15 AM');
|
||||
});
|
||||
|
||||
it('FE-W5TP-002: keeps morning hours unshifted in 12h mode', () => {
|
||||
use12h();
|
||||
render(<CustomTimePicker value="09:05" onChange={onChange} />);
|
||||
expect(screen.getByRole('textbox')).toHaveProperty('value', '9:05 AM');
|
||||
});
|
||||
|
||||
it('FE-W5TP-003: leaves an unparseable value untouched in 12h mode', () => {
|
||||
use12h();
|
||||
render(<CustomTimePicker value="later" onChange={onChange} />);
|
||||
expect(screen.getByRole('textbox')).toHaveProperty('value', 'later');
|
||||
});
|
||||
|
||||
it('FE-W5TP-004: shows -- for an unparseable hour and minute', () => {
|
||||
render(<CustomTimePicker value="later" onChange={onChange} />);
|
||||
openDropdown();
|
||||
expect(screen.getAllByText('--')).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('FE-W5TP-005: stepping up from an unparseable hour lands on 00', () => {
|
||||
render(<CustomTimePicker value="later" onChange={onChange} />);
|
||||
openDropdown();
|
||||
fireEvent.click(steppers()[1]);
|
||||
expect(onChange).toHaveBeenCalledWith('00:00');
|
||||
});
|
||||
|
||||
it('FE-W5TP-006: stepping down from an unparseable hour lands on 00', () => {
|
||||
render(<CustomTimePicker value="later" onChange={onChange} />);
|
||||
openDropdown();
|
||||
fireEvent.click(steppers()[2]);
|
||||
expect(onChange).toHaveBeenCalledWith('00:00');
|
||||
});
|
||||
|
||||
it('FE-W5TP-007: the minute-down button borrows an hour when it wraps below zero', () => {
|
||||
render(<CustomTimePicker value="10:00" onChange={onChange} />);
|
||||
openDropdown();
|
||||
fireEvent.click(steppers()[4]);
|
||||
expect(onChange).toHaveBeenCalledWith('09:55');
|
||||
});
|
||||
|
||||
it('FE-W5TP-008: the minute-down button keeps the hour when it does not wrap', () => {
|
||||
render(<CustomTimePicker value="10:30" onChange={onChange} />);
|
||||
openDropdown();
|
||||
fireEvent.click(steppers()[4]);
|
||||
expect(onChange).toHaveBeenCalledWith('10:25');
|
||||
});
|
||||
|
||||
it('FE-W5TP-009: stepping minutes with no minute set falls back to :00', () => {
|
||||
render(<CustomTimePicker value="10" onChange={onChange} />);
|
||||
openDropdown();
|
||||
fireEvent.click(steppers()[3]);
|
||||
expect(onChange).toHaveBeenLastCalledWith('10:00');
|
||||
fireEvent.click(steppers()[4]);
|
||||
expect(onChange).toHaveBeenLastCalledWith('10:00');
|
||||
});
|
||||
|
||||
it('FE-W5TP-010: typing in 12h mode is passed through unparsed', () => {
|
||||
use12h();
|
||||
render(<CustomTimePicker value="" onChange={onChange} />);
|
||||
fireEvent.change(screen.getByRole('textbox'), { target: { value: '5:30 pm' } });
|
||||
expect(onChange).toHaveBeenCalledTimes(1);
|
||||
expect(onChange).toHaveBeenCalledWith('5:30 pm');
|
||||
});
|
||||
|
||||
it('FE-W5TP-011: typing four digits inserts the colon while editing', () => {
|
||||
render(<CustomTimePicker value="" onChange={onChange} />);
|
||||
fireEvent.change(screen.getByRole('textbox'), { target: { value: '1430' } });
|
||||
expect(onChange).toHaveBeenLastCalledWith('14:30');
|
||||
});
|
||||
|
||||
it('FE-W5TP-012: typing a single-digit hour pads it while editing', () => {
|
||||
render(<CustomTimePicker value="" onChange={onChange} />);
|
||||
fireEvent.change(screen.getByRole('textbox'), { target: { value: '9:05' } });
|
||||
expect(onChange).toHaveBeenLastCalledWith('09:05');
|
||||
});
|
||||
|
||||
it('FE-W5TP-013: typing a complete HH:MM leaves it as is', () => {
|
||||
render(<CustomTimePicker value="" onChange={onChange} />);
|
||||
fireEvent.change(screen.getByRole('textbox'), { target: { value: '14:30' } });
|
||||
expect(onChange).toHaveBeenCalledTimes(2);
|
||||
expect(onChange).toHaveBeenLastCalledWith('14:30');
|
||||
});
|
||||
|
||||
it('FE-W5TP-014: blurring an empty field does not emit', () => {
|
||||
render(<CustomTimePicker value="" onChange={onChange} />);
|
||||
fireEvent.blur(screen.getByRole('textbox'));
|
||||
expect(onChange).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('FE-W5TP-015: blurring an unparseable value does not emit', () => {
|
||||
render(<CustomTimePicker value="later" onChange={onChange} />);
|
||||
fireEvent.blur(screen.getByRole('textbox'));
|
||||
expect(onChange).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('FE-W5TP-016: 12h blur handles a bare hour with a meridiem', () => {
|
||||
use12h();
|
||||
render(<CustomTimePicker value="5pm" onChange={onChange} />);
|
||||
fireEvent.blur(screen.getByRole('textbox'));
|
||||
expect(onChange).toHaveBeenCalledWith('17:00');
|
||||
});
|
||||
|
||||
it('FE-W5TP-017: 12h blur maps 12 AM to midnight and 12 PM to noon', () => {
|
||||
use12h();
|
||||
const { unmount } = render(<CustomTimePicker value="12:30 AM" onChange={onChange} />);
|
||||
fireEvent.blur(screen.getByRole('textbox'));
|
||||
expect(onChange).toHaveBeenCalledWith('00:30');
|
||||
unmount();
|
||||
|
||||
onChange.mockClear();
|
||||
render(<CustomTimePicker value="12:30 PM" onChange={onChange} />);
|
||||
fireEvent.blur(screen.getByRole('textbox'));
|
||||
expect(onChange).toHaveBeenCalledWith('12:30');
|
||||
});
|
||||
|
||||
it('FE-W5TP-018: 12h blur falls back to the numeric parser when no meridiem is given', () => {
|
||||
use12h();
|
||||
render(<CustomTimePicker value="1430" onChange={onChange} />);
|
||||
fireEvent.blur(screen.getByRole('textbox'));
|
||||
expect(onChange).toHaveBeenCalledWith('14:30');
|
||||
});
|
||||
|
||||
it('FE-W5TP-019: blur clamps out-of-range hours and minutes', () => {
|
||||
render(<CustomTimePicker value="99:99" onChange={onChange} />);
|
||||
fireEvent.blur(screen.getByRole('textbox'));
|
||||
expect(onChange).toHaveBeenCalledWith('23:59');
|
||||
});
|
||||
|
||||
it('FE-W5TP-020: blur pads a three-digit entry to HH:MM', () => {
|
||||
render(<CustomTimePicker value="945" onChange={onChange} />);
|
||||
fireEvent.blur(screen.getByRole('textbox'));
|
||||
expect(onChange).toHaveBeenCalledWith('09:45');
|
||||
});
|
||||
|
||||
it('FE-W5TP-021: a mousedown inside the field keeps the dropdown open', () => {
|
||||
const { container } = render(<CustomTimePicker value="10:00" onChange={onChange} />);
|
||||
openDropdown();
|
||||
fireEvent.mouseDown(container.firstElementChild!);
|
||||
expect(screen.getByText('✕')).toBeInTheDocument();
|
||||
|
||||
fireEvent.mouseDown(screen.getByText('✕'));
|
||||
expect(screen.getByText('✕')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-W5TP-022: the AM/PM stepper flips an AM hour to PM in both directions', () => {
|
||||
use12h();
|
||||
render(<CustomTimePicker value="02:00" onChange={onChange} />);
|
||||
openDropdown();
|
||||
expect(screen.getByText('AM')).toBeInTheDocument();
|
||||
|
||||
fireEvent.click(steppers()[5]);
|
||||
expect(onChange).toHaveBeenLastCalledWith('14:00');
|
||||
fireEvent.click(steppers()[6]);
|
||||
expect(onChange).toHaveBeenLastCalledWith('14:00');
|
||||
});
|
||||
|
||||
it('FE-W5TP-023: the AM/PM stepper flips a PM hour back to AM', () => {
|
||||
use12h();
|
||||
render(<CustomTimePicker value="14:00" onChange={onChange} />);
|
||||
openDropdown();
|
||||
fireEvent.click(steppers()[5]);
|
||||
expect(onChange).toHaveBeenLastCalledWith('02:00');
|
||||
fireEvent.click(steppers()[6]);
|
||||
expect(onChange).toHaveBeenLastCalledWith('02:00');
|
||||
});
|
||||
|
||||
it('FE-W5TP-025: stepping minutes with neither hour nor minute set lands on 00:00', () => {
|
||||
render(<CustomTimePicker value="later" onChange={onChange} />);
|
||||
openDropdown();
|
||||
fireEvent.click(steppers()[3]);
|
||||
expect(onChange).toHaveBeenLastCalledWith('00:00');
|
||||
fireEvent.click(steppers()[4]);
|
||||
expect(onChange).toHaveBeenLastCalledWith('00:00');
|
||||
});
|
||||
|
||||
it('FE-W5TP-028: minute wrapping carries an unparseable hour to 01 and 23', () => {
|
||||
const { unmount } = render(<CustomTimePicker value="x:55" onChange={onChange} />);
|
||||
openDropdown();
|
||||
fireEvent.click(steppers()[3]);
|
||||
expect(onChange).toHaveBeenLastCalledWith('01:00');
|
||||
unmount();
|
||||
|
||||
onChange.mockClear();
|
||||
render(<CustomTimePicker value="x:00" onChange={onChange} />);
|
||||
openDropdown();
|
||||
fireEvent.click(steppers()[4]);
|
||||
expect(onChange).toHaveBeenLastCalledWith('23:55');
|
||||
});
|
||||
|
||||
it('FE-W5TP-029: the AM/PM stepper defaults the minute when none is set', () => {
|
||||
use12h();
|
||||
const { unmount } = render(<CustomTimePicker value="14" onChange={onChange} />);
|
||||
openDropdown();
|
||||
fireEvent.click(steppers()[5]);
|
||||
expect(onChange).toHaveBeenLastCalledWith('02:00');
|
||||
|
||||
onChange.mockClear();
|
||||
fireEvent.click(steppers()[6]);
|
||||
expect(onChange).toHaveBeenLastCalledWith('02:00');
|
||||
unmount();
|
||||
|
||||
onChange.mockClear();
|
||||
render(<CustomTimePicker value="02" onChange={onChange} />);
|
||||
openDropdown();
|
||||
fireEvent.click(steppers()[5]);
|
||||
expect(onChange).toHaveBeenLastCalledWith('14:00');
|
||||
fireEvent.click(steppers()[6]);
|
||||
expect(onChange).toHaveBeenLastCalledWith('14:00');
|
||||
});
|
||||
|
||||
it('FE-W5TP-026: typing a value with no digits is passed through unchanged', () => {
|
||||
render(<CustomTimePicker value="" onChange={onChange} />);
|
||||
fireEvent.change(screen.getByRole('textbox'), { target: { value: 'noon' } });
|
||||
expect(onChange).toHaveBeenCalledTimes(1);
|
||||
expect(onChange).toHaveBeenCalledWith('noon');
|
||||
});
|
||||
|
||||
it('FE-W5TP-027: 12h blur keeps an AM hour below noon', () => {
|
||||
use12h();
|
||||
render(<CustomTimePicker value="5:30 AM" onChange={onChange} />);
|
||||
fireEvent.blur(screen.getByRole('textbox'));
|
||||
expect(onChange).toHaveBeenCalledWith('05:30');
|
||||
});
|
||||
|
||||
it('FE-W5TP-024: the steppers and the clear button highlight on hover', () => {
|
||||
use12h();
|
||||
render(<CustomTimePicker value="00:30" onChange={onChange} />);
|
||||
openDropdown();
|
||||
// 12 is the 12h rendering of hour 0
|
||||
expect(screen.getByText('12')).toBeInTheDocument();
|
||||
|
||||
for (const btn of steppers()) {
|
||||
fireEvent.mouseEnter(btn);
|
||||
expect(btn.style.color).toBe('var(--text-primary)');
|
||||
fireEvent.mouseLeave(btn);
|
||||
expect(btn.style.color).toBe('var(--text-faint)');
|
||||
}
|
||||
|
||||
const clear = screen.getByText('✕');
|
||||
fireEvent.mouseEnter(clear);
|
||||
expect(clear.style.color).toBe('rgb(239, 68, 68)');
|
||||
fireEvent.mouseLeave(clear);
|
||||
expect(clear.style.color).toBe('var(--text-faint)');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// FE-W4GB-001 to FE-W4GB-003
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { render, screen } from '../../../tests/helpers/render'
|
||||
import GuestBadge from './GuestBadge'
|
||||
|
||||
describe('GuestBadge', () => {
|
||||
it('FE-W4GB-001: renders the translated guest label with the accountless hint as title', () => {
|
||||
render(<GuestBadge />)
|
||||
const pill = screen.getByTitle(/without an account/i)
|
||||
|
||||
expect(pill).toHaveTextContent('Guest')
|
||||
expect(pill.querySelector('svg')).not.toBeNull()
|
||||
})
|
||||
|
||||
it('FE-W4GB-002: sizes the label at 10px by default', () => {
|
||||
render(<GuestBadge />)
|
||||
expect(screen.getByTitle(/without an account/i)).toHaveStyle({ fontSize: 'calc(10px * var(--fs-scale-caption, 1))' })
|
||||
})
|
||||
|
||||
it('FE-W4GB-003: shrinks to 9px in the xs variant', () => {
|
||||
render(<GuestBadge size="xs" />)
|
||||
expect(screen.getByTitle(/without an account/i)).toHaveStyle({ fontSize: 'calc(9px * var(--fs-scale-caption, 1))' })
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,66 @@
|
||||
// FE-W4SKEL-001 to FE-W4SKEL-008
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { render } from '../../../tests/helpers/render'
|
||||
import Skeleton, { SpotlightSkeleton, TripCardSkeleton, DaySkeleton } from './Skeleton'
|
||||
|
||||
describe('Skeleton', () => {
|
||||
it('FE-W4SKEL-001: defaults to a 14px-high shimmer bar hidden from a11y', () => {
|
||||
const { container } = render(<Skeleton />)
|
||||
const el = container.querySelector('.trek-skeleton') as HTMLElement
|
||||
|
||||
expect(el).not.toBeNull()
|
||||
expect(el.style.height).toBe('14px')
|
||||
expect(el).toHaveAttribute('aria-hidden')
|
||||
})
|
||||
|
||||
it('FE-W4SKEL-002: applies width, height and radius', () => {
|
||||
const { container } = render(<Skeleton width={120} height={40} radius={8} />)
|
||||
const el = container.querySelector('.trek-skeleton') as HTMLElement
|
||||
|
||||
expect(el.style.width).toBe('120px')
|
||||
expect(el.style.height).toBe('40px')
|
||||
expect(el.style.borderRadius).toBe('8px')
|
||||
})
|
||||
|
||||
it('FE-W4SKEL-003: accepts string sizes and merges extra style', () => {
|
||||
const { container } = render(<Skeleton width="60%" style={{ marginBottom: 8 }} />)
|
||||
const el = container.querySelector('.trek-skeleton') as HTMLElement
|
||||
|
||||
expect(el.style.width).toBe('60%')
|
||||
expect(el.style.marginBottom).toBe('8px')
|
||||
})
|
||||
|
||||
it('FE-W4SKEL-004: appends a caller className without dropping the base class', () => {
|
||||
const { container } = render(<Skeleton className="mt-2" />)
|
||||
const el = container.querySelector('.trek-skeleton') as HTMLElement
|
||||
|
||||
expect(el.className).toBe('trek-skeleton mt-2')
|
||||
})
|
||||
|
||||
it('FE-W4SKEL-005: trims the class list when no className is given', () => {
|
||||
const { container } = render(<Skeleton />)
|
||||
expect((container.firstElementChild as HTMLElement).className).toBe('trek-skeleton')
|
||||
})
|
||||
})
|
||||
|
||||
describe('composed skeletons', () => {
|
||||
it('FE-W4SKEL-006: SpotlightSkeleton renders the hero backdrop plus two bars', () => {
|
||||
const { container } = render(<SpotlightSkeleton />)
|
||||
|
||||
expect(container.querySelectorAll('.trek-skeleton')).toHaveLength(3)
|
||||
expect((container.firstElementChild as HTMLElement).style.minHeight).toBe('340px')
|
||||
})
|
||||
|
||||
it('FE-W4SKEL-007: TripCardSkeleton renders a cover plus two text bars', () => {
|
||||
const { container } = render(<TripCardSkeleton />)
|
||||
const bars = container.querySelectorAll('.trek-skeleton')
|
||||
|
||||
expect(bars).toHaveLength(3)
|
||||
expect((bars[0] as HTMLElement).style.height).toBe('140px')
|
||||
})
|
||||
|
||||
it('FE-W4SKEL-008: DaySkeleton renders three stacked bars', () => {
|
||||
const { container } = render(<DaySkeleton />)
|
||||
expect(container.querySelectorAll('.trek-skeleton')).toHaveLength(3)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,44 @@
|
||||
// FE-W4SPIN-001 to FE-W4SPIN-005
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { render } from '../../../tests/helpers/render'
|
||||
import { Spinner, PageSpinner } from './Spinner'
|
||||
|
||||
describe('Spinner', () => {
|
||||
it('FE-W4SPIN-001: renders the default page-loader ring', () => {
|
||||
const { container } = render(<Spinner />)
|
||||
const el = container.firstElementChild as HTMLElement
|
||||
|
||||
expect(el.className).toBe('w-6 h-6 border-2 border-zinc-300 border-t-zinc-900 rounded-full animate-spin')
|
||||
})
|
||||
|
||||
it('FE-W4SPIN-002: keeps caller classes and still spins', () => {
|
||||
const { container } = render(<Spinner className="w-10 h-10 border-4 border-accent" />)
|
||||
const el = container.firstElementChild as HTMLElement
|
||||
|
||||
expect(el.className).toBe('w-10 h-10 border-4 border-accent rounded-full animate-spin')
|
||||
})
|
||||
})
|
||||
|
||||
describe('PageSpinner', () => {
|
||||
it('FE-W4SPIN-003: centres the ring in a flex wrapper by default', () => {
|
||||
const { container } = render(<PageSpinner />)
|
||||
const wrapper = container.firstElementChild as HTMLElement
|
||||
|
||||
expect(wrapper.className).toBe('flex items-center justify-center')
|
||||
expect((wrapper.firstElementChild as HTMLElement).className).toContain('animate-spin')
|
||||
})
|
||||
|
||||
it('FE-W4SPIN-004: forwards wrapper classes and style', () => {
|
||||
const { container } = render(<PageSpinner wrapperClassName="h-screen grid place-items-center" wrapperStyle={{ minHeight: 200 }} />)
|
||||
const wrapper = container.firstElementChild as HTMLElement
|
||||
|
||||
expect(wrapper.className).toBe('h-screen grid place-items-center')
|
||||
expect(wrapper.style.minHeight).toBe('200px')
|
||||
})
|
||||
|
||||
it('FE-W4SPIN-005: forwards the ring className down to the Spinner', () => {
|
||||
const { container } = render(<PageSpinner className="w-8 h-8 border-2" />)
|
||||
|
||||
expect((container.querySelector('.animate-spin') as HTMLElement).className).toBe('w-8 h-8 border-2 rounded-full animate-spin')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,144 @@
|
||||
// FE-W4STAR-001 to FE-W4STAR-014
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import type { PlaceRatingVote } from '@trek/shared'
|
||||
import { render, screen, fireEvent, within } from '../../../tests/helpers/render'
|
||||
import { useAuthStore } from '../../store/authStore'
|
||||
import PlaceRating, { Stars } from './StarRating'
|
||||
|
||||
const VOTES: PlaceRatingVote[] = [
|
||||
{ user_id: 1, username: 'ada', avatar: 'ada.png', rating: 5 },
|
||||
{ user_id: 2, username: 'bob', avatar: null, rating: 3 },
|
||||
]
|
||||
|
||||
beforeEach(() => {
|
||||
useAuthStore.setState({ user: { id: 1, username: 'ada' } as never })
|
||||
})
|
||||
|
||||
describe('Stars', () => {
|
||||
it('FE-W4STAR-001: renders five stars and is not a radiogroup in display mode', () => {
|
||||
const { container } = render(<Stars value={3} />)
|
||||
|
||||
expect(container.querySelectorAll('svg')).toHaveLength(3 + 5)
|
||||
expect(container.querySelector('[role="radiogroup"]')).toBeNull()
|
||||
expect(container.querySelectorAll('button')).toHaveLength(0)
|
||||
})
|
||||
|
||||
it('FE-W4STAR-002: clips the overlay for a fractional average', () => {
|
||||
const { container } = render(<Stars value={3.4} />)
|
||||
const overlays = Array.from(container.querySelectorAll('span > span')) as HTMLElement[]
|
||||
const widths = overlays.map(o => o.style.width).filter(Boolean)
|
||||
|
||||
expect(widths).toHaveLength(4)
|
||||
expect(widths.slice(0, 3)).toEqual(['100%', '100%', '100%'])
|
||||
expect(Math.round(parseFloat(widths[3]))).toBe(40)
|
||||
})
|
||||
|
||||
it('FE-W4STAR-003: exposes a radiogroup with five radios when interactive', () => {
|
||||
render(<Stars value={0} onRate={() => {}} ariaLabel="Your rating" />)
|
||||
|
||||
expect(screen.getByRole('radiogroup', { name: 'Your rating' })).toBeInTheDocument()
|
||||
expect(screen.getAllByRole('radio')).toHaveLength(5)
|
||||
})
|
||||
|
||||
it('FE-W4STAR-004: marks the own vote as checked', () => {
|
||||
render(<Stars value={4} onRate={() => {}} myRating={4} />)
|
||||
|
||||
expect(screen.getByRole('radio', { name: '4' })).toHaveAttribute('aria-checked', 'true')
|
||||
expect(screen.getByRole('radio', { name: '2' })).toHaveAttribute('aria-checked', 'false')
|
||||
})
|
||||
|
||||
it('FE-W4STAR-005: casting a new vote reports the star index', () => {
|
||||
const onRate = vi.fn()
|
||||
render(<Stars value={0} onRate={onRate} myRating={null} />)
|
||||
|
||||
fireEvent.click(screen.getByRole('radio', { name: '4' }))
|
||||
|
||||
expect(onRate).toHaveBeenCalledWith(4)
|
||||
})
|
||||
|
||||
it('FE-W4STAR-006: clicking the own vote clears it', () => {
|
||||
const onRate = vi.fn()
|
||||
render(<Stars value={3} onRate={onRate} myRating={3} />)
|
||||
|
||||
fireEvent.click(screen.getByRole('radio', { name: '3' }))
|
||||
|
||||
expect(onRate).toHaveBeenCalledWith(null)
|
||||
})
|
||||
|
||||
it('FE-W4STAR-007: hovering previews the hovered value and leaving restores it', () => {
|
||||
const { container } = render(<Stars value={1} onRate={() => {}} />)
|
||||
const filled = () => Array.from(container.querySelectorAll('span > span')).filter(o => (o as HTMLElement).style.width).length
|
||||
|
||||
expect(filled()).toBe(1)
|
||||
fireEvent.mouseEnter(screen.getByRole('radio', { name: '4' }))
|
||||
expect(filled()).toBe(4)
|
||||
|
||||
fireEvent.mouseLeave(container.querySelector('[role="radiogroup"]')!)
|
||||
expect(filled()).toBe(1)
|
||||
})
|
||||
|
||||
it('FE-W4STAR-008: focus previews and blur clears the preview', () => {
|
||||
const { container } = render(<Stars value={0} onRate={() => {}} />)
|
||||
const filled = () => Array.from(container.querySelectorAll('span > span')).filter(o => (o as HTMLElement).style.width).length
|
||||
|
||||
fireEvent.focus(screen.getByRole('radio', { name: '5' }))
|
||||
expect(filled()).toBe(5)
|
||||
|
||||
fireEvent.blur(screen.getByRole('radio', { name: '5' }))
|
||||
expect(filled()).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('PlaceRating', () => {
|
||||
it('FE-W4STAR-009: shows the rounded average and the vote count', () => {
|
||||
render(<PlaceRating ratings={VOTES} ratingAvg={4.25} />)
|
||||
|
||||
// The average is rendered through toLocaleString, so build the expectation the same way.
|
||||
expect(screen.getByText('(2)').parentElement).toHaveTextContent(`${(4.3).toLocaleString()} (2)`)
|
||||
})
|
||||
|
||||
it('FE-W4STAR-010: shows the not-rated hint when there is no average', () => {
|
||||
render(<PlaceRating ratings={[]} ratingAvg={null} />)
|
||||
|
||||
expect(screen.getByText(/not rated/i)).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-W4STAR-011: renders the voter avatar strip with image and initial fallback', () => {
|
||||
const { container } = render(<PlaceRating ratings={VOTES} ratingAvg={4} />)
|
||||
|
||||
expect(container.querySelector('img')).toHaveAttribute('src', '/uploads/avatars/ada.png')
|
||||
expect(screen.getByText('B')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-W4STAR-012: hides the avatar strip in compact mode', () => {
|
||||
const { container } = render(<PlaceRating ratings={VOTES} ratingAvg={4} compact />)
|
||||
|
||||
expect(container.querySelector('img')).toBeNull()
|
||||
})
|
||||
|
||||
it('FE-W4STAR-013: hovering opens a voter tooltip that marks the current user', () => {
|
||||
const { container } = render(<PlaceRating ratings={VOTES} ratingAvg={4} />)
|
||||
fireEvent.mouseEnter(container.firstElementChild!)
|
||||
|
||||
const tip = screen.getByRole('tooltip')
|
||||
expect(within(tip).getByText('ada (you)')).toBeInTheDocument()
|
||||
expect(within(tip).getByText('bob')).toBeInTheDocument()
|
||||
|
||||
fireEvent.mouseLeave(container.firstElementChild!)
|
||||
expect(screen.queryByRole('tooltip')).toBeNull()
|
||||
})
|
||||
|
||||
it('FE-W4STAR-014: does not open a tooltip when nobody voted', () => {
|
||||
const { container } = render(<PlaceRating ratings={[]} ratingAvg={null} />)
|
||||
fireEvent.mouseEnter(container.firstElementChild!)
|
||||
|
||||
expect(screen.queryByRole('tooltip')).toBeNull()
|
||||
})
|
||||
|
||||
it('FE-W4STAR-015: pre-selects the signed-in user own vote in the stars', () => {
|
||||
useAuthStore.setState({ user: { id: 2, username: 'bob' } as never })
|
||||
render(<PlaceRating ratings={VOTES} ratingAvg={4} onRate={() => {}} />)
|
||||
|
||||
expect(screen.getByRole('radio', { name: '3' })).toHaveAttribute('aria-checked', 'true')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,173 @@
|
||||
// FE-W4TIP-001 to FE-W4TIP-013
|
||||
import { createRef, useRef } from 'react'
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
||||
import { render, screen, fireEvent, act } from '../../../tests/helpers/render'
|
||||
import Tooltip from './Tooltip'
|
||||
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers({ shouldAdvanceTime: true })
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers()
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
function hover(el: HTMLElement) {
|
||||
fireEvent.mouseEnter(el)
|
||||
act(() => { vi.advanceTimersByTime(300) })
|
||||
}
|
||||
|
||||
describe('Tooltip', () => {
|
||||
it('FE-W4TIP-001: renders the trigger and no tooltip until hovered', () => {
|
||||
render(<Tooltip label="Delete"><button>x</button></Tooltip>)
|
||||
|
||||
expect(screen.getByRole('button', { name: 'x' })).toBeInTheDocument()
|
||||
expect(screen.queryByRole('tooltip')).toBeNull()
|
||||
})
|
||||
|
||||
it('FE-W4TIP-002: opens only after the delay has elapsed', () => {
|
||||
render(<Tooltip label="Delete" delay={250}><button>x</button></Tooltip>)
|
||||
|
||||
fireEvent.mouseEnter(screen.getByRole('button'))
|
||||
act(() => { vi.advanceTimersByTime(200) })
|
||||
expect(screen.queryByRole('tooltip')).toBeNull()
|
||||
|
||||
act(() => { vi.advanceTimersByTime(100) })
|
||||
expect(screen.getByRole('tooltip')).toHaveTextContent('Delete')
|
||||
})
|
||||
|
||||
it('FE-W4TIP-003: leaving cancels a pending open', () => {
|
||||
render(<Tooltip label="Delete"><button>x</button></Tooltip>)
|
||||
const trigger = screen.getByRole('button')
|
||||
|
||||
fireEvent.mouseEnter(trigger)
|
||||
fireEvent.mouseLeave(trigger)
|
||||
act(() => { vi.advanceTimersByTime(500) })
|
||||
|
||||
expect(screen.queryByRole('tooltip')).toBeNull()
|
||||
})
|
||||
|
||||
it('FE-W4TIP-004: focus opens and blur closes the tooltip', () => {
|
||||
render(<Tooltip label="Delete"><button>x</button></Tooltip>)
|
||||
const trigger = screen.getByRole('button')
|
||||
|
||||
fireEvent.focus(trigger)
|
||||
act(() => { vi.advanceTimersByTime(300) })
|
||||
expect(screen.getByRole('tooltip')).toBeInTheDocument()
|
||||
|
||||
fireEvent.blur(trigger)
|
||||
expect(screen.queryByRole('tooltip')).toBeNull()
|
||||
})
|
||||
|
||||
it('FE-W4TIP-005: a disabled tooltip never opens', () => {
|
||||
render(<Tooltip label="Delete" disabled><button>x</button></Tooltip>)
|
||||
|
||||
hover(screen.getByRole('button'))
|
||||
|
||||
expect(screen.queryByRole('tooltip')).toBeNull()
|
||||
})
|
||||
|
||||
it('FE-W4TIP-006: an empty label never opens', () => {
|
||||
render(<Tooltip label=""><button>x</button></Tooltip>)
|
||||
|
||||
hover(screen.getByRole('button'))
|
||||
|
||||
expect(screen.queryByRole('tooltip')).toBeNull()
|
||||
})
|
||||
|
||||
it('FE-W4TIP-007: still chains the original handlers of the child', () => {
|
||||
const onMouseEnter = vi.fn()
|
||||
const onMouseLeave = vi.fn()
|
||||
const onFocus = vi.fn()
|
||||
const onBlur = vi.fn()
|
||||
render(
|
||||
<Tooltip label="Delete">
|
||||
<button onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave} onFocus={onFocus} onBlur={onBlur}>x</button>
|
||||
</Tooltip>,
|
||||
)
|
||||
const trigger = screen.getByRole('button')
|
||||
|
||||
fireEvent.mouseEnter(trigger)
|
||||
fireEvent.mouseLeave(trigger)
|
||||
fireEvent.focus(trigger)
|
||||
fireEvent.blur(trigger)
|
||||
|
||||
expect(onMouseEnter).toHaveBeenCalledOnce()
|
||||
expect(onMouseLeave).toHaveBeenCalledOnce()
|
||||
expect(onFocus).toHaveBeenCalledOnce()
|
||||
expect(onBlur).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('FE-W4TIP-008: forwards the node to an object ref on the child', () => {
|
||||
const ref = createRef<HTMLButtonElement>()
|
||||
render(<Tooltip label="Delete"><button ref={ref}>x</button></Tooltip>)
|
||||
|
||||
expect(ref.current).toBe(screen.getByRole('button'))
|
||||
})
|
||||
|
||||
it('FE-W4TIP-009: forwards the node to a callback ref on the child', () => {
|
||||
const seen: (HTMLElement | null)[] = []
|
||||
render(<Tooltip label="Delete"><button ref={(n: HTMLButtonElement | null) => { seen.push(n) }}>x</button></Tooltip>)
|
||||
|
||||
expect(seen[0]).toBe(screen.getByRole('button'))
|
||||
})
|
||||
|
||||
it('FE-W4TIP-010: positions the tooltip per placement and clamps it into the viewport', () => {
|
||||
vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockReturnValue({
|
||||
top: 100, bottom: 130, left: 200, right: 260, width: 60, height: 30, x: 200, y: 100, toJSON: () => ({}),
|
||||
} as DOMRect)
|
||||
|
||||
const { unmount } = render(<Tooltip label="Delete" placement="bottom"><button>x</button></Tooltip>)
|
||||
hover(screen.getByRole('button'))
|
||||
expect(screen.getByRole('tooltip')).toHaveStyle({ top: '136px' })
|
||||
unmount()
|
||||
|
||||
render(<Tooltip label="Delete" placement="right"><button>x</button></Tooltip>)
|
||||
hover(screen.getByRole('button'))
|
||||
expect(screen.getByRole('tooltip')).toHaveStyle({ left: '266px' })
|
||||
})
|
||||
|
||||
it('FE-W4TIP-011: clamps a top/left placement to the viewport padding', () => {
|
||||
vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockReturnValue({
|
||||
top: 0, bottom: 20, left: 0, right: 20, width: 20, height: 20, x: 0, y: 0, toJSON: () => ({}),
|
||||
} as DOMRect)
|
||||
|
||||
const { unmount } = render(<Tooltip label="Delete" placement="top"><button>x</button></Tooltip>)
|
||||
hover(screen.getByRole('button'))
|
||||
expect(screen.getByRole('tooltip')).toHaveStyle({ top: '6px' })
|
||||
unmount()
|
||||
|
||||
render(<Tooltip label="Delete" placement="left"><button>x</button></Tooltip>)
|
||||
hover(screen.getByRole('button'))
|
||||
expect(screen.getByRole('tooltip')).toHaveStyle({ left: '6px' })
|
||||
})
|
||||
|
||||
it('FE-W4TIP-012: clears a pending timer when the trigger unmounts', () => {
|
||||
const clear = vi.spyOn(window, 'clearTimeout')
|
||||
const { unmount } = render(<Tooltip label="Delete"><button>x</button></Tooltip>)
|
||||
|
||||
fireEvent.mouseEnter(screen.getByRole('button'))
|
||||
unmount()
|
||||
|
||||
expect(clear).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
describe('Tooltip — inside a component that owns the ref', () => {
|
||||
it('FE-W4TIP-013: keeps the owner ref pointing at the trigger', () => {
|
||||
function Owner() {
|
||||
const ref = useRef<HTMLButtonElement>(null)
|
||||
return (
|
||||
<Tooltip label="Delete">
|
||||
<button ref={ref} onClick={() => { ref.current?.setAttribute('data-clicked', '1') }}>x</button>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
render(<Owner />)
|
||||
|
||||
fireEvent.click(screen.getByRole('button'))
|
||||
|
||||
expect(screen.getByRole('button')).toHaveAttribute('data-clicked', '1')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,99 @@
|
||||
// FE-W4TLS-001 to FE-W4TLS-007
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
||||
import { render, screen, act } from '../../../tests/helpers/render'
|
||||
|
||||
vi.mock('../../mobile/components/MDancingTrek', () => ({
|
||||
default: ({ scene, mood, size }: { scene: string; mood: string; size: number }) =>
|
||||
<div data-testid="mascot" data-scene={scene} data-mood={mood} data-size={size} />,
|
||||
}))
|
||||
|
||||
import TripLoadingSplash from './TripLoadingSplash'
|
||||
|
||||
function stubReducedMotion(reduce: boolean) {
|
||||
Object.defineProperty(window, 'matchMedia', {
|
||||
writable: true,
|
||||
configurable: true,
|
||||
value: vi.fn((query: string) => ({
|
||||
matches: reduce && query.includes('reduced-motion'),
|
||||
media: query,
|
||||
addEventListener: vi.fn(),
|
||||
removeEventListener: vi.fn(),
|
||||
})),
|
||||
})
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
stubReducedMotion(false)
|
||||
vi.useFakeTimers({ shouldAdvanceTime: true })
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers()
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
describe('TripLoadingSplash', () => {
|
||||
it('FE-W4TLS-001: announces itself as a status region labelled with the trip title', () => {
|
||||
render(<TripLoadingSplash title="Iceland 2026" />)
|
||||
const root = screen.getByRole('status')
|
||||
|
||||
expect(root).toHaveAttribute('aria-label', 'Iceland 2026')
|
||||
expect(screen.getByText('Iceland 2026')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-W4TLS-002: falls back to the TREK wordmark without a title', () => {
|
||||
render(<TripLoadingSplash />)
|
||||
|
||||
expect(screen.getByRole('status')).toHaveAttribute('aria-label', 'TREK')
|
||||
expect(screen.getByText('TREK')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-W4TLS-003: starts on the packing scene', () => {
|
||||
render(<TripLoadingSplash />)
|
||||
|
||||
expect(screen.getByTestId('mascot')).toHaveAttribute('data-scene', 'packing')
|
||||
expect(screen.getByTestId('mascot')).toHaveAttribute('data-mood', 'happy')
|
||||
})
|
||||
|
||||
it('FE-W4TLS-004: advances through the journey scenes and loops', () => {
|
||||
render(<TripLoadingSplash />)
|
||||
|
||||
act(() => { vi.advanceTimersByTime(1400) })
|
||||
expect(screen.getByTestId('mascot')).toHaveAttribute('data-scene', 'transport')
|
||||
|
||||
act(() => { vi.advanceTimersByTime(1400 * 2) })
|
||||
expect(screen.getByTestId('mascot')).toHaveAttribute('data-scene', 'collections')
|
||||
|
||||
act(() => { vi.advanceTimersByTime(1400) })
|
||||
expect(screen.getByTestId('mascot')).toHaveAttribute('data-scene', 'packing')
|
||||
})
|
||||
|
||||
it('FE-W4TLS-005: widens the beat dot of the active step', () => {
|
||||
const { container } = render(<TripLoadingSplash />)
|
||||
const dots = () => Array.from(container.querySelectorAll('.rounded-full')) as HTMLElement[]
|
||||
|
||||
expect(dots().map(d => d.style.width)).toEqual(['20px', '6px', '6px', '6px'])
|
||||
|
||||
act(() => { vi.advanceTimersByTime(1400) })
|
||||
expect(dots().map(d => d.style.width)).toEqual(['6px', '20px', '6px', '6px'])
|
||||
})
|
||||
|
||||
it('FE-W4TLS-006: parks on the loading-photos step under reduced motion', () => {
|
||||
stubReducedMotion(true)
|
||||
const { container } = render(<TripLoadingSplash />)
|
||||
|
||||
expect(screen.getByTestId('mascot')).toHaveAttribute('data-scene', 'dashboard')
|
||||
|
||||
act(() => { vi.advanceTimersByTime(1400 * 3) })
|
||||
expect(screen.getByTestId('mascot')).toHaveAttribute('data-scene', 'dashboard')
|
||||
expect((container.querySelectorAll('.rounded-full')[2] as HTMLElement).style.width).toBe('20px')
|
||||
})
|
||||
|
||||
it('FE-W4TLS-007: skips the mascot entry animation under reduced motion', () => {
|
||||
stubReducedMotion(true)
|
||||
const { container } = render(<TripLoadingSplash />)
|
||||
const stage = container.querySelector('.m-splash-content > div > div') as HTMLElement
|
||||
|
||||
expect(stage.style.animation).toBe('')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user