mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-23 23:46:35 +00:00
fix(files): list a hotel booking's files and files pinned to a stop on the place card
A hotel booking reaches its place through the stay, not its own place_id, so the card listed the booking but not its confirmation. Links to a stop, which MCP's link_trip_file and plugins can make, were never returned by the file list at all; it now carries linked_assignment_ids. Without files the row no longer opens to nothing.
This commit is contained in:
@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'
|
||||
import { filesForPlace } from '../../../src/utils/placeFiles'
|
||||
import type { Reservation, TripFile } from '../../../src/types'
|
||||
|
||||
// FE-UTIL-PLACEFILES-001 to FE-UTIL-PLACEFILES-006
|
||||
// FE-UTIL-PLACEFILES-001 to FE-UTIL-PLACEFILES-008
|
||||
|
||||
const file = (over: Partial<TripFile>): TripFile => ({
|
||||
id: 1, trip_id: 5, original_name: 'a.pdf', url: '/uploads/a.pdf',
|
||||
@@ -54,4 +54,20 @@ describe('filesForPlace', () => {
|
||||
expect(filesForPlace([gone, bookingFileGone], 7, [booking({ id: 90, place_id: 7 })])).toEqual([])
|
||||
expect(filesForPlace([file({ id: 10, place_id: 7 })], undefined, [])).toEqual([])
|
||||
})
|
||||
|
||||
it('FE-UTIL-PLACEFILES-007: reaches a hotel booking through the stay on the place', () => {
|
||||
// A hotel booking keeps place_id empty; the place is the stay's (#2363).
|
||||
const stay = booking({ id: 90, place_id: null, assignment_id: null, accommodation_place_id: 7 })
|
||||
const stored = file({ id: 11, reservation_id: 90 })
|
||||
const linked = file({ id: 12, linked_reservation_ids: [90] })
|
||||
expect(filesForPlace([stored, linked], 7, [stay]).map(f => f.id)).toEqual([11, 12])
|
||||
// A stay on another place lends nothing to this one.
|
||||
expect(filesForPlace([stored], 7, [{ ...stay, accommodation_place_id: 8 }])).toEqual([])
|
||||
})
|
||||
|
||||
it('FE-UTIL-PLACEFILES-008: keeps a file pinned to one of the place\'s stops', () => {
|
||||
const pinned = file({ id: 13, linked_assignment_ids: [11] })
|
||||
expect(filesForPlace([pinned], 7, [], [11]).map(f => f.id)).toEqual([13])
|
||||
expect(filesForPlace([pinned], 7, [], [12])).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user