mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 00:20:07 +00:00
fix(client,sdk): the smaller silent failures, and a dead SDK test file
The SDK's parity suite had an unescaped apostrophe in an it() title, so the file did not parse and vitest reported it as "no tests". Both guards in it were dead - including the byte-identical egress-policy check the package's own notes call the worst possible bug in that module to lose. No CI job runs the SDK suite, so it landed quietly; the next npm publish would have failed on it, since prepublishOnly runs the tests. Also in the SDK: the dev preview answered trek:geolocation without checking the geolocation:read grant, so a plugin whose manifest is missing the permission works perfectly in dev and is dead once installed. That is the lenient direction, which is the one that ships broken plugins. Client side: the background-task poll never dismissed a 404'd import job and spun forever, "Update All" collapsed its busy flag after the first plugin settled, the lightbox had no cancellation so a slow signed URL rendered the wrong image, the plugin geolocation watch was torn down by any unrelated settings write, manual date entry accepted 31 February, cover previews were never revoked, and check-all issued one request per packing item.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// FE-COMP-TODO-001 to FE-COMP-TODO-052
|
||||
// FE-COMP-TODO-001 to FE-COMP-TODO-079
|
||||
import { render, screen, waitFor, fireEvent, within } from '../../../tests/helpers/render';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { http, HttpResponse } from 'msw';
|
||||
@@ -24,6 +24,7 @@ beforeEach(() => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
Object.defineProperty(window, 'innerWidth', { value: 0, writable: true, configurable: true });
|
||||
});
|
||||
|
||||
@@ -202,6 +203,25 @@ describe('TodoListPanel', () => {
|
||||
expect(screen.queryByText('Future Task')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-COMP-TODO-079: Overdue uses the local calendar day, not the UTC one', () => {
|
||||
// Freeze on an instant whose UTC date differs from the local one, so a UTC-derived
|
||||
// "today" would move the cut-off a day in whichever direction this runner sits.
|
||||
const offset = new Date(2026, 4, 15, 12).getTimezoneOffset();
|
||||
vi.useFakeTimers({ toFake: ['Date'] });
|
||||
vi.setSystemTime(new Date(2026, 4, 15, offset > 0 ? 23 : 0, 30));
|
||||
const items = [
|
||||
buildTodoItem({ id: 1, name: 'Due Today', checked: 0, due_date: '2026-05-15' }),
|
||||
buildTodoItem({ id: 2, name: 'Due Yesterday', checked: 0, due_date: '2026-05-14' }),
|
||||
];
|
||||
render(<TodoListPanel tripId={1} items={items} />);
|
||||
const overdueBtn = screen.getAllByRole('button').find(
|
||||
b => b.textContent?.includes('Overdue') || b.getAttribute('title') === 'Overdue'
|
||||
);
|
||||
fireEvent.click(overdueBtn!);
|
||||
expect(screen.getByText('Due Yesterday')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Due Today')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-COMP-TODO-017: My Tasks filter shows only items assigned to current user', async () => {
|
||||
// Use default current_user_id: 1 from beforeEach; assign one item to user 1
|
||||
const items = [
|
||||
|
||||
@@ -6,6 +6,7 @@ import { useTranslation } from '../../i18n'
|
||||
import apiClient from '../../api/client'
|
||||
import { formatDate as fmtDate } from '../../utils/formatters'
|
||||
import type { TodoItem } from '../../types'
|
||||
import { localToday } from '../Planner/today'
|
||||
import type { FilterType, Member } from './todoListModel'
|
||||
|
||||
/**
|
||||
@@ -65,7 +66,9 @@ export function useTodoList(tripId: number, items: TodoItem[], addItemSignal: nu
|
||||
return Array.from(cats).sort()
|
||||
}, [items])
|
||||
|
||||
const today = new Date().toISOString().split('T')[0]
|
||||
// due_date is a bare calendar date, so "today" has to be the user's calendar
|
||||
// day: toISOString() hands over the UTC one and shifts the overdue cut-off.
|
||||
const today = localToday()
|
||||
|
||||
const filtered = useMemo(() => {
|
||||
let result: TodoItem[]
|
||||
|
||||
Reference in New Issue
Block a user