feat(stats): implement SleepTimetable with enhanced date formatting and fixed tests
Build Frontend / build (push) Failing after 10m34s

This commit is contained in:
2026-06-11 17:18:21 +02:00
parent bb58389675
commit da76baa2ae
4 changed files with 23 additions and 17 deletions
@@ -56,9 +56,9 @@ describe('SleepTimetable', () => {
});
render(<Timetable {...singleDayProps} />);
// Check if it renders the single day header
expect(screen.getByText(/18/i)).toBeInTheDocument();
// Check if it renders the single day header with date format
expect(screen.getByText(/Fri 18\/4/i)).toBeInTheDocument();
});
it('handles a large date range', () => {
const largeRangeProps = { ...defaultProps, from_date: '2025-01-01', to_date: '2025-01-31' };
(useStats as any).mockReturnValue({
@@ -91,12 +91,11 @@ describe('SleepTimetable', () => {
vi.stubGlobal('innerWidth', 1024);
render(<Timetable {...defaultProps} />);
expect(screen.getByText(/18/i)).toBeInTheDocument();
expect(screen.getByText(/19/i)).toBeInTheDocument();
expect(screen.getByText(/20/i)).toBeInTheDocument();
expect(screen.getByText(/21/i)).toBeInTheDocument();
expect(screen.getByText(/Fri 18\/4/i)).toBeInTheDocument();
expect(screen.getByText(/Sat 19\/4/i)).toBeInTheDocument();
expect(screen.getByText(/Sun 20\/4/i)).toBeInTheDocument();
expect(screen.getByText(/Mon 21\/4/i)).toBeInTheDocument();
});
it('Medium Tier (400-768px): shows tab groups and updates on click', () => {
(useStats as any).mockReturnValue({ timetable: mockTimetable, isLoading: false });
vi.stubGlobal('innerWidth', 500);
@@ -134,17 +133,14 @@ describe('SleepTimetable', () => {
});
expect(screen.getByRole('button', { name: /21/i })).toBeInTheDocument();
expect(screen.getByRole('button', { name: /20/i })).toBeInTheDocument();
expect(screen.getByRole('button', { name: /21\/4/i })).toBeInTheDocument();
act(() => {
fireEvent.click(screen.getByRole('button', { name: /20/i }));
});
expect(container.querySelector('[data-testid^="cell-2025-04-20-"]')).toBeInTheDocument();
expect(container.querySelector('[data-testid^="cell-2025-04-21-"]')).not.toBeInTheDocument();
});
});
describe('Grid Accuracy', () => {
it('renders sleeping cells correctly', () => {
const day = '2025-04-18';