diff --git a/client/src/hooks/useResizablePanels.ts b/client/src/hooks/useResizablePanels.ts index 9e5484a40..c8929dbf5 100644 --- a/client/src/hooks/useResizablePanels.ts +++ b/client/src/hooks/useResizablePanels.ts @@ -82,15 +82,15 @@ export function useResizablePanels() { const shownRight = clampWidth(rightWidth, resizeMaxRight) const resizeMaxLeft = Math.max(MIN_SIDEBAR, room - (rightHidden ? 0 : shownRight)) // The drag listeners are bound once, so they read the live ceilings from here. - const maxRef = useRef({ left: resizeMaxLeft, right: resizeMaxRight }) - useEffect(() => { maxRef.current = { left: resizeMaxLeft, right: resizeMaxRight } }, [resizeMaxLeft, resizeMaxRight]) + const maxRef = useRef({ dayPlan: resizeMaxLeft, places: resizeMaxRight }) + useEffect(() => { maxRef.current = { dayPlan: resizeMaxLeft, places: resizeMaxRight } }, [resizeMaxLeft, resizeMaxRight]) // A mouse drags through mousemove; a finger on a tablet sends touch events and // never a mousemove, which is why the handles used to be dead on an iPad (#1012). useEffect(() => { const moveTo = (clientX: number) => { - if (isResizingLeft.current) setLeftWidth(remember('sidebarLeftWidth', clampWidth(clientX - 10, maxRef.current.left))) - if (isResizingRight.current) setRightWidth(remember('sidebarRightWidth', clampWidth(window.innerWidth - clientX - 10, maxRef.current.right))) + if (isResizingLeft.current) setLeftWidth(remember('sidebarLeftWidth', clampWidth(clientX - 10, maxRef.current.dayPlan))) + if (isResizingRight.current) setRightWidth(remember('sidebarRightWidth', clampWidth(window.innerWidth - clientX - 10, maxRef.current.places))) } const onMove = (e: MouseEvent) => moveTo(e.clientX) const onTouchMove = (e: TouchEvent) => { diff --git a/client/tests/integration/hooks/useResizablePanels.test.ts b/client/tests/integration/hooks/useResizablePanels.test.ts index c0b7102ca..9357349ad 100644 --- a/client/tests/integration/hooks/useResizablePanels.test.ts +++ b/client/tests/integration/hooks/useResizablePanels.test.ts @@ -50,6 +50,8 @@ describe('useResizablePanels', () => { }); it('FE-HOOK-PANELS-004: rightWidth loaded from localStorage when set', () => { + // Wide enough that the map's share leaves the stored width alone. + setViewport(1440, false); localStorage.setItem('sidebarRightWidth', '350'); const { result } = renderHook(() => useResizablePanels()); expect(result.current.rightWidth).toBe(350); diff --git a/server/tests/integration/packing.test.ts b/server/tests/integration/packing.test.ts index 1eb5df26d..b93903849 100644 --- a/server/tests/integration/packing.test.ts +++ b/server/tests/integration/packing.test.ts @@ -266,7 +266,7 @@ describe('Three-tier packing sharing (#858)', () => { .set('Cookie', authCookie(owner.id)) .send({ user_id: helper.id }); expect(assigned.status).toBe(201); - expect(assigned.body.item.contributors.map((c: any) => c.user_id)).toEqual([helper.id]); + expect(assigned.body.item.contributors.map((c: { user_id: number }) => c.user_id)).toEqual([helper.id]); const outsider = await request(app) .post(`/api/trips/${trip.id}/packing/${id}/contributors`) @@ -285,7 +285,7 @@ describe('Three-tier packing sharing (#858)', () => { .set('Cookie', authCookie(helper.id)); expect(ownerOff.status).toBe(200); expect(ownerOff.body.item.owner_id).toBeNull(); - expect(ownerOff.body.item.contributors.map((c: any) => c.user_id)).toEqual([helper.id]); + expect(ownerOff.body.item.contributors.map((c: { user_id: number }) => c.user_id)).toEqual([helper.id]); }); it('PACK-3T-005 — sharing can only be changed by the owner', async () => { diff --git a/server/tests/unit/nest/packing.service.test.ts b/server/tests/unit/nest/packing.service.test.ts index 471a297b4..301bc7786 100644 --- a/server/tests/unit/nest/packing.service.test.ts +++ b/server/tests/unit/nest/packing.service.test.ts @@ -78,6 +78,15 @@ async function tripItems(tripId: number) { } /** The stored item; fails the case when it is gone. */ +/** What the bringer tests read off an item the service hands back (#3098). */ +type BroughtItem = { + id: number; + is_private: number; + owner_id: number | null; + owner_username: string | null; + contributors: { user_id: number }[]; +}; + async function itemRow(id: number) { const row = await findRow(await orm(), PackingItems, { id }); if (!row) throw new Error(`no packing item ${id}`); @@ -734,10 +743,14 @@ describe('three-tier packing sharing (#858)', () => { const { user: stranger } = createUser(testDb); const trip = createTrip(testDb, owner.id); addTripMember(testDb, trip.id, friend.id); - const common = (await svc.createItem(trip.id, { name: 'Tent', visibility: 'common' }, owner.id)) as any; + const common = (await svc.createItem( + trip.id, + { name: 'Tent', visibility: 'common' }, + owner.id, + )) as unknown as BroughtItem; - const assigned = (await svc.addContributor(trip.id, common.id, friend.id, owner.id)) as any; - expect(assigned.contributors.map((c: any) => c.user_id)).toEqual([friend.id]); + const assigned = (await svc.addContributor(trip.id, common.id, friend.id, owner.id)) as unknown as BroughtItem; + expect(assigned.contributors.map((c: { user_id: number }) => c.user_id)).toEqual([friend.id]); expect(await svc.addContributor(trip.id, common.id, stranger.id, owner.id)).toBeNull(); }); @@ -747,15 +760,19 @@ describe('three-tier packing sharing (#858)', () => { const trip = createTrip(testDb, owner.id); addTripMember(testDb, trip.id, friend.id); // Personal first, then back to the shared list: the owner stays on as its bringer. - const item = (await svc.createItem(trip.id, { name: 'Stove', visibility: 'personal' }, owner.id)) as any; + const item = (await svc.createItem( + trip.id, + { name: 'Stove', visibility: 'personal' }, + owner.id, + )) as unknown as BroughtItem; await svc.setItemSharing(trip.id, item.id, owner.id, 'common', []); await svc.addContributor(trip.id, item.id, friend.id, friend.id); expect((await itemRow(item.id)).owner_id).toBe(owner.id); - const after = (await svc.removeContributor(trip.id, item.id, owner.id, friend.id)) as any; + const after = (await svc.removeContributor(trip.id, item.id, owner.id, friend.id)) as unknown as BroughtItem; expect(after.owner_id).toBeNull(); expect(after.owner_username).toBeNull(); - expect(after.contributors.map((c: any) => c.user_id)).toEqual([friend.id]); + expect(after.contributors.map((c: { user_id: number }) => c.user_id)).toEqual([friend.id]); expect(after.is_private).toBe(0); });