mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-14 08:11:03 +00:00
chore: keep the audit follow-ups within the lint and format ratchets
The bringers list moves next to the other bringer helpers so the card file exports components only, three tests read without non-null assertions or any, and three files take the formatting their checks expect.
This commit is contained in:
@@ -3,6 +3,7 @@ import { Check, ChevronRight, Loader2, Plus, RefreshCw, Search, Trash2, Waves, W
|
||||
import { useId } from 'react';
|
||||
import { useDateFormat } from '../../../hooks/useDateFormat';
|
||||
import { useTranslation } from '../../../i18n';
|
||||
import { formatDisplayDate } from '../../../utils/dateFormat';
|
||||
import {
|
||||
SettingRows,
|
||||
SETTINGS_BUTTON,
|
||||
@@ -16,7 +17,6 @@ import { EditorField, INPUT } from '../../shared/dialogParts';
|
||||
import { fs } from '../../shared/DialogShell';
|
||||
import ErrorBoundary from '../../shared/ErrorBoundary';
|
||||
import { Tooltip } from '../../shared/Tooltip';
|
||||
import { formatDisplayDate } from '../../../utils/dateFormat';
|
||||
import { AutoLoadSettings, AutoOriginPill, RequestList } from './PaddleAutoLoadParts';
|
||||
import { progressPercent, regionStatusTone } from './paddleRegionsModel';
|
||||
import { usePaddleRegionsAdmin } from './usePaddleRegionsAdmin';
|
||||
|
||||
@@ -506,6 +506,8 @@ describe('MapView on a real Leaflet map', () => {
|
||||
return found as L.Marker | null
|
||||
}
|
||||
await waitFor(() => expect(marker()?.getLatLng().lng).toBeCloseTo(23.73, 6))
|
||||
expect(map.getBounds().contains(marker()!.getLatLng())).toBe(true)
|
||||
const drawnMarker = marker()
|
||||
expect(drawnMarker).not.toBeNull()
|
||||
expect(drawnMarker && map.getBounds().contains(drawnMarker.getLatLng())).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// FE-PACK-BRINGERCARD-001 to FE-PACK-BRINGERCARD-004
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { render, screen } from '../../../tests/helpers/render';
|
||||
import { BringersCard, MoreBringers, bringersOf } from './PackingBringersCard';
|
||||
import { BringersCard, MoreBringers } from './PackingBringersCard';
|
||||
import { bringersOf } from './packingBringers';
|
||||
|
||||
const members = [
|
||||
{ id: 1, username: 'anna', avatar_url: '/uploads/avatars/anna.jpg' },
|
||||
|
||||
@@ -1,37 +1,6 @@
|
||||
import type { CSSProperties } from 'react';
|
||||
import { useTranslation } from '../../i18n';
|
||||
import type { TripMember } from './usePackingListPanel';
|
||||
|
||||
/** One person bringing a common item: the name, and the picture when the trip knows one. */
|
||||
export interface Bringer {
|
||||
name: string;
|
||||
avatar: string | null;
|
||||
}
|
||||
|
||||
/** The item's bringer first, then whoever also brings it, each once, with their picture from the trip's members. */
|
||||
export function bringersOf(
|
||||
item: {
|
||||
owner_id?: number | null;
|
||||
owner_username?: string | null;
|
||||
contributors?: { user_id: number; username: string }[] | null;
|
||||
},
|
||||
members: readonly TripMember[]
|
||||
): Bringer[] {
|
||||
const avatarOf = (id: number | null | undefined) => {
|
||||
const member = id == null ? undefined : members.find((m) => m.id === id);
|
||||
return member?.avatar_url ?? member?.avatar ?? null;
|
||||
};
|
||||
const all = [
|
||||
...(item.owner_username ? [{ id: item.owner_id ?? null, name: item.owner_username }] : []),
|
||||
...(item.contributors ?? []).map((c) => ({ id: c.user_id, name: c.username })),
|
||||
];
|
||||
const bringers: Bringer[] = [];
|
||||
for (const person of all) {
|
||||
if (bringers.some((b) => b.name === person.name)) continue;
|
||||
bringers.push({ name: person.name, avatar: avatarOf(person.id) });
|
||||
}
|
||||
return bringers;
|
||||
}
|
||||
import type { Bringer } from './packingBringers';
|
||||
|
||||
const CIRCLE: CSSProperties = {
|
||||
width: 20,
|
||||
|
||||
@@ -18,9 +18,9 @@ import { PopoverItem } from './PackingPopover'
|
||||
import { POPOVER, POPOVER_CAPTION, POPOVER_DIVIDER } from './packingPopoverStyles'
|
||||
import type { TripMember } from './usePackingListPanel'
|
||||
import { NumericInput } from '../shared/NumericInput'
|
||||
import { packingBringerNames } from './packingBringers'
|
||||
import { bringersOf, packingBringerNames } from './packingBringers'
|
||||
import { Tooltip } from '../shared/Tooltip'
|
||||
import { BringerAvatar, BringersCard, MoreBringers, bringersOf } from './PackingBringersCard'
|
||||
import { BringerAvatar, BringersCard, MoreBringers } from './PackingBringersCard'
|
||||
|
||||
interface ArtikelZeileProps {
|
||||
item: PackingItem
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { TripMember } from './usePackingListPanel';
|
||||
|
||||
interface BroughtItem {
|
||||
owner_username?: string | null;
|
||||
contributors?: { username: string }[] | null;
|
||||
@@ -12,3 +14,34 @@ export function packingBringerNames(item: BroughtItem): string {
|
||||
const names = [item.owner_username, ...(item.contributors ?? []).map((c) => c.username)];
|
||||
return [...new Set(names.filter((n): n is string => !!n))].join(', ');
|
||||
}
|
||||
|
||||
/** One person bringing a common item: the name, and the picture when the trip knows one. */
|
||||
export interface Bringer {
|
||||
name: string;
|
||||
avatar: string | null;
|
||||
}
|
||||
|
||||
/** The item's bringer first, then whoever also brings it, each once, with their picture from the trip's members. */
|
||||
export function bringersOf(
|
||||
item: {
|
||||
owner_id?: number | null;
|
||||
owner_username?: string | null;
|
||||
contributors?: { user_id: number; username: string }[] | null;
|
||||
},
|
||||
members: readonly TripMember[]
|
||||
): Bringer[] {
|
||||
const avatarOf = (id: number | null | undefined) => {
|
||||
const member = id == null ? undefined : members.find((m) => m.id === id);
|
||||
return member?.avatar_url ?? member?.avatar ?? null;
|
||||
};
|
||||
const all = [
|
||||
...(item.owner_username ? [{ id: item.owner_id ?? null, name: item.owner_username }] : []),
|
||||
...(item.contributors ?? []).map((c) => ({ id: c.user_id, name: c.username })),
|
||||
];
|
||||
const bringers: Bringer[] = [];
|
||||
for (const person of all) {
|
||||
if (bringers.some((b) => b.name === person.name)) continue;
|
||||
bringers.push({ name: person.name, avatar: avatarOf(person.id) });
|
||||
}
|
||||
return bringers;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ describe('DayHeader', () => {
|
||||
const tileDate = (time_format: string, date_format: string): string | null => {
|
||||
useSettingsStore.setState({ settings: { distance_unit: 'metric', time_format, date_format } as never })
|
||||
const { container, unmount } = wrap(<DayHeader day={day({ date: '2026-10-05' })} />)
|
||||
const text = container.querySelector('time')!.textContent
|
||||
const text = container.querySelector('time')?.textContent ?? null
|
||||
unmount()
|
||||
return text
|
||||
}
|
||||
|
||||
@@ -740,7 +740,7 @@ describe('getMergedItems: bookings in different time zones (#2929)', () => {
|
||||
const laxSea = { ...toSeattle, endpoints: ends(LAX, SEA) }
|
||||
const stopAt = (id: number, time: string, lat: number, lng: number) =>
|
||||
({ id, order_index: id, place: { place_time: time, lat, lng } })
|
||||
const drawn = (dayAssignments: any[], dayTransports: any[]) =>
|
||||
const drawn = (dayAssignments: Parameters<typeof getMergedItems>[0]['dayAssignments'], dayTransports: Parameters<typeof getMergedItems>[0]['dayTransports']) =>
|
||||
getMergedItems({ dayAssignments, dayNotes: [], dayTransports, dayId: DAY })
|
||||
const labels = (items: MergedItem[]) => items.map(i => `${i.type}:${i.data.id}`)
|
||||
|
||||
|
||||
@@ -671,7 +671,10 @@ describe('toChatHistory: calls the model made of the server tools (#2845)', () =
|
||||
const chat = toChatMessages({ system: '', messages: anthropic, tools: [] });
|
||||
chat.forEach((message, index) => {
|
||||
if (message.role !== 'tool') return;
|
||||
const before = chat.slice(0, index).reverse().find((earlier) => earlier.role === 'assistant');
|
||||
const before = chat
|
||||
.slice(0, index)
|
||||
.reverse()
|
||||
.find((earlier) => earlier.role === 'assistant');
|
||||
const named = ((before?.tool_calls ?? []) as Array<{ id: string }>).map((call) => call.id);
|
||||
expect(named).toContain(message.tool_call_id);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// COST-CATEGORY-001 to COST-CATEGORY-007: a typed category read as one of the fixed keys.
|
||||
import { RESERVATION_TYPES } from '../reservation/reservation-types';
|
||||
import { COST_CATEGORIES } from './budget.schema';
|
||||
import { COST_CATEGORY_HINT, costCategoryOf, storedCostCategory, typeToCostCategory } from './cost-category';
|
||||
import { RESERVATION_TYPES } from '../reservation/reservation-types';
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user